[PATCH] D84260: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 3

2020-07-24 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam marked an inline comment as done.
saiislam added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:129
+  auto *Alloca = Var.getPointer();
+  assert(isa(Alloca) ||
+ (isa(Alloca) &&

@arsenm , it wasn't possible to post D78495 and this patch separately due to 
their interdependence. Test 
"clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp" below checks for this 
change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84260



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


[PATCH] D84260: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 3

2020-07-24 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 280660.
saiislam added a comment.

Added InitTempAlloca address space cast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84260

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp

Index: clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
@@ -0,0 +1,25 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+#define N 100
+
+int test_amdgcn_target_temp_alloca() {
+  // CHECK-LABEL: test_amdgcn_target_temp_alloca
+  // CHECK-LABEL: entry:
+
+  int arr[N];
+
+  // CHECK:  %arr.addr = alloca [100 x i32]*, align 8, addrspace(5)
+  // CHECK-NEXT: %arr.addr.ascast = addrspacecast [100 x i32]* addrspace(5)* %arr.addr to [100 x i32]**
+  // CHECK-DAG:  store [100 x i32]* %arr, [100 x i32]** %arr.addr.ascast, align 8
+
+#pragma omp target
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+
+  return arr[0];
+}
Index: clang/test/OpenMP/amdgcn_target_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_target_codegen.cpp
@@ -0,0 +1,45 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+int test_amdgcn_target_tid_threads() {
+  // CHECK-LABEL: test_amdgcn_target_tid_threads
+  // CHECK-LABEL: entry:
+
+  int arr[N];
+
+// CHECK: %nvptx_num_threads = call i64 @__ockl_get_local_size(i32 0)
+// CHECK-DAG: [[VAR1:%[0-9]+]] = trunc i64 %nvptx_num_threads to i32
+// CHECK-DAG: %thread_limit = sub nuw i32 [[VAR1]], 64
+// CHECK-DAG: %nvptx_tid = call i32 @llvm.amdgcn.workitem.id.x()
+#pragma omp target
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+
+  return arr[0];
+}
+
+int test_amdgcn_target_tid_threads_simd() {
+  // CHECK-LABEL: test_amdgcn_target_tid_threads_simd
+  // CHECK-LABEL: entry:
+
+  int arr[N];
+
+// CHECK: %nvptx_num_threads = call i64 @__ockl_get_local_size(i32 0)
+// CHECK-DAG: [[VAR2:%[0-9]+]] = trunc i64 %nvptx_num_threads to i32
+// CHECK-DAG: call void @__kmpc_spmd_kernel_init(i32 [[VAR2]], i16 0, i16 0)
+#pragma omp target simd
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+  return arr[0];
+}
+
+#endif
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -19,6 +19,7 @@
 #include "CGObjCRuntime.h"
 #include "CGOpenCLRuntime.h"
 #include "CGOpenMPRuntime.h"
+#include "CGOpenMPRuntimeAMDGCN.h"
 #include "CGOpenMPRuntimeNVPTX.h"
 #include "CodeGenFunction.h"
 #include "CodeGenPGO.h"
@@ -215,6 +216,11 @@
"OpenMP NVPTX is only prepared to deal with device code.");
 OpenMPRuntime.reset(new CGOpenMPRuntimeNVPTX(*this));
 break;
+  case llvm::Triple::amdgcn:
+assert(getLangOpts().OpenMPIsDevice &&
+   "OpenMP AMDGCN is only prepared to deal with device code.");
+OpenMPRuntime.reset(new CGOpenMPRuntimeAMDGCN(*this));
+break;
   default:
 if (LangOpts.OpenMPSimd)
   OpenMPRuntime.reset(new CGOpenMPSIMDRuntime(*this));
Index: clang/lib/CodeGen/CMakeLists.txt
===
--- clang/lib/CodeGen/CMakeLists.txt
+++ clang/lib/CodeGen/CMakeLists.txt
@@ -62,6 +62,7 @@
   CGObjCRuntime.cpp
   CGOpenCLRuntime.cpp
   CGOpenMPRuntime.cpp
+  CGOpenMPRuntimeAMDGCN.cpp
   CGOpenMPRuntimeGPU.cpp
   CGOpenMPRuntimeNVPTX.cpp
   CGRecordLayoutBuilder.cpp
Index: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ 

[PATCH] D79744: clang: Use byref for aggregate kernel arguments

2020-07-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/CodeGen/CGFunctionInfo.h:52
+/// IndirectAliased - Similar to Indirect, but the pointer may not be
+/// writable.
+IndirectAliased,

Hmm.  I guess there's actually two different potential conventions here:

- The caller can provide the address of a known-immutable object that has the 
right value, and the callee has to copy it if it needs the object to have a 
unique address or wants to mutate it.

- The caller can provide the address of *any* object that has the right value, 
and the callee has to copy it if it needs the object to have a unique address, 
wants to mutate it, or needs the value to stick around across call boundaries.

The advantage of the second is that IRGen could avoid some copies on the caller 
side, which could be advantageous when the callee is sufficiently trivial.  The 
disadvantage is that the callee would have to defensively copy in more 
situations.

Probably we should use the former.  Please be explicit about it, though:

  Similar to Indirect, but the pointer may be to an object that is otherwise
  referenced.  The object is known to not be modified through any other
  references for the duration of the call, and the callee must not itself
  modify the object.  Because C allows parameter variables to be modified
  and guarantees that they have unique addresses, the callee must
  defensively copy the object into a local variable if it might be modified or
  its address might be compared.  Since those are uncommon, in principle
  this convention allows programs to avoid copies in more situations.
  However, it may introduce *extra* copies if the callee fails to prove that
  a copy is unnecessary and the caller naturally produces an unaliased
  object for the argument.



Comment at: clang/lib/CodeGen/CGCall.cpp:2213
 Attrs.addAlignmentAttr(Align.getQuantity());
 
   // byval disables readnone and readonly.

Please add a TODO here that we could add the `byref` attribute if we're willing 
to update the test cases.  Maybe whoever does that can add alignments at the 
same time.



Comment at: clang/lib/CodeGen/CGCall.cpp:2462
+// may be aliased, copy it since the incoming argument may not be
+// mutable.
 Address V = ParamAddr;

"copy it to ensure that the parameter variable is mutable and has a unique 
address, as C requires".

I've wanted Sema to track whether local variables are mutated or have their 
address taken for a long time; maybe someday we can do that and then take 
advantage of it here.  Just a random thought, sorry.



Comment at: clang/lib/CodeGen/CGCall.cpp:4696
+case ABIArgInfo::IndirectAliased:
+  // This should be similar to Indirect, but no valid use case right now.
+  llvm_unreachable("Call arguments not implemented for IndirectAliased");

Please just make this use the Indirect code.  If we gave it special attention, 
we could optimize it better, but conservatively doing what Indirect does should 
still work.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1997
   case ABIArgInfo::Ignore:
+  case ABIArgInfo::IndirectAliased:
 return false;

In principle, this can be `inreg` just as much as Indirect can.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8816
+  // FIXME: Should use byref when promoting pointers in structs, but this
+  // requires adding implementing the coercion.
+  if (!getContext().getLangOpts().OpenCL && LTy == OrigLTy &&

I don't see why you'd use `byref` when promoting pointers in structs.  Maybe it 
works as a hack with your backend, but it seems *extremely* special-case and 
should not be hacked into the general infrastructure.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9383
   case ABIArgInfo::InAlloca:
+  case ABIArgInfo::IndirectAliased:
 llvm_unreachable("Unsupported ABI kind for va_arg");

No reason not to use the Indirect code here.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9754
+  case ABIArgInfo::IndirectAliased:
 llvm_unreachable("Unsupported ABI kind for va_arg");
   case ABIArgInfo::Ignore:

Same.


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

https://reviews.llvm.org/D79744



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


[clang] 33d9c41 - [tsan] Allow TSan in the Clang driver for Apple Silicon Macs

2020-07-24 Thread Kuba Mracek via cfe-commits

Author: Kuba Mracek
Date: 2020-07-24T20:14:00-07:00
New Revision: 33d9c4109ac234bcf17501ba16880ce80622cc9c

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

LOG: [tsan] Allow TSan in the Clang driver for Apple Silicon Macs

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index f910c88fa967..325dcb7df545 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2714,6 +2714,7 @@ void Darwin::CheckObjCARC() const {
 
 SanitizerMask Darwin::getSupportedSanitizers() const {
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -2731,9 +2732,8 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
   && !(isTargetIPhoneOS() && isIPhoneOSVersionLT(5, 0)))
 Res |= SanitizerKind::Vptr;
 
-  if (isTargetMacOS()) {
-if (IsX86_64)
-  Res |= SanitizerKind::Thread;
+  if ((IsX86_64 || IsAArch64) && isTargetMacOS()) {
+Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 7340bfb35e40..cfefd3fb632c 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -458,6 +458,10 @@
 
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
 // CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option
+// RUN: %clang -target x86_64-apple-macos -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-MACOS
+// CHECK-TSAN-X86-64-MACOS-NOT: unsupported option
+// RUN: %clang -target arm64-apple-macos -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-ARM64-MACOS
+// CHECK-TSAN-ARM64-MACOS-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-iossimulator -fsanitize=thread %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
 // CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option



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


[PATCH] D84082: [tsan] Allow TSan in the Clang driver for Apple Silicon Macs

2020-07-24 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33d9c4109ac2: [tsan] Allow TSan in the Clang driver for 
Apple Silicon Macs (authored by kubamracek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84082

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -458,6 +458,10 @@
 
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
 // CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option
+// RUN: %clang -target x86_64-apple-macos -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-MACOS
+// CHECK-TSAN-X86-64-MACOS-NOT: unsupported option
+// RUN: %clang -target arm64-apple-macos -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-ARM64-MACOS
+// CHECK-TSAN-ARM64-MACOS-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-iossimulator -fsanitize=thread %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
 // CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2714,6 +2714,7 @@
 
 SanitizerMask Darwin::getSupportedSanitizers() const {
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -2731,9 +2732,8 @@
   && !(isTargetIPhoneOS() && isIPhoneOSVersionLT(5, 0)))
 Res |= SanitizerKind::Vptr;
 
-  if (isTargetMacOS()) {
-if (IsX86_64)
-  Res |= SanitizerKind::Thread;
+  if ((IsX86_64 || IsAArch64) && isTargetMacOS()) {
+Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -458,6 +458,10 @@
 
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
 // CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option
+// RUN: %clang -target x86_64-apple-macos -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-MACOS
+// CHECK-TSAN-X86-64-MACOS-NOT: unsupported option
+// RUN: %clang -target arm64-apple-macos -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-ARM64-MACOS
+// CHECK-TSAN-ARM64-MACOS-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-iossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
 // CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2714,6 +2714,7 @@
 
 SanitizerMask Darwin::getSupportedSanitizers() const {
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -2731,9 +2732,8 @@
   && !(isTargetIPhoneOS() && isIPhoneOSVersionLT(5, 0)))
 Res |= SanitizerKind::Vptr;
 
-  if (isTargetMacOS()) {
-if (IsX86_64)
-  Res |= SanitizerKind::Thread;
+  if ((IsX86_64 || IsAArch64) && isTargetMacOS()) {
+Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84572: Allow .dSYM's to be directly placed in an alternate directory

2020-07-24 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders updated this revision to Diff 280653.
dsanders added a comment.

Attempt to fix the windows-specific failure by using posix-style path::append()

That feels wrong but it's consistent with a test in the same file that already
passes because the path manipulation is an extension append
(bar/foo->bar/foo.dSYM) rather than a path component append 
(external->external/foo.dSYM)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84572

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -26,10 +26,21 @@
 //
 // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
 // RUN:   -o foo %s -g 2> %t
-// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
+// RUN: FileCheck -Doutfile=foo -Ddsymfile=foo.dSYM \
+// RUN:  -check-prefix=CHECK-OUTPUT-NAME < %t %s
 //
-// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: 
[{{.*}}], output: "foo"
-// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["foo"], output: "foo.dSYM"
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -o bar/foo %s -g 2> %t
+// RUN: FileCheck -Doutfile=bar/foo -Ddsymfile=bar/foo.dSYM \
+// RUN:   -check-prefix=CHECK-OUTPUT-NAME < %t %s
+//
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -o bar/foo -external-dsym-dir external %s -g 2> %t
+// RUN: FileCheck -Doutfile=bar/foo -Ddsymfile=external/foo.dSYM \
+// RUN:   -check-prefix=CHECK-OUTPUT-NAME < %t %s
+//
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: 
[{{.*}}], output: "[[outfile]]"
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["[[outfile]]"], output: "[[dsymfile]]"
 
 // Check that we only use dsymutil when needed.
 //
@@ -38,12 +49,5 @@
 // RUN:   -o foo %t.o -g 2> %t
 // RUN: not grep "Dsymutil" %t
 
-// Check that we put the .dSYM in the right place.
-// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
-// RUN:   -o bar/foo %s -g 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LOCATION < %t %s
-
-// CHECK-LOCATION: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["bar/foo"], output: "bar/foo.dSYM"
-
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4597,7 +4597,18 @@
   StringRef BaseName;
 
   // Dsymutil actions should use the full path.
-  if (isa(JA) || isa(JA))
+  if (isa(JA) &&
+  C.getArgs().hasArg(options::OPT_external_dsym_dir)) {
+SmallString<128> ExternalPath(
+C.getArgs().getLastArg(options::OPT_external_dsym_dir)->getValue());
+// We use posix style here because the tests (specifically
+// darwin-dsymutil.c) demonstrate that posix style paths are acceptable
+// even on Windows and if we don't then the similar test covering this
+// fails.
+llvm::sys::path::append(ExternalPath, llvm::sys::path::Style::posix,
+llvm::sys::path::filename(BasePath));
+BaseName = ExternalPath;
+  } else if (isa(JA) || isa(JA))
 BaseName = BasePath;
   else
 BaseName = llvm::sys::path::filename(BasePath);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -690,6 +690,9 @@
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">, Flags<[CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
 def e : JoinedOrSeparate<["-"], "e">, Group;
+def external_dsym_dir : JoinedOrSeparate<["-"], "external-dsym-dir">,
+  Flags<[DriverOption, RenderAsInput]>,
+  HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">;
 def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group, 
Flags<[CC1Option]>,
   HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">;
 def fPIC : Flag<["-"], "fPIC">, Group;


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -26,10 +26,21 @@
 //
 // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
 // RUN:   -o foo %s -g 2> %t
-// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
+// RUN: FileCheck -Doutfile=foo -Ddsymfile=foo.dSYM \
+// RUN:  -check-prefix=CHECK-OUTPUT-NAME < %t %s
 //
-// CHECK-OUTPUT-NAME: 

[PATCH] D84375: [git-clang-format] Add --diffstat parameter

2020-07-24 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

This looks fine to me, but I haven't worked on this part of code myself, so 
probably others who have can provide better review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84375



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


[PATCH] D84556: [WebAssembly] Remove intrinsics for SIMD widening ops

2020-07-24 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/test/CodeGen/WebAssembly/simd-widening.ll:113
+
+;; Also test that similar patterns are still expanded correctly
+

It'd be clearer to say starting indices of these don't start with 0 or 
[lanecount - 1] so they can't be widened using `widen_low` or `widen_high` 
instructions.

Question: Can we also widen these using shifts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84556



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2037
+bool isGeneratingTemporaryObject =
+ContainsCompileOrAssembleAction(Actions.back()) || LTOMode != 
LTOK_None;
 if ((enablesDebugInfo || willEmitRemarks(Args)) &&

beanz wrote:
> dsanders wrote:
> > This should fix the same issue as the workaround I was using in D84127.
> > 
> > I'm not entirely convinced that this is all of it though. It seems strange 
> > to me that these two scripts produce different build products (aside from 
> > ret0.o):
> > ```
> > $ rm -rf external ret0 ret0.*
> > $ echo 'int main() { return 0; }' > ret0.c
> > $ use_cflags="--sysroot=$SYSROOT -g"
> > $ ../build/bin/clang -o ret0 ret0.c ${=use_cflags}
> > $ ls
> > ret0  ret0.cret0.dSYM
> > ```
> > ```
> > $ rm -rf external ret0 ret0.*
> > $ echo 'int main() { return 0; }' > ret0.c
> > $ use_cflags="--sysroot=$SYSROOT -g"
> > $ ../build/bin/clang -c -o ret0.o ret0.c ${=use_cflags}
> > $ ../build/bin/clang -o ret0 ret0.o ${=use_cflags}
> > $ ls
> > ret0   ret0.c ret0.o
> > ```
> > I'd expect them to either consistently extract the dSYM or consistently 
> > lipo the slices together including the debug info. I don't have a strong 
> > opinion about which is right, it's just the inconsistency that's bothering 
> > me
> The reason they behave differently is because in the case where clang 
> compiles + links in the same invocation the intermediate object files are 
> deleted. In MachO we do not link debug information in ld, instead we do it in 
> dsymutil. dsymutil cannot run across a temporary object file that has been 
> deleted, so the clang driver runs it for you.
> 
> Clang doesn't run it in the case of just linking object files because it 
> takes time and isn't strictly required as long as you keep all your object 
> files around so that your debugger can find the unlinked debug info in the 
> object files. This is why one of the common ways people speed up debug builds 
> with mach-o is to skip dSYM generation.
That makes sense. Although when you do want dSYM's, it does end up requiring 
the build system to know the logic clang is using and either move the one clang 
emitted or invoke dsymutil to make one depending on what clang did. 

At the moment, the options that cause dsymutil to be invoked by clang that I 
know of are -flto, compiling/assembling, and multiple values for -arch. It 
would be easier on the build system if it could force them to be emitted and 
control where they end up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders added a comment.

In D84565#2173770 , @dsanders wrote:

> In D84565#2173744 , @beanz wrote:
>
> > @JDevlieghere you are right, I'm missing the change to how clang determines 
> > it needs to pass the linker the object file path. Update coming momentarily.
>
>
> Isn't that already based on isUsingLTO() and getLTOMode() or is there another 
> bit? I'm looking at darwin::Linker::AddLinkArgs()


Never mind. I've just seen the update :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders added a comment.

In D84565#2173744 , @beanz wrote:

> @JDevlieghere you are right, I'm missing the change to how clang determines 
> it needs to pass the linker the object file path. Update coming momentarily.


Isn't that already based on isUsingLTO() and getLTOMode() or is there another 
bit? I'm looking at darwin::Linker::AddLinkArgs()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz marked an inline comment as done.
beanz added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2037
+bool isGeneratingTemporaryObject =
+ContainsCompileOrAssembleAction(Actions.back()) || LTOMode != 
LTOK_None;
 if ((enablesDebugInfo || willEmitRemarks(Args)) &&

dsanders wrote:
> This should fix the same issue as the workaround I was using in D84127.
> 
> I'm not entirely convinced that this is all of it though. It seems strange to 
> me that these two scripts produce different build products (aside from 
> ret0.o):
> ```
> $ rm -rf external ret0 ret0.*
> $ echo 'int main() { return 0; }' > ret0.c
> $ use_cflags="--sysroot=$SYSROOT -g"
> $ ../build/bin/clang -o ret0 ret0.c ${=use_cflags}
> $ ls
> ret0  ret0.cret0.dSYM
> ```
> ```
> $ rm -rf external ret0 ret0.*
> $ echo 'int main() { return 0; }' > ret0.c
> $ use_cflags="--sysroot=$SYSROOT -g"
> $ ../build/bin/clang -c -o ret0.o ret0.c ${=use_cflags}
> $ ../build/bin/clang -o ret0 ret0.o ${=use_cflags}
> $ ls
> ret0   ret0.c ret0.o
> ```
> I'd expect them to either consistently extract the dSYM or consistently lipo 
> the slices together including the debug info. I don't have a strong opinion 
> about which is right, it's just the inconsistency that's bothering me
The reason they behave differently is because in the case where clang compiles 
+ links in the same invocation the intermediate object files are deleted. In 
MachO we do not link debug information in ld, instead we do it in dsymutil. 
dsymutil cannot run across a temporary object file that has been deleted, so 
the clang driver runs it for you.

Clang doesn't run it in the case of just linking object files because it takes 
time and isn't strictly required as long as you keep all your object files 
around so that your debugger can find the unlinked debug info in the object 
files. This is why one of the common ways people speed up debug builds with 
mach-o is to skip dSYM generation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 280647.
beanz added a comment.

Updated to also pass the linker -object_path_lto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -47,3 +47,13 @@
 
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
+
+// Check that clang provides the linker with a temporary object file path and
+// runs dsymutil when -flto is specified and no source is provided
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 %t.o -g -flto -### \
+// RUN:   2> %t
+// RUN: FileCheck -check-prefix=CHECK-DSYMUTIL-LTO < %t %s
+
+// CHECK-DSYMUTIL-LTO: "/usr/bin/ld" "-demangle" "-object_path_lto"
+// CHECK-DSYMUTIL-LTO: "/usr/bin/dsymutil" "-o" "a.out.dSYM" "a.out"
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -59,7 +59,8 @@
 };
 
 class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
-  bool NeedsTempPath(const InputInfoList ) const;
+  bool NeedsTempPath(const InputInfoList ,
+ const llvm::opt::ArgList ) const;
   void AddLinkArgs(Compilation , const llvm::opt::ArgList ,
llvm::opt::ArgStringList ,
const InputInfoList , unsigned Version[5]) const;
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -167,7 +167,13 @@
 CmdArgs.push_back("-force_cpusubtype_ALL");
 }
 
-bool darwin::Linker::NeedsTempPath(const InputInfoList ) const {
+bool darwin::Linker::NeedsTempPath(const InputInfoList ,
+   const ArgList ) const {
+  Arg *A = Args.getLastArg(options::OPT_g_Group);
+  if (A && !A->getOption().matches(options::OPT_g0) &&
+  !A->getOption().matches(options::OPT_gstabs))
+return true;
+
   // We only need to generate a temp path for LTO if we aren't compiling object
   // files. When compiling source files, we run 'dsymutil' after linking. We
   // don't run 'dsymutil' when compiling object files.
@@ -222,7 +228,7 @@
options::OPT_fno_application_extension, false))
 CmdArgs.push_back("-application_extension");
 
-  if (D.isUsingLTO() && Version[0] >= 116 && NeedsTempPath(Inputs)) {
+  if (D.isUsingLTO() && Version[0] >= 116 && NeedsTempPath(Inputs, Args)) {
 std::string TmpPathName;
 if (D.getLTOMode() == LTOK_Full) {
   // If we are using full LTO, then automatically create a temporary file
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2033,13 +2033,17 @@
 Arg *A = Args.getLastArg(options::OPT_g_Group);
 bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_gstabs);
+bool isGeneratingTemporaryObject =
+ContainsCompileOrAssembleAction(Actions.back()) || isUsingLTO();
 if ((enablesDebugInfo || willEmitRemarks(Args)) &&
-ContainsCompileOrAssembleAction(Actions.back())) {
+isGeneratingTemporaryObject) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we
-  // have a compile input. We need to run 'dsymutil' ourselves in such 
cases
-  // because the debug info will refer to a temporary object file which
-  // will be removed at the end of the compilation process.
+  // are linking a temporary object. This occurs when we have a compiler
+  // or assmbler input or if LTO is enabled. We need to run 'dsymutil'
+  // ourselves in such cases because the debug info will refer to the
+  // temporary object file which will be removed at the end of the
+  // compilation process.
   if (Act->getType() == types::TY_Image) {
 ActionList Inputs;
 Inputs.push_back(Actions.back());


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -47,3 +47,13 @@
 
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
+
+// Check that clang provides the linker with a temporary object file path and
+// runs dsymutil when -flto is specified and no source 

[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders added a comment.

In D84565#2173615 , @JDevlieghere 
wrote:

> When you don’t pass any specific options to the linker, it’s going to 
> generate a temporary `lto.o` file in `/tmp` and delete it after the link. 
> When `dsymutil` will try to read that, it won't be there anymore. Unless I'm 
> missing I don't think this is going to work. If it turns out I'm mistaken 
> please add that situation as a test case.


Are you thinking of the `-Wl,-object_path_lto,path/foo-lto.o` code in 
AddLLVM.cmake where dsymutil is invoked after clang finishes? I'm using the 
same code path as this patch in https://reviews.llvm.org/D84127 using an empty 
source file to force ContainsCompileOrAssembleAction() to be true and get 
dsymutil to be invoked. When clang manages both the per-arch links and the 
dsymutil, the temporary objects get unique names (e.g. `-object_path_lto 
/var/folders/0s/8zdwsz0d1glcx6v1nc_nv5gwgn/T/cc-95f3fc.o`) and stick around 
until after dsymutil is invoked.




Comment at: clang/lib/Driver/Driver.cpp:2037
+bool isGeneratingTemporaryObject =
+ContainsCompileOrAssembleAction(Actions.back()) || LTOMode != 
LTOK_None;
 if ((enablesDebugInfo || willEmitRemarks(Args)) &&

This should fix the same issue as the workaround I was using in D84127.

I'm not entirely convinced that this is all of it though. It seems strange to 
me that these two scripts produce different build products (aside from ret0.o):
```
$ rm -rf external ret0 ret0.*
$ echo 'int main() { return 0; }' > ret0.c
$ use_cflags="--sysroot=$SYSROOT -g"
$ ../build/bin/clang -o ret0 ret0.c ${=use_cflags}
$ ls
ret0  ret0.cret0.dSYM
```
```
$ rm -rf external ret0 ret0.*
$ echo 'int main() { return 0; }' > ret0.c
$ use_cflags="--sysroot=$SYSROOT -g"
$ ../build/bin/clang -c -o ret0.o ret0.c ${=use_cflags}
$ ../build/bin/clang -o ret0 ret0.o ${=use_cflags}
$ ls
ret0   ret0.c ret0.o
```
I'd expect them to either consistently extract the dSYM or consistently lipo 
the slices together including the debug info. I don't have a strong opinion 
about which is right, it's just the inconsistency that's bothering me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

@JDevlieghere you are right, I'm missing the change to how clang determines it 
needs to pass the linker the object file path. Update coming momentarily.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 280641.
beanz added a comment.

Fixing bad test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -47,3 +47,11 @@
 
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
+
+// Check that we run dsymutil when -flto is specified and no source is provided
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -arch x86_64 %t.o -g -flto 2> %t
+// RUN: FileCheck -check-prefix=CHECK-DSYMUTIL-LTO < %t %s
+
+// CHECK-DSYMUTIL-LTO: x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["a.out"], output: "a.out.dSYM"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2033,13 +2033,17 @@
 Arg *A = Args.getLastArg(options::OPT_g_Group);
 bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_gstabs);
+bool isGeneratingTemporaryObject =
+ContainsCompileOrAssembleAction(Actions.back()) || LTOMode != 
LTOK_None;
 if ((enablesDebugInfo || willEmitRemarks(Args)) &&
-ContainsCompileOrAssembleAction(Actions.back())) {
+isGeneratingTemporaryObject) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we
-  // have a compile input. We need to run 'dsymutil' ourselves in such 
cases
-  // because the debug info will refer to a temporary object file which
-  // will be removed at the end of the compilation process.
+  // are linking a temporary object. This occurs when we have a compiler
+  // or assmbler input or if LTO is enabled. We need to run 'dsymutil'
+  // ourselves in such cases because the debug info will refer to the
+  // temporary object file which will be removed at the end of the
+  // compilation process.
   if (Act->getType() == types::TY_Image) {
 ActionList Inputs;
 Inputs.push_back(Actions.back());


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -47,3 +47,11 @@
 
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
+
+// Check that we run dsymutil when -flto is specified and no source is provided
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -arch x86_64 %t.o -g -flto 2> %t
+// RUN: FileCheck -check-prefix=CHECK-DSYMUTIL-LTO < %t %s
+
+// CHECK-DSYMUTIL-LTO: x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["a.out"], output: "a.out.dSYM"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2033,13 +2033,17 @@
 Arg *A = Args.getLastArg(options::OPT_g_Group);
 bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_gstabs);
+bool isGeneratingTemporaryObject =
+ContainsCompileOrAssembleAction(Actions.back()) || LTOMode != LTOK_None;
 if ((enablesDebugInfo || willEmitRemarks(Args)) &&
-ContainsCompileOrAssembleAction(Actions.back())) {
+isGeneratingTemporaryObject) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we
-  // have a compile input. We need to run 'dsymutil' ourselves in such cases
-  // because the debug info will refer to a temporary object file which
-  // will be removed at the end of the compilation process.
+  // are linking a temporary object. This occurs when we have a compiler
+  // or assmbler input or if LTO is enabled. We need to run 'dsymutil'
+  // ourselves in such cases because the debug info will refer to the
+  // temporary object file which will be removed at the end of the
+  // compilation process.
   if (Act->getType() == types::TY_Image) {
 ActionList Inputs;
 Inputs.push_back(Actions.back());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84572: Allow .dSYM's to be directly placed in an alternate directory

2020-07-24 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders created this revision.
dsanders added reviewers: beanz, bogner.
Herald added a reviewer: JDevlieghere.
Herald added subscribers: cfe-commits, dang.
Herald added a project: clang.

Once available in the relevant toolchains this will allow us to implement
LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR after D84127 
 by directly placing the dSYM
in the desired location instead of emitting next to the output file and moving
it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84572

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -26,10 +26,21 @@
 //
 // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
 // RUN:   -o foo %s -g 2> %t
-// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
+// RUN: FileCheck -Doutfile=foo -Ddsymfile=foo.dSYM \
+// RUN:  -check-prefix=CHECK-OUTPUT-NAME < %t %s
 //
-// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: 
[{{.*}}], output: "foo"
-// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["foo"], output: "foo.dSYM"
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -o bar/foo %s -g 2> %t
+// RUN: FileCheck -Doutfile=bar/foo -Ddsymfile=bar/foo.dSYM \
+// RUN:   -check-prefix=CHECK-OUTPUT-NAME < %t %s
+//
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -o bar/foo -external-dsym-dir external %s -g 2> %t
+// RUN: FileCheck -Doutfile=bar/foo -Ddsymfile=external/foo.dSYM \
+// RUN:   -check-prefix=CHECK-OUTPUT-NAME < %t %s
+//
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: 
[{{.*}}], output: "[[outfile]]"
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["[[outfile]]"], output: "[[dsymfile]]"
 
 // Check that we only use dsymutil when needed.
 //
@@ -38,12 +49,5 @@
 // RUN:   -o foo %t.o -g 2> %t
 // RUN: not grep "Dsymutil" %t
 
-// Check that we put the .dSYM in the right place.
-// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
-// RUN:   -o bar/foo %s -g 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LOCATION < %t %s
-
-// CHECK-LOCATION: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["bar/foo"], output: "bar/foo.dSYM"
-
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4597,7 +4597,13 @@
   StringRef BaseName;
 
   // Dsymutil actions should use the full path.
-  if (isa(JA) || isa(JA))
+  if (isa(JA) &&
+  C.getArgs().hasArg(options::OPT_external_dsym_dir)) {
+SmallString<128> ExternalPath(
+C.getArgs().getLastArg(options::OPT_external_dsym_dir)->getValue());
+llvm::sys::path::append(ExternalPath, llvm::sys::path::filename(BasePath));
+BaseName = ExternalPath;
+  } else if (isa(JA) || isa(JA))
 BaseName = BasePath;
   else
 BaseName = llvm::sys::path::filename(BasePath);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -690,6 +690,9 @@
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">, Flags<[CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
 def e : JoinedOrSeparate<["-"], "e">, Group;
+def external_dsym_dir : JoinedOrSeparate<["-"], "external-dsym-dir">,
+  Flags<[DriverOption, RenderAsInput]>,
+  HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">;
 def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group, 
Flags<[CC1Option]>,
   HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">;
 def fPIC : Flag<["-"], "fPIC">, Group;


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -26,10 +26,21 @@
 //
 // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
 // RUN:   -o foo %s -g 2> %t
-// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
+// RUN: FileCheck -Doutfile=foo -Ddsymfile=foo.dSYM \
+// RUN:  -check-prefix=CHECK-OUTPUT-NAME < %t %s
 //
-// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [{{.*}}], output: "foo"
-// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["foo"], output: "foo.dSYM"
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -o bar/foo %s -g 2> %t
+// RUN: FileCheck 

[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-07-24 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74790a5dde9a: [PowerPC] Implement Truncate and Store VSX 
Vector Builtins (authored by amyk).

Changed prior to commit:
  https://reviews.llvm.org/D82467?vs=276881=280634#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -2,9 +2,12 @@
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
 ; RUN:   FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O0 \
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
 ; RUN:   FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O0 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s --check-prefix=CHECK-O0
 
 ; These test cases aims to test the builtins for the Power10 VSX vector
 ; instructions introduced in ISA 3.1.
@@ -19,6 +22,14 @@
 ; CHECK-NEXT:srwi r3, r3, 31
 ; CHECK-NEXT:extsw r3, r3
 ; CHECK-NEXT:blr
+;
+; CHECK-O0-LABEL: test_vec_test_lsbb_all_ones:
+; CHECK-O0:   # %bb.0: # %entry
+; CHECK-O0-NEXT:xvtlsbb cr0, v2
+; CHECK-O0-NEXT:mfocrf r3, 128
+; CHECK-O0-NEXT:srwi r3, r3, 31
+; CHECK-O0-NEXT:extsw r3, r3
+; CHECK-O0-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 1)
   ret i32 %0
@@ -32,7 +43,199 @@
 ; CHECK-NEXT:rlwinm r3, r3, 3, 31, 31
 ; CHECK-NEXT:extsw r3, r3
 ; CHECK-NEXT:blr
+;
+; CHECK-O0-LABEL: test_vec_test_lsbb_all_zeros:
+; CHECK-O0:   # %bb.0: # %entry
+; CHECK-O0-NEXT:xvtlsbb cr0, v2
+; CHECK-O0-NEXT:mfocrf r3, 128
+; CHECK-O0-NEXT:rlwinm r3, r3, 3, 31, 31
+; CHECK-O0-NEXT:extsw r3, r3
+; CHECK-O0-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 0)
   ret i32 %0
 }
+
+define void @vec_xst_trunc_sc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_sc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stxvrbx v2, r6, r5
+; CHECK-NEXT:blr
+;
+; CHECK-O0-LABEL: vec_xst_trunc_sc:
+; CHECK-O0:   # %bb.0: # %entry
+; CHECK-O0-NEXT:li r3, 0
+; CHECK-O0-NEXT:vextubrx r3, r3, v2
+; CHECK-O0-NEXT:# kill: def $r3 killed $r3 killed $x3
+; CHECK-O0-NEXT:add r4, r6, r5
+; CHECK-O0-NEXT:stb r3, 0(r4)
+; CHECK-O0-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <16 x i8>
+  %conv = extractelement <16 x i8> %0, i32 0
+  %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
+  store i8 %conv, i8* %add.ptr, align 1
+  ret void
+}
+
+define void @vec_xst_trunc_uc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_uc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stxvrbx v2, r6, r5
+; CHECK-NEXT:blr
+;
+; CHECK-O0-LABEL: vec_xst_trunc_uc:
+; CHECK-O0:   # %bb.0: # %entry
+; CHECK-O0-NEXT:li r3, 0
+; CHECK-O0-NEXT:vextubrx r3, r3, v2
+; CHECK-O0-NEXT:# kill: def $r3 killed $r3 killed $x3
+; CHECK-O0-NEXT:add r4, r6, r5
+; CHECK-O0-NEXT:stb r3, 0(r4)
+; CHECK-O0-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <16 x i8>
+  %conv = extractelement <16 x i8> %0, i32 0
+  %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
+  store i8 %conv, i8* %add.ptr, align 1
+  ret void
+}
+
+define void @vec_xst_trunc_ss(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_ss:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 1
+; CHECK-NEXT:stxvrhx v2, r6, r3
+; CHECK-NEXT:blr
+;
+; CHECK-O0-LABEL: vec_xst_trunc_ss:
+; CHECK-O0:   # %bb.0: # %entry
+; CHECK-O0-NEXT:li r3, 0
+; CHECK-O0-NEXT:vextuhrx r3, r3, v2
+; CHECK-O0-NEXT:# kill: def $r3 killed $r3 killed $x3
+; CHECK-O0-NEXT:sldi r4, r5, 1
+; CHECK-O0-NEXT:add r4, r6, r4
+; CHECK-O0-NEXT:sth r3, 0(r4)
+; CHECK-O0-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <8 x i16>
+  %conv = extractelement <8 x i16> %0, i32 0
+  %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
+  store i16 %conv, i16* %add.ptr, align 2
+  ret void
+}
+
+define void @vec_xst_trunc_us(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_us:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, 

[clang] 74790a5 - [PowerPC] Implement Truncate and Store VSX Vector Builtins

2020-07-24 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-07-24T19:22:39-05:00
New Revision: 74790a5dde9ae01b7e96bea0b2596ef37b5325bd

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

LOG: [PowerPC] Implement Truncate and Store VSX Vector Builtins

This patch implements the `vec_xst_trunc` function in altivec.h in  order to
utilize the Store VSX Vector Rightmost [byte | half | word | doubleword] Indexed
instructions introduced in Power10.

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

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index ac5f43836316..4e25ec118072 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16597,6 +16597,58 @@ static inline __ATTRS_o_ai void vec_xst(vector 
unsigned __int128 __vec,
 }
 #endif
 
+/* vec_xst_trunc */
+
+#if defined(__POWER10_VECTOR__) && defined(__VSX__)
+static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+  signed long long __offset,
+  signed char *__ptr) {
+  *(__ptr + __offset) = (signed char)__vec[0];
+}
+
+static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
+  signed long long __offset,
+  unsigned char *__ptr) {
+  *(__ptr + __offset) = (unsigned char)__vec[0];
+}
+
+static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+  signed long long __offset,
+  signed short *__ptr) {
+  *(__ptr + __offset) = (signed short)__vec[0];
+}
+
+static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
+  signed long long __offset,
+  unsigned short *__ptr) {
+  *(__ptr + __offset) = (unsigned short)__vec[0];
+}
+
+static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+  signed long long __offset,
+  signed int *__ptr) {
+  *(__ptr + __offset) = (signed int)__vec[0];
+}
+
+static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
+  signed long long __offset,
+  unsigned int *__ptr) {
+  *(__ptr + __offset) = (unsigned int)__vec[0];
+}
+
+static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+  signed long long __offset,
+  signed long long *__ptr) {
+  *(__ptr + __offset) = (signed long long)__vec[0];
+}
+
+static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
+  signed long long __offset,
+  unsigned long long *__ptr) {
+  *(__ptr + __offset) = (unsigned long long)__vec[0];
+}
+#endif
+
 /* vec_xst_be */
 
 #ifdef __LITTLE_ENDIAN__

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
index 6f38ac77ee24..2182a19f2452 100644
--- a/clang/test/CodeGen/builtins-ppc-p10vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -582,6 +582,54 @@ vector float test_vec_vec_splati_ins_f(void) {
   return vec_splati_ins(vfa, 0, 1.0f);
 }
 
+void test_vec_xst_trunc_sc(vector signed __int128 __a, signed long long __b,
+   signed char *__c) {
+  // CHECK: store i8 %{{.+}}, i8* %{{.+}}, align 1
+  vec_xst_trunc(__a, __b, __c);
+}
+
+void test_vec_xst_trunc_uc(vector unsigned __int128 __a, signed long long __b,
+   unsigned char *__c) {
+  // CHECK: store i8 %{{.+}}, i8* %{{.+}}, align 1
+  vec_xst_trunc(__a, __b, __c);
+}
+
+void test_vec_xst_trunc_ss(vector signed __int128 __a, signed long long __b,
+   signed short *__c) {
+  // CHECK: store i16 %{{.+}}, i16* %{{.+}}, align 2
+  vec_xst_trunc(__a, __b, __c);
+}
+
+void test_vec_xst_trunc_us(vector unsigned __int128 __a, signed long long __b,
+   unsigned short *__c) {
+  // CHECK: store i16 %{{.+}}, i16* %{{.+}}, align 2
+  vec_xst_trunc(__a, __b, __c);
+}
+
+void test_vec_xst_trunc_si(vector signed __int128 __a, signed long long __b,
+   signed int *__c) {
+  // CHECK: store i32 %{{.+}}, i32* %{{.+}}, align 4
+  

[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere requested changes to this revision.
JDevlieghere added a comment.
This revision now requires changes to proceed.

When you don’t pass any specific options to the linker, it’s going to generate 
a temporary `lto.o` file in `/tmp` and delete it after the link. When 
`dsymutil` will try to read that, it won't be there anymore. Unless I'm missing 
I don't think this is going to work. If it turns out I'm mistaken please add 
that situation as a test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565



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


[PATCH] D84182: [OPENMP]Fix PR46012: declare target pointer cannot be accessed in target region.

2020-07-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D84182#2173577 , @grokos wrote:

> @ABataev:
>
> After this patch was committed, I tried to run the following example:
>
>   #include 
>  
>   int *yptr;
>  
>   int main() {
> int y[10];
> y[1] = 1;
> yptr = [0];
>  
> printf(" = %p\n", );
> printf("[0] = %p\n", [0]);
>  
> #pragma omp target data map(to: yptr[0:5])
> #pragma omp target
> {
>   printf("y = %d\n", yptr[1]);
>   yptr[1] = 10;
>   printf("y = %d\n", yptr[1]);
> }
>  
> printf("y = %d\n", yptr[1]);
> return 0;
>   }
>
>
> The arguments clang generates are:
>
>   1) base = [0], begin = , size = 8, type = TARGET_PARAM | TO
>   2) base = , begin = [0], size = 8, type = PTR_AND_OBJ | TO
>
>
> The second argument is correct, the first argument doesn't make much sense. I 
> believe it should have its base set to , not [0].
>  y[0] is not the base for anything, it's only the pointee object.


Yes, I know, investigating it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84182



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


[PATCH] D84182: [OPENMP]Fix PR46012: declare target pointer cannot be accessed in target region.

2020-07-24 Thread George Rokos via Phabricator via cfe-commits
grokos added a comment.

@ABataev:

After this patch was committed, I tried to run the following example:

  #include 
  
  int *yptr;
  
  int main() {
int y[10];
y[1] = 1;
yptr = [0];
  
printf(" = %p\n", );
printf("[0] = %p\n", [0]);
  
#pragma omp target data map(to: yptr[0:5])
#pragma omp target
{
  printf("y = %d\n", yptr[1]);
  yptr[1] = 10;
  printf("y = %d\n", yptr[1]);
}
  
printf("y = %d\n", yptr[1]);
return 0;
  }

The arguments clang generates are:

  1) base = [0], begin = , size = 8, type = TARGET_PARAM | TO
  2) base = , begin = [0], size = 8, type = PTR_AND_OBJ | TO

The second argument is correct, the first argument doesn't make much sense. I 
believe it should have its base set to , not [0].
y[0] is not the base for anything, it's only the pointee object.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84182



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz created this revision.
beanz added reviewers: bogner, compnerd, aprantl, arphaman.
Herald added subscribers: dexonsmith, inglorion.
Herald added a reviewer: JDevlieghere.
Herald added a project: clang.

Clang should always add a dsymutil step whenever debug information is
generated and the compiler is acting as the linker driver with
temporary object files.

https://bugs.llvm.org/show_bug.cgi?id=46841


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84565

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -47,3 +47,11 @@
 
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
+
+// Check that we run dsymutil when -flto is specified and no source is provided
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -arch x86_64 %t.o -g -flto 2> %t
+// RUN: FileCheck -check-prefix=CHECK-DSYMUTIL-LTO < %t %s
+
+// CHECK-DSYMUTIL-LTO: "/usr/bin/dsymutil" "-o" "a.out.dSYM" "a.out"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2033,13 +2033,17 @@
 Arg *A = Args.getLastArg(options::OPT_g_Group);
 bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_gstabs);
+bool isGeneratingTemporaryObject =
+ContainsCompileOrAssembleAction(Actions.back()) || LTOMode != 
LTOK_None;
 if ((enablesDebugInfo || willEmitRemarks(Args)) &&
-ContainsCompileOrAssembleAction(Actions.back())) {
+isGeneratingTemporaryObject) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we
-  // have a compile input. We need to run 'dsymutil' ourselves in such 
cases
-  // because the debug info will refer to a temporary object file which
-  // will be removed at the end of the compilation process.
+  // are linking a temporary object. This occurs when we have a compiler
+  // or assmbler input or if LTO is enabled. We need to run 'dsymutil'
+  // ourselves in such cases because the debug info will refer to the
+  // temporary object file which will be removed at the end of the
+  // compilation process.
   if (Act->getType() == types::TY_Image) {
 ActionList Inputs;
 Inputs.push_back(Actions.back());


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -47,3 +47,11 @@
 
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
+
+// Check that we run dsymutil when -flto is specified and no source is provided
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -arch x86_64 %t.o -g -flto 2> %t
+// RUN: FileCheck -check-prefix=CHECK-DSYMUTIL-LTO < %t %s
+
+// CHECK-DSYMUTIL-LTO: "/usr/bin/dsymutil" "-o" "a.out.dSYM" "a.out"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2033,13 +2033,17 @@
 Arg *A = Args.getLastArg(options::OPT_g_Group);
 bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_gstabs);
+bool isGeneratingTemporaryObject =
+ContainsCompileOrAssembleAction(Actions.back()) || LTOMode != LTOK_None;
 if ((enablesDebugInfo || willEmitRemarks(Args)) &&
-ContainsCompileOrAssembleAction(Actions.back())) {
+isGeneratingTemporaryObject) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we
-  // have a compile input. We need to run 'dsymutil' ourselves in such cases
-  // because the debug info will refer to a temporary object file which
-  // will be removed at the end of the compilation process.
+  // are linking a temporary object. This occurs when we have a compiler
+  // or assmbler input or if LTO is enabled. We need to run 'dsymutil'
+  // ourselves in such cases because the debug info will refer to the
+  // temporary object file which will be removed at the end of the
+  // compilation process.
   if (Act->getType() == types::TY_Image) {
 ActionList Inputs;
 Inputs.push_back(Actions.back());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84564: [darwin] build and link with a separate compiler-rt builtins library for device simulators

2020-07-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: steven_wu, dexonsmith.
Herald added subscribers: Sanitizers, ributzka, jkorous, kristof.beyls, mgorny, 
dberris.
Herald added projects: clang, Sanitizers.

This change separates out the iOS/tvOS/watchOS simulator slices from the 
"libclang_rt..a" fat archive, by moving them out to their own 
"libclang_rt.sim.a" static archive. 
This allows us to build and to link with an arm64 device simulator slice for 
the simulators running on Apple Silicons, and to distribute it in one archive 
alongside the Intel simulator slices.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84564

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.iossim.a
  clang/test/Driver/darwin-ld.c
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake


Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -289,6 +289,15 @@
 endforeach(cflag)
   endif()
 
+  if ("${LIB_OS}" MATCHES ".*sim$")
+# Pass an explicit -simulator environment to the -target option to ensure
+# that we don't rely on the architecture to infer whether we're building
+# for the simulator.
+string(REGEX REPLACE "sim" "" base_os "${LIB_OS}")
+list(APPEND builtin_cflags
+ -target 
"${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator")
+  endif()
+
   set_target_compile_flags(${libname}
 ${sysroot_flag}
 ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}
@@ -449,16 +458,13 @@
 endif()
   endforeach()
 
-  # We put the x86 sim slices into the archives for their base OS
   foreach (os ${ARGN})
-if(NOT ${os} MATCHES ".*sim$")
-  darwin_lipo_libs(clang_rt.${os}
-PARENT_TARGET builtins
-LIPO_FLAGS ${${os}_builtins_lipo_flags} 
${${os}sim_builtins_lipo_flags}
-DEPENDS ${${os}_builtins_libs} 
${${os}sim_builtins_libs}
-OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
-INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR})
-endif()
+darwin_lipo_libs(clang_rt.${os}
+ PARENT_TARGET builtins
+ LIPO_FLAGS ${${os}_builtins_lipo_flags}
+ DEPENDS ${${os}_builtins_libs}
+ OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+ INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR})
   endforeach()
   darwin_add_embedded_builtin_libraries()
 endmacro()
Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -156,7 +156,7 @@
 // RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
 // LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
 // LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
-// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+// LINK_IOSSIM_PROFILE: libclang_rt.iossim.a
 
 // RUN: %clang -target arm64-apple-tvos8.3 -mlinker-version=400 
-mtvos-version-min=8.3 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1062,10 +1062,9 @@
 DarwinLibName += Component;
 if (!(Opts & RLO_IsEmbedded))
   DarwinLibName += "_";
-DarwinLibName += getOSLibraryNameSuffix();
-  } else
-DarwinLibName += getOSLibraryNameSuffix(true);
+  }
 
+  DarwinLibName += getOSLibraryNameSuffix();
   DarwinLibName += IsShared ? "_dynamic.dylib" : ".a";
   SmallString<128> Dir(getDriver().ResourceDir);
   llvm::sys::path::append(


Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -289,6 +289,15 @@
 endforeach(cflag)
   endif()
 
+  if ("${LIB_OS}" MATCHES ".*sim$")
+# Pass an explicit -simulator environment to the -target option to ensure
+# that we don't rely on the architecture to infer whether we're building
+# for the simulator.
+string(REGEX REPLACE "sim" "" base_os "${LIB_OS}")
+list(APPEND builtin_cflags
+ -target "${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator")
+  endif()
+
   set_target_compile_flags(${libname}
 ${sysroot_flag}
 ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}
@@ -449,16 +458,13 @@
 endif()
   endforeach()
 
-  # We put the x86 sim slices into the archives for their base OS
   foreach (os ${ARGN})
-if(NOT ${os} MATCHES ".*sim$")
-  

[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(Sorry this has been pending a while - I think it's basically there. Only 
things we really need to address to land this is have a consistent view of what 
the canonical decl is for the no-@interface case, and avoid too much 
duplication of mechanisms in the tests)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:360
+   dyn_cast(D)) {
+  // Objective-C implementation should map back to its interface.
+  D = IID->getClassInterface();

This just describes what the code is doing, say why instead?
// We treat ObjC{Interface,Implementation}Decl as if they were a decl/def pair.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:696
+  )cpp";
+  EXPECT_DECLS("ObjCImplementationDecl", "@interface Implicit");
+

Hmm, do we want to use the @interface or @implementation for this case? The 
interface is implicit but probably still has a valid location.
Currently symbolcollector and findtarget do different things...



Comment at: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp:614
+
+TEST_F(SymbolCollectorTest, ObjCClassExtensions) {
+  Annotations Header(R"(

dgoldman wrote:
> Here's the ClassExtension that I was talking about.
> 
> Ideally we can map each
> 
> `Cat ()` --> `@implementation Cat` like I did in XRefs
> 
> But as you said the `Cat ()` could be in a different file and I think it has 
> a different USR.
> 
> See also 
> https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html#//apple_ref/doc/uid/TP40011210-CH6-SW3
> Ideally we can map each
> Cat () --> @implementation Cat like I did in XRefs

I'm not sure there's anything that would ideally be done differently here.
The logic in xrefs is a special "go-to-definition" action - there's some 
ambiguity about what's being *targeted* by the user. But here there's no 
targeting going on, and there's no ambiguity about what's being *declared*.

The thing to test would be that we're emitting *refs* from `@interface [[Cat]] 
()` to catdecl.




Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:710
+  R"objc(
+@class Foo;
+@interface $decl[[Foo]]

maybe add a comment like // prefer interface definition over forward declaration



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:803
+  };
+  for (const char *Test : Tests) {
+Annotations T(Test);

this seems to be copy/pasted from the test above.
Is there a reason this can't be part of the test above?



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:838
+
+TEST(LocateSymbol, MultipleDeclsWithSameDefinition) {
+  // Ranges in tests:

and again here

Desire to split these tables up into named tests is something we want to 
address somehow, but we don't have a good answer right now and it's important 
for maintenance that the logic/annotation conventions don't diverge across 
different tests that could be the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-07-24 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

The `llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll` file actually exists, 
and there is a BE RUN line in it. I realized I didn't rebase this diff to my 
previous patch that introduced it. Thus on the commit, I will append my tests 
to that file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467



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


[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-24 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added a comment.

In D84422#2173449 , @RaviNarayanaswamy 
wrote:

> In D84422#2173372 , @jdenny wrote:
>
> > In D84422#2172898 , @jdenny wrote:
> >
> > > Has anyone clarified the motivation for this behavior?
> >
> >
> > I meant, is there any insight into why the spec specifies this behavior?
> >
> > In D84422#2172926 , @grokos wrote:
> >
> > > Instead of introducing new API functions and making all these changes in 
> > > all these files, wouldn't it be easier if we just unset the `PRESENT` 
> > > flag from arg_types in clang when we generate the call to 
> > > `__tgt_target_data_end_*` if we are exiting from a scoped environment?
> >
> >
> > Ah, that does sound simpler.  Thanks.  I'll look into it.
> >
> > Suppressing the presence check on exit from `omp target` would require a 
> > runtime change in addition to the Clang change you suggest for `omp target 
> > data`.  However, I've so far failed to formulate a reasonable test case.  
> > Specifically, I don't yet see a way to guarantee that the data will 
> > definitely be present at the start of `omp target` but might not be present 
> > by the end.  Is it possible?  If not, then maybe we should leave the check 
> > in place for `omp target`.
>
>
> I would rather not have a check if not required by the spec as it would an 
> unnecessary overhead to performance.


I've added a comment to the runtime code that performs the check.  As you can 
see, the check is performed regardless.  It's just a question of whether the 
runtime treats it as an error.  I don't think performance is an issue.

My concern here is that it will be hard to justify changes to the runtime if I 
cannot formulate a use case.




Comment at: openmp/libomptarget/src/omptarget.cpp:511
+  // "omp target exit data" but not upon exiting an "omp target data".
+  if (HasPresentModifier && for_exit_data) {
 MESSAGE("device mapping required by 'present' map type modifier does "

This is where the runtime performs the check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84422



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


[PATCH] D79744: clang: Use byref for aggregate kernel arguments

2020-07-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 280607.
arsenm added a comment.

Use distinct ABIArgInfo::Kind. Also don't enable this for OpenCL yet, since 
that requires fixing the callable kernel workaround


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

https://reviews.llvm.org/D79744

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl

Index: clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
+++ clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
@@ -67,7 +67,6 @@
 int i2;
 } struct_of_structs_arg_t;
 
-// CHECK: %union.transparent_u = type { i32 }
 typedef union
 {
   int b1;
@@ -237,7 +236,7 @@
 // CHECK: void @kernel_struct_of_structs_arg(%struct.struct_of_structs_arg %arg1.coerce)
 __kernel void kernel_struct_of_structs_arg(struct_of_structs_arg_t arg1) { }
 
-// CHECK: void @test_kernel_transparent_union_arg(%union.transparent_u %u.coerce)
+// CHECK: void @test_kernel_transparent_union_arg(i32 %u.coerce)
 __kernel void test_kernel_transparent_union_arg(transparent_u u) { }
 
 // CHECK: void @kernel_single_array_element_struct_arg(%struct.single_array_element_struct_arg %arg1.coerce)
Index: clang/test/CodeGenCUDA/kernel-args.cu
===
--- clang/test/CodeGenCUDA/kernel-args.cu
+++ clang/test/CodeGenCUDA/kernel-args.cu
@@ -8,14 +8,14 @@
   int a[32];
 };
 
-// AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A %x.coerce)
+// AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}})
 // NVPTX: define void @_Z6kernel1A(%struct.A* byval(%struct.A) align 4 %x)
 __global__ void kernel(A x) {
 }
 
 class Kernel {
 public:
-  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}})
   // NVPTX: define void @_ZN6Kernel12memberKernelE1A(%struct.A* byval(%struct.A) align 4 %x)
   static __global__ void memberKernel(A x){}
   template static __global__ void templateMemberKernel(T x) {}
@@ -29,11 +29,11 @@
 
 void test() {
   Kernel K;
-  // AMDGCN: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}}
   // NVPTX: define void @_Z14templateKernelI1AEvT_(%struct.A* byval(%struct.A) align 4 %x)
   launch((void*)templateKernel);
 
-  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}}
   // NVPTX: define void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A* byval(%struct.A) align 4 %x)
   launch((void*)Kernel::templateMemberKernel);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -257,6 +257,11 @@
<< " ByVal=" << getIndirectByVal()
<< " Realign=" << getIndirectRealign();
 break;
+  case IndirectAliased:
+OS << "Indirect Align=" << getIndirectAlign().getQuantity()
+   << " AadrSpace=" << getIndirectAddrSpace()
+   << " Realign=" << getIndirectRealign();
+break;
   case Expand:
 OS << "Expand";
 break;
@@ -1989,6 +1994,7 @@
   case ABIArgInfo::InAlloca:
 return true;
   case ABIArgInfo::Ignore:
+  case ABIArgInfo::IndirectAliased:
 return false;
   case ABIArgInfo::Indirect:
   case ABIArgInfo::Direct:
@@ -8792,18 +8798,30 @@
 
   // TODO: Can we omit empty structs?
 
-  llvm::Type *LTy = nullptr;
   if (const Type *SeltTy = isSingleElementStruct(Ty, getContext()))
-LTy = CGT.ConvertType(QualType(SeltTy, 0));
+Ty = QualType(SeltTy, 0);
 
+  llvm::Type *OrigLTy = CGT.ConvertType(Ty);
+  llvm::Type *LTy = OrigLTy;
   if (getContext().getLangOpts().HIP) {
-if (!LTy)
-  LTy = CGT.ConvertType(Ty);
 LTy = coerceKernelArgumentType(
-LTy, /*FromAS=*/getContext().getTargetAddressSpace(LangAS::Default),
+OrigLTy, /*FromAS=*/getContext().getTargetAddressSpace(LangAS::Default),
 /*ToAS=*/getContext().getTargetAddressSpace(LangAS::cuda_device));
   }
 
+  // FIXME: Should also use this for OpenCL, but it requires addressing the
+  // problem of kernels being called.
+  //
+  // FIXME: Should use byref when promoting pointers in structs, but this
+  // requires adding implementing the coercion.
+  if (!getContext().getLangOpts().OpenCL && LTy == OrigLTy &&
+  isAggregateTypeForABI(Ty)) {
+return 

[PATCH] D84499: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:73
 private:
+  template 

you don't need both RequestT and ClangdRequest as template params:
 - the things you're currently doing are all available through 
protobuf::Message base class
 - but why not move the request fromProtobuf call in here so you only need to 
pass a single parameter?



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:74
+  template 
+  typename std::result_of
+  typename std::result_of::type

can't the return type just be `auto`?
Then I think you don't need CallbackT as a template param.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:96
+} Counter(Request->DebugString());
+return std::forward(Call)(
+*Index, ClangdRequest, [&](const StreamType ) {

I don't think you need forward here... just take the param by const reference?



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:42
 
+llvm::cl::opt TracerFile(
+"tracer-file",

kbobyrev wrote:
> kadircet wrote:
> > i think `TraceFile` is more appropriate here.
> `TracerFile` is what `ClangdMain.cpp` has; I'm not against this, but I think 
> it'd be better to have them the same for consistency. WDYT?
(driveby, sorry)
TracerFile is the local variable name in ClangdMain, but the public interface 
(an environment variable there rather than a flag) is CLANGD_TRACE, and it's 
more important to be consistent with that.

So my vote would be --trace or --trace-file or env CLANGD_TRACE=...



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:49
+llvm::cl::desc("Pretty-print JSON output"),
+llvm::cl::init(true),
+};

kadircet wrote:
> this sounds like a debug feature, do we really want it to be true by default?
This option is not worth having at all, IMO.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:122
 }
-Index->lookup(Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
-return;
-  LookupReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
-  Reply->Write(NextMessage);
-});
+std::function kadircet wrote:
> > all of this trickery is really nice. but i am not sure if it improves 
> > readability at all, from the perspective of call sites the amount of code 
> > is almost the same. moreover it was some trivial lambda before and instead 
> > it is lots of template parameters now.
> > 
> > maybe just have templated function to replace the lambda body instead? e.g.
> > 
> > ```
> > template 
> > void IndexCallback(Marshaller , StreamType ) {
> >   trace::Span Tracer;
> >   auto SerializedSymbol = M.toProtobuf(Item);
> >   // log the events and much more ...
> > }
> > 
> > ```
> > 
> > then call it in the callbacks. WDYT?
> I think this is a good idea but I can't think of a nice way to do that, too. 
> `IndexCallback` would have to update `Sent` and `FailedToSend` (`Tracer` 
> should be outside of the callback, right?), and the callback signature if 
> fixed so I wouldn't be able to pass these parameters by reference :( I could 
> probably make those two fields of the class but this doesn't look very nice, 
> or pass member function (templated one) to the callback in each index 
> request, but this also doesn't look very nice.
> 
> I think the reason was initially to improve readability but then it's more 
> about code deduplication: right now there are 3 pieces of code that do 
> exactly the same, there will be a fourth one (relations request). Maybe 
> readability even decreases but I really think that having 4 pieces of code 
> with different types is not very nice. Also, D84525 compliments this and 
> there will be practically only no functional code in the functions themselves.
> 
> I can understand your argument and I partially support it but I really think 
> we're unfortunately choosing between bad and worse.
FWIW, I find the template to be very hard to read, and would prefer the version 
that is duplicated 4 times. 

I've left some suggestions for how to simplify (mostly, eliminating template 
parameters) but I'm still not sure it's worth it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84499



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


[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-24 Thread Ravi Narayanaswamy via Phabricator via cfe-commits
RaviNarayanaswamy added a comment.

In D84422#2173372 , @jdenny wrote:

> In D84422#2172898 , @jdenny wrote:
>
> > Has anyone clarified the motivation for this behavior?
>
>
> I meant, is there any insight into why the spec specifies this behavior?
>
> In D84422#2172926 , @grokos wrote:
>
> > Instead of introducing new API functions and making all these changes in 
> > all these files, wouldn't it be easier if we just unset the `PRESENT` flag 
> > from arg_types in clang when we generate the call to 
> > `__tgt_target_data_end_*` if we are exiting from a scoped environment?
>
>
> Ah, that does sound simpler.  Thanks.  I'll look into it.
>
> Suppressing the presence check on exit from `omp target` would require a 
> runtime change in addition to the Clang change you suggest for `omp target 
> data`.  However, I've so far failed to formulate a reasonable test case.  
> Specifically, I don't yet see a way to guarantee that the data will 
> definitely be present at the start of `omp target` but might not be present 
> by the end.  Is it possible?  If not, then maybe we should leave the check in 
> place for `omp target`.


I would rather not have a check if not required by the spec as it would an 
unnecessary overhead to performance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84422



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


[PATCH] D83914: [clangd] Plan features for FoldingRanges

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Need to resolve the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83914



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


[PATCH] D84525: [clangd] Add marshalling code for all request types

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 280600.
kbobyrev added a comment.

Add missing Limit & Filter for fromProtobuf(RefsRequest *)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84525

Files:
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -289,7 +289,8 @@
   auto Serialized = ProtobufMarshaller.toProtobuf(Request);
   EXPECT_EQ(Serialized.proximity_paths_size(), 2);
   auto Deserialized = ProtobufMarshaller.fromProtobuf();
-  EXPECT_THAT(Deserialized.ProximityPaths,
+  ASSERT_TRUE(Deserialized);
+  EXPECT_THAT(Deserialized->ProximityPaths,
   testing::ElementsAre(testPath("remote/Header.h"),
testPath("remote/subdir/OtherHeader.h")));
 }
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -59,14 +59,10 @@
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
-clangd::LookupRequest Req;
-for (const auto  : Request->ids()) {
-  auto SID = SymbolID::fromStr(StringRef(ID));
-  if (!SID)
-return grpc::Status::CANCELLED;
-  Req.IDs.insert(*SID);
-}
-Index->lookup(Req, [&](const clangd::Symbol ) {
+const auto Req = ProtobufMarshaller->fromProtobuf(Request);
+if (!Req)
+  return grpc::Status::CANCELLED;
+Index->lookup(*Req, [&](const clangd::Symbol ) {
   auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
   if (!SerializedSymbol)
 return;
@@ -84,7 +80,9 @@
  const FuzzyFindRequest *Request,
  grpc::ServerWriter *Reply) override {
 const auto Req = ProtobufMarshaller->fromProtobuf(Request);
-bool HasMore = Index->fuzzyFind(Req, [&](const clangd::Symbol ) {
+if (!Req)
+  return grpc::Status::CANCELLED;
+bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol ) {
   auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
   if (!SerializedSymbol)
 return;
@@ -100,14 +98,10 @@
 
   grpc::Status Refs(grpc::ServerContext *Context, const RefsRequest *Request,
 grpc::ServerWriter *Reply) override {
-clangd::RefsRequest Req;
-for (const auto  : Request->ids()) {
-  auto SID = SymbolID::fromStr(StringRef(ID));
-  if (!SID)
-return grpc::Status::CANCELLED;
-  Req.IDs.insert(*SID);
-}
-bool HasMore = Index->refs(Req, [&](const clangd::Ref ) {
+const auto Req = ProtobufMarshaller->fromProtobuf(Request);
+if (!Req)
+  return grpc::Status::CANCELLED;
+bool HasMore = Index->refs(*Req, [&](const clangd::Ref ) {
   auto SerializedRef = ProtobufMarshaller->toProtobuf(Reference);
   if (!SerializedRef)
 return;
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
@@ -38,10 +38,15 @@
   Marshaller() = delete;
   Marshaller(llvm::StringRef RemoteIndexRoot, llvm::StringRef LocalIndexRoot);
 
-  clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request);
   llvm::Optional fromProtobuf(const Symbol );
   llvm::Optional fromProtobuf(const Ref );
 
+  llvm::Optional
+  fromProtobuf(const LookupRequest *Message);
+  llvm::Optional
+  fromProtobuf(const FuzzyFindRequest *Message);
+  llvm::Optional fromProtobuf(const RefsRequest *Message);
+
   /// toProtobuf() functions serialize native clangd types and strip IndexRoot
   /// from the file paths specific to indexing machine. fromProtobuf() functions
   /// deserialize clangd types and translate relative paths into machine-native
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -17,6 +17,7 @@
 #include "index/SymbolOrigin.h"
 #include "support/Logger.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/None.h"
 

[PATCH] D82502: [PowerPC] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-24 Thread Albion Fung via Phabricator via cfe-commits
Conanap added a comment.

Addressed formatting comments




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:14156
+
+  // This transformation is only valid if the we are loading either a byte,
+  // halfword, word, or doubleword.

NeHuang wrote:
> nit: if we are loading either a byte
I'm not too sure what you mean, would you be able to elaborate?  
The comment is:


> This transformation is only valid if the we are loading either a byte,
> halfword, word, or doubleword.

Thanks!




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

https://reviews.llvm.org/D82502



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


[PATCH] D82502: [PowerPC] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-24 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 280597.
Conanap marked 2 inline comments as done.
Conanap retitled this revision from "[PowerPC][Power10]  Implement Load VSX 
Vector and Sign Extend and Zero Extend" to "[PowerPC] Implement Load VSX Vector 
and Sign Extend and Zero Extend".
Conanap edited the summary of this revision.

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

https://reviews.llvm.org/D82502

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -36,3 +36,61 @@
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 0)
   ret i32 %0
 }
+
+; These test cases tests that zero extending loads utilize the Load VSX Vector Rightmost
+; (lxvr[b|h|w|d]x) instructions in Power10.
+
+define dso_local <1 x i128> @vec_xl_zext(i64 %__offset, i8* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lxvrbx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i8, i8* %__pointer, i64 %__offset
+  %0 = load i8, i8* %add.ptr, align 1
+  %conv = zext i8 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_short(i64 %__offset, i16* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_short:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 1
+; CHECK-NEXT:lxvrhx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i16, i16* %__pointer, i64 %__offset
+  %0 = load i16, i16* %add.ptr, align 2
+  %conv = zext i16 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_word(i64 %__offset, i32* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_word:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 2
+; CHECK-NEXT:lxvrwx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i32, i32* %__pointer, i64 %__offset
+  %0 = load i32, i32* %add.ptr, align 4
+  %conv = zext i32 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_dw(i64 %__offset, i64* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_dw:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 3
+; CHECK-NEXT:lxvrdx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i64, i64* %__pointer, i64 %__offset
+  %0 = load i64, i64* %add.ptr, align 8
+  %conv = zext i64 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -18,6 +18,15 @@
 // address computations).
 class isPCRel { bit PCRel = 1; }
 
+// PowerPC specific type constraints.
+def SDT_PPCLXVRZX : SDTypeProfile<1, 2, [
+  SDTCisVT<0, v1i128>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
+]>;
+
+// PPC Specific DAG Nodes.
+def PPClxvrzx : SDNode<"PPCISD::LXVRZX", SDT_PPCLXVRZX,
+   [SDNPHasChain, SDNPMayLoad]>;
+
 // Top-level class for prefixed instructions.
 class PI pref, bits<6> opcode, dag OOL, dag IOL, string asmstr,
  InstrItinClass itin> : Instruction {
@@ -1098,6 +1107,15 @@
 (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_lt)>;
   def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, 0)),
 (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_eq)>;
+
+  def : Pat <(v1i128 (PPClxvrzx xoaddr:$src, 8)),
+ (v1i128 (COPY_TO_REGCLASS (LXVRBX xoaddr:$src), VRRC))>;
+  def : Pat <(v1i128 (PPClxvrzx xoaddr:$src, 16)),
+ (v1i128 (COPY_TO_REGCLASS (LXVRHX xoaddr:$src), VRRC))>;
+  def : Pat <(v1i128 (PPClxvrzx xoaddr:$src, 32)),
+ (v1i128 (COPY_TO_REGCLASS (LXVRWX xoaddr:$src), VRRC))>;
+  def : Pat <(v1i128 (PPClxvrzx xoaddr:$src, 64)),
+ (v1i128 (COPY_TO_REGCLASS (LXVRDX xoaddr:$src), VRRC))>;
 }
 
 let AddedComplexity = 400, Predicates = [PrefixInstrs] in {
Index: llvm/lib/Target/PowerPC/PPCISelLowering.h
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.h
+++ llvm/lib/Target/PowerPC/PPCISelLowering.h
@@ -493,6 +493,12 @@
 /// an 

[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-24 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 280592.
Conanap removed a reviewer: power-llvm-team.
Conanap added a comment.
Herald added a subscriber: kbarton.

Converted the impelmentation to an open coded implementation and updated the 
test cases as appropriate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83338

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-shift.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-shift.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vector-shift.ll
@@ -0,0 +1,45 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; These tests ensure that vector shift quadword builtins are correctly
+; exploited and selected for during codeGen.
+
+define dso_local <1 x i128> @test_vec_vslq(<1 x i128> %a, <1 x i128> %b) {
+; CHECK-LABEL: test_vec_vslq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vslq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %rem = urem <1 x i128> %b, 
+  %shl = shl <1 x i128> %a, %rem
+  ret <1 x i128> %shl
+}
+
+define dso_local <1 x i128> @test_vec_vsrq(<1 x i128> %a, <1 x i128> %b) {
+; CHECK-LABEL: test_vec_vsrq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsrq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %rem = urem <1 x i128> %b, 
+  %shr = lshr <1 x i128> %a, %rem
+  ret <1 x i128> %shr
+}
+
+define dso_local <1 x i128> @test_vec_vsraq(<1 x i128> %a, <1 x i128> %b) {
+; CHECK-LABEL: test_vec_vsraq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsraq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %rem = urem <1 x i128> %b, 
+  %shr = ashr <1 x i128> %a, %rem
+  ret <1 x i128> %shr
+}
+
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1100,6 +1100,22 @@
 (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_eq)>;
 }
 
+/* Vector shifts for ISA3_1 */
+let Predicates = [IsISA3_1] in {
+  def : Pat<(v1i128 (shl v1i128:$VRA, v1i128:$VRB)),
+(v1i128 (VSLQ v1i128:$VRA, v1i128:$VRB))>;
+  def : Pat<(v1i128 (PPCshl v1i128:$VRA, v1i128:$VRB)),
+(v1i128 (VSLQ v1i128:$VRA, v1i128:$VRB))>;
+  def : Pat<(v1i128 (srl v1i128:$VRA, v1i128:$VRB)),
+(v1i128 (VSRQ v1i128:$VRA, v1i128:$VRB))>;
+  def : Pat<(v1i128 (PPCsrl v1i128:$VRA, v1i128:$VRB)),
+(v1i128 (VSRQ v1i128:$VRA, v1i128:$VRB))>;
+  def : Pat<(v1i128 (sra v1i128:$VRA, v1i128:$VRB)),
+(v1i128 (VSRAQ v1i128:$VRA, v1i128:$VRB))>;
+  def : Pat<(v1i128 (PPCsra v1i128:$VRA, v1i128:$VRB)),
+(v1i128 (VSRAQ v1i128:$VRA, v1i128:$VRB))>;
+}
+
 let AddedComplexity = 400, Predicates = [PrefixInstrs] in {
  def : Pat<(v4i32 (build_vector i32immNonAllOneNonZero:$A,
 i32immNonAllOneNonZero:$A,
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1089,6 +1089,10 @@
   setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::v2i32, Legal);
   setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::v2i64, Legal);
 }
+
+if(Subtarget.isISA3_1()) {
+  setOperationAction(ISD::SRA, MVT::v1i128, Legal);
+}
   }
 
   if (Subtarget.hasQPX()) {
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -21,6 +21,7 @@
 vector unsigned int vuia, vuib, vuic;
 vector signed long long vslla, vsllb;
 vector unsigned long long vulla, vullb, vullc;
+vector signed __int128 vi128a;
 vector unsigned __int128 vui128a, vui128b, vui128c;
 vector float vfa, vfb;
 vector double vda, vdb;
@@ -593,3 +594,45 @@
   // CHECK-NEXT: ret i32
   return vec_test_lsbb_all_zeros(vuca);
 }
+
+vector unsigned __int128 test_vec_slq_unsigned (void) {
+  // CHECK-LABEL: test_vec_slq_unsigned
+  // CHECK: shl <1 x i128> %{{.+}}, %{{.+}}
+  // CHECK: ret <1 x i128> %{{.+}}
+  return vec_sl(vui128a, vui128b);
+}
+
+vector signed __int128 test_vec_slq_signed (void) {
+  // CHECK-LABEL: test_vec_slq_signed
+  // CHECK: shl <1 x i128> %{{.+}}, %{{.+}}
+  // CHECK: ret <1 x i128>
+ 

[PATCH] D83817: [clangd] Add option to use remote index as static index

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 280593.
kbobyrev added a comment.

Remove unused Remote category.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83817

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -14,6 +14,7 @@
 #include "Transport.h"
 #include "index/Background.h"
 #include "index/Serialization.h"
+#include "index/remote/Client.h"
 #include "refactor/Rename.h"
 #include "support/Path.h"
 #include "support/Shutdown.h"
@@ -449,6 +450,21 @@
 init(true),
 };
 
+#ifdef CLANGD_ENABLE_REMOTE
+opt RemoteIndexAddress{
+"remote-index-address",
+cat(Features),
+desc("Address of the remote index server"),
+};
+
+// FIXME(kirillbobyrev): Should this be the location of compile_commands.json?
+opt ProjectRoot{
+"project-path",
+cat(Features),
+desc("Path to the project root. Requires remote-index-address to be set."),
+};
+#endif
+
 /// Supports a test URI scheme with relaxed constraints for lit tests.
 /// The path in a test URI will be combined with a platform-specific fake
 /// directory to form an absolute path. For example, test:///a.cpp is resolved
@@ -680,6 +696,23 @@
 if (Sync)
   AsyncIndexLoad.wait();
   }
+#ifdef CLANGD_ENABLE_REMOTE
+  if (RemoteIndexAddress.empty() != ProjectRoot.empty()) {
+llvm::errs() << "remote-index-address and project-path have to be "
+"specified at the same time.";
+return 1;
+  }
+  if (!RemoteIndexAddress.empty()) {
+if (IndexFile.empty()) {
+  log("Connecting to remote index at {0}", RemoteIndexAddress);
+  StaticIdx = remote::getClient(RemoteIndexAddress, ProjectRoot);
+  EnableBackgroundIndex = false;
+} else {
+  elog("When enabling remote index, IndexFile should not be specified. "
+   "Only one can be used at time. Remote index will ignored.");
+}
+  }
+#endif
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;
   Opts.BuildRecoveryAST = RecoveryAST;
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -1 +1,2 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
+#define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMTE@
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -114,6 +114,15 @@
   omp_gen
   )
 
+# FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
+option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
+set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
+
+if (CLANGD_ENABLE_REMOTE)
+  include(FindGRPC)
+endif()
+add_subdirectory(index/remote)
+
 clang_target_link_libraries(clangDaemon
   PRIVATE
   clangAST
@@ -131,6 +140,7 @@
   clangToolingInclusions
   clangToolingRefactoring
   clangToolingSyntax
+  clangdRemoteIndex
   )
 
 add_subdirectory(refactor/tweaks)
@@ -153,12 +163,4 @@
 add_subdirectory(unittests)
 endif()
 
-# FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
-option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
-set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
-
-if (CLANGD_ENABLE_REMOTE)
-  include(FindGRPC)
-endif()
-add_subdirectory(index/remote)
 add_subdirectory(index/dex/dexp)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-24 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bf4c1f4fb25: Reapply [DomTree] Replace ChildrenGetter 
with GraphTraits over GraphDiff. (authored by asbirlea).

Changed prior to commit:
  https://reviews.llvm.org/D77341?vs=280326=280590#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341

Files:
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/CFGDiff.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree , BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree , DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree , DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree , DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree ,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree ,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT )
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT 
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,8 +107,7 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
+  template  struct ChildrenGetter {
 using ResultTy = SmallVector;
 
 static ResultTy Get(NodePtr N, std::integral_constant) {
@@ -121,50 +120,16 @@
   return ResultTy(IChildren.begin(), IChildren.end());
 }
 
-using Tag = std::integral_constant;
+using Tag = std::integral_constant;
 
 // The function below is the core part of the batch updater. It allows the
 // Depth Based Search algorithm to perform incremental updates in lockstep
 // with updates to the CFG. We emulated lockstep CFG updates by getting its
 // next snapshots by reverse-applying future updates.
 static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was performed.
-  auto  = (Inverse != IsPostDom) ? BUI->FuturePredecessors
-: BUI->FutureSuccessors;
-  auto FCIt = FutureChildren.find(N);
-  if (FCIt == FutureChildren.end()) return Res;
-
-  for (auto 

[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-24 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D84422#2172898 , @jdenny wrote:

> Has anyone clarified the motivation for this behavior?


I meant, is there any insight into why the spec specifies this behavior?

In D84422#2172926 , @grokos wrote:

> Instead of introducing new API functions and making all these changes in all 
> these files, wouldn't it be easier if we just unset the `PRESENT` flag from 
> arg_types in clang when we generate the call to `__tgt_target_data_end_*` if 
> we are exiting from a scoped environment?


Ah, that does sound simpler.  Thanks.  I'll look into it.

Suppressing the presence check on exit from `omp target` would require a 
runtime change in addition to the Clang change you suggest for `omp target 
data`.  However, I've so far failed to formulate a reasonable test case.  
Specifically, I don't yet see a way to guarantee that the data will definitely 
be present at the start of `omp target` but might not be present by the end.  
Is it possible?  If not, then maybe we should leave the check in place for `omp 
target`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84422



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


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-24 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Great, thank you for confirming :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D83817: [clangd] Add option to use remote index as static index

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 280589.
kbobyrev marked 7 inline comments as done.
kbobyrev added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83817

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -14,6 +14,7 @@
 #include "Transport.h"
 #include "index/Background.h"
 #include "index/Serialization.h"
+#include "index/remote/Client.h"
 #include "refactor/Rename.h"
 #include "support/Path.h"
 #include "support/Shutdown.h"
@@ -64,6 +65,7 @@
 OptionCategory Features("clangd feature options");
 OptionCategory Misc("clangd miscellaneous options");
 OptionCategory Protocol("clangd protocol and logging options");
+OptionCategory Remote("clangd remote index options");
 const OptionCategory *ClangdCategories[] = {, ,
 , };
 
@@ -449,6 +451,21 @@
 init(true),
 };
 
+#ifdef CLANGD_ENABLE_REMOTE
+opt RemoteIndexAddress{
+"remote-index-address",
+cat(Features),
+desc("Address of the remote index server"),
+};
+
+// FIXME(kirillbobyrev): Should this be the location of compile_commands.json?
+opt ProjectRoot{
+"project-path",
+cat(Features),
+desc("Path to the project root. Requires remote-index-address to be set."),
+};
+#endif
+
 /// Supports a test URI scheme with relaxed constraints for lit tests.
 /// The path in a test URI will be combined with a platform-specific fake
 /// directory to form an absolute path. For example, test:///a.cpp is resolved
@@ -680,6 +697,23 @@
 if (Sync)
   AsyncIndexLoad.wait();
   }
+#ifdef CLANGD_ENABLE_REMOTE
+  if (RemoteIndexAddress.empty() != ProjectRoot.empty()) {
+llvm::errs() << "remote-index-address and project-path have to be "
+"specified at the same time.";
+return 1;
+  }
+  if (!RemoteIndexAddress.empty()) {
+if (IndexFile.empty()) {
+  log("Connecting to remote index at {0}", RemoteIndexAddress);
+  StaticIdx = remote::getClient(RemoteIndexAddress, ProjectRoot);
+  EnableBackgroundIndex = false;
+} else {
+  elog("When enabling remote index, IndexFile should not be specified. "
+   "Only one can be used at time. Remote index will ignored.");
+}
+  }
+#endif
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;
   Opts.BuildRecoveryAST = RecoveryAST;
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -1 +1,2 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
+#define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMTE@
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -114,6 +114,15 @@
   omp_gen
   )
 
+# FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
+option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
+set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
+
+if (CLANGD_ENABLE_REMOTE)
+  include(FindGRPC)
+endif()
+add_subdirectory(index/remote)
+
 clang_target_link_libraries(clangDaemon
   PRIVATE
   clangAST
@@ -131,6 +140,7 @@
   clangToolingInclusions
   clangToolingRefactoring
   clangToolingSyntax
+  clangdRemoteIndex
   )
 
 add_subdirectory(refactor/tweaks)
@@ -153,12 +163,4 @@
 add_subdirectory(unittests)
 endif()
 
-# FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
-option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
-set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
-
-if (CLANGD_ENABLE_REMOTE)
-  include(FindGRPC)
-endif()
-add_subdirectory(index/remote)
 add_subdirectory(index/dex/dexp)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84499: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:61
   Callback(*Response);
+  ++Received;
 }

kadircet wrote:
> shouldn't we increment this before the `continue` above ? (or rename this to 
> `successful` rather than `received` ?)
Makes sense, I didn't think of "received" in terms of "overall" :P



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:42
 
+llvm::cl::opt TracerFile(
+"tracer-file",

kadircet wrote:
> i think `TraceFile` is more appropriate here.
`TracerFile` is what `ClangdMain.cpp` has; I'm not against this, but I think 
it'd be better to have them the same for consistency. WDYT?



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:48
+"pretty",
+llvm::cl::desc("Pretty-print JSON output"),
+llvm::cl::init(true),

kadircet wrote:
> is it only for pretty printing trace files? do we expect to have any other 
> components this will interact in future? (if not maybe state that in the 
> comments)
Yeah, right now it's only for trace files. It's quite possible that there will 
be something else that could be pretty-printed in the future, but not right 
now, so I changed description (specified trace files).



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:122
 }
-Index->lookup(Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
-return;
-  LookupReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
-  Reply->Write(NextMessage);
-});
+std::function all of this trickery is really nice. but i am not sure if it improves 
> readability at all, from the perspective of call sites the amount of code is 
> almost the same. moreover it was some trivial lambda before and instead it is 
> lots of template parameters now.
> 
> maybe just have templated function to replace the lambda body instead? e.g.
> 
> ```
> template 
> void IndexCallback(Marshaller , StreamType ) {
>   trace::Span Tracer;
>   auto SerializedSymbol = M.toProtobuf(Item);
>   // log the events and much more ...
> }
> 
> ```
> 
> then call it in the callbacks. WDYT?
I think this is a good idea but I can't think of a nice way to do that, too. 
`IndexCallback` would have to update `Sent` and `FailedToSend` (`Tracer` should 
be outside of the callback, right?), and the callback signature if fixed so I 
wouldn't be able to pass these parameters by reference :( I could probably make 
those two fields of the class but this doesn't look very nice, or pass member 
function (templated one) to the callback in each index request, but this also 
doesn't look very nice.

I think the reason was initially to improve readability but then it's more 
about code deduplication: right now there are 3 pieces of code that do exactly 
the same, there will be a fourth one (relations request). Maybe readability 
even decreases but I really think that having 4 pieces of code with different 
types is not very nice. Also, D84525 compliments this and there will be 
practically only no functional code in the functions themselves.

I can understand your argument and I partially support it but I really think 
we're unfortunately choosing between bad and worse.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84499



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


[PATCH] D84499: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 280587.
kbobyrev marked 7 inline comments as done.
kbobyrev added a comment.

Resolve most review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84499

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -8,7 +8,10 @@
 
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
+#include "support/Logger.h"
+#include "support/Trace.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
@@ -16,6 +19,7 @@
 
 #include 
 #include 
+#include 
 
 #include "Index.grpc.pb.h"
 
@@ -35,6 +39,16 @@
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt TracerFile(
+"tracer-file",
+llvm::cl::desc("Path to the file where tracer logs will be stored"));
+
+llvm::cl::opt PrettyPrint{
+"pretty",
+llvm::cl::desc("Pretty-print JSON output in the trace"),
+llvm::cl::init(false),
+};
+
 llvm::cl::opt ServerAddress(
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
@@ -56,24 +70,63 @@
   }
 
 private:
+  template 
+  typename std::result_of::type
+  streamRPC(const RequestT *Request, grpc::ServerWriter *Reply,
+ClangdRequestT ClangdRequest, IndexCall &) {
+// Adding Sent and FailedToSend messages to the tracer has to happen after
+// Callback but the temporary value can not be stored. Use a dummy struct
+// to hold data for tracer and then add data to the trace on destruction
+// happening after the callback.
+struct TracerCounter {
+  trace::Span Tracer;
+  unsigned Sent = 0;
+  unsigned FailedToSend = 0;
+  TracerCounter(llvm::StringRef RequestInfo)
+  : Tracer(RequestT::descriptor()->name()) {
+SPAN_ATTACH(Tracer, "Request", RequestInfo);
+  }
+  ~TracerCounter() {
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
+  }
+} Counter(Request->DebugString());
+return std::forward(Call)(
+*Index, ClangdRequest, [&](const StreamType ) {
+  auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
+  if (!SerializedItem) {
+++Counter.FailedToSend;
+return;
+  }
+  ReplyT NextMessage;
+  *NextMessage.mutable_stream_result() = *SerializedItem;
+  Reply->Write(NextMessage);
+  ++Counter.Sent;
+});
+  }
+
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
 clangd::LookupRequest Req;
 for (const auto  : Request->ids()) {
   auto SID = SymbolID::fromStr(StringRef(ID));
-  if (!SID)
+  if (!SID) {
+elog("Lookup request cancelled: invalid SymbolID {1}", SID.takeError());
 return grpc::Status::CANCELLED;
+  }
   Req.IDs.insert(*SID);
 }
-Index->lookup(Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
-return;
-  LookupReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
-  Reply->Write(NextMessage);
-});
+std::function)>
+IndexCall = ::SymbolIndex::lookup;
+streamRPC>(
+Request, Reply, Req, std::move(IndexCall));
 LookupReply LastMessage;
 LastMessage.set_final_result(true);
 Reply->Write(LastMessage);
@@ -84,14 +137,15 @@
  const FuzzyFindRequest *Request,
  grpc::ServerWriter *Reply) override {
 const auto Req = ProtobufMarshaller->fromProtobuf(Request);
-bool HasMore = Index->fuzzyFind(Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
-return;
-  FuzzyFindReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
-  Reply->Write(NextMessage);
-});
+std::function)>
+IndexCall = ::SymbolIndex::fuzzyFind;
+bool HasMore =
+streamRPC>(
+Request, Reply, Req, std::move(IndexCall));
 FuzzyFindReply LastMessage;
 LastMessage.set_final_result(HasMore);
 Reply->Write(LastMessage);
@@ -103,18 +157,20 @@
 clangd::RefsRequest Req;
 for (const auto  : Request->ids()) {
   auto SID = 

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-24 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Numbers for the newest version: 
https://llvm-compile-time-tracker.com/compare.php?from=183342c0a9850e60dd7a004b651c83dfb3a7d25e=eabcf534fe8760d14c95b40f07c61450c819d643=instructions

This is now a geomean 0.2% regressions, and I don't see any large outliers for 
individual files either (everything is below 2%). So this should be fine now, 
at least where compile-time impact is concerned :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D83814: [clangd] Add Random Forest runtime for code completion.

2020-07-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D83814#2166349 , @usaxena95 wrote:

> This is still WIP and I will provide more details in the description once 
> this is finalized.


This really should have high level documentation - I don't think Nathan will be 
the only one to ask these questions.
We need a description of what problem this solves, what the concepts are 
(trees, features, scores), inference, training, data sources, generated API.

Given that the implementation is necessarily split across CMake, generated 
code, generator, and data (but not a lot of hand-written C++) I think it's 
probably best documented in a README.md or so in the model/ dir.

Seems fine to do that in this patch, or ahead of time (before the 
implementation)... I wouldn't wait to do it after, it'll help with the review.

---

One question we haven't discussed is how workspace/symbol should work. (This 
uses the hand-tuned score function with some different logic). This is relevant 
to naming: it's not the "completion model" if it also has other features.




Comment at: clang-tools-extra/clangd/CMakeLists.txt:30
+  
+set(DF_COMPILER ${CMAKE_CURRENT_SOURCE_DIR}/CompletionModelCodegen.py)
+include(${CMAKE_CURRENT_SOURCE_DIR}/CompletionModel.cmake)

if you want the compiler script to be a parameter, make it an argument to the 
function rather than a magic variable. 

But really, I think the CompletionModel.cmake is tightly coupled to the python 
script, I think it can be hardcoded there.



Comment at: clang-tools-extra/clangd/CompletionModel.cmake:1
+# Run the Completion Model Codegenerator on the model in the 
+# ${model} directory.

I think there's some confusion in the naming.

You've got the code split into two locations: the generic generator and the 
specific code completion model.

However the directory named just "model" contains the specific stuff, and the 
generic parts are named "completionmodel!".

I'd suggest either:
 - don't generalize, and put everything in clangd/quality or so
 - split into clangd/quality/ and clangd/forest/ for the specific/generic parts



Comment at: clang-tools-extra/clangd/CompletionModel.cmake:5
+# ${CMAKE_BINARY_DIR}/generated/decision_forest. The generated header
+# will define a C++ class called ${cpp_class} - which may be a
+# namespace-qualified class name.

what does the class do?



Comment at: clang-tools-extra/clangd/CompletionModel.cmake:7
+# namespace-qualified class name.
+function(df_compile model fname cpp_class)  
+  set(model_json ${model}/forest.json)

df is cryptic.
decision_forest or gen_decision_forest?



Comment at: clang-tools-extra/clangd/CompletionModel.cmake:17
+COMMAND "${Python3_EXECUTABLE}" ${DF_COMPILER} 
+  --model ${model}
+  --output_dir ${output_dir}

I'd suggest passing the component filenames explicitly here since you're 
computing them anyway



Comment at: clang-tools-extra/clangd/CompletionModel.cmake:19
+  --output_dir ${output_dir}
+  --fname ${fname}
+  --cpp_class ${cpp_class}

fname -> filename



Comment at: clang-tools-extra/clangd/CompletionModel.cmake:29
+GENERATED 1
+COMPILE_FLAGS -Wno-unused-label)
+

this needs to be guarded based on the compiler - other compilers use different 
flags

I'd suggest just -Wno-usuned



Comment at: clang-tools-extra/clangd/CompletionModel.cmake:31
+
+  set(GENERATED_CC ${df_cpp} PARENT_SCOPE)
+  set(DF_INCLUDE ${output_dir} PARENT_SCOPE)  

It'd be nice to avoid passing data out by setting magic variables with generic 
names.

The caller is already passing in the filename they want, so they know what it 
is.



Comment at: clang-tools-extra/clangd/CompletionModelCodegen.py:1
+import argparse
+import json

this needs documentation throughout



Comment at: clang-tools-extra/clangd/CompletionModelCodegen.py:9
+
+class Feature:
+class Type(Enum):

Hmm, do these classes really pay for themselves compared to just using the 
JSON-decoded data structures directly and writing functions?

e.g.

```
def setter(feature):
  if (feature['kind'] == KIND_CATEGORICAL)
return "void Set{feature}(float V) {{ {feature} = OrderEncode(V); 
}}".format(feature['name'])
  ...
```



Comment at: clang-tools-extra/clangd/CompletionModelCodegen.py:10
+class Feature:
+class Type(Enum):
+NUMERICAL = 1

These labels seem a bit abstract, what do you think about "number"/"enum"?



Comment at: clang-tools-extra/clangd/CompletionModelCodegen.py:21
+if self.type == Feature.Type.CATEGORICAL:
+assert 'header' in feature_json, "Header not found in categorical 
feature."
+

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-24 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Yes. The difference in perf in instructions and cycles count is due to 
reversing the update order.
I'm still not seeing meaningful changes in wall-time even with the update order 
reversed, but reliable wall-time testing is hard.

I do have changes that

- drop the GraphTraits usage entirely in favor of the getChildren() method in 
GraphDiff
- refactor the hashmaps in GraphDiff

but I plan to send those separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D84556: [WebAssembly] Remove intrinsics for SIMD widening ops

2020-07-24 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added a reviewer: aheejin.
Herald added subscribers: llvm-commits, cfe-commits, sunfish, hiraditya, 
jgravelle-google, sbc100, dschuff.
Herald added projects: clang, LLVM.

Instead, pattern match extends of extract_subvectors to generate
widening operations. Since extract_subvector is not a legal node, this
is implemented via a custom combine that recognizes extract_subvector
nodes before they are legalized. The combine produces custom ISD nodes
that are later pattern matched directly, just like the intrinsic was.

Also removes the clang builtins for these operations since the
instructions can now be generated from portable code sequences.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84556

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-widening.ll

Index: llvm/test/CodeGen/WebAssembly/simd-widening.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/simd-widening.ll
@@ -0,0 +1,179 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mattr=+simd128 | FileCheck %s
+
+;; Test that SIMD widening operations can be successfully selected
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+define <8 x i16> @widen_low_i8x16_s(<16 x i8> %v) {
+; CHECK-LABEL: widen_low_i8x16_s:
+; CHECK: .functype widen_low_i8x16_s (v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i16x8.widen_low_i8x16_s
+; CHECK-NEXT:# fallthrough-return
+  %low = shufflevector <16 x i8> %v, <16 x i8> undef,
+   <8 x i32> 
+  %widened = sext <8 x i8> %low to <8 x i16>
+  ret <8 x i16> %widened
+}
+
+define <8 x i16> @widen_low_i8x16_u(<16 x i8> %v) {
+; CHECK-LABEL: widen_low_i8x16_u:
+; CHECK: .functype widen_low_i8x16_u (v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i16x8.widen_low_i8x16_u
+; CHECK-NEXT:# fallthrough-return
+  %low = shufflevector <16 x i8> %v, <16 x i8> undef,
+   <8 x i32> 
+  %widened = zext <8 x i8> %low to <8 x i16>
+  ret <8 x i16> %widened
+}
+
+define <8 x i16> @widen_high_i8x16_s(<16 x i8> %v) {
+; CHECK-LABEL: widen_high_i8x16_s:
+; CHECK: .functype widen_high_i8x16_s (v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i16x8.widen_high_i8x16_s
+; CHECK-NEXT:# fallthrough-return
+  %low = shufflevector <16 x i8> %v, <16 x i8> undef,
+   <8 x i32> 
+  %widened = sext <8 x i8> %low to <8 x i16>
+  ret <8 x i16> %widened
+}
+
+define <8 x i16> @widen_high_i8x16_u(<16 x i8> %v) {
+; CHECK-LABEL: widen_high_i8x16_u:
+; CHECK: .functype widen_high_i8x16_u (v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i16x8.widen_high_i8x16_u
+; CHECK-NEXT:# fallthrough-return
+  %low = shufflevector <16 x i8> %v, <16 x i8> undef,
+   <8 x i32> 
+  %widened = zext <8 x i8> %low to <8 x i16>
+  ret <8 x i16> %widened
+}
+
+define <4 x i32> @widen_low_i16x8_s(<8 x i16> %v) {
+; CHECK-LABEL: widen_low_i16x8_s:
+; CHECK: .functype widen_low_i16x8_s (v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i32x4.widen_low_i16x8_s
+; CHECK-NEXT:# fallthrough-return
+  %low = shufflevector <8 x i16> %v, <8 x i16> undef,
+   <4 x i32> 
+  %widened = sext <4 x i16> %low to <4 x i32>
+  ret <4 x i32> %widened
+}
+
+define <4 x i32> @widen_low_i16x8_u(<8 x i16> %v) {
+; CHECK-LABEL: widen_low_i16x8_u:
+; CHECK: .functype widen_low_i16x8_u (v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i32x4.widen_low_i16x8_u
+; CHECK-NEXT:# fallthrough-return
+  %low = shufflevector <8 x i16> %v, <8 x i16> undef,
+   <4 x i32> 
+  %widened = zext <4 x i16> %low to <4 x i32>
+  ret <4 x i32> %widened
+}
+
+define <4 x i32> @widen_high_i16x8_s(<8 x i16> %v) {
+; CHECK-LABEL: widen_high_i16x8_s:
+; CHECK: .functype widen_high_i16x8_s (v128) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i32x4.widen_high_i16x8_s
+; CHECK-NEXT:# fallthrough-return
+  %low = shufflevector <8 x i16> %v, <8 x i16> undef,
+   <4 x i32> 
+  %widened = sext <4 x i16> %low to <4 x i32>
+  ret <4 x i32> %widened
+}
+
+define <4 x i32> @widen_high_i16x8_u(<8 x i16> %v) {
+; CHECK-LABEL: widen_high_i16x8_u:
+; CHECK: .functype widen_high_i16x8_u (v128) -> 

[clang] 313b607 - Revert "Add Debug Info Size to Symbol Status"

2020-07-24 Thread Walter Erquinigo via cfe-commits

Author: Walter Erquinigo
Date: 2020-07-24T13:28:29-07:00
New Revision: 313b60742af1f567ef7d8e26eb5b1015a7b5c78f

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

LOG: Revert "Add Debug Info Size to Symbol Status"

This reverts commit 986e3af53bfe591e88a1ae4f82ea1cc0a15819a3.

It incorrectly deleted clang/tools/clang-format/git-clang-format

Added: 


Modified: 
clang/tools/clang-format/git-clang-format
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/test/API/tools/lldb-vscode/module/Makefile
lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
lldb/tools/lldb-vscode/JSONUtils.cpp

Removed: 




diff  --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index e69de29bb2d1..f3cd585e7f4a 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -0,0 +1,585 @@
+#!/usr/bin/env python
+#
+#===- git-clang-format - ClangFormat Git Integration -*- python 
-*--===#
+#
+# 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
+#
+#======#
+
+r"""
+clang-format git integration
+
+
+This file provides a clang-format integration for git. Put it somewhere in your
+path and ensure that it is executable. Then, "git clang-format" will invoke
+clang-format on the changes in current files or a specific commit.
+
+For further details, run:
+git clang-format -h
+
+Requires Python 2.7 or Python 3
+"""
+
+from __future__ import absolute_import, division, print_function
+import argparse
+import collections
+import contextlib
+import errno
+import os
+import re
+import subprocess
+import sys
+
+usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
+
+desc = '''
+If zero or one commits are given, run clang-format on all lines that 
diff er
+between the working directory and , which defaults to HEAD.  Changes 
are
+only applied to the working directory.
+
+If two commits are given (requires --
diff ), run clang-format on all lines in the
+second  that 
diff er from the first .
+
+The following git-config settings set the default of the corresponding option:
+  clangFormat.binary
+  clangFormat.commit
+  clangFormat.extensions
+  clangFormat.style
+'''
+
+# Name of the temporary index file in which save the output of clang-format.
+# This file is created within the .git directory.
+temp_index_basename = 'clang-format-index'
+
+
+Range = collections.namedtuple('Range', 'start, count')
+
+
+def main():
+  config = load_git_config()
+
+  # In order to keep '--' yet allow options after positionals, we need to
+  # check for '--' ourselves.  (Setting nargs='*' throws away the '--', while
+  # nargs=argparse.REMAINDER disallows options after positionals.)
+  argv = sys.argv[1:]
+  try:
+idx = argv.index('--')
+  except ValueError:
+dash_dash = []
+  else:
+dash_dash = argv[idx:]
+argv = argv[:idx]
+
+  default_extensions = ','.join([
+  # From clang/lib/Frontend/FrontendOptions.cpp, all lower case
+  'c', 'h',  # C
+  'm',  # ObjC
+  'mm',  # ObjC++
+  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx',  # C++
+  'cu',  # CUDA
+  # Other languages that clang-format supports
+  'proto', 'protodevel',  # Protocol Buffers
+  'java',  # Java
+  'js',  # JavaScript
+  'ts',  # TypeScript
+  'cs',  # C Sharp
+  ])
+
+  p = argparse.ArgumentParser(
+usage=usage, formatter_class=argparse.RawDescriptionHelpFormatter,
+description=desc)
+  p.add_argument('--binary',
+ default=config.get('clangformat.binary', 'clang-format'),
+ help='path to clang-format'),
+  p.add_argument('--commit',
+ default=config.get('clangformat.commit', 'HEAD'),
+ help='default commit to use if none is specified'),
+  p.add_argument('--
diff ', action='store_true',
+ help='print a 
diff  instead of applying the changes')
+  p.add_argument('--extensions',
+ default=config.get('clangformat.extensions',
+default_extensions),
+ help=('comma-separated list of file extensions to format, '
+   'excluding the period and case-insensitive')),
+  p.add_argument('-f', '--force', action='store_true',
+ help='allow changes to unstaged files')
+  p.add_argument('-p', '--patch', action='store_true',
+ help='select hunks interactively')
+  p.add_argument('-q', '--quiet', action='count', default=0,
+   

[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-24 Thread Yifan Shen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG986e3af53bfe: Add Debug Info Size to Symbol Status (authored 
by aelitashen, committed by Walter Erquinigo wall...@fb.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp

Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -7,6 +7,8 @@
 //===--===//
 
 #include 
+#include 
+#include 
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FormatAdapters.h"
@@ -327,6 +329,50 @@
   return llvm::json::Value(std::move(object));
 }
 
+static uint64_t GetDebugInfoSizeInSection(lldb::SBSection section) {
+  uint64_t debug_info_size = 0;
+  llvm::StringRef section_name(section.GetName());
+  if (section_name.startswith(".debug") || section_name.startswith("__debug") ||
+  section_name.startswith(".apple") || section_name.startswith("__apple"))
+debug_info_size += section.GetFileByteSize();
+  size_t num_sub_sections = section.GetNumSubSections();
+  for (size_t i = 0; i < num_sub_sections; i++) {
+debug_info_size +=
+GetDebugInfoSizeInSection(section.GetSubSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static uint64_t GetDebugInfoSize(lldb::SBModule module) {
+  uint64_t debug_info_size = 0;
+  size_t num_sections = module.GetNumSections();
+  for (size_t i = 0; i < num_sections; i++) {
+debug_info_size += GetDebugInfoSizeInSection(module.GetSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static std::string ConvertDebugInfoSizeToString(uint64_t debug_info) {
+  std::ostringstream oss;
+  oss << " (";
+  oss << std::fixed << std::setprecision(1);
+
+  if (debug_info < 1024) {
+oss << debug_info << "B";
+  } else if (debug_info < 1024 * 1024) {
+double kb = double(debug_info) / 1024.0;
+oss << kb << "KB";
+  } else if (debug_info < 1024 * 1024 * 1024) {
+double mb = double(debug_info) / (1024.0 * 1024.0);
+oss << mb << "MB";
+  } else {
+double gb = double(debug_info) / (1024.0 * 1024.0 * 1024.0);
+oss << gb << "GB";
+;
+  }
+  oss << ")";
+  return oss.str();
+}
 llvm::json::Value CreateModule(lldb::SBModule ) {
   llvm::json::Object object;
   if (!module.IsValid())
@@ -339,9 +385,15 @@
   std::string module_path(module_path_arr);
   object.try_emplace("path", module_path);
   if (module.GetNumCompileUnits() > 0) {
-object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_str = "Symbols loaded.";
+uint64_t debug_info = GetDebugInfoSize(module);
+if (debug_info > 0) {
+  symbol_str += ConvertDebugInfoSizeToString(debug_info);
+}
+object.try_emplace("symbolStatus", symbol_str);
 char symbol_path_arr[PATH_MAX];
-module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
+module.GetSymbolFileSpec().GetPath(symbol_path_arr,
+   sizeof(symbol_path_arr));
 std::string symbol_path(symbol_path_arr);
 object.try_emplace("symbolFilePath", symbol_path);
   } else {
@@ -352,8 +404,9 @@
   object.try_emplace("addressRange", loaded_addr);
   std::string version_str;
   uint32_t version_nums[3];
-  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
-  for (uint32_t i=0; ihttps://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#======#
-
-r"""
-clang-format git integration
-
-
-This file provides a clang-format integration for git. Put it somewhere in your
-path and ensure that it is executable. Then, "git clang-format" will invoke
-clang-format on the changes in current files or a specific commit.
-
-For further details, run:
-git clang-format -h
-
-Requires Python 2.7 or Python 3
-"""
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import collections
-import contextlib
-import errno
-import os
-import re
-import subprocess
-import sys
-
-usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
-
-desc = '''
-If zero or one commits are given, run clang-format on all lines that differ
-between the working directory and , which defaults to HEAD.  Changes are
-only applied to the working directory.
-
-If two commits are given (requires --diff), run clang-format on all lines in the
-second  that differ from the first .
-
-The 

[clang] 986e3af - Add Debug Info Size to Symbol Status

2020-07-24 Thread Walter Erquinigo via cfe-commits

Author: Yifan Shen
Date: 2020-07-24T13:26:06-07:00
New Revision: 986e3af53bfe591e88a1ae4f82ea1cc0a15819a3

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

LOG: Add Debug Info Size to Symbol Status

Summary: If a module has debug info, the size of debug symbol will be displayed 
after the Symbols Loaded Message for each module in the VScode modules 
view.{F12335461}

Reviewers: wallace, clayborg

Reviewed By: wallace, clayborg

Subscribers: cfe-commits, aprantl, lldb-commits

Tags: #lldb, #clang

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

Added: 


Modified: 
clang/tools/clang-format/git-clang-format
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/test/API/tools/lldb-vscode/module/Makefile
lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
lldb/tools/lldb-vscode/JSONUtils.cpp

Removed: 




diff  --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index f3cd585e7f4a..e69de29bb2d1 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -1,585 +0,0 @@
-#!/usr/bin/env python
-#
-#===- git-clang-format - ClangFormat Git Integration -*- python 
-*--===#
-#
-# 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
-#
-#======#
-
-r"""
-clang-format git integration
-
-
-This file provides a clang-format integration for git. Put it somewhere in your
-path and ensure that it is executable. Then, "git clang-format" will invoke
-clang-format on the changes in current files or a specific commit.
-
-For further details, run:
-git clang-format -h
-
-Requires Python 2.7 or Python 3
-"""
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import collections
-import contextlib
-import errno
-import os
-import re
-import subprocess
-import sys
-
-usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
-
-desc = '''
-If zero or one commits are given, run clang-format on all lines that 
diff er
-between the working directory and , which defaults to HEAD.  Changes 
are
-only applied to the working directory.
-
-If two commits are given (requires --
diff ), run clang-format on all lines in the
-second  that 
diff er from the first .
-
-The following git-config settings set the default of the corresponding option:
-  clangFormat.binary
-  clangFormat.commit
-  clangFormat.extensions
-  clangFormat.style
-'''
-
-# Name of the temporary index file in which save the output of clang-format.
-# This file is created within the .git directory.
-temp_index_basename = 'clang-format-index'
-
-
-Range = collections.namedtuple('Range', 'start, count')
-
-
-def main():
-  config = load_git_config()
-
-  # In order to keep '--' yet allow options after positionals, we need to
-  # check for '--' ourselves.  (Setting nargs='*' throws away the '--', while
-  # nargs=argparse.REMAINDER disallows options after positionals.)
-  argv = sys.argv[1:]
-  try:
-idx = argv.index('--')
-  except ValueError:
-dash_dash = []
-  else:
-dash_dash = argv[idx:]
-argv = argv[:idx]
-
-  default_extensions = ','.join([
-  # From clang/lib/Frontend/FrontendOptions.cpp, all lower case
-  'c', 'h',  # C
-  'm',  # ObjC
-  'mm',  # ObjC++
-  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx',  # C++
-  'cu',  # CUDA
-  # Other languages that clang-format supports
-  'proto', 'protodevel',  # Protocol Buffers
-  'java',  # Java
-  'js',  # JavaScript
-  'ts',  # TypeScript
-  'cs',  # C Sharp
-  ])
-
-  p = argparse.ArgumentParser(
-usage=usage, formatter_class=argparse.RawDescriptionHelpFormatter,
-description=desc)
-  p.add_argument('--binary',
- default=config.get('clangformat.binary', 'clang-format'),
- help='path to clang-format'),
-  p.add_argument('--commit',
- default=config.get('clangformat.commit', 'HEAD'),
- help='default commit to use if none is specified'),
-  p.add_argument('--
diff ', action='store_true',
- help='print a 
diff  instead of applying the changes')
-  p.add_argument('--extensions',
- default=config.get('clangformat.extensions',
-default_extensions),
- help=('comma-separated list of file extensions to format, '
-   'excluding the period and case-insensitive')),
-  p.add_argument('-f', '--force', action='store_true',
- 

[PATCH] D84554: Use INTERFACE_COMPILE_OPTIONS to disable -Wsuggest-override for any target that links to gtest

2020-07-24 Thread Logan Smith via Phabricator via cfe-commits
logan-5 created this revision.
logan-5 added a reviewer: labath.
Herald added subscribers: llvm-commits, cfe-commits, msifontes, jurahul, 
Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, aartbik, lucyrfox, 
mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, 
rriddle, mehdi_amini, usaxena95, kadircet, arphaman, jkorous, hiraditya, mgorny.
Herald added a reviewer: bollu.
Herald added a reviewer: DavidTruby.
Herald added projects: clang, MLIR, LLVM.

This cleans up several CMakeLists.txt's where `-Wno-suggest-override` was 
manually specified. These test targets now inherit this flag from the gtest 
target.

Some unittests CMakeLists.txt's, in particular Flang and LLDB, are not touched 
by this patch. Flang manually adds the gtest sources itself in some 
configurations, rather than linking to LLVM's gtest target, so this fix would 
be insufficient to cover those cases. Similarly, LLDB has subdirectories that 
manually add the gtest headers to their include path without linking to the 
gtest target, so those subdirectories still need -Wno-suggest-override to be 
manually specified to compile without warnings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84554

Files:
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/unittests/CMakeLists.txt
  clang/unittests/CMakeLists.txt
  lld/unittests/CMakeLists.txt
  llvm/lib/Testing/Support/CMakeLists.txt
  llvm/unittests/CMakeLists.txt
  llvm/utils/unittest/CMakeLists.txt
  mlir/unittests/CMakeLists.txt
  polly/unittests/CMakeLists.txt

Index: polly/unittests/CMakeLists.txt
===
--- polly/unittests/CMakeLists.txt
+++ polly/unittests/CMakeLists.txt
@@ -19,10 +19,6 @@
   target_link_libraries(${test_name} PRIVATE Polly)
 endfunction()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_compile_options("-Wno-suggest-override")
-endif()
-
 add_subdirectory(Isl)
 add_subdirectory(Flatten)
 add_subdirectory(DeLICM)
Index: mlir/unittests/CMakeLists.txt
===
--- mlir/unittests/CMakeLists.txt
+++ mlir/unittests/CMakeLists.txt
@@ -5,10 +5,6 @@
   add_unittest(MLIRUnitTests ${test_dirname} ${ARGN})
 endfunction()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_compile_options("-Wno-suggest-override")
-endif()
-
 add_subdirectory(Analysis)
 add_subdirectory(Dialect)
 add_subdirectory(IR)
Index: llvm/utils/unittest/CMakeLists.txt
===
--- llvm/utils/unittest/CMakeLists.txt
+++ llvm/utils/unittest/CMakeLists.txt
@@ -43,9 +43,6 @@
 if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
   add_definitions("-Wno-covered-switch-default")
 endif()
-if(CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
 
 set(LLVM_REQUIRES_RTTI 1)
 add_definitions( -DGTEST_HAS_RTTI=0 )
@@ -73,6 +70,14 @@
   BUILDTREE_ONLY
 )
 
+# The googletest and googlemock sources don't presently use the 'override' 
+# keyword, which leads to lots of warnings from -Wsuggest-override. Disable 
+# that warning here for any targets that link to gtest.
+if(CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+  add_definitions("-Wno-suggest-override")
+  set_target_properties(gtest PROPERTIES INTERFACE_COMPILE_OPTIONS "-Wno-suggest-override")
+endif()
+
 add_subdirectory(UnitTestMain)
 
 # When LLVM_LINK_LLVM_DYLIB is enabled, libLLVM.so is added to the interface
Index: llvm/unittests/CMakeLists.txt
===
--- llvm/unittests/CMakeLists.txt
+++ llvm/unittests/CMakeLists.txt
@@ -14,10 +14,6 @@
   add_llvm_unittest(${test_dir_name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
 endfunction()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_compile_options("-Wno-suggest-override")
-endif()
-
 add_subdirectory(ADT)
 add_subdirectory(Analysis)
 add_subdirectory(AsmParser)
Index: llvm/lib/Testing/Support/CMakeLists.txt
===
--- llvm/lib/Testing/Support/CMakeLists.txt
+++ llvm/lib/Testing/Support/CMakeLists.txt
@@ -1,10 +1,6 @@
 add_definitions(-DGTEST_LANG_CXX11=1)
 add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_compile_options("-Wno-suggest-override")
-endif()
-
 add_llvm_library(LLVMTestingSupport
   Annotations.cpp
   Error.cpp
Index: lld/unittests/CMakeLists.txt
===
--- lld/unittests/CMakeLists.txt
+++ lld/unittests/CMakeLists.txt
@@ -12,9 +12,5 @@
   target_link_libraries(${test_dirname} ${LLVM_COMMON_LIBS})
 endfunction()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_compile_options("-Wno-suggest-override")
-endif()
-
 add_subdirectory(DriverTests)
 add_subdirectory(MachOTests)
Index: clang/unittests/CMakeLists.txt
===
--- clang/unittests/CMakeLists.txt
+++ 

[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-07-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 280567.
yaxunl marked 9 inline comments as done.
yaxunl added a comment.

revised by Artem's comments


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

https://reviews.llvm.org/D60620

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/TargetID.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Compilation.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/TargetID.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/CodeGenCUDA/target-id.hip
  clang/test/CodeGenOpenCL/target-id.cl
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_908.bc
  clang/test/Driver/amdgpu-features.c
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Driver/hip-invalid-target-id.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-features.hip
  clang/test/Driver/invalid-target-id.cl
  clang/test/Driver/target-id-macros.cl
  clang/test/Driver/target-id-macros.hip
  clang/test/Driver/target-id.cl
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -83,26 +83,26 @@
   {{"mullins"},   {"gfx703"},  GK_GFX703,  FEATURE_NONE},
   {{"gfx704"},{"gfx704"},  GK_GFX704,  FEATURE_NONE},
   {{"bonaire"},   {"gfx704"},  GK_GFX704,  FEATURE_NONE},
-  {{"gfx801"},{"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"carrizo"},   {"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx802"},{"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"iceland"},   {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"tonga"}, {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx803"},{"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"fiji"},  {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"polaris10"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"polaris11"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx810"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32},
-  {{"stoney"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx900"},{"gfx900"},  GK_GFX900,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx902"},{"gfx902"},  GK_GFX902,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx904"},{"gfx904"},  GK_GFX904,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
-  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
-  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx801"},{"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"carrizo"},   {"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx802"},{"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"iceland"},   {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"tonga"}, {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx803"},{"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"fiji"},  {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"polaris10"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"polaris11"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx810"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"stoney"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx900"},{"gfx900"},  GK_GFX900,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx902"},{"gfx902"},  GK_GFX902,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx904"},{"gfx904"},  GK_GFX904,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx908"},

[PATCH] D83972: Modify ImportDefiniton for ObjCInterfaceDecl so that we always the ImportDeclContext one we start the definition

2020-07-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0db2934b0fa9: [ASTImporter] Modify ImportDefiniton for 
ObjCInterfaceDecl so that we always… (authored by shafik).
Herald added projects: clang, LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83972

Files:
  clang/lib/AST/ASTImporter.cpp
  lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py


Index: lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
===
--- lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
+++ lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
@@ -14,9 +14,8 @@
 lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.m"))
 
 self.expect_expr("chb->hb->field1", result_type="unsigned int", 
result_value="0")
-
-## FIXME field2 should have a value of 1
-self.expect("expr chb->hb->field2", matching=False, substrs = ["= 1"]) 
# this must happen second
+## This should happen second
+self.expect_expr("chb->hb->field2", result_type="unsigned int", 
result_value="1")
 
 self.expect_expr("hb2->field1", result_type="unsigned int", 
result_value="10")
 self.expect_expr("hb2->field2", result_type="unsigned int", 
result_value="3")
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4758,11 +4758,10 @@
   return ToImplOrErr.takeError();
   }
 
-  if (shouldForceImportDeclContext(Kind)) {
-// Import all of the members of this class.
-if (Error Err = ImportDeclContext(From, /*ForceImport=*/true))
-  return Err;
-  }
+  // Import all of the members of this class.
+  if (Error Err = ImportDeclContext(From, /*ForceImport=*/true))
+return Err;
+
   return Error::success();
 }
 


Index: lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
===
--- lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
+++ lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
@@ -14,9 +14,8 @@
 lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
 
 self.expect_expr("chb->hb->field1", result_type="unsigned int", result_value="0")
-
-## FIXME field2 should have a value of 1
-self.expect("expr chb->hb->field2", matching=False, substrs = ["= 1"]) # this must happen second
+## This should happen second
+self.expect_expr("chb->hb->field2", result_type="unsigned int", result_value="1")
 
 self.expect_expr("hb2->field1", result_type="unsigned int", result_value="10")
 self.expect_expr("hb2->field2", result_type="unsigned int", result_value="3")
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -4758,11 +4758,10 @@
   return ToImplOrErr.takeError();
   }
 
-  if (shouldForceImportDeclContext(Kind)) {
-// Import all of the members of this class.
-if (Error Err = ImportDeclContext(From, /*ForceImport=*/true))
-  return Err;
-  }
+  // Import all of the members of this class.
+  if (Error Err = ImportDeclContext(From, /*ForceImport=*/true))
+return Err;
+
   return Error::success();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0db2934 - [ASTImporter] Modify ImportDefiniton for ObjCInterfaceDecl so that we always the ImportDeclContext one we start the definition

2020-07-24 Thread via cfe-commits

Author: shafik
Date: 2020-07-24T13:15:08-07:00
New Revision: 0db2934b0fa9e00ac98e2cb168adba96f6bcd0da

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

LOG: [ASTImporter] Modify ImportDefiniton for ObjCInterfaceDecl so that we 
always the ImportDeclContext one we start the definition

Once we start the definition of an ObjCInterfaceDecl we won't attempt to 
ImportDeclContext
later on. Unlike RecordDecl case which uses DefinitionCompleter to force 
completeDefinition
we don't seem to have a similar mechanism for ObjCInterfaceDecl.

This fix was needed due to a bug we see in LLDB expression parsing where an 
initial expression
cause an ObjCInterfaceDecl to be defined and subsequent expressions during 
import do not call
ImportDeclContext and we can end up in a situation where ivars are imported out 
of order and not all ivars are imported.

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index fcfaba625a722..e0bca8f08bb41 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -4758,11 +4758,10 @@ Error ASTNodeImporter::ImportDefinition(
   return ToImplOrErr.takeError();
   }
 
-  if (shouldForceImportDeclContext(Kind)) {
-// Import all of the members of this class.
-if (Error Err = ImportDeclContext(From, /*ForceImport=*/true))
-  return Err;
-  }
+  // Import all of the members of this class.
+  if (Error Err = ImportDeclContext(From, /*ForceImport=*/true))
+return Err;
+
   return Error::success();
 }
 

diff  --git a/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py 
b/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
index 6118854131024..4154bb144b350 100644
--- a/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
+++ b/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
@@ -14,9 +14,8 @@ def test(self):
 lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.m"))
 
 self.expect_expr("chb->hb->field1", result_type="unsigned int", 
result_value="0")
-
-## FIXME field2 should have a value of 1
-self.expect("expr chb->hb->field2", matching=False, substrs = ["= 1"]) 
# this must happen second
+## This should happen second
+self.expect_expr("chb->hb->field2", result_type="unsigned int", 
result_value="1")
 
 self.expect_expr("hb2->field1", result_type="unsigned int", 
result_value="10")
 self.expect_expr("hb2->field2", result_type="unsigned int", 
result_value="3")



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


[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-07-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 20 inline comments as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Driver/Driver.h:332
 
+  llvm::Triple getHIPOffloadTargetTriple() const;
+

tra wrote:
> This is used exclusively by the Driver.cpp and does not have to be a public 
> API call.
done



Comment at: clang/lib/Basic/TargetID.cpp:18
+
+static const llvm::SmallVector
+getAllPossibleAMDGPUTargetIDFeatures(const llvm::Triple ,

tra wrote:
> Nit. You could use llvm::SmallVectorImpl -- caller only 
> cares that it's an array of StringRef and does not need to know the size hint.
> Makes it easier to change the hint w/o having to replace the constant 
> evrywhere.
It seems I cannot return a SmallVector as SmallVectorImpl since copy ctor is 
deleted.



Comment at: clang/lib/Basic/TargetID.cpp:53
+
+llvm::StringRef parseTargetID(const llvm::Triple ,
+  llvm::StringRef OffloadArch,

tra wrote:
> tra wrote:
> > A comment describing expected format would be helpful.
> > 
> I'd restructure things a bit.
> First, I'd make return type std::optionaland fold IsValid into it.
> Then I would make FeatureMap argument a non-optional, so the parsing can 
> concentrate on parsing only.
> Then I'd add another overload without FeatureMap argument, which would be a 
> warpper over the real parser with a temp FeatureMap which will be discarded.
> 
> This should make things easier to read.
done



Comment at: clang/lib/Basic/TargetID.cpp:53-69
+llvm::StringRef parseTargetID(const llvm::Triple ,
+  llvm::StringRef OffloadArch,
+  llvm::StringMap *FeatureMap,
+  bool *IsValid) {
+  llvm::StringRef ArchStr;
+  auto SetValid = [&](bool Valid) {
+if (IsValid)

yaxunl wrote:
> tra wrote:
> > tra wrote:
> > > A comment describing expected format would be helpful.
> > > 
> > I'd restructure things a bit.
> > First, I'd make return type std::optionaland fold IsValid into 
> > it.
> > Then I would make FeatureMap argument a non-optional, so the parsing can 
> > concentrate on parsing only.
> > Then I'd add another overload without FeatureMap argument, which would be a 
> > warpper over the real parser with a temp FeatureMap which will be discarded.
> > 
> > This should make things easier to read.
> done
parseTargetID actually has two usage pattern: 1. parse the entire target ID 
including processor and features and returns the processor, features, and 
whether the target ID is valid 2. parse the processor part of the target ID 
only and returns the processor or an empty string if the processor is invalid

For usage 1 I will revise it by your suggestion.

For usage 2 I will separate it to a different function getProcessorFromTargetID



Comment at: clang/lib/Basic/TargetID.cpp:103
+
+std::string getCanonicalTargetID(llvm::StringRef Processor,
+ const llvm::StringMap ) {

tra wrote:
> What does 'canonical' mean? A comment would be helpful.
done



Comment at: clang/lib/Basic/TargetID.cpp:116
+static llvm::StringRef
+parseCanonicalTargetIDWithoutCheck(llvm::StringRef OffloadArch,
+   llvm::StringMap *FeatureMap) {

tra wrote:
> Perhaps we can further split parsing offloadID vs checking whether it's valid 
> and make parseTargetID above call this parse-only helper.
> 
> E.g. something like this:
> 
> ```
> something parseTargetIDhelper(something); // Parses targetID 
> something isTargetIdValid(something);  // Verivies validity of parsed 
> parts.
> std::optional parseTargetID(FeatureMap) {
>parseTargetIDhelper(...);
>if (!targetIDValid())
>   return None;
>return Good;
> }
> std::optional parseTargetID() {
>auto TempFeatureMap;
>   return parseTargetID();
> }
> ```
done



Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:366
+  std::replace(NewF.begin(), NewF.end(), '-', '_');
+  Builder.defineMacro(Twine("__amdgcn_") + Twine(NewF) + Twine("__"),
+  Loc->second ? "1" : "0");

tra wrote:
> Nit: Should it be "__amdgcn_feature_" to make it more explicit where these 
> macros are derived from?
done



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:601-605
+llvm::MDString::get(
+getModule().getContext(),
+TargetIDStr == ""
+? TargetIDStr
+: (Twine(getTriple().str()) + "-" + TargetIDStr).str()));

tra wrote:
> I think this may cause problems.
> 
> Twine.str() will return a temporary std::string.
> MDString::get takes a StringRef as the second parameter, so it will be a 
> reference to the temporary. It will then get added to the module's metadata 
> which will probably outlive the temporary 

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D77341#2171305 , @asbirlea wrote:

> The increase in number of instructions and cycles was caused by reversing the 
> order in which the updates are applied by GraphDiff.
>  I'll look into re-adding some of the original cleanups in a follow-up patch.


Fascinating - and you were able to reproduce this by just reversing the order 
in the old code (using ChildrenGetter/building a vector and returning it - not 
using all the iterator adapters, etc) and that the performance problem was no 
longer present in the new code if you changed its order to match?

Huh. (again, sorry this has been such a slog :/)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D84476: Make hip math headers easier to use from C

2020-07-24 Thread Jon Chesterfield via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG679158e662aa: Make hip math headers easier to use from C 
(authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84476

Files:
  clang/lib/Headers/__clang_hip_libdevice_declares.h
  clang/lib/Headers/__clang_hip_math.h


Index: clang/lib/Headers/__clang_hip_math.h
===
--- clang/lib/Headers/__clang_hip_math.h
+++ clang/lib/Headers/__clang_hip_math.h
@@ -95,8 +95,10 @@
 }
 
 // BEGIN FLOAT
+#ifdef __cplusplus
 __DEVICE__
 inline float abs(float __x) { return __ocml_fabs_f32(__x); }
+#endif
 __DEVICE__
 inline float acosf(float __x) { return __ocml_acos_f32(__x); }
 __DEVICE__
@@ -251,7 +253,7 @@
   uint32_t sign : 1;
 } bits;
 
-static_assert(sizeof(float) == sizeof(ieee_float), "");
+static_assert(sizeof(float) == sizeof(struct ieee_float), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -553,8 +555,10 @@
 // END FLOAT
 
 // BEGIN DOUBLE
+#ifdef __cplusplus
 __DEVICE__
 inline double abs(double __x) { return __ocml_fabs_f64(__x); }
+#endif
 __DEVICE__
 inline double acos(double __x) { return __ocml_acos_f64(__x); }
 __DEVICE__
@@ -712,7 +716,7 @@
   uint32_t exponent : 11;
   uint32_t sign : 1;
 } bits;
-static_assert(sizeof(double) == sizeof(ieee_double), "");
+static_assert(sizeof(double) == sizeof(struct ieee_double), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -1178,6 +1182,7 @@
   return std::max(__arg1, __arg2);
 }
 
+#ifdef __cplusplus
 __DEVICE__
 inline float pow(float __base, int __iexp) { return powif(__base, __iexp); }
 
@@ -1188,6 +1193,7 @@
 inline _Float16 pow(_Float16 __base, int __iexp) {
   return __ocml_pown_f16(__base, __iexp);
 }
+#endif
 
 #pragma pop_macro("__DEF_FUN1")
 #pragma pop_macro("__DEF_FUN2")
Index: clang/lib/Headers/__clang_hip_libdevice_declares.h
===
--- clang/lib/Headers/__clang_hip_libdevice_declares.h
+++ clang/lib/Headers/__clang_hip_libdevice_declares.h
@@ -10,7 +10,9 @@
 #ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__
 #define __CLANG_HIP_LIBDEVICE_DECLARES_H__
 
+#ifdef __cplusplus
 extern "C" {
+#endif
 
 // BEGIN FLOAT
 __device__ __attribute__((const)) float __ocml_acos_f32(float);
@@ -316,7 +318,7 @@
 __device__ inline __2f16
 __llvm_amdgcn_rcp_2f16(__2f16 __x) // Not currently exposed by ROCDL.
 {
-  return __2f16{__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y)};
+  return (__2f16){__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y)};
 }
 __device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16);
 __device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16);
@@ -325,6 +327,8 @@
 __device__ __attribute__((const)) __2f16 __ocml_trunc_2f16(__2f16);
 __device__ __attribute__((const)) __2f16 __ocml_pown_2f16(__2f16, __2i16);
 
+#ifdef __cplusplus
 } // extern "C"
+#endif
 
 #endif // __CLANG_HIP_LIBDEVICE_DECLARES_H__


Index: clang/lib/Headers/__clang_hip_math.h
===
--- clang/lib/Headers/__clang_hip_math.h
+++ clang/lib/Headers/__clang_hip_math.h
@@ -95,8 +95,10 @@
 }
 
 // BEGIN FLOAT
+#ifdef __cplusplus
 __DEVICE__
 inline float abs(float __x) { return __ocml_fabs_f32(__x); }
+#endif
 __DEVICE__
 inline float acosf(float __x) { return __ocml_acos_f32(__x); }
 __DEVICE__
@@ -251,7 +253,7 @@
   uint32_t sign : 1;
 } bits;
 
-static_assert(sizeof(float) == sizeof(ieee_float), "");
+static_assert(sizeof(float) == sizeof(struct ieee_float), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -553,8 +555,10 @@
 // END FLOAT
 
 // BEGIN DOUBLE
+#ifdef __cplusplus
 __DEVICE__
 inline double abs(double __x) { return __ocml_fabs_f64(__x); }
+#endif
 __DEVICE__
 inline double acos(double __x) { return __ocml_acos_f64(__x); }
 __DEVICE__
@@ -712,7 +716,7 @@
   uint32_t exponent : 11;
   uint32_t sign : 1;
 } bits;
-static_assert(sizeof(double) == sizeof(ieee_double), "");
+static_assert(sizeof(double) == sizeof(struct ieee_double), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -1178,6 +1182,7 @@
   return std::max(__arg1, __arg2);
 }
 
+#ifdef __cplusplus
 __DEVICE__
 inline float pow(float __base, int __iexp) { return powif(__base, __iexp); }
 
@@ -1188,6 +1193,7 @@
 inline _Float16 pow(_Float16 __base, int __iexp) {
   return __ocml_pown_f16(__base, __iexp);
 }
+#endif
 
 #pragma pop_macro("__DEF_FUN1")
 #pragma pop_macro("__DEF_FUN2")
Index: clang/lib/Headers/__clang_hip_libdevice_declares.h
===
--- clang/lib/Headers/__clang_hip_libdevice_declares.h
+++ clang/lib/Headers/__clang_hip_libdevice_declares.h
@@ -10,7 +10,9 @@
 #ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__
 #define __CLANG_HIP_LIBDEVICE_DECLARES_H__
 
+#ifdef 

[clang] 679158e - Make hip math headers easier to use from C

2020-07-24 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2020-07-24T20:50:46+01:00
New Revision: 679158e662aa247282b8eea4c2d60b33204171fb

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

LOG: Make hip math headers easier to use from C

Summary:
Make hip math headers easier to use from C

Motivation is a step towards using the hip math headers to implement math.h
for openmp, which needs to work with C as well as C++. NFC for C++ code.

Reviewers: yaxunl, jdoerfert

Reviewed By: yaxunl

Subscribers: sstefan1, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Headers/__clang_hip_libdevice_declares.h
clang/lib/Headers/__clang_hip_math.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_libdevice_declares.h 
b/clang/lib/Headers/__clang_hip_libdevice_declares.h
index 711040443440..2cf9cc7f1eb6 100644
--- a/clang/lib/Headers/__clang_hip_libdevice_declares.h
+++ b/clang/lib/Headers/__clang_hip_libdevice_declares.h
@@ -10,7 +10,9 @@
 #ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__
 #define __CLANG_HIP_LIBDEVICE_DECLARES_H__
 
+#ifdef __cplusplus
 extern "C" {
+#endif
 
 // BEGIN FLOAT
 __device__ __attribute__((const)) float __ocml_acos_f32(float);
@@ -316,7 +318,7 @@ __device__ __attribute__((pure)) __2f16 
__ocml_log2_2f16(__2f16);
 __device__ inline __2f16
 __llvm_amdgcn_rcp_2f16(__2f16 __x) // Not currently exposed by ROCDL.
 {
-  return __2f16{__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y)};
+  return (__2f16){__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y)};
 }
 __device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16);
 __device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16);
@@ -325,6 +327,8 @@ __device__ __attribute__((const)) __2f16 
__ocml_sqrt_2f16(__2f16);
 __device__ __attribute__((const)) __2f16 __ocml_trunc_2f16(__2f16);
 __device__ __attribute__((const)) __2f16 __ocml_pown_2f16(__2f16, __2i16);
 
+#ifdef __cplusplus
 } // extern "C"
+#endif
 
 #endif // __CLANG_HIP_LIBDEVICE_DECLARES_H__

diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index 47d3c1717559..f9ca9bf606fb 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -95,8 +95,10 @@ inline uint64_t __make_mantissa(const char *__tagp) {
 }
 
 // BEGIN FLOAT
+#ifdef __cplusplus
 __DEVICE__
 inline float abs(float __x) { return __ocml_fabs_f32(__x); }
+#endif
 __DEVICE__
 inline float acosf(float __x) { return __ocml_acos_f32(__x); }
 __DEVICE__
@@ -251,7 +253,7 @@ inline float nanf(const char *__tagp) {
   uint32_t sign : 1;
 } bits;
 
-static_assert(sizeof(float) == sizeof(ieee_float), "");
+static_assert(sizeof(float) == sizeof(struct ieee_float), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -553,8 +555,10 @@ inline float __tanf(float __x) { return 
__ocml_tan_f32(__x); }
 // END FLOAT
 
 // BEGIN DOUBLE
+#ifdef __cplusplus
 __DEVICE__
 inline double abs(double __x) { return __ocml_fabs_f64(__x); }
+#endif
 __DEVICE__
 inline double acos(double __x) { return __ocml_acos_f64(__x); }
 __DEVICE__
@@ -712,7 +716,7 @@ inline double nan(const char *__tagp) {
   uint32_t exponent : 11;
   uint32_t sign : 1;
 } bits;
-static_assert(sizeof(double) == sizeof(ieee_double), "");
+static_assert(sizeof(double) == sizeof(struct ieee_double), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -1178,6 +1182,7 @@ __host__ inline static int max(int __arg1, int __arg2) {
   return std::max(__arg1, __arg2);
 }
 
+#ifdef __cplusplus
 __DEVICE__
 inline float pow(float __base, int __iexp) { return powif(__base, __iexp); }
 
@@ -1188,6 +1193,7 @@ __DEVICE__
 inline _Float16 pow(_Float16 __base, int __iexp) {
   return __ocml_pown_f16(__base, __iexp);
 }
+#endif
 
 #pragma pop_macro("__DEF_FUN1")
 #pragma pop_macro("__DEF_FUN2")



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


[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-07-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D82598#2172416 , @NoQ wrote:

> I still wonder what made this statement live in my example. There must have 
> been some non-trivial liveness analysis going on that caused a statement to 
> be live; probably something to do with the C++ destructor elements.


Pushed rG032b78a0762bee129f33e4255ada6d374aa70c71 
. Mind 
that no `ObjCForCollectionStmt` was found in the `DumpLiveStms` run.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82598



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


[clang] 032b78a - [analyzer] Revert the accidental commit of D82122

2020-07-24 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-07-24T21:33:18+02:00
New Revision: 032b78a0762bee129f33e4255ada6d374aa70c71

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

LOG: [analyzer] Revert the accidental commit of D82122

Was accidentally squished into
rGb6cbe6cb0399d4671e5384dcc326af56bc6bd122. The assert fires on the code
snippet included in this commit.

More discussion can be found in https://reviews.llvm.org/D82598.

Added: 
clang/test/Analysis/live-stmts.mm

Modified: 
clang/lib/StaticAnalyzer/Core/Environment.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/Environment.cpp 
b/clang/lib/StaticAnalyzer/Core/Environment.cpp
index 9e6d79bb7dcc..1ccf4c6104a6 100644
--- a/clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -183,18 +183,12 @@ EnvironmentManager::removeDeadBindings(Environment Env,
  F.getTreeFactory());
 
   // Iterate over the block-expr bindings.
-  for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
+  for (Environment::iterator I = Env.begin(), E = Env.end();
+   I != E; ++I) {
 const EnvironmentEntry  = I.getKey();
 const SVal  = I.getData();
 
-const bool IsBlkExprLive =
-SymReaper.isLive(BlkExpr.getStmt(), BlkExpr.getLocationContext());
-
-assert((isa(BlkExpr.getStmt()) || !IsBlkExprLive) &&
-   "Only Exprs can be live, LivenessAnalysis argues about the liveness 
"
-   "of *values*!");
-
-if (IsBlkExprLive) {
+if (SymReaper.isLive(BlkExpr.getStmt(), BlkExpr.getLocationContext())) {
   // Copy the binding to the new map.
   EBMapRef = EBMapRef.add(BlkExpr, X);
 

diff  --git a/clang/test/Analysis/live-stmts.mm 
b/clang/test/Analysis/live-stmts.mm
new file mode 100644
index ..a6ddd03ca5d8
--- /dev/null
+++ b/clang/test/Analysis/live-stmts.mm
@@ -0,0 +1,101 @@
+// RUN: %clang_analyze_cc1 -w -fblocks %s \
+// RUN:   -analyzer-checker=debug.DumpLiveStmts \
+// RUN:   2>&1 | FileCheck %s
+
+@interface Item
+// ...
+@end
+
+@interface Collection
+// ...
+@end
+
+typedef void (^Blk)();
+
+struct RAII {
+  Blk blk;
+
+public:
+  RAII(Blk blk): blk(blk) {}
+
+// CHECK: [ B0 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B1 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B2 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+
+  ~RAII() { blk(); }
+
+// CHECK-NEXT: [ B0 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B1 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B2 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+};
+
+void foo(Collection *coll) {
+  RAII raii(^{});
+  for (Item *item in coll) {}
+}
+// CHECK-NEXT: [ B0 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B1 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B2 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-NEXT: DeclStmt {{.*}}
+// CHECK-NEXT: `-VarDecl {{.*}}  item 'Item *'
+// CHECK-EMPTY:
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' 
+// CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 
'coll' 'Collection *'
+// CHECK-EMPTY:
+// CHECK-NEXT: CompoundStmt {{.*}}
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B3 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-NEXT: DeclStmt {{.*}}
+// CHECK-NEXT: `-VarDecl {{.*}}  item 'Item *'
+// CHECK-EMPTY:
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' 
+// CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 
'coll' 'Collection *'
+// CHECK-EMPTY:
+// CHECK-NEXT: CompoundStmt {{.*}}
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B4 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-NEXT: DeclStmt {{.*}}
+// CHECK-NEXT: `-VarDecl {{.*}}  item 'Item *'
+// CHECK-EMPTY:
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' 
+// CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 
'coll' 'Collection *'
+// CHECK-EMPTY:
+// CHECK-NEXT: CompoundStmt {{.*}}
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B5 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-NEXT: DeclStmt {{.*}}
+// CHECK-NEXT: `-VarDecl {{.*}}  item 'Item *'
+// CHECK-EMPTY:
+// CHECK-NEXT: CompoundStmt {{.*}}
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B0 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+// CHECK-NEXT: [ B1 (live statements at block exit) ]
+// CHECK-EMPTY:
+// CHECK-EMPTY:
+



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D84476: Make hip math headers easier to use from C

2020-07-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.




Comment at: clang/lib/Headers/__clang_hip_math.h:561
 inline double abs(double __x) { return __ocml_fabs_f64(__x); }
+#endif
 __DEVICE__

JonChesterfield wrote:
> yaxunl wrote:
> > jdoerfert wrote:
> > > Nit: You mix the C and C++ math declarations in this file, while 
> > > possible, I somehow thing the cuda_{cmath/math} split is nicer.
> > right
> Open to me implementing that in a later patch?
If you could work on it that would be great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84476



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


[PATCH] D84348: WIP: Add complete id-expression support to syntax trees

2020-07-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:295
   syntax::NestedNameSpecifier *qualifier();
-  // TODO after expose `id-expression` from `DependentScopeDeclRefExpr`:
   // Add accessor for `template_opt`.
+  syntax::Leaf *templateKeyword();

You can remove this todo now.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:748
+  bool isDecltype(const Type ) {
+return T.getTypeClass() == Type::TypeClass::Decltype;
+  }

Please use `isa(T)` and inline this expression into its only user.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:753
+return T.getTypeClass() == Type::TypeClass::TemplateSpecialization ||
+   T.getTypeClass() == 
Type::TypeClass::DependentTemplateSpecialization;
+  }

Ditto, please use `isa` and inline into the only user.




Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:803
+// The 'template' keyword is always present in dependent template
+// specializations
+SR.setBegin(DependentTL.getTemplateKeywordLoc());

... except in the case of incorrect code. Feel free to just add a TODO.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:819
+  auto *NS = BuildNameSpecifier(*NNS);
+  if (!syntax::GlobalNameSpecifier::classof(NS))
+Builder.foldNode(Builder.getRange(getLocalSourceRange(it)), NS,

Please use `isa(NS)`.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:821
+Builder.foldNode(Builder.getRange(getLocalSourceRange(it)), NS,
+ nullptr);
+  Builder.markChild(NS, syntax::NodeRole::NestedNameSpecifier_specifier);

Could you add an overload for `foldNode` that takes a `NestedNameSpecifierLoc` 
but ignores it, just like we have an overload of `foldNode` that takes a 
`TypeLoc` but ignores it?



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:834
+  // FIXME: I feel like this could be upstreamed.
+  SourceRange getUnqualifiedIdSourceRange(DeclRefExpr *S) {
+if (S->hasExplicitTemplateArgs())

WDYM by "upstream"?



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:844
 
+if (auto TKL = S->getTemplateKeywordLoc(); TKL.isValid())
+  Builder.markChildToken(TKL, syntax::NodeRole::TemplateKeyword);

Please don't use C++17, Clang uses C++14 now.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:873
 template
-static T f(){}
+struct TS {
+  static void f();

TS => ST (struct template?)



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:879
+template
+struct TS {
+  struct S {

ST


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84348



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


[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-24 Thread George Rokos via Phabricator via cfe-commits
grokos added a comment.

So let's proceed with the patch.

Instead of introducing new API functions and making all these changes in all 
these files, wouldn't it be easier if we just unset the `PRESENT` flag from 
arg_types in clang when we generate the call to `__tgt_target_data_end_*` if we 
are exiting from a scoped environment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84422



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


[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-24 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D84422#2170702 , @RaviNarayanaswamy 
wrote:

> In D84422#2170667 , @grokos wrote:
>
> > So is the test case that motivated this patch illegal OpenMP code?
> >
> >   #pragma omp target enter data map(alloc:i)
> >   #pragma omp target data map(present, alloc: i)
> >   {
> > #pragma omp target exit data map(delete:i) // you cannot delete that 
> > object in the scope, illegal code?
> >   } // fails presence check here
>
>
> According to spec the test should work.  ie should not check for presence on 
> exit from a blocked openmp pragma scope.


It sounds like this patch's motivation is correct then.  Has anyone clarified 
the motivation for this behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84422



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


[PATCH] D69330: [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-07-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.
Herald added a subscriber: dang.

I wasn't able to add you to the bug report, but I discovered this: 
https://bugs.llvm.org/show_bug.cgi?id=46837

I'm still working on it, but if you have a suggestion, I'd appreciate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330



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


[PATCH] D84476: Make hip math headers easier to use from C

2020-07-24 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield marked 4 inline comments as done.
JonChesterfield added inline comments.



Comment at: clang/lib/Headers/__clang_hip_math.h:561
 inline double abs(double __x) { return __ocml_fabs_f64(__x); }
+#endif
 __DEVICE__

yaxunl wrote:
> jdoerfert wrote:
> > Nit: You mix the C and C++ math declarations in this file, while possible, 
> > I somehow thing the cuda_{cmath/math} split is nicer.
> right
Open to me implementing that in a later patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84476



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


[PATCH] D84476: Make hip math headers easier to use from C

2020-07-24 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 280524.
JonChesterfield added a comment.

- Fix missing underscores


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84476

Files:
  clang/lib/Headers/__clang_hip_libdevice_declares.h
  clang/lib/Headers/__clang_hip_math.h


Index: clang/lib/Headers/__clang_hip_math.h
===
--- clang/lib/Headers/__clang_hip_math.h
+++ clang/lib/Headers/__clang_hip_math.h
@@ -95,8 +95,10 @@
 }
 
 // BEGIN FLOAT
+#ifdef __cplusplus
 __DEVICE__
 inline float abs(float __x) { return __ocml_fabs_f32(__x); }
+#endif
 __DEVICE__
 inline float acosf(float __x) { return __ocml_acos_f32(__x); }
 __DEVICE__
@@ -251,7 +253,7 @@
   uint32_t sign : 1;
 } bits;
 
-static_assert(sizeof(float) == sizeof(ieee_float), "");
+static_assert(sizeof(float) == sizeof(struct ieee_float), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -553,8 +555,10 @@
 // END FLOAT
 
 // BEGIN DOUBLE
+#ifdef __cplusplus
 __DEVICE__
 inline double abs(double __x) { return __ocml_fabs_f64(__x); }
+#endif
 __DEVICE__
 inline double acos(double __x) { return __ocml_acos_f64(__x); }
 __DEVICE__
@@ -712,7 +716,7 @@
   uint32_t exponent : 11;
   uint32_t sign : 1;
 } bits;
-static_assert(sizeof(double) == sizeof(ieee_double), "");
+static_assert(sizeof(double) == sizeof(struct ieee_double), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -1178,6 +1182,7 @@
   return std::max(__arg1, __arg2);
 }
 
+#ifdef __cplusplus
 __DEVICE__
 inline float pow(float __base, int __iexp) { return powif(__base, __iexp); }
 
@@ -1188,6 +1193,7 @@
 inline _Float16 pow(_Float16 __base, int __iexp) {
   return __ocml_pown_f16(__base, __iexp);
 }
+#endif
 
 #pragma pop_macro("__DEF_FUN1")
 #pragma pop_macro("__DEF_FUN2")
Index: clang/lib/Headers/__clang_hip_libdevice_declares.h
===
--- clang/lib/Headers/__clang_hip_libdevice_declares.h
+++ clang/lib/Headers/__clang_hip_libdevice_declares.h
@@ -10,7 +10,9 @@
 #ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__
 #define __CLANG_HIP_LIBDEVICE_DECLARES_H__
 
+#ifdef __cplusplus
 extern "C" {
+#endif
 
 // BEGIN FLOAT
 __device__ __attribute__((const)) float __ocml_acos_f32(float);
@@ -316,7 +318,7 @@
 __device__ inline __2f16
 __llvm_amdgcn_rcp_2f16(__2f16 __x) // Not currently exposed by ROCDL.
 {
-  return __2f16{__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y)};
+  return (__2f16){__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y)};
 }
 __device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16);
 __device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16);
@@ -325,6 +327,8 @@
 __device__ __attribute__((const)) __2f16 __ocml_trunc_2f16(__2f16);
 __device__ __attribute__((const)) __2f16 __ocml_pown_2f16(__2f16, __2i16);
 
+#ifdef __cplusplus
 } // extern "C"
+#endif
 
 #endif // __CLANG_HIP_LIBDEVICE_DECLARES_H__


Index: clang/lib/Headers/__clang_hip_math.h
===
--- clang/lib/Headers/__clang_hip_math.h
+++ clang/lib/Headers/__clang_hip_math.h
@@ -95,8 +95,10 @@
 }
 
 // BEGIN FLOAT
+#ifdef __cplusplus
 __DEVICE__
 inline float abs(float __x) { return __ocml_fabs_f32(__x); }
+#endif
 __DEVICE__
 inline float acosf(float __x) { return __ocml_acos_f32(__x); }
 __DEVICE__
@@ -251,7 +253,7 @@
   uint32_t sign : 1;
 } bits;
 
-static_assert(sizeof(float) == sizeof(ieee_float), "");
+static_assert(sizeof(float) == sizeof(struct ieee_float), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -553,8 +555,10 @@
 // END FLOAT
 
 // BEGIN DOUBLE
+#ifdef __cplusplus
 __DEVICE__
 inline double abs(double __x) { return __ocml_fabs_f64(__x); }
+#endif
 __DEVICE__
 inline double acos(double __x) { return __ocml_acos_f64(__x); }
 __DEVICE__
@@ -712,7 +716,7 @@
   uint32_t exponent : 11;
   uint32_t sign : 1;
 } bits;
-static_assert(sizeof(double) == sizeof(ieee_double), "");
+static_assert(sizeof(double) == sizeof(struct ieee_double), "");
   } __tmp;
 
   __tmp.bits.sign = 0u;
@@ -1178,6 +1182,7 @@
   return std::max(__arg1, __arg2);
 }
 
+#ifdef __cplusplus
 __DEVICE__
 inline float pow(float __base, int __iexp) { return powif(__base, __iexp); }
 
@@ -1188,6 +1193,7 @@
 inline _Float16 pow(_Float16 __base, int __iexp) {
   return __ocml_pown_f16(__base, __iexp);
 }
+#endif
 
 #pragma pop_macro("__DEF_FUN1")
 #pragma pop_macro("__DEF_FUN2")
Index: clang/lib/Headers/__clang_hip_libdevice_declares.h
===
--- clang/lib/Headers/__clang_hip_libdevice_declares.h
+++ clang/lib/Headers/__clang_hip_libdevice_declares.h
@@ -10,7 +10,9 @@
 #ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__
 #define __CLANG_HIP_LIBDEVICE_DECLARES_H__
 
+#ifdef __cplusplus
 extern "C" {
+#endif
 
 // BEGIN FLOAT
 __device__ 

[PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments

2020-07-24 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D83268#2172748 , @protze.joachim 
wrote:

> I carefully made sure, that the freshly built clang was used to execute the 
> test. I opened https://bugs.llvm.org/show_bug.cgi?id=46836 to track the issue 
> and made it release blocker.


The question is if you picked up a fresly build device runtime as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83268



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


[PATCH] D84476: Make hip math headers easier to use from C

2020-07-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Headers/__clang_hip_math.h:98
 // BEGIN FLOAT
+#ifdef _cplusplus
 __DEVICE__

typo ?



Comment at: clang/lib/Headers/__clang_hip_math.h:558
 // BEGIN DOUBLE
+#ifdef _cplusplus
 __DEVICE__

typo



Comment at: clang/lib/Headers/__clang_hip_math.h:561
 inline double abs(double __x) { return __ocml_fabs_f64(__x); }
+#endif
 __DEVICE__

jdoerfert wrote:
> Nit: You mix the C and C++ math declarations in this file, while possible, I 
> somehow thing the cuda_{cmath/math} split is nicer.
right



Comment at: clang/lib/Headers/__clang_hip_math.h:1185
 
+#ifdef _cplusplus
 __DEVICE__

typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84476



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


[PATCH] D83592: [Coverage] Add comment to skipped regions

2020-07-24 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/lib/Lex/Preprocessor.cpp:973
+  if ((LexLevel == 0 || PreprocessToken) &&
+  !Result.getFlag(Token::IsReinjected)) {
+if (LexLevel == 0)

zequanwu wrote:
> hans wrote:
> > zequanwu wrote:
> > > @hans , can you take a look on this part? I saw `TokenCount` was 
> > > introduced for a warning `-Wmax-tokens`.
> > Can you explain why things are changing here?
> > 
> > The idea of TokenCount is to simply count the preprocessor tokens. At this 
> > point I think you have more knowledge here than I did when I added it :)
> In `CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks`, I set 
> `OnToken` to a lambda to update `PrevTokLoc` after lexing a new token. But, 
> the original condition ` if (LexLevel == 0 && 
> !Result.getFlag(Token::IsReinjected)) ` will not call `OnToken` if it's  
> lexing a directive, like `#if`, `#define` etc, because the LexLevel is 
> greater than 0. In order to update `PrevTokLoc` even when lexing directive, I 
> add `PreprocessToken` which will be set to true in 
> `CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks` just to invoke 
> `OnToken` without increment `TokenCount` when lexing directives. 
Ah, I see. That sounds okay to me.


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

https://reviews.llvm.org/D83592



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


[PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments

2020-07-24 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim reopened this revision.
protze.joachim added a comment.
This revision is now accepted and ready to land.

I carefully made sure, that the freshly built clang was used to execute the 
test. I opened https://bugs.llvm.org/show_bug.cgi?id=46836 to track the issue 
and made it release blocker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83268



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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-24 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor added a comment.

In D84005#2171982 , @MForster wrote:

> @milseman, @doug.gregor, could you please help with the open questions on 
> this review?
>
> Specifically:
>
> - Is `ns_error_domain` ever needed for something other than an enum?


No, it only makes sense on enums.

> - Why is this designed in the way it is (requiring an identifier for the 
> domain, not allowing literals and then only using the name of the identifier 
> from Swift)?

It's codifying the design of NSError, which has been this way since... longer 
than Clang has existed, and is independent of Swift. NSErrors have a domain 
(identified by an NSString constant symbol, not a literal, for pointer 
uniqueness and code size)  and a code (an integer, conventionally defined by an 
enum). The two need to be used together, e.g., you create an NSError with a 
domain and a code from that domain. This attribute finally ties those things 
together at the source level.

This is leads to the answer to Aaron's question:

> Are there plans to use this attribute in Clang itself?

It would absolutely make sense to add some warnings if you've mismatched your 
domain and code when constructing an NSError (e.g., uses of 
https://developer.apple.com/documentation/foundation/nserror/1522782-errorwithdomain?language=objc)
 or even if when testing an error in an "if" statement (if checking both domain 
and code, make sure the code enumerator is from the same domain). I bet you'd 
catch some fiddly error-handling bugs this way.

> - Is it ok to make this attribute inheritable?

Sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005



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


[PATCH] D84348: WIP: Add complete id-expression support to syntax trees

2020-07-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 280511.
eduucaldas added a comment.

- Remove UnknownNameSpecifier, answer to comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84348

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -867,24 +867,47 @@
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-namespace a {
+namespace n {
   struct S {
 template
-static T f(){}
+struct TS {
+  static void f();
+};
   };
 }
+template
+struct TS {
+  struct S {
+template
+static U f();
+  };
+};
 void test() {
-  ::  // global-namespace-specifier
-  a:: // namespace-specifier
-  S:: // type-name-specifier
+  :: // global-namespace-specifier
+  n::// namespace-specifier
+  S::// type-name-specifier
+  template TS:: // type-template-instantiation-specifier
+  f();
+
+  n::// namespace-specifier
+  S::// type-name-specifier
+  TS::  // type-template-instantiation-specifier
+  f();
+
+  TS:: // type-name-specifier
+  S::   // type-name-specifier
   f();
+
+  TS:: // type-name-specifier
+  S::   // type-name-specifier
+  template f();
 }
 )cpp",
   R"txt(
 *: TranslationUnit
 |-NamespaceDefinition
 | |-namespace
-| |-a
+| |-n
 | |-{
 | |-SimpleDeclaration
 | | |-struct
@@ -898,19 +921,58 @@
 | | | | `-T
 | | | |->
 | | | `-SimpleDeclaration
-| | |   |-static
-| | |   |-T
-| | |   |-SimpleDeclarator
-| | |   | |-f
-| | |   | `-ParametersAndQualifiers
-| | |   |   |-(
-| | |   |   `-)
-| | |   `-CompoundStatement
-| | | |-{
-| | | `-}
+| | |   |-struct
+| | |   |-TS
+| | |   |-{
+| | |   |-SimpleDeclaration
+| | |   | |-static
+| | |   | |-void
+| | |   | |-SimpleDeclarator
+| | |   | | |-f
+| | |   | | `-ParametersAndQualifiers
+| | |   | |   |-(
+| | |   | |   `-)
+| | |   | `-;
+| | |   |-}
+| | |   `-;
 | | |-}
 | | `-;
 | `-}
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-typename
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-TS
+|   |-{
+|   |-SimpleDeclaration
+|   | |-struct
+|   | |-S
+|   | |-{
+|   | |-TemplateDeclaration
+|   | | |-template
+|   | | |-<
+|   | | |-UnknownDeclaration
+|   | | | |-typename
+|   | | | `-U
+|   | | |->
+|   | | `-SimpleDeclaration
+|   | |   |-static
+|   | |   |-U
+|   | |   |-SimpleDeclarator
+|   | |   | |-f
+|   | |   | `-ParametersAndQualifiers
+|   | |   |   |-(
+|   | |   |   `-)
+|   | |   `-;
+|   | |-}
+|   | `-;
+|   |-}
+|   `-;
 `-SimpleDeclaration
   |-void
   |-SimpleDeclarator
@@ -924,14 +986,81 @@
 | |-UnknownExpression
 | | |-IdExpression
 | | | |-NestedNameSpecifier
-| | | | |-NameSpecifier
-| | | | | `-::
-| | | | |-NameSpecifier
-| | | | | |-a
-| | | | | `-::
-| | | | `-NameSpecifier
-| | | |   |-S
-| | | |   `-::
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-n
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-S
+| | | | |-::
+| | | | |-SimpleTemplateNameSpecifier
+| | | | | |-template
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | `->
+| | | | `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-IdentifierNameSpecifier
+| | | | | `-n
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-S
+| | | | |-::
+| | | | |-SimpleTemplateNameSpecifier
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | `->
+| | | | `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-SimpleTemplateNameSpecifier
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | `->
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-S
+| | | | `-::
+| | | `-UnqualifiedId
+| | |   |-f
+| | |   |-<
+| | |   |-int
+| | |   `->
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-SimpleTemplateNameSpecifier
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | `->
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-S
+   

[PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments

2020-07-24 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim added a comment.

This patch breaks compilation of previously working code.

I added the following to 
`openmp/libomptarget/test/offloading/offloading_success.c`:

  +// RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda

which results in

  # command stderr:
  ptxas offloading_success-openmp-nvptx64-nvidia-cuda.s, line 173; error   : 
Call has wrong number of parameters
  ptxas fatal   : Ptx assembly aborted due to errors
  clang-12: error: ptxas command failed with exit code 255 (use -v to see 
invocation)

The file `offloading_success-openmp-nvptx64-nvidia-cuda.s` contains:

  .func  (.param .b32 func_retval0) __kmpc_kernel_parallel
  (
  .param .b64 __kmpc_kernel_parallel_param_0,
  .param .b32 __kmpc_kernel_parallel_param_1
  )
  ;

For the clang 11 release, we should either fix the codegen or revert this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83268



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


[PATCH] D83987: [libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given.

2020-07-24 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 280507.
dokyungs added a comment.

Relanding this reverted commit. (See summary)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/fuzzer/noasan-memcmp.test
  compiler-rt/test/fuzzer/noasan-memcmp64.test
  compiler-rt/test/fuzzer/noasan-strcmp.test
  compiler-rt/test/fuzzer/noasan-strncmp.test
  compiler-rt/test/fuzzer/noasan-strstr.test

Index: compiler-rt/test/fuzzer/noasan-strstr.test
===
--- compiler-rt/test/fuzzer/noasan-strstr.test
+++ compiler-rt/test/fuzzer/noasan-strstr.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
 RUN: not %run %t-NoAsanStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strstr %S/CustomAllocator.cpp %S/StrstrTest.cpp -o %t-NoAsanCustomAllocatorStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrstrTest.cpp -o %t-NoAsanCustomAllocatorStrstrTest
 RUN: not %run %t-NoAsanCustomAllocatorStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-strncmp.test
===
--- compiler-rt/test/fuzzer/noasan-strncmp.test
+++ compiler-rt/test/fuzzer/noasan-strncmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
 RUN: not %run %t-NoAsanStrncmpTest -seed=2 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strncmp %S/CustomAllocator.cpp %S/StrncmpTest.cpp -o %t-NoAsanCustomAllocatorStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrncmpTest.cpp -o %t-NoAsanCustomAllocatorStrncmpTest
 RUN: not %run %t-NoAsanCustomAllocatorStrncmpTest -seed=2 -runs=1000   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-strcmp.test
===
--- compiler-rt/test/fuzzer/noasan-strcmp.test
+++ compiler-rt/test/fuzzer/noasan-strcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
 RUN: not %run %t-NoAsanStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strcmp %S/CustomAllocator.cpp %S/StrcmpTest.cpp -o %t-NoAsanCustomAllocatorStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrcmpTest.cpp -o %t-NoAsanCustomAllocatorStrcmpTest
 RUN: not %run %t-NoAsanCustomAllocatorStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-memcmp64.test
===
--- compiler-rt/test/fuzzer/noasan-memcmp64.test
+++ compiler-rt/test/fuzzer/noasan-memcmp64.test
@@ -1,6 +1,6 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-NoAsanMemcmp64BytesTest -seed=1 -runs=100   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-memcmp.test
===
--- compiler-rt/test/fuzzer/noasan-memcmp.test
+++ compiler-rt/test/fuzzer/noasan-memcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
 RUN: not %run %t-NoAsanMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-memcmp %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
 RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: clang/lib/Driver/SanitizerArgs.cpp

[PATCH] D83592: [Coverage] Add comment to skipped regions

2020-07-24 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 280504.
zequanwu added a comment.

Change `newSR.ColumnEnd = 1` to `newSR.ColumnEnd = SR.ColumnStart + 1` to 
ensure ColumnEnd >= ColumnStart.


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

https://reviews.llvm.org/D83592

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/builtinmacro.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/comment-in-macro.c
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/includehell.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/logical.cpp
  clang/test/CoverageMapping/loops.cpp
  clang/test/CoverageMapping/macro-expressions.cpp
  clang/test/CoverageMapping/macroparams2.c
  clang/test/CoverageMapping/macros.c
  clang/test/CoverageMapping/macroscopes.cpp
  clang/test/CoverageMapping/moremacros.c
  clang/test/CoverageMapping/objc.m
  clang/test/CoverageMapping/pr32679.cpp
  clang/test/CoverageMapping/preprocessor.c
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/test.c
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  clang/test/CoverageMapping/while.c
  clang/test/lit.cfg.py
  compiler-rt/test/profile/Inputs/instrprof-comdat.h
  compiler-rt/test/profile/coverage_comments.cpp
  compiler-rt/test/profile/instrprof-set-file-object-merging.c

Index: compiler-rt/test/profile/instrprof-set-file-object-merging.c
===
--- compiler-rt/test/profile/instrprof-set-file-object-merging.c
+++ compiler-rt/test/profile/instrprof-set-file-object-merging.c
@@ -34,7 +34,7 @@
 // CHECK:   17|  2|
 // CHECK:   18|  2|  FILE *F = fopen(argv[1], "r+b");
 // CHECK:   19|  2|  if (!F) {
-// CHECK:   20|  1|// File might not exist, try opening with truncation
+// CHECK:   20|   |// File might not exist, try opening with truncation
 // CHECK:   21|  1|F = fopen(argv[1], "w+b");
 // CHECK:   22|  1|  }
 // CHECK:   23|  2|  __llvm_profile_set_file_object(F, 1);
Index: compiler-rt/test/profile/coverage_comments.cpp
===
--- /dev/null
+++ compiler-rt/test/profile/coverage_comments.cpp
@@ -0,0 +1,71 @@
+// RUN: %clangxx_profgen -fcoverage-mapping -Wno-comment -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+
+int main() {   // CHECK:   [[# @LINE]]| 1|int main() {
+/* comment */ int x = 0;   // CHECK-NEXT:  [[# @LINE]]| 1|
+int y = 0; /* comment */   // CHECK-NEXT:  [[# @LINE]]| 1|
+int z = 0; // comment  // CHECK-NEXT:  [[# @LINE]]| 1|
+// comment // CHECK-NEXT:  [[# @LINE]]|  |
+   // CHECK-NEXT:  [[# @LINE]]|  |
+x = 0; /*  // CHECK-NEXT:  [[# @LINE]]| 1|
+comment// CHECK-NEXT:  [[# @LINE]]|  |
+*/ // CHECK-NEXT:  [[# @LINE]]|  |
+   // CHECK-NEXT:  [[# @LINE]]|  |
+/* // CHECK-NEXT:  [[# @LINE]]|  |
+comment// CHECK-NEXT:  [[# @LINE]]|  |
+*/ x = 0;  // CHECK-NEXT:  [[# @LINE]]| 1|
+   // CHECK-NEXT:  [[# @LINE]]|  |
+/* comment */  // CHECK-NEXT:  [[# @LINE]]|  |
+// comment // CHECK-NEXT:  [[# @LINE]]|  |
+/* comment */  // CHECK-NEXT:  [[# @LINE]]|  |
+z =// CHECK-NEXT:  [[# @LINE]]| 1|
+x // comment   // CHECK-NEXT:  [[# @LINE]]| 1|
+// comment // CHECK-NEXT:  [[# @LINE]]|  |
++ /*   // CHECK-NEXT:  [[# @LINE]]| 1|
+comment// CHECK-NEXT:  [[# @LINE]]|  |
+*/ // CHECK-NEXT:  [[# @LINE]]|  |
+/* // CHECK-NEXT:  [[# @LINE]]|  |
+comment// CHECK-NEXT:  [[# @LINE]]|  |
+*/y;   // CHECK-NEXT:  [[# @LINE]]| 1|
+   // CHECK-NEXT:  [[# @LINE]]|  |
+// Comments inside directives. // 

[PATCH] D83592: [Coverage] Add comment to skipped regions

2020-07-24 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done.
zequanwu added inline comments.



Comment at: clang/lib/Lex/Preprocessor.cpp:973
+  if ((LexLevel == 0 || PreprocessToken) &&
+  !Result.getFlag(Token::IsReinjected)) {
+if (LexLevel == 0)

hans wrote:
> zequanwu wrote:
> > @hans , can you take a look on this part? I saw `TokenCount` was introduced 
> > for a warning `-Wmax-tokens`.
> Can you explain why things are changing here?
> 
> The idea of TokenCount is to simply count the preprocessor tokens. At this 
> point I think you have more knowledge here than I did when I added it :)
In `CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks`, I set `OnToken` 
to a lambda to update `PrevTokLoc` after lexing a new token. But, the original 
condition ` if (LexLevel == 0 && !Result.getFlag(Token::IsReinjected)) ` will 
not call `OnToken` if it's  lexing a directive, like `#if`, `#define` etc, 
because the LexLevel is greater than 0. In order to update `PrevTokLoc` even 
when lexing directive, I add `PreprocessToken` which will be set to true in 
`CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks` just to invoke 
`OnToken` without increment `TokenCount` when lexing directives. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83592



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


[PATCH] D83961: [Analyzer] Fix bug report source locations in minimal output.

2020-07-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D83961#2166903 , @balazske wrote:

> Every other test failure comes from RetainCount checker except 
> //malloc-plist.c//.


Aha, ok. So, anyway, for retain count checker we ultimately only care about 
plist and html reports, not about text reports. It's also probably easier to 
write more precise tests after your patch: test functions are unlikely to have 
multiple possible uniqueing locations, and even if there are they can be 
discriminated between by warning message text.

But i'd still rather have it explained why does your patch affect the location 
of `RefLeakReport`s in order to make sure we understand what we're doing. This 
consequence of the patch wasn't intended - what other unintended consequences 
does it have? Are we even sure that plist/html reports don't change? Is 
`RefLeakReport` even implemented correctly from our current point of view? Or, 
regardless of correctness, do we want its current implementation to have the 
old behavior or the new behavior?

I should probably investigate this myself from the fairness/justice point of 
view but you'll probably land your patch faster if you don't wait on me to get 
un-busy with other stuff :/ As a bonus, you might be able to get away without 
updating all the tests if you find out that this change is accidental and not 
really intended :) Note that you don't need to know Objective-C or know much 
about the checker to investigate these things; say, CGColorSpace.c is a pure C 
test with a straightforward resource leak bug. The customizations in 
`RefLeakReport` aren't really checker-specific either - we simply didn't ever 
make up our mind on whether they should apply to all leak reports or to none; 
they have visual consequences on plist reports though.




Comment at: clang/test/Analysis/malloc-plist.c:137-139
 if (y)
-y++;
-}//expected-warning{{Potential leak}}
+  y++; //expected-warning{{Potential leak}}
+}

balazske wrote:
> NoQ wrote:
> > This sounds like an expected change: we're now displaying the same report 
> > on a different path. Except it's the longer path rather than the shorter 
> > path, so it still looks suspicious.
> This location may be wrong but it is then another problem. The important 
> thing is that after this patch the same location is used for a warning in 
> `text-minimal` mode as it is in `text` mode. Without the patch in 
> `text-minimal` mode a different location is used for this warning, the one at 
> the end of the function. But still in `text` mode (without the patch) the 
> location at `y++` is shown. (The warning in function `function_with_leak4` in 
> the same test is already at a similar location, not at the end of function.)
Oh, wait, the other path isn't in fact shorter. In both cases it leaks 
immediately after the if-statement, and the path with `y++` is in fact a bit 
shorter (it immediately hits `PreStmtPurgeDeadSymbols` for the `DeclRefExpr` 
whereas the other path hits `CallExitBegin` first, because the call is inlined).

So it's a good and expected change!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83961



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


[PATCH] D84540: [CodeGen][ObjC] Mark calls to objc_unsafeClaimAutoreleasedReturnValue as notail on x86-64

2020-07-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, erik.pilkington.
ahatanak added a project: clang.
Herald added subscribers: ributzka, dexonsmith, jkorous.

This is needed because the epilogue code inserted before tail calls on x86-64 
breaks the handshake between the caller and callee.

Calls to objc_retainAutoreleasedReturnValue used to have the same problem, 
which was fixed in https://reviews.llvm.org/D59656.

rdar://problem/66029552


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84540

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGenObjC/arc-unsafeclaim.m

Index: clang/test/CodeGenObjC/arc-unsafeclaim.m
===
--- clang/test/CodeGenObjC/arc-unsafeclaim.m
+++ clang/test/CodeGenObjC/arc-unsafeclaim.m
@@ -1,16 +1,16 @@
 //   Make sure it works on x86-64.
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime=macosx-10.11 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-UNOPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime=macosx-10.11 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-UNOPTIMIZED -check-prefix=NOTAIL-CALL
 
 //   Make sure it works on x86-32.
-// RUN: %clang_cc1 -triple i386-apple-darwin11 -fobjc-runtime=macosx-fragile-10.11 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-UNOPTIMIZED -check-prefix=CHECK-MARKED
+// RUN: %clang_cc1 -triple i386-apple-darwin11 -fobjc-runtime=macosx-fragile-10.11 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-UNOPTIMIZED -check-prefix=CHECK-MARKED -check-prefix=CALL
 
 //   Make sure it works on ARM.
-// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-UNOPTIMIZED -check-prefix=CHECK-MARKED
-// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-OPTIMIZED
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-UNOPTIMIZED -check-prefix=CHECK-MARKED -check-prefix=CALL
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-OPTIMIZED -check-prefix=CALL
 
 //   Make sure it works on ARM64.
-// RUN: %clang_cc1 -triple armv7-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-UNOPTIMIZED -check-prefix=CHECK-MARKED
-// RUN: %clang_cc1 -triple armv7-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-OPTIMIZED
+// RUN: %clang_cc1 -triple armv7-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-UNOPTIMIZED -check-prefix=CHECK-MARKED -check-prefix=CALL
+// RUN: %clang_cc1 -triple armv7-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-OPTIMIZED -check-prefix=CALL
 
 //   Make sure that it's implicitly disabled if the runtime version isn't high enough.
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-10.10 -fobjc-arc -emit-llvm -o - %s | FileCheck %s -check-prefix=DISABLED
@@ -29,7 +29,8 @@
 // CHECK:[[T0:%.*]] = call [[A:.*]]* @makeA()
 // CHECK-MARKED-NEXT:call void asm sideeffect
 // CHECK-NEXT:   [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
-// CHECK-NEXT:   [[T2:%.*]] = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* [[T1]])
+// NOTAIL-CALL-NEXT: [[T2:%.*]] = notail call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* [[T1]])
+// CALL-NEXT:[[T2:%.*]] = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* [[T1]])
 // CHECK-NEXT:   [[T3:%.*]] = bitcast i8* [[T2]] to [[A]]*
 // CHECK-NEXT:   [[T4:%.*]] = bitcast [[A]]* [[T3]] to i8*
 // CHECK-NEXT:   store i8* [[T4]], i8** [[X]]
@@ -53,7 +54,8 @@
 // CHECK:[[T0:%.*]] = call [[A]]* @makeA()
 // CHECK-MARKED-NEXT:call void asm sideeffect
 // CHECK-NEXT:   [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
-// CHECK-NEXT:   [[T2:%.*]] = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* [[T1]])
+// NOTAIL-CALL-NEXT: [[T2:%.*]] = notail call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* [[T1]])
+// CALL-NEXT:[[T2:%.*]] = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* [[T1]])
 // CHECK-NEXT:   [[T3:%.*]] = bitcast i8* [[T2]] to 

[PATCH] D84348: WIP: Add complete id-expression support to syntax trees

2020-07-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 280497.
eduucaldas added a comment.

- Improve getLocalSourceRange
- nested-name-specifier is now a ::-separated list of name-specifiers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84348

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -867,24 +867,47 @@
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-namespace a {
+namespace n {
   struct S {
 template
-static T f(){}
+struct TS {
+  static void f();
+};
   };
 }
+template
+struct TS {
+  struct S {
+template
+static U f();
+  };
+};
 void test() {
-  ::  // global-namespace-specifier
-  a:: // namespace-specifier
-  S:: // type-name-specifier
+  :: // global-namespace-specifier
+  n::// namespace-specifier
+  S::// type-name-specifier
+  template TS:: // type-template-instantiation-specifier
+  f();
+
+  n::// namespace-specifier
+  S::// type-name-specifier
+  TS::  // type-template-instantiation-specifier
+  f();
+
+  TS:: // type-name-specifier
+  S::   // type-name-specifier
   f();
+
+  TS:: // type-name-specifier
+  S::   // type-name-specifier
+  template f();
 }
 )cpp",
   R"txt(
 *: TranslationUnit
 |-NamespaceDefinition
 | |-namespace
-| |-a
+| |-n
 | |-{
 | |-SimpleDeclaration
 | | |-struct
@@ -898,19 +921,58 @@
 | | | | `-T
 | | | |->
 | | | `-SimpleDeclaration
-| | |   |-static
-| | |   |-T
-| | |   |-SimpleDeclarator
-| | |   | |-f
-| | |   | `-ParametersAndQualifiers
-| | |   |   |-(
-| | |   |   `-)
-| | |   `-CompoundStatement
-| | | |-{
-| | | `-}
+| | |   |-struct
+| | |   |-TS
+| | |   |-{
+| | |   |-SimpleDeclaration
+| | |   | |-static
+| | |   | |-void
+| | |   | |-SimpleDeclarator
+| | |   | | |-f
+| | |   | | `-ParametersAndQualifiers
+| | |   | |   |-(
+| | |   | |   `-)
+| | |   | `-;
+| | |   |-}
+| | |   `-;
 | | |-}
 | | `-;
 | `-}
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-typename
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-TS
+|   |-{
+|   |-SimpleDeclaration
+|   | |-struct
+|   | |-S
+|   | |-{
+|   | |-TemplateDeclaration
+|   | | |-template
+|   | | |-<
+|   | | |-UnknownDeclaration
+|   | | | |-typename
+|   | | | `-U
+|   | | |->
+|   | | `-SimpleDeclaration
+|   | |   |-static
+|   | |   |-U
+|   | |   |-SimpleDeclarator
+|   | |   | |-f
+|   | |   | `-ParametersAndQualifiers
+|   | |   |   |-(
+|   | |   |   `-)
+|   | |   `-;
+|   | |-}
+|   | `-;
+|   |-}
+|   `-;
 `-SimpleDeclaration
   |-void
   |-SimpleDeclarator
@@ -924,14 +986,81 @@
 | |-UnknownExpression
 | | |-IdExpression
 | | | |-NestedNameSpecifier
-| | | | |-NameSpecifier
-| | | | | `-::
-| | | | |-NameSpecifier
-| | | | | |-a
-| | | | | `-::
-| | | | `-NameSpecifier
-| | | |   |-S
-| | | |   `-::
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-n
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-S
+| | | | |-::
+| | | | |-SimpleTemplateNameSpecifier
+| | | | | |-template
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | `->
+| | | | `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-IdentifierNameSpecifier
+| | | | | `-n
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-S
+| | | | |-::
+| | | | |-SimpleTemplateNameSpecifier
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | `->
+| | | | `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-SimpleTemplateNameSpecifier
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | `->
+| | | | |-::
+| | | | |-IdentifierNameSpecifier
+| | | | | `-S
+| | | | `-::
+| | | `-UnqualifiedId
+| | |   |-f
+| | |   |-<
+| | |   |-int
+| | |   `->
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-SimpleTemplateNameSpecifier
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | `->
+| | | | |-::
+| | | 

[PATCH] D84371: [DFSan] Add efficient fast16labels instrumentation mode.

2020-07-24 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 280485.
morehouse marked 5 inline comments as done.
morehouse added a comment.

- Rename flag
- Clarify doc example
- Use temporary variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84371

Files:
  clang/docs/DataFlowSanitizer.rst
  compiler-rt/lib/dfsan/dfsan.cpp
  compiler-rt/lib/dfsan/dfsan_flags.inc
  compiler-rt/lib/dfsan/done_abilist.txt
  compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp
  compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp
  compiler-rt/test/dfsan/fast16labels.c
  compiler-rt/test/fuzzer/dataflow.test
  compiler-rt/test/fuzzer/only-some-bytes-fork.test
  compiler-rt/test/fuzzer/only-some-bytes.test
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/fast16labels.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/fast16labels.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/DataFlowSanitizer/fast16labels.ll
@@ -0,0 +1,100 @@
+; Test that -dfsan-fast-16-labels mode uses inline ORs rather than calling
+; __dfsan_union or __dfsan_union_load.
+; RUN: opt < %s -dfsan -dfsan-fast-16-labels -S | FileCheck %s --implicit-check-not="call{{.*}}__dfsan_union"
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i8 @add(i8 %a, i8 %b) {
+  ; CHECK-LABEL: define i8 @"dfs$add"
+  ; CHECK-DAG: %[[ALABEL:.*]] = load{{.*}}__dfsan_arg_tls, i64 0, i64 0
+  ; CHECK-DAG: %[[BLABEL:.*]] = load{{.*}}__dfsan_arg_tls, i64 0, i64 1
+  ; CHECK: %[[ADDLABEL:.*]] = or i16 %[[ALABEL]], %[[BLABEL]]
+  ; CHECK: add i8
+  ; CHECK: store i16 %[[ADDLABEL]], i16* @__dfsan_retval_tls
+  ; CHECK: ret i8
+  %c = add i8 %a, %b
+  ret i8 %c
+}
+
+define i8 @load8(i8* %p) {
+  ; CHECK-LABEL: define i8 @"dfs$load8"
+  ; CHECK: load i16, i16*
+  ; CHECK: ptrtoint i8* {{.*}} to i64
+  ; CHECK: and i64
+  ; CHECK: mul i64
+  ; CHECK: inttoptr i64
+  ; CHECK: load i16, i16*
+  ; CHECK: or i16
+  ; CHECK: load i8, i8*
+  ; CHECK: store i16 {{.*}} @__dfsan_retval_tls
+  ; CHECK: ret i8
+
+  %a = load i8, i8* %p
+  ret i8 %a
+}
+
+define i16 @load16(i16* %p) {
+  ; CHECK-LABEL: define i16 @"dfs$load16"
+  ; CHECK: ptrtoint i16*
+  ; CHECK: and i64
+  ; CHECK: mul i64
+  ; CHECK: inttoptr i64 {{.*}} i16*
+  ; CHECK: getelementptr i16
+  ; CHECK: load i16, i16*
+  ; CHECK: load i16, i16*
+  ; CHECK: or i16
+  ; CHECK: or i16
+  ; CHECK: load i16, i16*
+  ; CHECK: store {{.*}} @__dfsan_retval_tls
+  ; CHECK: ret i16
+
+  %a = load i16, i16* %p
+  ret i16 %a
+}
+
+define i32 @load32(i32* %p) {
+  ; CHECK-LABEL: define i32 @"dfs$load32"
+  ; CHECK: ptrtoint i32*
+  ; CHECK: and i64
+  ; CHECK: mul i64
+  ; CHECK: inttoptr i64 {{.*}} i16*
+  ; CHECK: bitcast i16* {{.*}} i64*
+  ; CHECK: load i64, i64*
+  ; CHECK: lshr i64 {{.*}}, 32
+  ; CHECK: or i64
+  ; CHECK: lshr i64 {{.*}}, 16
+  ; CHECK: or i64
+  ; CHECK: trunc i64 {{.*}} i16
+  ; CHECK: or i16
+  ; CHECK: load i32, i32*
+  ; CHECK: store i16 {{.*}} @__dfsan_retval_tls
+  ; CHECK: ret i32
+
+  %a = load i32, i32* %p
+  ret i32 %a
+}
+
+define i64 @load64(i64* %p) {
+  ; CHECK-LABEL: define i64 @"dfs$load64"
+  ; CHECK: ptrtoint i64*
+  ; CHECK: and i64
+  ; CHECK: mul i64
+  ; CHECK: inttoptr i64 {{.*}} i16*
+  ; CHECK: bitcast i16* {{.*}} i64*
+  ; CHECK: load i64, i64*
+  ; CHECK: getelementptr i64, i64* {{.*}}, i64 1
+  ; CHECK: load i64, i64*
+  ; CHECK: or i64
+  ; CHECK: lshr i64 {{.*}}, 32
+  ; CHECK: or i64
+  ; CHECK: lshr i64 {{.*}}, 16
+  ; CHECK: or i64
+  ; CHECK: trunc i64 {{.*}} i16
+  ; CHECK: or i16
+  ; CHECK: load i64, i64*
+  ; CHECK: store i16 {{.*}} @__dfsan_retval_tls
+  ; CHECK: ret i64
+
+  %a = load i64, i64* %p
+  ret i64 %a
+}
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -91,6 +91,7 @@
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/Local.h"
+#include "llvm/Transforms/Utils/ModuleUtils.h"
 #include 
 #include 
 #include 
@@ -176,6 +177,14 @@
 cl::desc("Insert calls to __dfsan_*_callback functions on data events."),
 cl::Hidden, cl::init(false));
 
+// Use a distinct bit for each base label, enabling faster unions with less
+// instrumentation.  Limits the max number of base labels to 16.
+static cl::opt ClFast16Labels(
+"dfsan-fast-16-labels",
+cl::desc("Use more efficient instrumentation, limiting the number of "
+ "labels to 16."),
+cl::Hidden, cl::init(false));
+
 static StringRef GetGlobalTypeString(const 

[PATCH] D84371: [DFSan] Add efficient fast16labels instrumentation mode.

2020-07-24 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: compiler-rt/lib/dfsan/dfsan.cpp:180
 dfsan_label __dfsan_union(dfsan_label l1, dfsan_label l2) {
-  if (flags().fast16labels)
+  if (fast16labels)
 return l1 | l2;

vitalybuka wrote:
> isn't better just create new set of callbacks?
> e.g __dfsan_fast16_union
> and then we don't need any flags or preinit array initialization
Should work for `__dfsan_union` and `__dfsan_union_load`, but what about all 
the other API functions the user can call directly?  We wouldn't be able to 
warn in those cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84371



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


[PATCH] D84511: Fix update_cc_test_checks.py --llvm-bin after D78478

2020-07-24 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson marked an inline comment as done.
arichardson added inline comments.



Comment at: clang/test/utils/update_cc_test_checks/lit.local.cfg:24
+# works as expected
+config.substitutions.append(
+('%update_cc_test_checks_llvm_bin', "%s %s %s" % (

MaskRay wrote:
> The substitution is here just to make a test. Can it be tested with existing 
> substitutions?
I can't think of an easy way since we need to invoke update_cc_test_checks.py 
without the "--clang" argument and we need a substitution for the path to the 
update script.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84511



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


[PATCH] D83088: Introduce CfgTraits abstraction

2020-07-24 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle updated this revision to Diff 280481.
nhaehnle marked an inline comment as done.
nhaehnle added a comment.

  v6:
  - implement predecessors/successors for all CfgTraits implementations
  - fix error in unwrapRange
  - rename toGeneric/fromGeneric into wrapRef/unwrapRef to have naming
that is consistent with {wrap,unwrap}{Iterator,Range}
  - use getVRegDef instead of getUniqueVRegDef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/CodeGen/MachineCfgTraits.h
  llvm/include/llvm/IR/CFG.h
  llvm/include/llvm/Support/CfgTraits.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/MachineCfgTraits.cpp
  llvm/lib/IR/CFG.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CfgTraits.cpp
  llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
  mlir/include/mlir/IR/Dominance.h

Index: mlir/include/mlir/IR/Dominance.h
===
--- mlir/include/mlir/IR/Dominance.h
+++ mlir/include/mlir/IR/Dominance.h
@@ -10,8 +10,46 @@
 #define MLIR_IR_DOMINANCE_H
 
 #include "mlir/IR/RegionGraphTraits.h"
+#include "llvm/Support/CfgTraits.h"
 #include "llvm/Support/GenericDomTree.h"
 
+namespace mlir {
+
+/// Partial CFG traits for MLIR's CFG, without a value type.
+class CfgTraitsBase : public llvm::CfgTraitsBase {
+public:
+  using ParentType = Region;
+  using BlockRef = Block *;
+  using ValueRef = void;
+
+  static llvm::CfgBlockRef wrapRef(BlockRef block) {
+return makeOpaque(block);
+  }
+  static BlockRef unwrapRef(llvm::CfgBlockRef block) {
+return static_cast(getOpaque(block));
+  }
+};
+
+class CfgTraits : public llvm::CfgTraits {
+public:
+  static Region *getBlockParent(Block *block) { return block->getParent(); }
+
+  static auto predecessors(Block *block) {
+return llvm::inverse_children(block);
+  }
+
+  static auto successors(Block *block) {
+return llvm::children(block);
+  }
+};
+
+} // namespace mlir
+
+template <>
+struct llvm::CfgTraitsFor {
+  using CfgTraits = mlir::CfgTraits;
+};
+
 extern template class llvm::DominatorTreeBase;
 extern template class llvm::DominatorTreeBase;
 
Index: llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
===
--- llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
+++ llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
@@ -18,9 +18,42 @@
 #include "VPlan.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/IR/Dominators.h"
+#include "llvm/Support/CfgTraits.h"
 
 namespace llvm {
 
+/// Partial CFG traits for VPlan's CFG, without a value type.
+class VPCfgTraitsBase : public CfgTraitsBase {
+public:
+  using ParentType = VPRegionBlock;
+  using BlockRef = VPBlockBase *;
+  using ValueRef = void;
+
+  static CfgBlockRef wrapRef(BlockRef block) {
+return makeOpaque(block);
+  }
+  static BlockRef unwrapRef(CfgBlockRef block) {
+return static_cast(getOpaque(block));
+  }
+};
+
+class VPCfgTraits : public CfgTraits {
+public:
+  static VPRegionBlock *getBlockParent(VPBlockBase *block) {
+return block->getParent();
+  }
+
+  static auto predecessors(VPBlockBase *block) {
+return llvm::inverse_children(block);
+  }
+
+  static auto successors(VPBlockBase *block) {
+return llvm::children(block);
+  }
+};
+
+template <> struct CfgTraitsFor { using CfgTraits = VPCfgTraits; };
+
 /// Template specialization of the standard LLVM dominator tree utility for
 /// VPBlockBases.
 using VPDominatorTree = DomTreeBase;
Index: llvm/lib/Support/CfgTraits.cpp
===
--- /dev/null
+++ llvm/lib/Support/CfgTraits.cpp
@@ -0,0 +1,14 @@
+//===- CfgTraits.cpp - Traits for generically working on CFGs ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/CfgTraits.h"
+
+using namespace llvm;
+
+void CfgInterface::anchor() {}
+void CfgPrinter::anchor() {}
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -71,6 +71,7 @@
   BranchProbability.cpp
   BuryPointer.cpp
   CachePruning.cpp
+  CfgTraits.cpp
   circular_raw_ostream.cpp
   Chrono.cpp
   COM.cpp
Index: llvm/lib/IR/CMakeLists.txt
===
--- llvm/lib/IR/CMakeLists.txt
+++ llvm/lib/IR/CMakeLists.txt
@@ -4,6 +4,7 @@
   Attributes.cpp
   AutoUpgrade.cpp
   BasicBlock.cpp
+  CFG.cpp
   Comdat.cpp
   ConstantFold.cpp
   ConstantRange.cpp
Index: llvm/lib/IR/CFG.cpp

[PATCH] D84192: [OpenMP5.0] map item can be non-contiguous for target update

2020-07-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D84192#2172482 , @cchen wrote:

> @ABataev, do I need to wait for the runtime patch to commit this one? If so, 
> do you have some recommend reviewers for me to add to that patch? I have 
> pinged several times for that patch but haven't got many reviews for it. 
> Thanks!


Yes, it must be committed after runtime patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84192



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


[PATCH] D84192: [OpenMP5.0] map item can be non-contiguous for target update

2020-07-24 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

@ABataev, do I need to wait for the runtime patch to commit this one? If so, do 
you have some recommend reviewers for me to add to that patch? I have pinged 
several times for that patch but haven't got many reviews for it. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84192



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


[PATCH] D84192: [OpenMP5.0] map item can be non-contiguous for target update

2020-07-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84192



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


[PATCH] D84535: [clangd] Switch from EXPECT_TRUE to ASSERT_TRUE in remote marshalling tests

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

When dereferencing Optional's it makes sense to use ASSERT_TRUE for better
test failures readability. Switch from EXPECT_TRUE to ASSERT_TRUE where
it is appropriate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84535

Files:
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -49,11 +49,11 @@
   "clangd/unittests/remote/MarshallingTests.cpp",
   Strings);
   auto Serialized = ProtobufMarshaller.toProtobuf(Original);
-  EXPECT_TRUE(Serialized);
+  ASSERT_TRUE(Serialized);
   EXPECT_EQ(Serialized->location().file_path(),
 "clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp");
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  EXPECT_TRUE(Deserialized);
+  ASSERT_TRUE(Deserialized);
   EXPECT_STREQ(Deserialized->Location.FileURI,
testPathURI("home/my-projects/llvm-project/clang-tools-extra/"
"clangd/unittests/remote/MarshallingTests.cpp",
@@ -73,7 +73,7 @@
   // Can not use URIs with scheme different from "file".
   auto UnittestURI =
   URI::create(testPath("project/lib/HelloWorld.cpp"), "unittest");
-  EXPECT_TRUE(bool(UnittestURI));
+  ASSERT_TRUE(bool(UnittestURI));
   WithInvalidURI.Location.FileURI =
   Strings.save(UnittestURI->toString()).begin();
   Serialized = ProtobufMarshaller.toProtobuf(WithInvalidURI);
@@ -92,7 +92,7 @@
   clangd::Symbol Sym;
 
   auto ID = SymbolID::fromStr("057557CEBF6E6B2D");
-  EXPECT_TRUE(bool(ID));
+  ASSERT_TRUE(bool(ID));
   Sym.ID = *ID;
 
   index::SymbolInfo Info;
@@ -140,9 +140,9 @@
   // Check that symbols are exactly the same if the path to indexed project is
   // the same on indexing machine and the client.
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  EXPECT_TRUE(Serialized);
+  ASSERT_TRUE(Serialized);
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  EXPECT_TRUE(Deserialized);
+  ASSERT_TRUE(Deserialized);
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -154,7 +154,7 @@
   // Missing definition is OK.
   Sym.Definition = clangd::SymbolLocation();
   Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  EXPECT_TRUE(Serialized);
+  ASSERT_TRUE(Serialized);
   Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
   EXPECT_TRUE(Deserialized);
 
@@ -172,7 +172,7 @@
 
   // Schemes other than "file" can not be used.
   auto UnittestURI = URI::create(testPath("home/SomePath.h"), "unittest");
-  EXPECT_TRUE(bool(UnittestURI));
+  ASSERT_TRUE(bool(UnittestURI));
   Location.FileURI = Strings.save(UnittestURI->toString()).begin();
   Sym.Definition = Location;
   Serialized = ProtobufMarshaller.toProtobuf(Sym);
@@ -183,9 +183,9 @@
   Sym.Definition = Location;
   // Check that the symbol is valid and passing the correct path works.
   Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  EXPECT_TRUE(Serialized);
+  ASSERT_TRUE(Serialized);
   Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  EXPECT_TRUE(Deserialized);
+  ASSERT_TRUE(Deserialized);
   EXPECT_STREQ(Deserialized->Definition.FileURI,
testPathURI("home/File.h", Strings));
   // Fail with a wrong root.
@@ -214,9 +214,9 @@
 testPath("llvm-project/"));
 
   auto Serialized = ProtobufMarshaller.toProtobuf(Ref);
-  EXPECT_TRUE(Serialized);
+  ASSERT_TRUE(Serialized);
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  EXPECT_TRUE(Deserialized);
+  ASSERT_TRUE(Deserialized);
   EXPECT_EQ(toYAML(Ref), toYAML(*Deserialized));
 }
 
@@ -272,9 +272,9 @@
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
   EXPECT_EQ(static_cast(Serialized->headers_size()),
 ValidHeaders.size());
-  EXPECT_TRUE(Serialized);
+  ASSERT_TRUE(Serialized);
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  EXPECT_TRUE(Deserialized);
+  ASSERT_TRUE(Deserialized);
 
   Sym.IncludeHeaders = ValidHeaders;
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84525: [clangd] Add marshalling code for all request types

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:55
+template 
+llvm::Optional> getIDs(MessageT *Message) {
+  llvm::DenseSet Result;

kadircet wrote:
> I would make this return an expected instead of an optional and print the 
> error in the callers, instead of logging twice.
> 
> (I also think a similar problem is present with the existing `fromProtobuf` 
> APIs too, they return None in case of failure while logging the error, and 
> then callers again log the error. I am not sure if we plan to implement some 
> error handling strategies but even if we did, it feels like Marshalling is 
> the lowest layer that wouldn't know any other strategy to handle such errors, 
> so it seems like always returning an error from the marshalling and letting 
> the caller handle the error sounds like a safe bet. But no action needed in 
> this patch just stating some ideas in case you find them useful :D)
Good point: we thought about error handling and discussed it with Sam on 
multiple occasions, we tested several strategies and I think converged to this. 
I don't think it's optimal, you are right, but this code is consistent with the 
rest of the file.

The problem here is that in some cases these should actually be `Optional`s 
(some fields may or may not be missing) and in some cases it makes sense to 
have `Expected`s, which would leave a weird mixture of these things. But maybe 
carefully thinking about those cases would simplify the code.

How do you feel about leaving this as is and maybe carefully thinking about 
`Optional`s to `Expected` in the next patches?



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:292
   auto Deserialized = ProtobufMarshaller.fromProtobuf();
-  EXPECT_THAT(Deserialized.ProximityPaths,
+  EXPECT_TRUE(Deserialized);
+  EXPECT_THAT(Deserialized->ProximityPaths,

kadircet wrote:
> `ASSERT_TRUE` to ensure we don't try to dereference in case of None.
Good point, I should do `ASSERT_TRUE` in most cases throughout the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84525



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


[PATCH] D84348: WIP: Add complete id-expression support to syntax trees

2020-07-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

What is this diff based on? On the left I see, for example, 
NamespaceNameSpecifier, which is not in the repository yet.




Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:777
   // FIXME: Support Microsoft's __super
-  return new (allocator()) syntax::UnknownNameSpecifier;
+  assert(false && "We don't yet treat the __super specifier");
 }

s/treat/support/

Also, use llvm::report_fatal_error instead? assert is not supposed to ever 
trigger.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84348



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


[PATCH] D84525: [clangd] Add marshalling code for all request types

2020-07-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 280476.
kbobyrev marked 4 inline comments as done.
kbobyrev added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84525

Files:
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -289,7 +289,8 @@
   auto Serialized = ProtobufMarshaller.toProtobuf(Request);
   EXPECT_EQ(Serialized.proximity_paths_size(), 2);
   auto Deserialized = ProtobufMarshaller.fromProtobuf();
-  EXPECT_THAT(Deserialized.ProximityPaths,
+  ASSERT_TRUE(Deserialized);
+  EXPECT_THAT(Deserialized->ProximityPaths,
   testing::ElementsAre(testPath("remote/Header.h"),
testPath("remote/subdir/OtherHeader.h")));
 }
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -59,14 +59,10 @@
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
-clangd::LookupRequest Req;
-for (const auto  : Request->ids()) {
-  auto SID = SymbolID::fromStr(StringRef(ID));
-  if (!SID)
-return grpc::Status::CANCELLED;
-  Req.IDs.insert(*SID);
-}
-Index->lookup(Req, [&](const clangd::Symbol ) {
+const auto Req = ProtobufMarshaller->fromProtobuf(Request);
+if (!Req)
+  return grpc::Status::CANCELLED;
+Index->lookup(*Req, [&](const clangd::Symbol ) {
   auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
   if (!SerializedSymbol)
 return;
@@ -84,7 +80,9 @@
  const FuzzyFindRequest *Request,
  grpc::ServerWriter *Reply) override {
 const auto Req = ProtobufMarshaller->fromProtobuf(Request);
-bool HasMore = Index->fuzzyFind(Req, [&](const clangd::Symbol ) {
+if (!Req)
+  return grpc::Status::CANCELLED;
+bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol ) {
   auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
   if (!SerializedSymbol)
 return;
@@ -100,14 +98,10 @@
 
   grpc::Status Refs(grpc::ServerContext *Context, const RefsRequest *Request,
 grpc::ServerWriter *Reply) override {
-clangd::RefsRequest Req;
-for (const auto  : Request->ids()) {
-  auto SID = SymbolID::fromStr(StringRef(ID));
-  if (!SID)
-return grpc::Status::CANCELLED;
-  Req.IDs.insert(*SID);
-}
-bool HasMore = Index->refs(Req, [&](const clangd::Ref ) {
+const auto Req = ProtobufMarshaller->fromProtobuf(Request);
+if (!Req)
+  return grpc::Status::CANCELLED;
+bool HasMore = Index->refs(*Req, [&](const clangd::Ref ) {
   auto SerializedRef = ProtobufMarshaller->toProtobuf(Reference);
   if (!SerializedRef)
 return;
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
@@ -38,10 +38,15 @@
   Marshaller() = delete;
   Marshaller(llvm::StringRef RemoteIndexRoot, llvm::StringRef LocalIndexRoot);
 
-  clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request);
   llvm::Optional fromProtobuf(const Symbol );
   llvm::Optional fromProtobuf(const Ref );
 
+  llvm::Optional
+  fromProtobuf(const LookupRequest *Message);
+  llvm::Optional
+  fromProtobuf(const FuzzyFindRequest *Message);
+  llvm::Optional fromProtobuf(const RefsRequest *Message);
+
   /// toProtobuf() functions serialize native clangd types and strip IndexRoot
   /// from the file paths specific to indexing machine. fromProtobuf() functions
   /// deserialize clangd types and translate relative paths into machine-native
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -17,6 +17,7 @@
 #include "index/SymbolOrigin.h"
 #include "support/Logger.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/DenseSet.h"
 #include 

[PATCH] D84192: [OpenMP5.0] map item can be non-contiguous for target update

2020-07-24 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 280474.
cchen added a comment.

Fix coding style and argument on getIntTypeForBitwidth


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84192

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -79,6 +79,10 @@
 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(*(this+this)) // expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}}
 {}
+
+double marr[10][5][10];
+#pragma omp target update to(marr [0:1][2:4][1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
   }
 };
 
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -39,10 +39,33 @@
 foo();
   }
 
+  double marr[10][5][10];
+#pragma omp target update to(marr[0:2][2:4][1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr[0:2][2:4][1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+#pragma omp target update to(marr[0:][1:2:2][1:2]) // le50-error {{array section does not specify length for outermost dimension}} le45-error {{expected ']'}} le45-note {{to match this '['}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr[0:][1:2:2][1:2]) // le50-error {{array section does not specify length for outermost dimension}} le45-error {{expected ']'}} le45-note {{to match this '['}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  int arr[4][3][2][1];
+#pragma omp target update to(arr[0:2][2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(arr[0:2][2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  double ***dptr;
+#pragma omp target update to(dptr[0:2][2:4][1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target 

[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-24 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

I realize it may be possible to open code these, as these functions already 
exist in altivec.h. Could you look into if this is the case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83338



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


[PATCH] D84197: [PowerPC][Power10] 128-bit Vector String Isolate instruction definitions and MC Tests

2020-07-24 Thread Amy Kwan via Phabricator via cfe-commits
amyk requested changes to this revision.
amyk added a comment.
This revision now requires changes to proceed.

Could you please add back the MC tests for the rightmost load/store 
instructions, and then add the vector string isolate tests to the end of the 
file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84197



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


[PATCH] D83955: [PowerPC][Power10] Implementation of 128-bit Binary Vector Multiply builtins

2020-07-24 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision as: amyk.
amyk added a comment.

I think this LGTM now. The file is already upstream, so your tests will need to 
be added to that file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83955



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


[PATCH] D84192: [OpenMP5.0] map item can be non-contiguous for target update

2020-07-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8914
+  ASTContext  = CGF.getContext();
+  QualType Int64Ty = C.getIntTypeForBitwidth(/*DestWidth=*/64, 
/*Signed=*/true);
+  RecordDecl *RD;

1. The second argument must be of integer type, not boolean.
2. Why it is signed?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16915
+  continue;
+else if (OASE && OASE->getLength())
+  break;

No need for `else` here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84192



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


[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-07-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I still wonder what made this statement live in my example. There must have 
been some non-trivial liveness analysis going on that caused a statement to be 
live; probably something to do with the C++ destructor elements.

In D82598#2172371 , @Szelethus wrote:

> Wow, I never realized I accidentally landed that assert (D82122#2172360 
> ), but I guess its great to have 
> that covered. Would you prefer to have that reverted as I'm looking to fix 
> this for good?


It doesn't add any actual functionality so i think it makes sense to revert 
unless you have a quick fix.

Also if the assert is in fact true then i'd rather make a much stronger 
statement by banning statements from the Environment entirely, as in, like, at 
compile time by making it accept `Expr *` instead of `Stmt *`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82598



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


[PATCH] D83088: Introduce CfgTraits abstraction

2020-07-24 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle marked 3 inline comments as done.
nhaehnle added inline comments.



Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:44
+// use on a 32-bit architecture.
+assert(wrapped != (uintptr_t)-1 && wrapped != (uintptr_t)-2);
+

arsenm wrote:
> I feel like there should be a better way to do this; we should probably have 
> an assert where virtual registers are created
The reason for doing it here is that this is the place where the reinterpret 
happens. If the check is elsewhere, it's easy to miss by a user of this.



Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:101
+  return nullptr;
+return m_regInfo->getUniqueVRegDef(value)->getParent();
+  }

arsenm wrote:
> I think regular getVRegDef is preferable for SSA MIR
Fixed locally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088



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


[PATCH] D84192: [OpenMP5.0] map item can be non-contiguous for target update

2020-07-24 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

@ABataev, is there any other concern for this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84192



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


[PATCH] D84534: [AIX] Static init frontend recovery and backend support

2020-07-24 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: jasonliu, hubert.reinterpretcast, yusra.syeda, 
zarko, xingxue.
Xiangling_L added a project: LLVM.
Herald added subscribers: llvm-commits, cfe-commits, jfb, kbarton, hiraditya, 
nemanjai.
Herald added a project: clang.

1. Frontend side
2. Recovered AIX static init frontend to use the linkage type and function 
names Clang chooses for sinit related function;
3. Removed the `GlobalUniqueModuleId` calculation and usage;
4. Adjusted the FE testcases accordingly;
5. Added one frontend testcase to demonstrate and validate separate 
initialization on AIX;

2. Backend side on the assembly path only
3. Set correct linkage and function names for sinit/sterm functions
4. Added testcases


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84534

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
  llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
  llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll

Index: llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
@@ -0,0 +1,10 @@
+; RUN: not llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 655, void ()* @foo, i8* null }]
+
+define void @foo() {
+  ret void
+}
+
+// CHECK: LLVM ERROR: prioritized sinit and sterm functions are not yet supported
Index: llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
@@ -0,0 +1,7 @@
+; RUN: not llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }]
+@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* null }]
+
+// CHECK: LLVM ERROR: cannot produce a unique identifier for this module based on strong external symbols
Index: llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
@@ -0,0 +1,31 @@
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s
+
+@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @init1, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @init2, i8* null }]
+@llvm.global_dtors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @destruct1, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @destruct2, i8* null }]
+
+define i32 @extFunc() {
+entry:
+  ret i32 3
+}
+
+define internal void @init1() {
+  ret void
+}
+
+define internal void @destruct1() {
+  ret void
+}
+
+define internal void @init2() {
+  ret void
+}
+
+define internal void @destruct2() {
+  ret void
+}
+
+; CHECK: .globl	.__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_0
+; CHECK: .globl	.__sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_0
+; CHECK: .globl	.__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_1
+; CHECK: .globl	.__sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_1
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -67,6 +67,7 @@
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Transforms/Utils/ModuleUtils.h"
 #include 
 #include 
 #include 
@@ -153,6 +154,9 @@
   /// linkage for them in AIX.
   SmallPtrSet ExtSymSDNodeSymbols;
 
+  /// A unique trailing identifier as a part of sinit/sterm functions.
+  std::string GlobalUniqueModuleId;
+
   static void ValidateGV(const GlobalVariable *GV);
   // Record a list of 

  1   2   >