[clang] 8924779 - [clang] Fix ConceptSpecializationExpr::getEndLoc()

2020-07-28 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-07-29T02:44:26-04:00
New Revision: 89247792c5bdd58500b0e6c5e56532424c2e2ca1

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

LOG: [clang] Fix ConceptSpecializationExpr::getEndLoc()

Summary:
It returned an invalid location in case of a constrained-parameter
with no explicit arguments.

Reviewers: hokein

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/ExprConcepts.h
clang/test/AST/ast-dump-concepts.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ExprConcepts.h 
b/clang/include/clang/AST/ExprConcepts.h
index 2a88ed5175d2..1544c498ef66 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++ b/clang/include/clang/AST/ExprConcepts.h
@@ -126,7 +126,11 @@ class ConceptSpecializationExpr final : public Expr, 
public ConceptReference,
   }
 
   SourceLocation getEndLoc() const LLVM_READONLY {
-return ArgsAsWritten->RAngleLoc;
+// If the ConceptSpecializationExpr is the ImmediatelyDeclaredConstraint
+// of a TypeConstraint written syntactically as a constrained-parameter,
+// there may not be a template argument list.
+return ArgsAsWritten->RAngleLoc.isValid() ? ArgsAsWritten->RAngleLoc
+  : ConceptName.getEndLoc();
   }
 
   // Iterators

diff  --git a/clang/test/AST/ast-dump-concepts.cpp 
b/clang/test/AST/ast-dump-concepts.cpp
index 530c1baeffa7..3429fa6b46be 100644
--- a/clang/test/AST/ast-dump-concepts.cpp
+++ b/clang/test/AST/ast-dump-concepts.cpp
@@ -6,14 +6,22 @@
 // RUN: -ast-dump-all -ast-dump-filter Foo /dev/null \
 // RUN: | FileCheck --strict-whitespace %s
 
+template 
+concept unary_concept = true;
+
 template 
 concept binary_concept = true;
 
 template 
 struct Foo {
   // CHECK:  TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 
'binary_concept'
-  // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool'
+  // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}}  'bool'
   // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int'
   template  R>
   Foo(R);
+
+  // CHECK:  TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 
'unary_concept'
+  // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}}  'bool'
+  template 
+  Foo(R);
 };



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


[PATCH] D83242: [clang][BPF] support type existence/size and enum value relocations

2020-07-28 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 281481.
yonghong-song retitled this revision from "[clang][BPF] support expr with 
typedef/record type for TYPE_EXISTENCE reloc" to "[clang][BPF] support type 
existence/size and enum value relocations".
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

support relocations for type_sizeof and enum_value as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/BPF.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-bpf-preserve-field-info-1.c
  clang/test/CodeGen/builtins-bpf-preserve-field-info-2.c
  clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
  clang/test/Sema/builtins-bpf.c

Index: clang/test/Sema/builtins-bpf.c
===
--- clang/test/Sema/builtins-bpf.c
+++ clang/test/Sema/builtins-bpf.c
@@ -1,14 +1,36 @@
 // RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
 
-struct s { int a; int b[4]; int c:1; };
-union u { int a; int b[4]; int c:1; };
+struct s {
+  int a;
+  int b[4];
+  int c:1;
+};
+union u {
+  int a;
+  int b[4];
+  int c:1;
+};
+typedef struct {
+  int a;
+  int b;
+} __t;
+typedef int (*__f)(void);
+enum AA {
+  VAL1 = 1,
+  VAL2 = 2,
+  VAL3 = 10,
+};
+typedef enum {
+  VAL10 = 10,
+  VAL11 = 11,
+} __BB;
 
 unsigned invalid1(const int *arg) {
-  return __builtin_preserve_field_info(arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 not a field access}}
+  return __builtin_preserve_field_info(arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
 }
 
 unsigned invalid2(const int *arg) {
-  return __builtin_preserve_field_info(*arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 not a field access}}
+  return __builtin_preserve_field_info(*arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
 }
 
 void *invalid3(struct s *arg) {
@@ -46,3 +68,38 @@
 unsigned invalid11(struct s *arg, int info_kind) {
   return __builtin_preserve_field_info(arg->a, info_kind); // expected-error {{__builtin_preserve_field_info argument 2 not a constant}}
 }
+
+unsigned valid12() {
+  const struct s t;
+  return __builtin_preserve_field_info(t, 8) +
+ __builtin_preserve_field_info(*(struct s *)0, 8);
+}
+
+unsigned valid13() {
+  __t t;
+  return __builtin_preserve_field_info(t, 8) +
+ __builtin_preserve_field_info(*(__t *)0, 8);
+}
+
+unsigned valid14() {
+  enum AA t;
+  return __builtin_preserve_field_info(t, 8) +
+ __builtin_preserve_field_info(*(enum AA *)0, 8);
+}
+
+unsigned invalid15() {
+  return __builtin_preserve_field_info(*(__BB *)2, 10); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
+}
+
+unsigned invalid16() {
+  return __builtin_preserve_field_info(*(__BB *)VAL3, 10); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
+}
+
+unsigned invalid17(struct s *arg) {
+  return __builtin_preserve_field_info(arg->a + 2, 8); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
+}
+
+unsigned invalid18() {
+  enum AA t = 1;
+  return __builtin_preserve_field_info(t, 10); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
+}
Index: clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
@@ -0,0 +1,55 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x, y) (__builtin_preserve_field_info((x), (y)))
+
+struct s {
+  char a;
+};
+typedef int __int;
+enum AA {
+  VAL1 = 1,
+  VAL2 = 2,
+};
+typedef enum AA __AA;
+
+unsigned unit1() {
+  struct s v = {};
+  return _(v, 8) + _(*(struct s *)0, 8);
+}
+
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0s_struct.ss(%struct.s* %{{[0-9a-z]+}}, i64 8), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S:[0-9]+]]
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0s_struct.ss(%struct.s* null, i64 8), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S]]
+
+unsigned unit2() {
+  __int n;
+  return _(n, 8) + _(*(__int *)0, 8);
+}
+
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0i32(i32* %{{[0-9a-z]+}}, i64 8), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[TYPEDEF_INT:[0-9]+]]
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0i32(i32* null, i64 8), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[TYPEDEF_INT]]
+
+unsigned unit3() {
+  enum AA t;
+  return _(t, 8) + _(*(enum AA *)0, 8);
+}
+
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0i32(i32* %{{[0-9a-z]+}}, i64 8), !dbg !{{[0-9]+}}, !llvm.preserve.ac

[PATCH] D84743: [Clang][AMDGCN] Universal device offloading macros header

2020-07-28 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Headers/offload_macros.h:1
+//===--- offload_macros.h - Universal _DEVICE Offloading Macros Header ---===//
+//

After @MaskRay noticed this, I think this should be `__offload_macros.h` to 
make it clear this is an internal header.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84743

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


[PATCH] D84743: [Clang][AMDGCN] Universal device offloading macros header

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

In D84743#2181044 , @MaskRay wrote:

> In D84743#2181031 , @jdoerfert wrote:
>
>> In D84743#2179441 , @tra wrote:
>>
>>> I'm not sure it's particularly useful, to be honest. CUDA code still needs 
>>> to be compatible with NVCC so it can't be used in portable code like TF or 
>>> other currently used CUDA libraries.
>>> It could be useful internally, though, so I'm fine with it for that purpose.
>>
>> FWIW, I was only thinking about `clang/lib/Header` usage. *Potentially* 
>> documented for user of clang.
>
> Honestly I am a bit uneasy with the new clang/lib/Header file. It will be 
> part of the clang resource directory and users on every target will be able 
> to `#include ` it.
> This is also a namespace pollution - used incorrectly, people can trip over 
> it if they have files of the same name.

There are two levels to it though. 1) `clang/lib/Header`, and 2) 
`clang/lib/Header/XX`. We do not expose X to every user on every 
target, so when we do we really want the headers to be first. So for 2) the 
names should match existing system headers we want to wrap. For 1) the header 
names should be "in the compiler namespace". That said, the file above is not 
and I didn't notice before. The existing CUDA overloads that live in 1) start 
with `__cuda`, which should be sufficient for users not to trip over them. I 
mean, they could trip over a lot of things that starts with `__`. I imagine we 
have a `__gpu_...` set of header soon to avoid duplicating or polluting the 
`__cuda` ones (more). Now that I finished all this, also the `XX` above 
needs to be renamed into `__X`, but that seems easy enough to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84743

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


[PATCH] D84743: [Clang][AMDGCN] Universal device offloading macros header

2020-07-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D84743#2181031 , @jdoerfert wrote:

> In D84743#2179441 , @tra wrote:
>
>> I'm not sure it's particularly useful, to be honest. CUDA code still needs 
>> to be compatible with NVCC so it can't be used in portable code like TF or 
>> other currently used CUDA libraries.
>> It could be useful internally, though, so I'm fine with it for that purpose.
>
> FWIW, I was only thinking about `clang/lib/Header` usage. *Potentially* 
> documented for user of clang.

Honestly I am a bit uneasy with the new clang/lib/Header file. It will be part 
of the clang resource directory and users on every target will be able to 
`#include ` it.
This is also a namespace pollution - used incorrectly, people can trip over it 
if they have files of the same name.

I think there really should be a good justification for it being being part of 
the resource directory and not a library, and there needs to be a specification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84743

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


[PATCH] D83281: [OpenMP] Allow traits for the OpenMP context selector `isa`

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

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83281

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


[PATCH] D84794: Mark override to a function which overrides a virtual one

2020-07-28 Thread Anh Tuyen Tran via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8dbe9b249846: [Clang-tools-extra] Mark override a function 
which overrides a virtual one (authored by anhtuyen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84794

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -283,7 +283,7 @@
   };
 
 public:
-  void run() {
+  void run() override {
 using namespace clang::clangd;
 // Read input file (as specified in global option)
 auto Buffer = llvm::MemoryBuffer::getFile(IndexLocation);


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -283,7 +283,7 @@
   };
 
 public:
-  void run() {
+  void run() override {
 using namespace clang::clangd;
 // Read input file (as specified in global option)
 auto Buffer = llvm::MemoryBuffer::getFile(IndexLocation);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84743: [Clang][AMDGCN] Universal device offloading macros header

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

In D84743#2179441 , @tra wrote:

> I'm not sure it's particularly useful, to be honest. CUDA code still needs to 
> be compatible with NVCC so it can't be used in portable code like TF or other 
> currently used CUDA libraries.
> It could be useful internally, though, so I'm fine with it for that purpose.

FWIW, I was only thinking about `clang/lib/Header` usage. *Potentially* 
documented for user of clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84743

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


[clang-tools-extra] 8dbe9b2 - [Clang-tools-extra] Mark override a function which overrides a virtual one

2020-07-28 Thread Anh Tuyen Tran via cfe-commits

Author: Anh Tuyen Tran
Date: 2020-07-29T05:30:33Z
New Revision: 8dbe9b249846be81bc676543698db14ee37e28e2

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

LOG: [Clang-tools-extra] Mark override a function which overrides a virtual one

Function void run() on line 286 overrides a virtual function on line 92 of
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp.  Not marking it override will
cause a build failure when we use -Werror (every warning is treated as an 
error).

Reviewed By: kbobyrev (Kirill Bobyrev)

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

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index 80d87aa3f9f5..ca35f620bba1 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -283,7 +283,7 @@ class Export : public Command {
   };
 
 public:
-  void run() {
+  void run() override {
 using namespace clang::clangd;
 // Read input file (as specified in global option)
 auto Buffer = llvm::MemoryBuffer::getFile(IndexLocation);



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


[PATCH] D84812: [clang-tidy][NFC] Added convienence methods for getting optional options

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



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:224
+  else
+consumeError(ValueOr.takeError());
+  return llvm::None;

Is this specialization defined only because parsing a string option can never 
fail? I'd let this special case behavior fall out of the primary template if 
possible.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:485
+/// Logs an Error to stderr if a \p Err is not a MissingOptionError.
+static void logOptionParsingError(llvm::Error &&Err);
 

"logIfOptionParsingError" to express the conditionality of behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84812

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


[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

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



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:124
+static void
+populateNaimgStyle(std::vector &Styles,
+   const ClangTidyCheck::OptionsView &Options) {

I think it would be better to return the vector by value.



Comment at: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h:62
 
+  using OptionalStyle = llvm::Optional;
+

I'd suggest to inline the definition of this typedef, because it makes code 
more obscure for the benefit of shortening the name by a couple of characters.



Comment at: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h:76
+
+  mutable llvm::StringMap> NamingStylesCache;
+

It would be nice to add the comment that explains what the keys for the map and 
the vector are.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

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


[PATCH] D84824: [HIP] Emit target-id module flag

2020-07-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

Separate this patch from https://reviews.llvm.org/D60620 since it depends on 
https://reviews.llvm.org/D80750


https://reviews.llvm.org/D84824

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/target-id.hip
  clang/test/CodeGenCXX/conditional-temporaries.cpp
  clang/test/CodeGenOpenCL/target-id.cl


Index: clang/test/CodeGenOpenCL/target-id.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/target-id.cl
@@ -0,0 +1,21 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -target-cpu gfx908 -target-feature +xnack \
+// RUN:   -target-feature -sram-ecc \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix=ID1 %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -target-cpu fiji \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix=ID2 %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix=NONE %s
+
+// ID1: !{i32 8, !"target-id", !"amdgcn-amd-amdhsa-gfx908:sram-ecc-:xnack+"}
+// ID2: !{i32 8, !"target-id", !"amdgcn-amd-amdhsa-gfx803"}
+// NONE: !{i32 8, !"target-id", !""}
+
+kernel void foo() {}
Index: clang/test/CodeGenCXX/conditional-temporaries.cpp
===
--- clang/test/CodeGenCXX/conditional-temporaries.cpp
+++ clang/test/CodeGenCXX/conditional-temporaries.cpp
@@ -64,8 +64,8 @@
 bool success() {
   // CHECK-LEGACY-OPT: ret i1 true
   // X64-NEWPM-OPT: ret i1 true
-  // AMDGCN-NEWPM-OPT: [[CTORS:%.*]] = load i32, i32* addrspacecast (i32 
addrspace(1)* @_ZN12_GLOBAL__N_19ctorcallsE to i32*), align 4, !tbaa !2
-  // AMDGCN-NEWPM-OPT: [[DTORS:%.*]] = load i32, i32* addrspacecast (i32 
addrspace(1)* @_ZN12_GLOBAL__N_19dtorcallsE to i32*), align 4, !tbaa !2
+  // AMDGCN-NEWPM-OPT: [[CTORS:%.*]] = load i32, i32* addrspacecast (i32 
addrspace(1)* @_ZN12_GLOBAL__N_19ctorcallsE to i32*), align 4
+  // AMDGCN-NEWPM-OPT: [[DTORS:%.*]] = load i32, i32* addrspacecast (i32 
addrspace(1)* @_ZN12_GLOBAL__N_19dtorcallsE to i32*), align 4
   // AMDGCN-NEWPM-OPT: %cmp = icmp eq i32 [[CTORS]], [[DTORS]]
   // AMDGCN-NEWPM-OPT: ret i1 %cmp
   return ctorcalls == dtorcalls;
Index: clang/test/CodeGenCUDA/target-id.hip
===
--- /dev/null
+++ clang/test/CodeGenCUDA/target-id.hip
@@ -0,0 +1,13 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -target-cpu gfx908 -target-feature +xnack \
+// RUN:   -target-feature -sram-ecc \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: !{i32 8, !"target-id", !"amdgcn-amd-amdhsa-gfx908:xnack+:sram-ecc-"}
+__global__ void foo() {}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -593,6 +593,18 @@
   llvm::DenormalMode::IEEE);
   }
 
+  if (auto TargetID = getTarget().getTargetID()) {
+auto TargetIDStr = TargetID.getValue();
+// Empty target ID is emitted as empty string in module flag.
+getModule().addModuleFlag(
+llvm::Module::MergeTargetID, "target-id",
+llvm::MDString::get(
+getModule().getContext(),
+TargetIDStr == ""
+? TargetIDStr
+: (Twine(getTriple().str()) + "-" + TargetIDStr).str()));
+  }
+
   // Emit OpenCL specific module metadata: OpenCL/SPIR version.
   if (LangOpts.OpenCL) {
 EmitOpenCLMetadata();


Index: clang/test/CodeGenOpenCL/target-id.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/target-id.cl
@@ -0,0 +1,21 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -target-cpu gfx908 -target-feature +xnack \
+// RUN:   -target-feature -sram-ecc \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix=ID1 %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -target-cpu fiji \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix=ID2 %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix=NONE %s
+
+// ID1: !{i32 8, !"target-id", !"amdgcn-amd-amdhsa-gfx908:sram-ecc-:xnack+"}
+// ID2: !{i32 8, !"target-id", !"amdgcn-amd-amdhsa-gfx803"}
+// NONE: !{i32 8, !"target-id", !""}
+
+kernel void foo() {}
Index: clang/test/CodeGenCXX/conditional-temporaries.cpp
===
--- clang

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

2020-07-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 281465.
yaxunl added a comment.

separate emitting target-id module flag to a different patch.


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/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/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"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAM_ECC},
+  {{"gfx909"},{"gfx909"}

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:266
+PGOOldCFGHashing("pgo-instr-old-cfg-hashing", cl::init(false), cl::Hidden,
+ cl::desc("Use the old CFG function hashing."));
+

Nit: descriptions usually don't end with a period

(I know that some descriptions in this file are not consistent)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D83648: [Driver] Fix integrated_as definition by setting it as a DriverOption

2020-07-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Fixed by 6a75496836ea14bcfd2f4b59d35a1cad4ac58cee 
 :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83648

___
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-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

@tra target ID documentation is added by https://reviews.llvm.org/D84822


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

https://reviews.llvm.org/D60620

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


LLVM buildmaster will be restarted soon

2020-07-28 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted in the nearest hour.

Thanks

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


[PATCH] D84820: [WebAssembly] Implement prototype v128.load{32,64}_zero instructions

2020-07-28 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.
tlively requested review of this revision.

Specified in https://github.com/WebAssembly/simd/pull/237, these
instructions load the first vector lane from memory and zero the other
lanes. Since these instructions are not officially part of the SIMD
proposal, they are only available on an opt-in basis via LLVM
intrinsics and clang builtin functions. If these instructions are
merged to the proposal, this implementation will change so that the
instructions will be generated from normal IR. At that point the
intrinsics and builtin functions would be removed.

This PR also changes the opcodes for the experimental f32x4.qfm{a,s}
instructions because their opcodes conflicted with those of the
v128.load{32,64}_zero instructions. The new opcodes were chosen to
match those used in V8.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84820

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-load-zero-offset.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -610,10 +610,16 @@
 # CHECK: f32x4.convert_i32x4_u # encoding: [0xfd,0xfb,0x01]
 f32x4.convert_i32x4_u
 
-# CHECK: f32x4.qfma # encoding: [0xfd,0xfc,0x01]
+# CHECK: v128.load32_zero 32 # encoding: [0xfd,0xfc,0x01,0x02,0x20]
+v128.load32_zero 32
+
+# CHECK: v128.load64_zero 32 # encoding: [0xfd,0xfd,0x01,0x03,0x20]
+v128.load64_zero 32
+
+# CHECK: f32x4.qfma # encoding: [0xfd,0xb4,0x01]
 f32x4.qfma
 
-# CHECK: f32x4.qfms # encoding: [0xfd,0xfd,0x01]
+# CHECK: f32x4.qfms # encoding: [0xfd,0xd4,0x01]
 f32x4.qfms
 
 # CHECK: f64x2.qfma # encoding: [0xfd,0xfe,0x01]
Index: llvm/test/CodeGen/WebAssembly/simd-load-zero-offset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/simd-load-zero-offset.ll
@@ -0,0 +1,228 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -verify-machineinstrs -mattr=+simd128 | FileCheck %s
+
+; Test SIMD v128.load{32,64}_zero instructions
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+declare <4 x i32> @llvm.wasm.load32.zero(i32*)
+declare <2 x i64> @llvm.wasm.load64.zero(i64*)
+
+;===
+; v128.load32_zero
+;===
+
+define <4 x i32> @load_zero_i32_no_offset(i32* %p) {
+; CHECK-LABEL: load_zero_i32_no_offset:
+; CHECK: .functype load_zero_i32_no_offset (i32) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:v128.load32_zero 0
+; CHECK-NEXT:# fallthrough-return
+  %v = tail call <4 x i32> @llvm.wasm.load32.zero(i32* %p)
+  ret <4 x i32> %v
+}
+
+define <4 x i32> @load_zero_i32_with_folded_offset(i32* %p) {
+; CHECK-LABEL: load_zero_i32_with_folded_offset:
+; CHECK: .functype load_zero_i32_with_folded_offset (i32) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:v128.load32_zero 24
+; CHECK-NEXT:# fallthrough-return
+  %q = ptrtoint i32* %p to i32
+  %r = add nuw i32 %q, 24
+  %s = inttoptr i32 %r to i32*
+  %t = tail call <4 x i32> @llvm.wasm.load32.zero(i32* %s)
+  ret <4 x i32> %t
+}
+
+define <4 x i32> @load_zero_i32_with_folded_gep_offset(i32* %p) {
+; CHECK-LABEL: load_zero_i32_with_folded_gep_offset:
+; CHECK: .functype load_zero_i32_with_folded_gep_offset (i32) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:v128.load32_zero 24
+; CHECK-NEXT:# fallthrough-return
+  %s = getelementptr inbounds i32, i32* %p, i32 6
+  %t = tail call <4 x i32> @llvm.wasm.load32.zero(i32* %s)
+  ret <4 x i32> %t
+}
+
+define <4 x i32> @load_zero_i32_with_unfolded_gep_negative_offset(i32* %p) {
+; CHECK-LABEL: load_zero_i32_with_unfolded_gep_negative_offset:
+; CHECK: .functype load_zero_i32_with_unfolded_gep_negative_offset (i32) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i32.const -24
+; CHECK-NEXT:i32.add
+; CHECK-NEXT:v128.load32_zero 0
+; CHECK-NEXT:# fallthrough-return
+  %

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

2020-07-28 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



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

tlively wrote:
> aheejin wrote:
> > tlively wrote:
> > > aheejin wrote:
> > > > 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?
> > > Sure, since I didn't end up testing more patterns, I can make the comment 
> > > more specific.
> > > 
> > > Regarding shifts, I don't think it's possible to do widening with shifts 
> > > because widening has to fundamentally change the number of lanes, which 
> > > shifts can't do.
> > What I meant was, in case of i16x8->i32x4, the current code can widen i16x8 
> > input vector with elements in the indices 0 to 4. If those elements are 
> > instead in 1 to 5, can we first shift that to 0~4 and widen it?
> Oh gotcha. No, unfortunately I don't think that would work. The SIMD shift 
> instructions shift bytes within lanes but they can't shift data into a 
> different lane. Even if we used shifts on larger lanes to try to overcome 
> that limitation, a 64x2 shift would still not be able to shift data from the 
> high half of the vector to the low half or vice versa, which we would need to 
> do to implement your suggestion.
Ah right... I was confused about SIMD shifts. Thanks.


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] D84556: [WebAssembly] Remove intrinsics for SIMD widening ops

2020-07-28 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



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

aheejin wrote:
> tlively wrote:
> > aheejin wrote:
> > > 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?
> > Sure, since I didn't end up testing more patterns, I can make the comment 
> > more specific.
> > 
> > Regarding shifts, I don't think it's possible to do widening with shifts 
> > because widening has to fundamentally change the number of lanes, which 
> > shifts can't do.
> What I meant was, in case of i16x8->i32x4, the current code can widen i16x8 
> input vector with elements in the indices 0 to 4. If those elements are 
> instead in 1 to 5, can we first shift that to 0~4 and widen it?
Oh gotcha. No, unfortunately I don't think that would work. The SIMD shift 
instructions shift bytes within lanes but they can't shift data into a 
different lane. Even if we used shifts on larger lanes to try to overcome that 
limitation, a 64x2 shift would still not be able to shift data from the high 
half of the vector to the low half or vice versa, which we would need to do to 
implement your suggestion.


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


[clang] d352705 - [NFC] Edit the comment for the return type of await_suspend

2020-07-28 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2020-07-29T10:20:55+08:00
New Revision: d3527052fc2a952d752f82ffbe39220bad33fc8d

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

LOG: [NFC] Edit the comment for the return type of await_suspend

Added: 


Modified: 
clang/lib/Sema/SemaCoroutine.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 992cccac6405..990ab2633520 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -449,7 +449,8 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, 
VarDecl *CoroPromise,
   if (!AwaitSuspend->getType()->isDependentType()) {
 // [expr.await]p3 [...]
 //   - await-suspend is the expression e.await_suspend(h), which shall be
-// a prvalue of type void or bool.
+// a prvalue of type void, bool, or std::coroutine_handle for some
+// type Z.
 QualType RetType = AwaitSuspend->getCallReturnType(S.Context);
 
 // Experimental support for coroutine_handle returning await_suspend.



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


[PATCH] D84494: [Analyzer] Use of BugType in DereferenceChecker (NFC).

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

> `BuiltinBug` is deprecated and we should be using `BugType` anyway

Like, i've never heard of `BuiltinBug` being deprecated but i'm pretty happy 
that it gets removed :)




Comment at: clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp:215
   // The explicit NULL case.
+  // We know that 'location' cannot be non-null.  This is what
+  // we call an "explicit" null dereference.

vsavchenko wrote:
> Maybe "is definitely null" here? Otherwise it can be pretty confusing with a 
> double negation.
Also this entire comment should be inside the if-statement, on the same level 
as the next comment.



Comment at: 
clang/test/Analysis/Inputs/expected-plists/conditional-path-notes.c.plist:270
descriptionDereference of null pointer (loaded from 
variable 'x')
-   categoryLogic error
+   categoryMemory error
typeDereference of null pointer

balazske wrote:
> vsavchenko wrote:
> > I might've missed some discussions on that matter, so please correct me on 
> > that.
> > In my opinion, null pointer dereference is not a memory error.  Null 
> > address is not a correct memory and never was, so it is a logic error that 
> > a special value is being interpreted as the pointer to something.
> I can not decide which is better, "logic error" can be said for almost every 
> possible bug. Here the problem is at least related to memory handling. The 
> reference of undefined pointer value is "logic error" too (it is known that 
> the value was not initialized) but a memory error (try to access invalid or 
> valid but wrong address). Probably "pointer handling error" is better?
> (One value for bug category is not a good approach, it is never possible to 
> classify a bug to exactly one.)
Maybe let's not change it then, if there are no clear pros or cons? Users 
already got used to it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84494

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


[PATCH] D73151: [analyzer] Fix handle leak false positive when the handle dies too early

2020-07-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/test/Analysis/fuchsia_handle.cpp:80
+  zx_status_t status = zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated through 2nd parameter}}
+  if (status == 0) { // expected-note {{Assuming 'status' is equal to 0}}

NoQ wrote:
> jroelofs wrote:
> > jroelofs wrote:
> > > @xazax.hun, @dcoughlin Is it expected that these diagnostics be 
> > > non-deterministic? I'm seeing this test case fail sporadically [1] 
> > > because sometimes the analyzer sees that the 3rd argument leaks, and 
> > > other times it sees that the 2nd does.
> > > 
> > > The easy fix here would be to adjust the regex to be flexible against 
> > > that difference, but I didn't want to cover up an underlying issue by 
> > > committing that blindly:
> > > 
> > > ```
> > > // expected-note@-1 {{Handle allocated through (2nd|3rd) parameter}}
> > > ```
> > > 
> > > 1: 
> > > http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/17048/console
> > erm, wrong link. this is the correct one:
> > 
> > http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/17049/#showFailuresLink
> Hmm, no, these diagnostics shouldn't be non-deterministic. It's a bug. Thanks 
> a lot for noticing!
> 
> Non-determinism in *notes* shouldn't be too bad. Also investigation may get 
> pretty long because diagnostic sorting and de-duplication is a highly 
> automated process. I believe we should cover up the problem to suppress 
> buildbot failures and investigate when we can. I'll commit the cover-up.
rGc26f237cef1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73151

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


[clang] c26f237 - [analyzer] FuchsiaHandleChecker: Suppress a non-deterministic test failure.

2020-07-28 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-07-28T18:57:11-07:00
New Revision: c26f237cef1b33277f072c609c19192c5213f348

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

LOG: [analyzer] FuchsiaHandleChecker: Suppress a non-deterministic test failure.

Noticed by Jon Roelofs in https://reviews.llvm.org/D73151#2180499

Added: 


Modified: 
clang/test/Analysis/fuchsia_handle.cpp

Removed: 




diff  --git a/clang/test/Analysis/fuchsia_handle.cpp 
b/clang/test/Analysis/fuchsia_handle.cpp
index dade5261bd78..d104b13c77ab 100644
--- a/clang/test/Analysis/fuchsia_handle.cpp
+++ b/clang/test/Analysis/fuchsia_handle.cpp
@@ -77,7 +77,9 @@ void handleDieBeforeErrorSymbol01() {
 void handleDieBeforeErrorSymbol02() {
   zx_handle_t sa, sb;
   zx_status_t status = zx_channel_create(0, &sa, &sb);
-  // expected-note@-1 {{Handle allocated through 2nd parameter}}
+  // FIXME: There appears to be non-determinism in choosing
+  // which handle to report.
+  // expected-note-re@-3 {{Handle allocated through {{(2nd|3rd)}} parameter}}
   if (status == 0) { // expected-note {{Assuming 'status' is equal to 0}}
  // expected-note@-1 {{Taking true branch}}
 return; // expected-warning {{Potential leak of handle}}



___
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-28 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



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

tlively wrote:
> aheejin wrote:
> > 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?
> Sure, since I didn't end up testing more patterns, I can make the comment 
> more specific.
> 
> Regarding shifts, I don't think it's possible to do widening with shifts 
> because widening has to fundamentally change the number of lanes, which 
> shifts can't do.
What I meant was, in case of i16x8->i32x4, the current code can widen i16x8 
input vector with elements in the indices 0 to 4. If those elements are instead 
in 1 to 5, can we first shift that to 0~4 and widen it?


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] D73151: [analyzer] Fix handle leak false positive when the handle dies too early

2020-07-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/test/Analysis/fuchsia_handle.cpp:80
+  zx_status_t status = zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated through 2nd parameter}}
+  if (status == 0) { // expected-note {{Assuming 'status' is equal to 0}}

jroelofs wrote:
> jroelofs wrote:
> > @xazax.hun, @dcoughlin Is it expected that these diagnostics be 
> > non-deterministic? I'm seeing this test case fail sporadically [1] because 
> > sometimes the analyzer sees that the 3rd argument leaks, and other times it 
> > sees that the 2nd does.
> > 
> > The easy fix here would be to adjust the regex to be flexible against that 
> > difference, but I didn't want to cover up an underlying issue by committing 
> > that blindly:
> > 
> > ```
> > // expected-note@-1 {{Handle allocated through (2nd|3rd) parameter}}
> > ```
> > 
> > 1: 
> > http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/17048/console
> erm, wrong link. this is the correct one:
> 
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/17049/#showFailuresLink
Hmm, no, these diagnostics shouldn't be non-deterministic. It's a bug. Thanks a 
lot for noticing!

Non-determinism in *notes* shouldn't be too bad. Also investigation may get 
pretty long because diagnostic sorting and de-duplication is a highly automated 
process. I believe we should cover up the problem to suppress buildbot failures 
and investigate when we can. I'll commit the cover-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73151

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


[PATCH] D84622: [PowerPC] Implement Vector Extract Low/High Order Builtins in LLVM/Clang

2020-07-28 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang accepted this revision.
steven.zhang added a comment.
This revision is now accepted and ready to land.

LGTM. But please hold on for one more days to see if there is other comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84622

___
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-28 Thread Thomas Lively via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11bb7eef4152: [WebAssembly] Remove intrinsics for SIMD 
widening ops (authored by tlively).

Changed prior to commit:
  https://reviews.llvm.org/D84556?vs=280581&id=281442#toc

Repository:
  rG LLVM Github Monorepo

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

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,180 @@
+; 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) -> (v128)
+; CHECK-NEXT:  # %bb.0:
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:i32x4.widen_high_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
+}
+

[clang] 11bb7ee - [WebAssembly] Remove intrinsics for SIMD widening ops

2020-07-28 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-07-28T18:25:55-07:00
New Revision: 11bb7eef4152cab895983f19e638f0cfdf8a580f

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

LOG: [WebAssembly] Remove intrinsics for SIMD widening ops

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.

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

Added: 
llvm/test/CodeGen/WebAssembly/simd-widening.ll

Modified: 
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

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index ecee7782920f..d0f40f991a4c 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -169,14 +169,5 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, 
"V16cV8sV8s", "nc", "simd128
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_widen_low_s_i16x8_i8x16, "V8sV16c", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_high_s_i16x8_i8x16, "V8sV16c", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_low_u_i16x8_i8x16, "V8sV16c", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_high_u_i16x8_i8x16, "V8sV16c", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_low_s_i32x4_i16x8, "V4iV8s", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_high_s_i32x4_i16x8, "V4iV8s", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_low_u_i32x4_i16x8, "V4iV8s", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_widen_high_u_i32x4_i16x8, "V4iV8s", "nc", 
"simd128")
-
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d572de1b8b79..ecc0b5bf2dc4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16528,40 +16528,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 CGM.getIntrinsic(IntNo, {ConvertType(E->getType()), Low->getType()});
 return Builder.CreateCall(Callee, {Low, High});
   }
-  case WebAssembly::BI__builtin_wasm_widen_low_s_i16x8_i8x16:
-  case WebAssembly::BI__builtin_wasm_widen_high_s_i16x8_i8x16:
-  case WebAssembly::BI__builtin_wasm_widen_low_u_i16x8_i8x16:
-  case WebAssembly::BI__builtin_wasm_widen_high_u_i16x8_i8x16:
-  case WebAssembly::BI__builtin_wasm_widen_low_s_i32x4_i16x8:
-  case WebAssembly::BI__builtin_wasm_widen_high_s_i32x4_i16x8:
-  case WebAssembly::BI__builtin_wasm_widen_low_u_i32x4_i16x8:
-  case WebAssembly::BI__builtin_wasm_widen_high_u_i32x4_i16x8: {
-Value *Vec = EmitScalarExpr(E->getArg(0));
-unsigned IntNo;
-switch (BuiltinID) {
-case WebAssembly::BI__builtin_wasm_widen_low_s_i16x8_i8x16:
-case WebAssembly::BI__builtin_wasm_widen_low_s_i32x4_i16x8:
-  IntNo = Intrinsic::wasm_widen_low_signed;
-  break;
-case WebAssembly::BI__builtin_wasm_widen_high_s_i16x8_i8x16:
-case WebAssembly::BI__builtin_wasm_widen_high_s_i32x4_i16x8:
-  IntNo = Intrinsic::wasm_widen_high_signed;
-  break;
-case WebAssembly::BI__builtin_wasm_widen_low_u_i16x8_i8x16:
-case WebAssembly::BI__builtin_wasm_widen_low_u_i32x4_i16x8:
-  IntNo = Intrinsic::wasm_widen_low_unsigned;
-  break;
-case WebAssembly::BI__builtin_wasm_widen_high_u_i16x8_i8x16:
-case WebAssembly::BI__builtin_wasm_widen_high_u_i32x4_i16x8:
-  IntNo = Intrinsic::wasm_widen_high_unsigned;
-  break;
-default:
-  llvm_unreachable("unexpected builtin ID");
-}
-Function *Callee =
-CGM.getIntrinsic(IntNo, {ConvertType(E->getType()), Vec->getType()});
-return Builder.CreateCall(Callee, Vec);
-  }
   case WebAssembly::BI__builtin_wasm_shuffle_v8x16: {
 Value *Ops[18];
 size_t OpIdx = 0;

diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index b781238

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

2020-07-28 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



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

aheejin wrote:
> 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?
Sure, since I didn't end up testing more patterns, I can make the comment more 
specific.

Regarding shifts, I don't think it's possible to do widening with shifts 
because widening has to fundamentally change the number of lanes, which shifts 
can't do.


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] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

2020-07-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 281439.
njames93 added a comment.

Add missing new lines in test files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/header.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
@@ -0,0 +1,34 @@
+// Setup header directory
+
+// RUN: rm -rf %theaders
+// RUN: mkdir %theaders
+// RUN: cp -R %S/Inputs/readability-identifier-naming/. %theaders
+
+// C++11 isnt explicitly required, but failing to specify a standard means the
+// check will run multiple times for different standards. This will cause the
+// second test to fail as the header file will be changed during the first run.
+
+// RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t -- \
+// RUN:   -config='{ InheritParentConfig: true, CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.FunctionCase, value: camelBack} \
+// RUN:  ]}' -header-filter='.*' -- -I%theaders
+
+#include "global-style1/header.h"
+#include "global-style2/header.h"
+// CHECK-MESSAGES-DAG: global-style1/header.h:5:6: warning: invalid case style for global function 'style1Bad'
+// CHECK-MESSAGES-DAG: global-style2/header.h:5:6: warning: invalid case style for global function 'style2Bad'
+
+void goodStyle() {
+  style1_good();
+  STYLE2_GOOD();
+}
+// CHECK-MESSAGES-DAG: :[[@LINE+1]]:6: warning: invalid case style for function 'bad_style'
+void bad_style() {
+  style1Bad();
+  style2Bad();
+}
+
+//  CHECK-FIXES: void badStyle() {
+// CHECK-FIXES-NEXT:   style1_bad();
+// CHECK-FIXES-NEXT:   STYLE2_BAD();
+// CHECK-FIXES-NEXT: }
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
@@ -5,11 +5,11 @@
 // RUN:   {key: readability-identifier-naming.ClassCase, value: UUPER_CASE}, \
 // RUN:   {key: readability-identifier-naming.StructCase, value: CAMEL}, \
 // RUN:   {key: readability-identifier-naming.EnumCase, value: AnY_cASe}, \
-// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not warning
+// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not error
 
-// CHECK-DAG: warning: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
-// CHECK-DAG: warning: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
 // Don't try to suggest an alternative for 'CAMEL'
-// CHECK-DAG: warning: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
+// CHECK-DAG: error: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
 // This fails on the EditDistance, but as it matches ignoring case suggest the correct value
-// CHECK-DAG: warning: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
@@ -0,0 +1,5 @@
+
+
+void STYLE2_GOOD();
+
+void style2Bad()

[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

2020-07-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.
Herald added a subscriber: aheejin.

When checking for the style of a decl that isn't in the main file, the check 
will now search for the configuration that the included files uses to gather 
the style for its decls.

This can be useful to silence warnings in header files that follow a different 
naming convention without using header-filter to silence all warnings(even from 
other checks) in the header file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84814

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/header.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
@@ -0,0 +1,34 @@
+// Setup header directory
+
+// RUN: rm -rf %theaders
+// RUN: mkdir %theaders
+// RUN: cp -R %S/Inputs/readability-identifier-naming/. %theaders
+
+// C++11 isnt explicitly required, but failing to specify a standard means the
+// check will run multiple times for different standards. This will cause the
+// second test to fail as the header file will be changed during the first run.
+
+// RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t -- \
+// RUN:   -config='{ InheritParentConfig: true, CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.FunctionCase, value: camelBack} \
+// RUN:  ]}' -header-filter='.*' -- -I%theaders
+
+#include "global-style1/header.h"
+#include "global-style2/header.h"
+// CHECK-MESSAGES-DAG: global-style1/header.h:5:6: warning: invalid case style for global function 'style1Bad'
+// CHECK-MESSAGES-DAG: global-style2/header.h:5:6: warning: invalid case style for global function 'style2Bad'
+
+void goodStyle() {
+  style1_good();
+  STYLE2_GOOD();
+}
+// CHECK-MESSAGES-DAG: :[[@LINE+1]]:6: warning: invalid case style for function 'bad_style'
+void bad_style() {
+  style1Bad();
+  style2Bad();
+}
+
+//  CHECK-FIXES: void badStyle() {
+// CHECK-FIXES-NEXT:   style1_bad();
+// CHECK-FIXES-NEXT:   STYLE2_BAD();
+// CHECK-FIXES-NEXT: }
\ No newline at end of file
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
@@ -5,11 +5,11 @@
 // RUN:   {key: readability-identifier-naming.ClassCase, value: UUPER_CASE}, \
 // RUN:   {key: readability-identifier-naming.StructCase, value: CAMEL}, \
 // RUN:   {key: readability-identifier-naming.EnumCase, value: AnY_cASe}, \
-// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not warning
+// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not error
 
-// CHECK-DAG: warning: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
-// CHECK-DAG: warning: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
 // Don't try to suggest an alternative for 'CAMEL'
-// CHECK-DAG: warning: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
+// CHECK-DAG: error: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
 // This fails on the EditDistance, but as it matches ignoring case suggest the correct value
-// CHECK-DAG: warning: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
+// CHECK-DAG: error

[PATCH] D84812: [clang-tidy][NFC] Added convienence methods for getting optional options

2020-07-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 281433.
njames93 added a comment.

Fix wrong patch diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84812

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h

Index: clang-tools-extra/clang-tidy/ClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -268,7 +268,7 @@
   if (llvm::Expected ValueOr = get(LocalName))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -314,7 +314,7 @@
   if (llvm::Expected ValueOr = getLocalOrGlobal(LocalName))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -353,7 +353,7 @@
   if (auto ValueOr = get(LocalName, IgnoreCase))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -395,10 +395,35 @@
   if (auto ValueOr = getLocalOrGlobal(LocalName, IgnoreCase))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
+/// Returns the value for the option \p LocalName represented as a ``T``.
+/// If the option is missing returns None, if the option can't be parsed
+/// as a ``T``, log that to stderr and return None.
+template 
+llvm::Optional getOptional(StringRef LocalName) const {
+  if (auto ValueOr = get(LocalName))
+return *ValueOr;
+  else
+logOptionParsingError(ValueOr.takeError());
+  return llvm::None;
+}
+
+/// Returns the value for the local or global option \p LocalName
+/// represented as a ``T``.
+/// If the option is missing returns None, if the
+/// option can't be parsed as a ``T``, log that to stderr and return None.
+template 
+llvm::Optional getOptionalLocalOrGlobal(StringRef LocalName) const {
+  if (auto ValueOr = getLocalOrGlobal(LocalName))
+return *ValueOr;
+  else
+logOptionParsingError(ValueOr.takeError());
+  return llvm::None;
+}
+
 /// Stores an option with the check-local name \p LocalName with
 /// string value \p Value to \p Options.
 void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
@@ -456,7 +481,8 @@
 void storeInt(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
   int64_t Value) const;
 
-static void logErrToStdErr(llvm::Error &&Err);
+/// Logs an Error to stderr if a \p Err is not a MissingOptionError.
+static void logOptionParsingError(llvm::Error &&Err);
 
 std::string NamePrefix;
 const ClangTidyOptions::OptionMap &CheckOptions;
@@ -524,6 +550,19 @@
 ClangTidyOptions::OptionMap &Options, StringRef LocalName,
 bool Value) const;
 
+/// Returns the value for the option \p LocalName.
+/// If the option is missing returns None.
+template <>
+Optional ClangTidyCheck::OptionsView::getOptional(
+StringRef LocalName) const;
+
+/// Returns the value for the local or global option \p LocalName.
+/// If the option is missing returns None.
+template <>
+Optional
+ClangTidyCheck::OptionsView::getOptionalLocalOrGlobal(
+StringRef LocalName) const;
+
 } // namespace tidy
 } // namespace clang
 
Index: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -10,6 +10,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -126,7 +127,7 @@
   llvm::Expected ValueOr = get(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logErrToStdErr(ValueOr.takeError());
+  logOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -145,7 +146,7 @@
   llvm::Expected ValueOr = getLocalOrGlobal(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logErrToStdErr(ValueOr.takeError());
+  logOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -204,13 +205,36 @@
   Iter->second.Value);
 }
 
-void ClangTidyCheck::OptionsView::logErrToStdErr(llvm::Error &&Err) {
-  llvm::logAllUnhandledErrors(
-  llvm::handleErrors(std::move(Err),
- [](const MissingOptionError &) -> llvm::Error {
-   return llvm::Error::success();
- }),
-

[PATCH] D84812: [clang-tidy][NFC] Added convienence methods for getting optional options

2020-07-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.
Herald added a subscriber: aheejin.

These methods abstract away Error handling when trying to read options that 
can't be parsed by logging the error automatically and returning None.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84812

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/header.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
@@ -0,0 +1,34 @@
+// Setup header directory
+
+// RUN: rm -rf %theaders
+// RUN: mkdir %theaders
+// RUN: cp -R %S/Inputs/readability-identifier-naming/. %theaders
+
+// C++11 isnt explicitly required, but failing to specify a standard means the
+// check will run multiple times for different standards. This will cause the
+// second test to fail as the header file will be changed during the first run.
+
+// RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t -- \
+// RUN:   -config='{ InheritParentConfig: true, CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.FunctionCase, value: camelBack} \
+// RUN:  ]}' -header-filter='.*' -- -I%theaders
+
+#include "global-style1/header.h"
+#include "global-style2/header.h"
+// CHECK-MESSAGES-DAG: global-style1/header.h:5:6: warning: invalid case style for global function 'style1Bad'
+// CHECK-MESSAGES-DAG: global-style2/header.h:5:6: warning: invalid case style for global function 'style2Bad'
+
+void goodStyle() {
+  style1_good();
+  STYLE2_GOOD();
+}
+// CHECK-MESSAGES-DAG: :[[@LINE+1]]:6: warning: invalid case style for function 'bad_style'
+void bad_style() {
+  style1Bad();
+  style2Bad();
+}
+
+//  CHECK-FIXES: void badStyle() {
+// CHECK-FIXES-NEXT:   style1_bad();
+// CHECK-FIXES-NEXT:   STYLE2_BAD();
+// CHECK-FIXES-NEXT: }
\ No newline at end of file
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
@@ -5,11 +5,11 @@
 // RUN:   {key: readability-identifier-naming.ClassCase, value: UUPER_CASE}, \
 // RUN:   {key: readability-identifier-naming.StructCase, value: CAMEL}, \
 // RUN:   {key: readability-identifier-naming.EnumCase, value: AnY_cASe}, \
-// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not warning
+// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not error
 
-// CHECK-DAG: warning: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
-// CHECK-DAG: warning: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
 // Don't try to suggest an alternative for 'CAMEL'
-// CHECK-DAG: warning: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
+// CHECK-DAG: error: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
 // This fails on the EditDistance, but as it matches ignoring case suggest the correct value
-// CHECK-DAG: warning: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
Index: clang-to

[PATCH] D84711: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-28 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8055
   for (const auto L : C->component_lists()) {
-InfoGen(std::get<0>(L), std::get<1>(L), OMPC_MAP_to, llvm::None,
+SmallVector MapModifiers;
+translateMotionModifiers(C->getMotionModifiers(), MapModifiers);

I haven't managed to locally reproduce the bot failures I saw today when trying 
to push this patch.  Somehow they're dropping the present modifiers during 
codegen.  I think it's due to memory corruption that my machines aren't 
managing to experience.  The culprit seems to be that `MapModifiers` is local 
here, but the `InfoGen` call below stores it in a `MapInfo` as an `ArrayRef`, 
which becames a dangling ref by the time it's used.

One solution is to change `MapInfo` to store a `SmallVector` instead.  Another 
would be for `MapInfo` to store a second `ArrayRef` for 
`C->getMotionModifiers()`, which would be translated to runtime map flags 
later.  I'm planning to try the latter solution tomorrow.  I prefer it because 
it seems more space efficient and because it translates motion modifiers 
directly to runtime flags instead of translating to map type modifiers first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84711

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


[clang] 69fc33f - Revert "[OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)"

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T20:30:05-04:00
New Revision: 69fc33f0cd130b02a38d2fc582afc7b0fcd6458a

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

LOG: Revert "[OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)"

This reverts commit 3c3faae497046be706df29e16c9fbccb7e1fce09.

It breaks a number of bots.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 46c26c6c77de..c649502f765b 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,20 +6329,8 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
-  /// Motion-modifiers for the 'to' clause.
-  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
-  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
-
-  /// Location of motion-modifiers for the 'to' clause.
-  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
-
-  /// Colon location.
-  SourceLocation ColonLoc;
-
   /// Build clause with number of variables \a NumVars.
   ///
-  /// \param TheMotionModifiers Motion-modifiers.
-  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6354,24 +6342,13 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPToClause(ArrayRef TheMotionModifiers,
-   ArrayRef TheMotionModifiersLoc,
-   NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy &Locs,
const OMPMappableExprListSizeTy &Sizes)
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, &MapperQualifierLoc,
-  &MapperIdInfo) {
-assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
-   "Unexpected number of motion modifiers.");
-llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
-
-assert(llvm::array_lengthof(MotionModifiersLoc) ==
-   TheMotionModifiersLoc.size() &&
-   "Unexpected number of motion modifier locations.");
-llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
-  }
+  &MapperIdInfo) {}
 
   /// Build an empty clause.
   ///
@@ -6384,29 +6361,6 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
-  /// Set motion-modifier for the clause.
-  ///
-  /// \param I index for motion-modifier.
-  /// \param T motion-modifier for the clause.
-  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
-assert(I < NumberOfOMPMotionModifiers &&
-   "Unexpected index to store motion modifier, exceeds array size.");
-MotionModifiers[I] = T;
-  }
-
-  /// Set location for the motion-modifier.
-  ///
-  /// \param I index for motion-modifier location.
-  /// \param TLoc motion-modifier location.
-  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
-assert(I < NumberOfOMPMotionModifiers &&
-   "Index to store motion modifier location exceeds array size.");
-MotionModifiersLoc[I] = TLoc;
-  }
-
-  /// Set colon location.
-  void set

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

changes like in llvm/test/Transforms/PGOProfile/PR41279.ll etc can be 
independently committed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D84782#2180578 , @davidxl wrote:

> Can you split out the test changes and commit it separately?

How exactly? Do you mean commit the non-test part without flipping the flag and 
then flip it with the test changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281426.
yamauchi added a comment.

Rebase (converting one more test) and fixing a typo and whitespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__pro

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

2020-07-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

LGTM.




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" % (

vitalybuka wrote:
> arichardson wrote:
> > 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.
> If there are concerns here, I'd recommend to land minimal fix for the tool 
> and move test plumbing into a separate patch.
> If there are concerns here, I'd recommend to land minimal fix for the tool 
> and move test plumbing into a separate patch.

+1


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] D84511: Fix update_cc_test_checks.py --llvm-bin after D78478

2020-07-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka 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" % (

arichardson wrote:
> 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.
If there are concerns here, I'd recommend to land minimal fix for the tool and 
move test plumbing into a separate patch.


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] D84511: Fix update_cc_test_checks.py --llvm-bin after D78478

2020-07-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

LGTM as it fixes update_cc_test_checks.py




Comment at: llvm/utils/update_cc_test_checks.py:116-126
+def infer_dependent_args(args):
+  if args.clang is None:
+if args.llvm_bin is None:
+  args.clang = 'clang'
+else:
+  args.clang = os.path.join(args.llvm_bin, 'clang')
+  if args.opt is None:

I guess empty clang also make no sense, "not args.clang" is better here



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] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

Can you split out the test changes and commit it separately?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84405: CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

2020-07-28 Thread Tom Stellard via Phabricator via cfe-commits
tstellar marked an inline comment as done.
tstellar added inline comments.



Comment at: clang/test/CodeGen/builtins-overflow.c:123
+  // CHECK: br i1 [[C2]]
+  int r;
+  if (__builtin_mul_overflow(x, y, &r))

vsk wrote:
> vsk wrote:
> > Could you add a test for the volatile result case?
> I think this is still missing?
Yes, I forgot to add this, there is one in the latest patch now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84405

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


[clang-tools-extra] fb22678 - [clangd] Use elog instead of llvm::errs, log instead of llvm::outs

2020-07-28 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-07-29T01:48:24+02:00
New Revision: fb22678cd67801e41af4917acceb4014ab5d007e

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

LOG: [clangd] Use elog instead of llvm::errs, log instead of llvm::outs

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang-tools-extra/clangd/indexer/IndexerMain.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 364e4db6503c..c3f9efeb7ec0 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -39,6 +39,15 @@ llvm::cl::opt IndexPath(llvm::cl::desc(""),
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt LogLevel{
+"log",
+llvm::cl::desc("Verbosity of log messages written to stderr"),
+values(clEnumValN(Logger::Error, "error", "Error messages only"),
+   clEnumValN(Logger::Info, "info", "High level execution tracing"),
+   clEnumValN(Logger::Debug, "verbose", "Low level details")),
+llvm::cl::init(Logger::Info),
+};
+
 llvm::cl::opt TraceFile(
 "trace-file",
 llvm::cl::desc("Path to the file where tracer logs will be stored"));
@@ -173,7 +182,7 @@ void runServer(std::unique_ptr Index,
   Builder.AddListeningPort(ServerAddress, grpc::InsecureServerCredentials());
   Builder.RegisterService(&Service);
   std::unique_ptr Server(Builder.BuildAndStart());
-  llvm::outs() << "Server listening on " << ServerAddress << '\n';
+  log("Server listening on {0}", ServerAddress);
 
   Server->Wait();
 }
@@ -191,10 +200,16 @@ int main(int argc, char *argv[]) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   if (!llvm::sys::path::is_absolute(IndexRoot)) {
-elog("Index root should be an absolute path.");
+llvm::errs() << "Index root should be an absolute path.\n";
 return -1;
   }
 
+  llvm::errs().SetBuffered();
+  // Don't flush stdout when logging for thread safety.
+  llvm::errs().tie(nullptr);
+  clang::clangd::StreamLogger Logger(llvm::errs(), LogLevel);
+  clang::clangd::LoggingSession LoggingSession(Logger);
+
   llvm::Optional TracerStream;
   std::unique_ptr Tracer;
   if (!TraceFile.empty()) {
@@ -220,7 +235,7 @@ int main(int argc, char *argv[]) {
   std::unique_ptr Index = openIndex(IndexPath);
 
   if (!Index) {
-elog("Failed to open the index.");
+llvm::errs() << "Failed to open the index.\n";
 return -1;
   }
 

diff  --git a/clang-tools-extra/clangd/indexer/IndexerMain.cpp 
b/clang-tools-extra/clangd/indexer/IndexerMain.cpp
index dac038308d9e..46224238c3fc 100644
--- a/clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ b/clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -16,6 +16,7 @@
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolCollector.h"
+#include "support/Logger.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
@@ -122,7 +123,7 @@ int main(int argc, const char **argv) {
   std::make_unique(Data),
   clang::tooling::getStripPluginsAdjuster());
   if (Err) {
-llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+clang::clangd::elog("{0}", std::move(Err));
   }
 
   // Emit collected data.

diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 0d4267774c92..daf87d11c384 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -657,16 +657,16 @@ clangd accepts flags on the commandline, and in the 
CLANGD_FLAGS environment var
   // continuing.
   llvm::SmallString<128> Path(CompileCommandsDir);
   if (std::error_code EC = llvm::sys::fs::make_absolute(Path)) {
-llvm::errs() << "Error while converting the relative path specified by 
"
-"--compile-commands-dir to an absolute path: "
- << EC.message() << ". The argument will be ignored.\n";
+elog("Error while converting the relative path specified by "
+ "--compile-commands-dir to an absolute path: {0}. The argument "
+ "will be ignored.",
+ EC.message());
   } else {
 CompileCommandsDirPath = std::string(Path.str());
   }
 } else {
-  llvm::errs()
-  << "Path specified by --compile-commands-dir does not exist. The "
- "argument will be ignored.\n";
+  elog("Path

[PATCH] D84697: [clangd] Use elog instead of llvm::errs, log instead of llvm::outs

2020-07-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb22678cd678: [clangd] Use elog instead of llvm::errs, log 
instead of llvm::outs (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84697

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  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
@@ -657,16 +657,16 @@
   // continuing.
   llvm::SmallString<128> Path(CompileCommandsDir);
   if (std::error_code EC = llvm::sys::fs::make_absolute(Path)) {
-llvm::errs() << "Error while converting the relative path specified by "
-"--compile-commands-dir to an absolute path: "
- << EC.message() << ". The argument will be ignored.\n";
+elog("Error while converting the relative path specified by "
+ "--compile-commands-dir to an absolute path: {0}. The argument "
+ "will be ignored.",
+ EC.message());
   } else {
 CompileCommandsDirPath = std::string(Path.str());
   }
 } else {
-  llvm::errs()
-  << "Path specified by --compile-commands-dir does not exist. The "
- "argument will be ignored.\n";
+  elog("Path specified by --compile-commands-dir does not exist. The "
+   "argument will be ignored.");
 }
   }
 
@@ -750,7 +750,7 @@
   elog("Couldn't determine user config file, not loading");
 }
 std::vector ProviderPointers;
-for (const auto& P : ProviderStack)
+for (const auto &P : ProviderStack)
   ProviderPointers.push_back(P.get());
 Config = config::Provider::combine(std::move(ProviderPointers));
 Opts.ConfigProvider = Config.get();
Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -16,6 +16,7 @@
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolCollector.h"
+#include "support/Logger.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
@@ -122,7 +123,7 @@
   std::make_unique(Data),
   clang::tooling::getStripPluginsAdjuster());
   if (Err) {
-llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+clang::clangd::elog("{0}", std::move(Err));
   }
 
   // Emit collected data.
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
@@ -39,6 +39,15 @@
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt LogLevel{
+"log",
+llvm::cl::desc("Verbosity of log messages written to stderr"),
+values(clEnumValN(Logger::Error, "error", "Error messages only"),
+   clEnumValN(Logger::Info, "info", "High level execution tracing"),
+   clEnumValN(Logger::Debug, "verbose", "Low level details")),
+llvm::cl::init(Logger::Info),
+};
+
 llvm::cl::opt TraceFile(
 "trace-file",
 llvm::cl::desc("Path to the file where tracer logs will be stored"));
@@ -173,7 +182,7 @@
   Builder.AddListeningPort(ServerAddress, grpc::InsecureServerCredentials());
   Builder.RegisterService(&Service);
   std::unique_ptr Server(Builder.BuildAndStart());
-  llvm::outs() << "Server listening on " << ServerAddress << '\n';
+  log("Server listening on {0}", ServerAddress);
 
   Server->Wait();
 }
@@ -191,10 +200,16 @@
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   if (!llvm::sys::path::is_absolute(IndexRoot)) {
-elog("Index root should be an absolute path.");
+llvm::errs() << "Index root should be an absolute path.\n";
 return -1;
   }
 
+  llvm::errs().SetBuffered();
+  // Don't flush stdout when logging for thread safety.
+  llvm::errs().tie(nullptr);
+  clang::clangd::StreamLogger Logger(llvm::errs(), LogLevel);
+  clang::clangd::LoggingSession LoggingSession(Logger);
+
   llvm::Optional TracerStream;
   std::unique_ptr Tracer;
   if (!TraceFile.empty()) {
@@ -220,7 +235,7 @@
   std::unique_ptr Index = openIndex(IndexPath);
 
   if (!Index) {
-elog("Failed to open the index.");
+llvm::errs() << "Failed to open the index.\n";
 return -1;
   }
 
___
cfe-commits mailing list
cfe-commits@lis

[PATCH] D84405: CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

2020-07-28 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 281419.
tstellar added a comment.

Add volatile test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84405

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-overflow.c

Index: clang/test/CodeGen/builtins-overflow.c
===
--- clang/test/CodeGen/builtins-overflow.c
+++ clang/test/CodeGen/builtins-overflow.c
@@ -1,9 +1,9 @@
 // Test CodeGen for Security Check Overflow Builtins.
 // rdar://13421498
 
-// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i32 -DLONG_MAX=2147483647 %s
+// RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i64 -DLONG_MAX=9223372036854775807 %s
+// RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i32 -DLONG_MAX=2147483647 %s
 
 extern unsigned UnsignedErrorCode;
 extern unsigned long UnsignedLongErrorCode;
@@ -111,6 +111,51 @@
   return r;
 }
 
+int test_mul_overflow_uint_uint_int(unsigned x, unsigned y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_uint_uint_int
+  // CHECK: [[S:%.+]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %{{.+}}, i32 %{{.+}})
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i32, i1 } [[S]], 0
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i32, i1 } [[S]], 1
+  // CHECK: [[C1:%.+]] = icmp ugt i32 [[Q]], 2147483647
+  // CHECK: [[C2:%.+]] = or i1 [[C]], [[C1]]
+  // CHECK: store i32 [[Q]], i32*
+  // CHECK: br i1 [[C2]]
+  int r;
+  if (__builtin_mul_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
+int test_mul_overflow_uint_uint_int_volatile(unsigned x, unsigned y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_uint_uint_int_volatile
+  // CHECK: [[S:%.+]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %{{.+}}, i32 %{{.+}})
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i32, i1 } [[S]], 0
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i32, i1 } [[S]], 1
+  // CHECK: [[C1:%.+]] = icmp ugt i32 [[Q]], 2147483647
+  // CHECK: [[C2:%.+]] = or i1 [[C]], [[C1]]
+  // CHECK: store volatile i32 [[Q]], i32*
+  // CHECK: br i1 [[C2]]
+  volatile int r;
+  if (__builtin_mul_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
+long test_mul_overflow_ulong_ulong_long(unsigned long x, unsigned long y) {
+  // CHECK-LABEL: @test_mul_overflow_ulong_ulong_long
+  // CHECK: [[S:%.+]] =  call { [[LONG_TYPE]], i1 } @llvm.umul.with.overflow.[[LONG_TYPE]]([[LONG_TYPE]] %{{.+}}, [[LONG_TYPE]] %{{.+}})
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { [[LONG_TYPE]], i1 } [[S]], 0
+  // CHECK-DAG: [[C:%.+]] = extractvalue { [[LONG_TYPE]], i1 } [[S]], 1
+  // CHECK: [[C1:%.+]] = icmp ugt [[LONG_TYPE]] [[Q]], [[LONG_MAX]]
+  // CHECK: [[C2:%.+]] = or i1 [[C]], [[C1]]
+  // LONG64: store [[LONG_TYPE]] [[Q]], [[LONG_TYPE]]*
+  // LONG64: br i1 [[C2]]
+  long r;
+  if (__builtin_mul_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
 int test_mul_overflow_int_int_int(int x, int y) {
   // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_int_int_int
   // CHECK-NOT: ext
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1408,6 +1408,47 @@
   return RValue::get(BufAddr.getPointer());
 }
 
+static bool isSpecialUnsignedMultiplySignedResult(
+unsigned BuiltinID, WidthAndSignedness Op1Info, WidthAndSignedness Op2Info,
+WidthAndSignedness ResultInfo) {
+  return BuiltinID == Builtin::BI__builtin_mul_overflow &&
+ Op1Info.Width == Op2Info.Width && Op2Info.Width == ResultInfo.Width &&
+ !Op1Info.Signed && !Op2Info.Signed && ResultInfo.Signed;
+}
+
+static RValue EmitCheckedUnsignedMultiplySignedResult(
+CodeGenFunction &CGF, const clang::Expr *Op1, WidthAndSignedness Op1Info,
+const clang::Expr *Op2, WidthAndSignedness Op2Info,
+const clang::Expr *ResultArg, QualType ResultQTy,
+WidthAndSignedness ResultInfo) {
+  assert(isSpecialUnsignedMultiplySignedResult(
+ Builtin::BI__builtin_mul_overflow, Op1Info, Op2Info, ResultInfo) &&
+ "Cannot specialize this multiply");
+
+  llvm::Value *V1 = CGF.EmitScalarExpr(Op1);
+  llvm::Value *V2 = CGF.EmitScalarExpr(Op2);
+
+  llvm::Value *HasOverflow;
+  llvm::Value *Result = EmitOverflowIntrinsic(
+  CGF, llvm::Intrinsic::umul_with_overflow, V1, V2, HasOverflow);
+
+  // The intrinsic call will detect overflow when the value is > UINT_MAX,
+  // however, since the original builtin had a 

[PATCH] D82898: [clang-tidy] Handled insertion only fixits when determining conflicts.

2020-07-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:629
 Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId);
-  else
+return;
+  case ET_Insert:

aaron.ballman wrote:
> I'd drop these `return` statements and the unreachable, below. The switch is 
> fully-covered, so we'll get a diagnostic if any new enumerations are added 
> and we forget to update this switch.
I'd still need a `break` anyway, but yes the unreachable probably isn't required



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:703
+  Apply[Event.ErrorId] = false;
+continue;
+  case Event::ET_Insert:

aaron.ballman wrote:
> Similar here with `continue` and the unreachable.
As this is in a loop, I'm torn whether using `break` makes it less readable. 
WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82898

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


[PATCH] D82898: [clang-tidy] Handled insertion only fixits when determining conflicts.

2020-07-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 281418.
njames93 marked 2 inline comments as done.
njames93 added a comment.

Remove unreachable after switch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82898

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables,readability-isolate-declaration %t
+
+void foo() {
+  int A, B, C;
+  // CHECK-MESSAGES-DAG: :[[@LINE-1]]:7: warning: variable 'A' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-2]]:10: warning: variable 'B' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-3]]:13: warning: variable 'C' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+
+  // Only the isolate declarations fix-it should be applied
+
+  //  CHECK-FIXES: int A;
+  // CHECK-FIXES-NEXT: int B;
+  // CHECK-FIXES-NEXT: int C;
+}
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -590,6 +591,7 @@
 // An event can be either the begin or the end of an interval.
 enum EventType {
   ET_Begin = 1,
+  ET_Insert = 0,
   ET_End = -1,
 };
 
@@ -621,10 +623,17 @@
   //   one will be processed before, disallowing the second one, and the
   //   end point of the first one will also be processed before,
   //   disallowing the first one.
-  if (Type == ET_Begin)
+  switch (Type) {
+  case ET_Begin:
 Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId);
-  else
+break;
+  case ET_Insert:
+Priority = std::make_tuple(Begin, Type, -End, ErrorSize, ErrorId);
+break;
+  case ET_End:
 Priority = std::make_tuple(End, Type, -Begin, ErrorSize, ErrorId);
+break;
+  }
 }
 
 bool operator<(const Event &Other) const {
@@ -662,19 +671,19 @@
   }
 
   // Build events from error intervals.
-  std::map> FileEvents;
+  llvm::StringMap> FileEvents;
   for (unsigned I = 0; I < ErrorFixes.size(); ++I) {
 for (const auto &FileAndReplace : *ErrorFixes[I].second) {
   for (const auto &Replace : FileAndReplace.second) {
 unsigned Begin = Replace.getOffset();
 unsigned End = Begin + Replace.getLength();
-const std::string &FilePath = std::string(Replace.getFilePath());
-// FIXME: Handle empty intervals, such as those from insertions.
-if (Begin == End)
-  continue;
-auto &Events = FileEvents[FilePath];
-Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
-Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
+auto &Events = FileEvents[Replace.getFilePath()];
+if (Begin == End) {
+  Events.emplace_back(Begin, End, Event::ET_Insert, I, Sizes[I]);
+} else {
+  Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
+  Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
+}
   }
 }
   }
@@ -686,14 +695,20 @@
 llvm::sort(Events);
 int OpenIntervals = 0;
 for (const auto &Event : Events) {
-  if (Event.Type == Event::ET_End)
---OpenIntervals;
-  // This has to be checked after removing the interval from the count if it
-  // is an end event, or before adding it if it is a begin event.
-  if (OpenIntervals != 0)
-Apply[Event.ErrorId] = false;
-  if (Event.Type == Event::ET_Begin)
-++OpenIntervals;
+  switch (Event.Type) {
+  case Event::ET_Begin:
+if (OpenIntervals++ != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  case Event::ET_Insert:
+if (OpenIntervals != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  case Event::ET_End:
+if (--OpenIntervals != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  }
 }
 assert(OpenIntervals == 0 && "Amount of begin/end points doesn't match");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llv

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D84782#2180432 , @davidxl wrote:

> On version bump --- looks like FrontPGO has been bumping version for hashing 
> changes while IR PGO had not, so it is ok to leave the version unchanged 
> (current situation is also confusing as the version of IR and FE PGO are 
> mixed).
>
> On the other hand, just in case, we need to introduce a temporary internal 
> option for people to be able to keep on using old profile (with older scheme 
> of hashing) for a while. Basically, under the option, the hashing scheme 
> falls back to the old way.
>
> other than that, looks fine.

Thanks. Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281417.
yamauchi added a comment.

Add a flag to back out to the old hashing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 2)
   br label %sw.epilog
 
 sw

[PATCH] D84697: [clangd] Use elog instead of llvm::errs, log instead of llvm::outs

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

Resolve post-LGTM comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84697

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  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
@@ -657,16 +657,16 @@
   // continuing.
   llvm::SmallString<128> Path(CompileCommandsDir);
   if (std::error_code EC = llvm::sys::fs::make_absolute(Path)) {
-llvm::errs() << "Error while converting the relative path specified by "
-"--compile-commands-dir to an absolute path: "
- << EC.message() << ". The argument will be ignored.\n";
+elog("Error while converting the relative path specified by "
+ "--compile-commands-dir to an absolute path: {0}. The argument "
+ "will be ignored.",
+ EC.message());
   } else {
 CompileCommandsDirPath = std::string(Path.str());
   }
 } else {
-  llvm::errs()
-  << "Path specified by --compile-commands-dir does not exist. The "
- "argument will be ignored.\n";
+  elog("Path specified by --compile-commands-dir does not exist. The "
+   "argument will be ignored.");
 }
   }
 
@@ -750,7 +750,7 @@
   elog("Couldn't determine user config file, not loading");
 }
 std::vector ProviderPointers;
-for (const auto& P : ProviderStack)
+for (const auto &P : ProviderStack)
   ProviderPointers.push_back(P.get());
 Config = config::Provider::combine(std::move(ProviderPointers));
 Opts.ConfigProvider = Config.get();
Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -16,6 +16,7 @@
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolCollector.h"
+#include "support/Logger.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
@@ -122,7 +123,7 @@
   std::make_unique(Data),
   clang::tooling::getStripPluginsAdjuster());
   if (Err) {
-llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+clang::clangd::elog("{0}", std::move(Err));
   }
 
   // Emit collected data.
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
@@ -39,6 +39,15 @@
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt LogLevel{
+"log",
+llvm::cl::desc("Verbosity of log messages written to stderr"),
+values(clEnumValN(Logger::Error, "error", "Error messages only"),
+   clEnumValN(Logger::Info, "info", "High level execution tracing"),
+   clEnumValN(Logger::Debug, "verbose", "Low level details")),
+llvm::cl::init(Logger::Info),
+};
+
 llvm::cl::opt TraceFile(
 "trace-file",
 llvm::cl::desc("Path to the file where tracer logs will be stored"));
@@ -173,7 +182,7 @@
   Builder.AddListeningPort(ServerAddress, grpc::InsecureServerCredentials());
   Builder.RegisterService(&Service);
   std::unique_ptr Server(Builder.BuildAndStart());
-  llvm::outs() << "Server listening on " << ServerAddress << '\n';
+  log("Server listening on {0}", ServerAddress);
 
   Server->Wait();
 }
@@ -191,10 +200,16 @@
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
   if (!llvm::sys::path::is_absolute(IndexRoot)) {
-elog("Index root should be an absolute path.");
+llvm::errs() << "Index root should be an absolute path.\n";
 return -1;
   }
 
+  llvm::errs().SetBuffered();
+  // Don't flush stdout when logging for thread safety.
+  llvm::errs().tie(nullptr);
+  clang::clangd::StreamLogger Logger(llvm::errs(), LogLevel);
+  clang::clangd::LoggingSession LoggingSession(Logger);
+
   llvm::Optional TracerStream;
   std::unique_ptr Tracer;
   if (!TraceFile.empty()) {
@@ -220,7 +235,7 @@
   std::unique_ptr Index = openIndex(IndexPath);
 
   if (!Index) {
-elog("Failed to open the index.");
+llvm::errs() << "Failed to open the index.\n";
 return -1;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

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

This is useful for the remote index: system libraries and external dependencies
would still have a different location on local and remote machine, so they
should be simply excluded.

Unfortunately, it is not possible to filter symbols during indexing because
symbol information is merged throughout the whole process, so the only option
is to do post-processing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84811

Files:
  clang-tools-extra/clangd/indexer/IndexerMain.cpp

Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -20,7 +20,9 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 
 namespace clang {
@@ -35,9 +37,36 @@
"binary RIFF format")),
llvm::cl::init(IndexFileFormat::RIFF));
 
+static llvm::cl::opt
+ProjectRoot("project-root",
+llvm::cl::desc("Filter out all symbols outside of this "
+   "directory. This is useful for remote index."),
+llvm::cl::Hidden);
+
+bool filterURI(llvm::StringRef URI, llvm::StringRef IndexRoot) {
+  auto Parsed = URI::parse(URI);
+  return !Parsed || !Parsed->body().startswith(IndexRoot);
+}
+
+/// Returns true if \p Sym should be excluded from index.
+bool filterSymbol(const Symbol &Sym, llvm::StringRef IndexRoot) {
+  if (*Sym.CanonicalDeclaration.FileURI)
+if (filterURI(Sym.CanonicalDeclaration.FileURI, IndexRoot))
+  return true;
+  if (*Sym.Definition.FileURI)
+if (filterURI(Sym.Definition.FileURI, IndexRoot))
+  return true;
+  for (const auto &Header : Sym.IncludeHeaders)
+if (!isLiteralInclude(Header.IncludeHeader))
+  if (filterURI(Header.IncludeHeader, IndexRoot))
+return true;
+  return false;
+}
+
 class IndexActionFactory : public tooling::FrontendActionFactory {
 public:
-  IndexActionFactory(IndexFileIn &Result) : Result(Result) {}
+  IndexActionFactory(IndexFileIn &Result, llvm::StringRef IndexRoot)
+  : Result(Result), IndexRoot(IndexRoot) {}
 
   std::unique_ptr create() override {
 SymbolCollector::Options Opts;
@@ -56,10 +85,10 @@
 },
 [&](RefSlab S) {
   std::lock_guard Lock(SymbolsMu);
-  for (const auto &Sym : S) {
+  for (const auto &SymbolAndRefs : S) {
 // Deduplication happens during insertion.
-for (const auto &Ref : Sym.second)
-  Refs.insert(Sym.first, Ref);
+for (const auto &Ref : SymbolAndRefs.second)
+  Refs.insert(SymbolAndRefs.first, Ref);
   }
 },
 [&](RelationSlab S) {
@@ -77,6 +106,38 @@
 Result.Symbols = std::move(Symbols).build();
 Result.Refs = std::move(Refs).build();
 Result.Relations = std::move(Relations).build();
+
+// Post-filtering.
+if (!IndexRoot.empty()) {
+  llvm::DenseSet ExcludeIDs;
+  for (const auto &Sym : *Result.Symbols)
+if (filterSymbol(Sym, IndexRoot))
+  ExcludeIDs.insert(Sym.ID);
+
+  llvm::errs() << "Total symbols collected: " << Result.Symbols->size()
+   << ". Filtering out " << ExcludeIDs.size() << " of them.\n";
+
+  if (!ExcludeIDs.empty()) {
+SymbolSlab::Builder FilteredSymbols;
+RefSlab::Builder FilteredRefs;
+RelationSlab::Builder FilteredRelations;
+for (const auto &Sym : *Result.Symbols)
+  if (ExcludeIDs.find(Sym.ID) == ExcludeIDs.end())
+FilteredSymbols.insert(Sym);
+for (const auto &SymbolAndRefs : *Result.Refs)
+  if (ExcludeIDs.find(SymbolAndRefs.first) == ExcludeIDs.end())
+for (const auto &Ref : SymbolAndRefs.second)
+  FilteredRefs.insert(SymbolAndRefs.first, Ref);
+for (const auto &Rel : *Result.Relations)
+  if ((ExcludeIDs.find(Rel.Object) == ExcludeIDs.end()) &&
+  (ExcludeIDs.find(Rel.Subject) == ExcludeIDs.end()))
+FilteredRelations.insert(Rel);
+
+Result.Symbols = std::move(FilteredSymbols).build();
+Result.Refs = std::move(FilteredRefs).build();
+Result.Relations = std::move(FilteredRelations).build();
+  }
+}
   }
 
 private:
@@ -85,6 +146,7 @@
   SymbolSlab::Builder Symbols;
   RefSlab::Builder Refs;
   RelationSlab::Builder Relations;
+  std::string IndexRoot;
 };
 
 } // namespace
@@ -119,7 +181,9 @@
   // Collect

[PATCH] D73151: [analyzer] Fix handle leak false positive when the handle dies too early

2020-07-28 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: clang/test/Analysis/fuchsia_handle.cpp:80
+  zx_status_t status = zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated through 2nd parameter}}
+  if (status == 0) { // expected-note {{Assuming 'status' is equal to 0}}

jroelofs wrote:
> @xazax.hun, @dcoughlin Is it expected that these diagnostics be 
> non-deterministic? I'm seeing this test case fail sporadically [1] because 
> sometimes the analyzer sees that the 3rd argument leaks, and other times it 
> sees that the 2nd does.
> 
> The easy fix here would be to adjust the regex to be flexible against that 
> difference, but I didn't want to cover up an underlying issue by committing 
> that blindly:
> 
> ```
> // expected-note@-1 {{Handle allocated through (2nd|3rd) parameter}}
> ```
> 
> 1: 
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/17048/console
erm, wrong link. this is the correct one:

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/17049/#showFailuresLink


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73151

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


[PATCH] D73151: [analyzer] Fix handle leak false positive when the handle dies too early

2020-07-28 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added subscribers: dcoughlin, jroelofs.
jroelofs added inline comments.
Herald added subscribers: ASDenysPetrov, martong.



Comment at: clang/test/Analysis/fuchsia_handle.cpp:80
+  zx_status_t status = zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated through 2nd parameter}}
+  if (status == 0) { // expected-note {{Assuming 'status' is equal to 0}}

@xazax.hun, @dcoughlin Is it expected that these diagnostics be 
non-deterministic? I'm seeing this test case fail sporadically [1] because 
sometimes the analyzer sees that the 3rd argument leaks, and other times it 
sees that the 2nd does.

The easy fix here would be to adjust the regex to be flexible against that 
difference, but I didn't want to cover up an underlying issue by committing 
that blindly:

```
// expected-note@-1 {{Handle allocated through (2nd|3rd) parameter}}
```

1: 
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/17048/console


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73151

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


[PATCH] D83115: [Analyzer] Report every bug if only uniqueing location differs.

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

Whoops, i meant to post the comment in 
https://reviews.llvm.org/rG22a084cfa337d5e5ea90eba5261f7937e28d250b#937772 
here. Anyway, i found a crash caused by this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83115

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

> Many tests can also be enhanced to filter out the hash details if they are 
> not part the main test.

Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281407.
yamauchi added a comment.

Shift the higher 32 bits by 28 bits and add.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 2)
   br label %sw.epilog
 
 

[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-07-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:116-121
+  unsigned Priority = 0;
   for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
  E = ClangTidyModuleRegistry::end();
I != E; ++I)
-Options = Options.mergeWith(I->instantiate()->getModuleOptions());
+Options =
+Options.mergeWith(I->instantiate()->getModuleOptions(), ++Priority);

Is there a reason for incrementing the priority on each successive iteration, 
Seems like a bug that will lead to the later registered modules having higher 
priority for their options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184

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


[PATCH] D84711: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-28 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c3faae49704: [OpenMP] Implement TR8 `present` motion 
modifier in Clang (1/2) (authored by jdenny).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84711

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/declare_mapper_ast_print.c
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp

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,10 @@
-// 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,lt50,lt51 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp -fopenmp-version=51 -ferror-limit 100 -o - -std=c++11 %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,lt50,lt51 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -25,6 +27,10 @@
   return 0;
 }
 
+struct S {
+  int i;
+};
+
 int main(int argc, char **argv) {
   int m;
   #pragma omp target update // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
@@ -34,15 +40,114 @@
   #pragma omp target update to(m) ] // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
   #pragma omp target update to(m) ) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
 
+  #pragma omp declare mapper(id: S s) map(s.i)
+  S s;
+
+  // Check parsing with no modifiers.
+  // lt51-error@+2 {{expected expression}}
+  // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(: s)
+  // expected-error@+2 {{expected expression}}
+  // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(:)
+  // expected-error@+2 2 {{expected expression}}
+  // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(,:)
+
+  // Check parsing with one modifier.
+  // expected-error@+2 {{use of undeclared identifier 'foobar'}}
+  // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(foobar: s)
+  // expected-error@+3 {{expected ',' or ')' in 'to' clause}}
+  // expected-error@+2 {{expected ')'}}
+  // expected-note@+1 {{to match this '('}}
+  #pragma omp target update to(m: s)
+  #pragma omp target update to(mapper(id): s)
+  // lt51-error@+2 {{use of undeclared identifier 'present'}}
+  // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(present: s)
+  // ge51-warning@+4 {{missing ':' after motion modifier - ignoring}}
+  // lt51-warning@+3 {{missing ':' after ) - ignoring}}
+  // expected-error@+2 {{expected expression}}
+  // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp targ

[clang] 3c3faae - [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T19:15:18-04:00
New Revision: 3c3faae497046be706df29e16c9fbccb7e1fce09

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

LOG: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

This patch implements Clang front end support for the OpenMP TR8
`present` motion modifier for `omp target update` directives.  The
next patch in this series implements OpenMP runtime support.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index c649502f765b..46c26c6c77de 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,8 +6329,20 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
+  /// Motion-modifiers for the 'to' clause.
+  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
+  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
+
+  /// Location of motion-modifiers for the 'to' clause.
+  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
+
+  /// Colon location.
+  SourceLocation ColonLoc;
+
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param TheMotionModifiers Motion-modifiers.
+  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6342,13 +6354,24 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(ArrayRef TheMotionModifiers,
+   ArrayRef TheMotionModifiersLoc,
+   NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy &Locs,
const OMPMappableExprListSizeTy &Sizes)
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, &MapperQualifierLoc,
-  &MapperIdInfo) {}
+  &MapperIdInfo) {
+assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
+   "Unexpected number of motion modifiers.");
+llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
+
+assert(llvm::array_lengthof(MotionModifiersLoc) ==
+   TheMotionModifiersLoc.size() &&
+   "Unexpected number of motion modifier locations.");
+llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
+  }
 
   /// Build an empty clause.
   ///
@@ -6361,6 +6384,29 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
+  /// Set motion-modifier for the clause.
+  ///
+  /// \param I index for motion-modifier.
+  /// \param T motion-modifier for the clause.
+  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
+assert(I < NumberOfOMPMotionModifiers &&
+   "Unexpected index to store motion modifier, exceeds array size.");
+MotionModifiers[I] = T;
+  }
+
+  /// Set location for the motion-modifier.
+  ///
+  /// \param I index for motion-modifier location.
+  /// \param TLoc motion-modifier location.
+  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
+assert(I < NumberOfOMPMoti

[PATCH] D84710: [OpenMP][NFC] Consolidate `to` and `from` clause modifiers

2020-07-28 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa3d1f88fa7da: [OpenMP][NFC] Consolidate `to` and `from` 
clause modifiers (authored by jdenny).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84710

Files:
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp

Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -3442,21 +3442,10 @@
   Data.ColonLoc = ConsumeToken();
   } else if (Kind == OMPC_to || Kind == OMPC_from) {
 if (Tok.is(tok::identifier)) {
-  bool IsMapperModifier = false;
-  if (Kind == OMPC_to) {
-auto Modifier =
-static_cast(getOpenMPSimpleClauseType(
-Kind, PP.getSpelling(Tok), getLangOpts().OpenMP));
-if (Modifier == OMPC_TO_MODIFIER_mapper)
-  IsMapperModifier = true;
-  } else {
-auto Modifier =
-static_cast(getOpenMPSimpleClauseType(
-Kind, PP.getSpelling(Tok), getLangOpts().OpenMP));
-if (Modifier == OMPC_FROM_MODIFIER_mapper)
-  IsMapperModifier = true;
-  }
-  if (IsMapperModifier) {
+  auto Modifier =
+  static_cast(getOpenMPSimpleClauseType(
+  Kind, PP.getSpelling(Tok), getLangOpts().OpenMP));
+  if (Modifier == OMPC_MOTION_MODIFIER_mapper) {
 // Parse the mapper modifier.
 ConsumeToken();
 IsInvalidMapperModifier = parseMapperModifier(Data);
Index: clang/lib/Basic/OpenMPKinds.cpp
===
--- clang/lib/Basic/OpenMPKinds.cpp
+++ clang/lib/Basic/OpenMPKinds.cpp
@@ -64,17 +64,12 @@
 return Type;
   }
   case OMPC_to:
-return llvm::StringSwitch(Str)
-#define OPENMP_TO_MODIFIER_KIND(Name)  \
-  .Case(#Name, static_cast(OMPC_TO_MODIFIER_##Name))
-#include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_TO_MODIFIER_unknown);
   case OMPC_from:
 return llvm::StringSwitch(Str)
-#define OPENMP_FROM_MODIFIER_KIND(Name) \
-  .Case(#Name, static_cast(OMPC_FROM_MODIFIER_##Name))
+#define OPENMP_MOTION_MODIFIER_KIND(Name)  \
+  .Case(#Name, static_cast(OMPC_MOTION_MODIFIER_##Name))
 #include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_FROM_MODIFIER_unknown);
+.Default(OMPC_MOTION_MODIFIER_unknown);
   case OMPC_dist_schedule:
 return llvm::StringSwitch(Str)
 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
@@ -258,29 +253,18 @@
 }
 llvm_unreachable("Invalid OpenMP 'map' clause type");
   case OMPC_to:
-switch (Type) {
-case OMPC_TO_MODIFIER_unknown:
-  return "unknown";
-#define OPENMP_TO_MODIFIER_KIND(Name)  \
-  case OMPC_TO_MODIFIER_##Name:\
-return #Name;
-#include "clang/Basic/OpenMPKinds.def"
-default:
-  break;
-}
-llvm_unreachable("Invalid OpenMP 'to' clause type");
   case OMPC_from:
 switch (Type) {
-case OMPC_FROM_MODIFIER_unknown:
+case OMPC_MOTION_MODIFIER_unknown:
   return "unknown";
-#define OPENMP_FROM_MODIFIER_KIND(Name)\
-  case OMPC_FROM_MODIFIER_##Name:  \
+#define OPENMP_MOTION_MODIFIER_KIND(Name)  \
+  case OMPC_MOTION_MODIFIER_##Name:\
 return #Name;
 #include "clang/Basic/OpenMPKinds.def"
 default:
   break;
 }
-llvm_unreachable("Invalid OpenMP 'from' clause type");
+llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
   case OMPC_dist_schedule:
 switch (Type) {
 case OMPC_DIST_SCHEDULE_unknown:
Index: clang/include/clang/Basic/OpenMPKinds.h
===
--- clang/include/clang/Basic/OpenMPKinds.h
+++ clang/include/clang/Basic/OpenMPKinds.h
@@ -86,20 +86,12 @@
 static constexpr unsigned NumberOfOMPMapClauseModifiers =
 OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
 
-/// OpenMP modifier kind for 'to' clause.
-enum OpenMPToModifierKind {
-#define OPENMP_TO_MODIFIER_KIND(Name) \
-  OMPC_TO_MODIFIER_##Name,
+/// OpenMP modifier kind for 'to' or 'from' clause.
+enum OpenMPMotionModifierKind {
+#define OPENMP_MOTION_MODIFIER_KIND(Name) \
+  OMPC_MOTION_MODIFIER_##Name,
 #include "clang/Basic/OpenMPKinds.def"
-  OMPC_TO_MODIFIER_unknown
-};
-
-/// OpenMP modifier kind for 'from' clause.
-enum OpenMPFromModifierKind {
-#define OPENMP_FROM_MODI

[clang] a3d1f88 - [OpenMP][NFC] Consolidate `to` and `from` clause modifiers

2020-07-28 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-28T19:15:18-04:00
New Revision: a3d1f88fa7da3dfc0b4319f2e4eb7374fa60b819

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

LOG: [OpenMP][NFC] Consolidate `to` and `from` clause modifiers

`to` and `from` clauses take the same modifiers, which are called
"motion modifiers" in TR8, so implement handling of their modifiers
once not twice.  This will make it easier to implement additional
motion modifiers in the future.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/Parse/ParseOpenMP.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index 275c4fcdabb2..04ecbeaaa03e 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -29,11 +29,8 @@
 #ifndef OPENMP_MAP_MODIFIER_KIND
 #define OPENMP_MAP_MODIFIER_KIND(Name)
 #endif
-#ifndef OPENMP_TO_MODIFIER_KIND
-#define OPENMP_TO_MODIFIER_KIND(Name)
-#endif
-#ifndef OPENMP_FROM_MODIFIER_KIND
-#define OPENMP_FROM_MODIFIER_KIND(Name)
+#ifndef OPENMP_MOTION_MODIFIER_KIND
+#define OPENMP_MOTION_MODIFIER_KIND(Name)
 #endif
 #ifndef OPENMP_DIST_SCHEDULE_KIND
 #define OPENMP_DIST_SCHEDULE_KIND(Name)
@@ -126,11 +123,8 @@ OPENMP_MAP_MODIFIER_KIND(close)
 OPENMP_MAP_MODIFIER_KIND(mapper)
 OPENMP_MAP_MODIFIER_KIND(present)
 
-// Modifiers for 'to' clause.
-OPENMP_TO_MODIFIER_KIND(mapper)
-
-// Modifiers for 'from' clause.
-OPENMP_FROM_MODIFIER_KIND(mapper)
+// Modifiers for 'to' or 'from' clause.
+OPENMP_MOTION_MODIFIER_KIND(mapper)
 
 // Static attributes for 'dist_schedule' clause.
 OPENMP_DIST_SCHEDULE_KIND(static)
@@ -163,8 +157,7 @@ OPENMP_REDUCTION_MODIFIER(task)
 #undef OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND
 #undef OPENMP_MAP_KIND
 #undef OPENMP_MAP_MODIFIER_KIND
-#undef OPENMP_TO_MODIFIER_KIND
-#undef OPENMP_FROM_MODIFIER_KIND
+#undef OPENMP_MOTION_MODIFIER_KIND
 #undef OPENMP_DIST_SCHEDULE_KIND
 #undef OPENMP_DEFAULTMAP_KIND
 #undef OPENMP_DEFAULTMAP_MODIFIER

diff  --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index dc6198f93f9d..3e9b5c4a8b14 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -86,20 +86,12 @@ enum OpenMPMapModifierKind {
 static constexpr unsigned NumberOfOMPMapClauseModifiers =
 OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
 
-/// OpenMP modifier kind for 'to' clause.
-enum OpenMPToModifierKind {
-#define OPENMP_TO_MODIFIER_KIND(Name) \
-  OMPC_TO_MODIFIER_##Name,
+/// OpenMP modifier kind for 'to' or 'from' clause.
+enum OpenMPMotionModifierKind {
+#define OPENMP_MOTION_MODIFIER_KIND(Name) \
+  OMPC_MOTION_MODIFIER_##Name,
 #include "clang/Basic/OpenMPKinds.def"
-  OMPC_TO_MODIFIER_unknown
-};
-
-/// OpenMP modifier kind for 'from' clause.
-enum OpenMPFromModifierKind {
-#define OPENMP_FROM_MODIFIER_KIND(Name) \
-  OMPC_FROM_MODIFIER_##Name,
-#include "clang/Basic/OpenMPKinds.def"
-  OMPC_FROM_MODIFIER_unknown
+  OMPC_MOTION_MODIFIER_unknown
 };
 
 /// OpenMP attributes for 'dist_schedule' clause.

diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 4807702e896e..da362f99ed29 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -64,17 +64,12 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind 
Kind, StringRef Str,
 return Type;
   }
   case OMPC_to:
-return llvm::StringSwitch(Str)
-#define OPENMP_TO_MODIFIER_KIND(Name)  
\
-  .Case(#Name, static_cast(OMPC_TO_MODIFIER_##Name))
-#include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_TO_MODIFIER_unknown);
   case OMPC_from:
 return llvm::StringSwitch(Str)
-#define OPENMP_FROM_MODIFIER_KIND(Name) \
-  .Case(#Name, static_cast(OMPC_FROM_MODIFIER_##Name))
+#define OPENMP_MOTION_MODIFIER_KIND(Name)  
\
+  .Case(#Name, static_cast(OMPC_MOTION_MODIFIER_##Name))
 #include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_FROM_MODIFIER_unknown);
+.Default(OMPC_MOTION_MODIFIER_unknown);
   case OMPC_dist_schedule:
 return llvm::StringSwitch(Str)
 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
@@ -258,29 +253,18 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 llvm_unreachable("Invalid OpenMP 'map' clause type");
   case OMPC_to:
-switch (Type) {
-case OMPC_TO_MODIFIER_unknown:
-  return "unknown";
-#define OPENMP_TO_MODIFIER_KIND(Name)   

[PATCH] D84767: [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in target region.

2020-07-28 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

In D84767#2180280 , @ye-luo wrote:

> This patch
> GPU activities:   96.99%  350.05ms10  35.005ms  1.5680us  350.00ms  
> [CUDA memcpy HtoD]
> before the July21 change
> GPU activities:   95.33%  20.317ms 4  5.0793ms  1.6000us  20.305ms  
> [CUDA memcpy HtoD]
> Still more transfer than it should.

@ABataev could you have a look. My July 21 compiler was built before 
"[OPENMP]Fix PR46012: declare target pointer cannot be accessed in target 
region." gets in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84767

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

On version bump --- looks like FrontPGO has been bumping version for hashing 
changes while IR PGO had not, so it is ok to leave the version unchanged 
(current situation is also confusing as the version of IR and FE PGO are mixed).

On the other hand, just in case, we need to introduce a temporary internal 
option for people to be able to keep on using old profile (with older scheme of 
hashing) for a while. Basically, under the option, the hashing scheme falls 
back to the old way.

other than that, looks fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 281399.
ychen added a comment.

- Update `-debug-pass-manager-verbose` test. Some output should be ignored.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84774

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/test/Transforms/LoopUnroll/revisit.ll
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll

Index: llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
===
--- llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -19,7 +19,6 @@
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
-; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
 ; NEW-PM-NOT: Running analysis:
 
 ; IR-LABEL: @f1
Index: llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
===
--- llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
+++ llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
@@ -6,20 +6,19 @@
 ; RUN: opt -S -passes='loop(require),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s
 ;
 ; CHECK: Starting llvm::Function pass manager run.
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Running analysis: LoopAnalysis
 ; CHECK: Running analysis: InnerAnalysisManagerProxy<
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner2.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on outer.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Running pass: LoopUnrollPass
 ; CHECK: Clearing all analysis results for: inner2.header
@@ -29,16 +28,15 @@
 ; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header
 ; CHECK: Invalidating all non-preserved analyses for: inner1.header.1
 ; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header:
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header.1
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header.1
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header.1:
 ; CHECK: Finished Loop pass manager run.
Index: llvm/test/Transforms/LoopUnroll/revisit.ll
===
--- llvm/test/Transforms/LoopUnroll/revisit.ll
+++ llvm/test/Transforms/LoopUnroll/revisit.ll
@@ -15,7 +15,7 @@
 ; Basic test is fully unrolled and we revisit the post-unroll new sibling
 ; loops, including the ones

[PATCH] D84467: Add support for Branch Coverage in LLVM Source-Based Code Coverage

2020-07-28 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

I haven't taken a close look at the tests yet, but plan on getting to it soon.

I'm not sure whether this is something you've already tried, but for this kind 
of change, it can be helpful to verify that a stage2 clang self-host with 
assertions enabled completes successfully. For coverage specifically, it's 
possible to do that by setting '-DLLVM_BUILD_INSTRUMENTED_COVERAGE=On' during 
the stage2 cmake step.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84467

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


[PATCH] D84038: On Windows build, making the /bigobj flag global , instead of passing it per file.

2020-07-28 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG80bd6ae13ea2: On Windows build, making the /bigobj flag 
global , instead of passing it per… (authored by zahiraam, committed by 
Meinersbur).
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D84038?vs=281205&id=281397#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84038

Files:
  clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/Sema/CMakeLists.txt
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/Tooling/CMakeLists.txt
  lldb/source/API/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/lib/Passes/CMakeLists.txt
  mlir/lib/Dialect/SPIRV/CMakeLists.txt

Index: mlir/lib/Dialect/SPIRV/CMakeLists.txt
===
--- mlir/lib/Dialect/SPIRV/CMakeLists.txt
+++ mlir/lib/Dialect/SPIRV/CMakeLists.txt
@@ -1,6 +1,3 @@
-if (MSVC)
-  set_source_files_properties(SPIRVDialect.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
 
 set(LLVM_TARGET_DEFINITIONS SPIRVCanonicalization.td)
 mlir_tablegen(SPIRVCanonicalization.inc -gen-rewriters)
Index: llvm/lib/Passes/CMakeLists.txt
===
--- llvm/lib/Passes/CMakeLists.txt
+++ llvm/lib/Passes/CMakeLists.txt
@@ -1,7 +1,3 @@
-if (MSVC)
-  set_source_files_properties(PassBuilder.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
-
 add_llvm_component_library(LLVMPasses
   PassBuilder.cpp
   PassPlugin.cpp
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -473,6 +473,10 @@
   endif()
 endif()
   endif()
+  # By default MSVC has a 2^16 limit on the number of sections in an object file,
+  # but in many objects files need more than that. This flag is to increase the
+  # number of sections.
+  append("/bigobj" CMAKE_CXX_FLAGS)
 endif( MSVC )
 
 # Warnings-as-errors handling for GCC-compatible compilers:
Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -126,9 +126,6 @@
   set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH   "${PYTHON_RPATH}")
 endif()
 
-if (MSVC)
-  set_source_files_properties(SBReproducer.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
 
 if(lldb_python_wrapper)
   add_dependencies(liblldb swig_wrapper)
Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -4,14 +4,6 @@
   Support
   )
 
-# By default MSVC has a 2^16 limit on the number of sections in an object file,
-# and this needs more than that.
-if (MSVC)
-  set_source_files_properties(RecursiveASTVisitorTest.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(RecursiveASTVisitorTestExprVisitor.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(RecursiveASTVisitorTests/Callbacks.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(SourceCodeTest.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
 
 add_clang_unittest(ToolingTests
   ASTSelectionTest.cpp
Index: clang/unittests/ASTMatchers/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/CMakeLists.txt
+++ clang/unittests/ASTMatchers/CMakeLists.txt
@@ -3,15 +3,6 @@
   Support
   )
 
-# By default MSVC has a 2^16 limit on the number of sections in an object file,
-# and this needs more than that.
-if (MSVC)
-  set_source_files_properties(InternalASTMatchersTest.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(NodeMatchersTest.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(NarrowingMatchersTest.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(ASTTraversalMatchersTest.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
-
 add_clang_unittest(ASTMatchersTests
   ASTMatchersInternalTest.cpp
   ASTMatchersNodeTest.cpp
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -3,9 +3,6 @@
   Support
   )
 
-if (MSVC)
-  set_source_files_properties(ASTImporterTest.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
Index: clang/lib/Sema/CMakeLists.txt
===
--- clang/lib/Sema/CMakeLists.txt
+++ clang/lib/Sema/CMakeLists.txt
@@

[clang] 80bd6ae - On Windows build, making the /bigobj flag global , instead of passing it per file.

2020-07-28 Thread Michael Kruse via cfe-commits

Author: Zahira Ammarguellat
Date: 2020-07-28T18:04:36-05:00
New Revision: 80bd6ae13ea23d453a1f45d6ccdbfc7d0c877bb0

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

LOG: On Windows build, making the /bigobj flag global , instead of passing it 
per file.

To avoid having this flag be passed in per/file manner, we are instead
passing it globally.

This fixes this bug: https://bugs.llvm.org/show_bug.cgi?id=46733

Reviewed-by: aaron.ballman, beanz, meinersbur

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

Added: 


Modified: 
clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
clang/lib/CodeGen/CMakeLists.txt
clang/lib/Sema/CMakeLists.txt
clang/unittests/AST/CMakeLists.txt
clang/unittests/ASTMatchers/CMakeLists.txt
clang/unittests/Tooling/CMakeLists.txt
lldb/source/API/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/lib/Passes/CMakeLists.txt
mlir/lib/Dialect/SPIRV/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt 
b/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
index adb891575b30..7110a503869e 100644
--- a/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
+++ b/clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
@@ -3,15 +3,6 @@ set(LLVM_LINK_COMPONENTS
   Support
 )
 
-# The registry source file ends up generating a lot of sections for each
-# matcher. Each matcher appears to get a vtable and several methods. Each
-# method needs .text, .pdata, .xdata, and .debug sections, adding to the
-# section multiplier. By default MSVC has a 2^16 limit on the number of
-# sections in an object file, and this needs more than that.
-if (MSVC)
-  set_source_files_properties(Registry.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
-
 add_clang_library(clangDynamicASTMatchers
   Diagnostics.cpp
   Marshallers.cpp

diff  --git a/clang/lib/CodeGen/CMakeLists.txt 
b/clang/lib/CodeGen/CMakeLists.txt
index 8afd7219fbe1..88647a2007fb 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -26,10 +26,6 @@ set(LLVM_LINK_COMPONENTS
   TransformUtils
   )
 
-if (MSVC)
-  set_source_files_properties(CodeGenModule.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-endif()
-
 add_clang_library(clangCodeGen
   BackendUtil.cpp
   CGAtomic.cpp

diff  --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index adadc06e209c..042ff561664d 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -3,15 +3,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-if (MSVC)
-  set_source_files_properties(SemaDeclAttr.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-  set_source_files_properties(SemaExpr.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(SemaExprCXX.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-  set_source_files_properties(SemaTemplate.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-  set_source_files_properties(SemaTemplateDeduction.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
-  set_source_files_properties(SemaOpenMP.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
-
 clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
   SOURCE OpenCLBuiltins.td
   TARGET ClangOpenCLBuiltinsImpl

diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index 2e750ac9ea92..2d5d0172afed 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -3,9 +3,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-if (MSVC)
-  set_source_files_properties(ASTImporterTest.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-endif()
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp

diff  --git a/clang/unittests/ASTMatchers/CMakeLists.txt 
b/clang/unittests/ASTMatchers/CMakeLists.txt
index c9ac6c57d689..b40b3886dcd2 100644
--- a/clang/unittests/ASTMatchers/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/CMakeLists.txt
@@ -3,15 +3,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-# By default MSVC has a 2^16 limit on the number of sections in an object file,
-# and this needs more than that.
-if (MSVC)
-  set_source_files_properties(InternalASTMatchersTest.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
-  set_source_files_properties(NodeMatchersTest.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
-  set_source_files_properties(NarrowingMatchersTest.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
-  set_source_files_properties(ASTTraversalMatchersTest.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
-endif()
-
 add_clang_unittest(ASTMatchersTests
   ASTMatchersInternalTest.cpp
   ASTMatchersNodeTest.cpp

diff  --git a/clang/unittests/Tooling/CMakeLists.txt 
b/clang/unittests/Tooling/CMakeLists.txt
index c439f5a78637..f290c3d2bede 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -4,14 +4,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-#

[PATCH] D84467: Add support for Branch Coverage in LLVM Source-Based Code Coverage

2020-07-28 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:4359
+  /// condition (i.e. no "&&" or "||").
+  static bool isLeafCondition(const Expr *C);
+

alanphipps wrote:
> vsk wrote:
> > vsk wrote:
> > > It might be helpful to either require that `C` be the RHS of a logical 
> > > binop (e.g. by passing the binop expr in), or to document that 
> > > requirement.
> > Given a logical binop like `E = a && !(b || c)`, 
> > `isLeafCondition(E->getRHS())` is true. That seems a bit counter-intuitive, 
> > because `E->getRHS()` contains another leaf condition. Would it make sense 
> > to rename the condition (perhaps to something like 
> > 'InstrumentedCondition')? Have I misunderstood what a leaf condition is?
> Background: isLeafCondition() is an auxiliary routine that is used during 1.) 
> counter allocation on binop RHS (CodeGenPGO.cpp), 2.) counter instrumentation 
> (CodeGenFunction.cpp), and 3.) branch region generation 
> (CoverageMappingGen.cpp).  In the #3 case, it isn't always looking at the RHS 
> of a logical binop but can be used to assess whether any condition is 
> instrumented/evaluated.
> 
> Given your example condition:
> 
> E = a && !(b || c)
> 
> You are correct that isLeafCondition(E->getRHS()) will return true, but I 
> think it should actually return false here (and bypass logical-NOT), so I 
> will adapt this. 
> 
> However, given a condition that includes an binary operator (like assign):
> 
> E = a && (x = !(b || c))
> 
> isLeafCondition(E->getRHS()) will also return true, and I think that is the 
> correct behavior.  Given that, then I agree that maybe isLeafCondition() 
> should be renamed to isInstrumentedCondition() since it's not technically 
> just leaves that are tracked in the presence of operators.
What is special about the assignment expression nested within "a && (x = !(b || 
c))" that necessitates an extra counter compared to "a && !(b || c)"?



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:46
 class SourceMappingRegion {
+  /// Primary Counter that is also used for Branch Regions for "True" branches
   Counter Count;

nit: Please end comments with a '.'



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:523
+
+RegionStack.emplace_back(Count, FalseCount, StartLoc, EndLoc,
+ FalseCount.hasValue());

It looks like this sets up a deferred region when a branch count (FalseCount) 
is available. Could you explain why, and when the deferred region is expected 
to be complete?



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:623
 // separate region for each expansion.
+// Don't do this for branch regions
 SourceLocation NestedLoc = getStartOfFileOrMacro(EndLoc);

Could you explain why there's an exception for branch regions here?



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:724
 
+  /// Determine whether the given condition folds to true or false
+  bool ConditionFoldsToBool(const Expr *Cond) {

nit: 'can be constant folded' may be slightly more idiomatic.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:742
+// function's SourceRegions) because it doesn't apply to any other source
+// code other than the Condition.
+if (CodeGenFunction::isLeafCondition(C)) {

Is there some alternative to pushing and then immediately popping branch 
regions? Did you try adding the region directly to the function's 
SourceRegions, and find that there was some issue with the more direct approach?



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:749
+  // constant-folding by ensuring that ConstantFoldsToSimpleInteger() in
+  // CodeGenFunction.c always returns false, but that is very heavy-handed.
+  if (ConditionFoldsToBool(C))

Right, I don't think that alternative is practicable.



Comment at: llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp:659
 
+void SourceCoverageViewHTML::renderBranchView(raw_ostream &OS,
+  BranchView &BRV,

Wdyt of displaying branch-taken counts using tooltips? This would match the way 
region execution counts are shown, which could be nice, because the information 
wouldn't interrupt the flow of source code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84467

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


[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 281395.
ychen added a comment.

- Add `-debug-pass-manager-verbose` to print adaptor passes. (test case in 
pass-pipeline-parsing.ll where we could ask for adaptor pass from `-passes`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84774

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/test/Transforms/LoopUnroll/revisit.ll
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll

Index: llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
===
--- llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -19,7 +19,6 @@
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
-; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
 ; NEW-PM-NOT: Running analysis:
 
 ; IR-LABEL: @f1
Index: llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
===
--- llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
+++ llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
@@ -6,20 +6,19 @@
 ; RUN: opt -S -passes='loop(require),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s
 ;
 ; CHECK: Starting llvm::Function pass manager run.
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Running analysis: LoopAnalysis
 ; CHECK: Running analysis: InnerAnalysisManagerProxy<
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner2.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on outer.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Running pass: LoopUnrollPass
 ; CHECK: Clearing all analysis results for: inner2.header
@@ -29,16 +28,15 @@
 ; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header
 ; CHECK: Invalidating all non-preserved analyses for: inner1.header.1
 ; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header:
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header.1
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header.1
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header.1:
 ; CHECK: Finished Loop pass manager run.
Index: llvm/test/Transforms/LoopUnroll/revisit.ll
===
--- llvm/test/Transforms/LoopUnroll/revisit.ll
+++ llvm/test/Transforms/LoopUnroll/revisit.ll
@@ -15,7 +15,7 @@
 ; Basic test is fully unr

[PATCH] D84794: Mark override to a function which overrides a virtual one

2020-07-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84794

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


[clang] 9cf98d2 - PR46637: Fix handling of placeholder types in trailing-return-types.

2020-07-28 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-28T15:54:10-07:00
New Revision: 9cf98d26e7b1204478cc13ae3df44a6843965c11

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

LOG: PR46637: Fix handling of placeholder types in trailing-return-types.

Only permit a placeholder type in a trailing-return-type if it would
also have been permitted in the decl-specifier sequence of a
corresponding declaration with no trailing-return-type. The standard
doesn't actually say this, but this is the only thing that makes sense.

Also fix handling of an 'auto' in a trailing-return-type in a parameter
of a generic lambda. We used to crash if we saw such a thing.

Added: 


Modified: 
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaType.cpp
clang/test/SemaCXX/auto-type-from-cxx.cpp
clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
clang/test/SemaCXX/trailing-return-0x.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 8db03babfb1e..0a22b5af7c64 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -2435,6 +2435,15 @@ class Declarator {
 return true;
 return false;
   }
+  /// Get the trailing return type appearing (at any level) within this
+  /// declarator.
+  ParsedType getTrailingReturnType() const {
+for (const auto &Chunk : type_objects())
+  if (Chunk.Kind == DeclaratorChunk::Function &&
+  Chunk.Fun.hasTrailingReturnType())
+return Chunk.Fun.getTrailingReturnType();
+return ParsedType();
+  }
 
   /// \brief Sets a trailing requires clause for this declarator.
   void setTrailingRequiresClause(Expr *TRC) {

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 63e2d0d17fca..fd4300f563a9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -8179,6 +8179,8 @@ class Sema final {
   /// Completely replace the \c auto in \p TypeWithAuto by
   /// \p Replacement. This does not retain any \c auto type sugar.
   QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
+  TypeSourceInfo *ReplaceAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto,
+QualType Replacement);
 
   /// Result type of DeduceAutoType.
   enum DeduceAutoResult {

diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 8e7b4e1655ea..1f7d0f0e8d97 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4896,6 +4896,13 @@ QualType Sema::ReplaceAutoType(QualType TypeWithAuto,
   .TransformType(TypeWithAuto);
 }
 
+TypeSourceInfo *Sema::ReplaceAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto,
+QualType TypeToReplaceAuto) {
+  return SubstituteDeducedTypeTransform(*this, TypeToReplaceAuto,
+/*UseTypeSugar*/ false)
+  .TransformType(TypeWithAuto);
+}
+
 void Sema::DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init) {
   if (isa(Init))
 Diag(VDecl->getLocation(),

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 4c7eece68bca..78c65ad01e47 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -3099,24 +3099,10 @@ static void diagnoseRedundantReturnTypeQualifiers(Sema 
&S, QualType RetTy,
   D.getDeclSpec().getUnalignedSpecLoc());
 }
 
-static void CopyTypeConstraintFromAutoType(Sema &SemaRef, const AutoType *Auto,
-   AutoTypeLoc AutoLoc,
-   TemplateTypeParmDecl *TP,
-   SourceLocation EllipsisLoc) {
-
-  TemplateArgumentListInfo TAL(AutoLoc.getLAngleLoc(), AutoLoc.getRAngleLoc());
-  for (unsigned Idx = 0; Idx < AutoLoc.getNumArgs(); ++Idx)
-TAL.addArgument(AutoLoc.getArgLoc(Idx));
-
-  SemaRef.AttachTypeConstraint(
-  AutoLoc.getNestedNameSpecifierLoc(), AutoLoc.getConceptNameInfo(),
-  AutoLoc.getNamedConcept(),
-  AutoLoc.hasExplicitTemplateArgs() ? &TAL : nullptr, TP, EllipsisLoc);
-}
-
-static QualType InventTemplateParameter(
-TypeProcessingState &state, QualType T, TypeSourceInfo *TSI, AutoType 
*Auto,
-InventedTemplateParameterInfo &Info) {
+static std::pair
+InventTemplateParameter(TypeProcessingState &state, QualType T,
+TypeSourceInfo *TrailingTSI, AutoType *Auto,
+InventedTemplateParameterInfo &Info) {
   S

[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-28 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe22de4e46d1d: [DominatorTree] Simplify ChildrenGetter. 
(authored by asbirlea).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84713

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h

Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -103,31 +103,13 @@
 // in progress, we need this information to continue it.
   }
 
-  template  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-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) {
-  if (!BUI)
-return Get(N, Tag());
+  template 
+  static SmallVector getChildren(NodePtr N, BatchUpdatePtr BUI) {
+if (BUI)
   return BUI->PreViewCFG.template getChildren(N);
-}
-  };
+GraphDiffT GD;
+return GD.template getChildren(N);
+  }
 
   NodePtr getIDom(NodePtr BB) const {
 auto InfoIt = NodeToInfo.find(BB);
@@ -194,8 +176,7 @@
   NumToNode.push_back(BB);
 
   constexpr bool Direction = IsReverse != IsPostDom;  // XOR.
-  for (const NodePtr Succ :
-   ChildrenGetter::Get(BB, BatchUpdates)) {
+  for (const NodePtr Succ : getChildren(BB, BatchUpdates)) {
 const auto SIT = NodeToInfo.find(Succ);
 // Don't visit nodes more than once but remember to collect
 // ReverseChildren.
@@ -330,7 +311,7 @@
   // to CFG nodes within infinite loops.
   static bool HasForwardSuccessors(const NodePtr N, BatchUpdatePtr BUI) {
 assert(N && "N must be a valid node");
-return !ChildrenGetter::Get(N, BUI).empty();
+return !getChildren(N, BUI).empty();
   }
 
   static NodePtr GetEntryNode(const DomTreeT &DT) {
@@ -748,8 +729,7 @@
 //
 // Invariant: there is an optimal path from `To` to TN with the minimum
 // depth being CurrentLevel.
-for (const NodePtr Succ :
- ChildrenGetter::Get(TN->getBlock(), BUI)) {
+for (const NodePtr Succ : getChildren(TN->getBlock(), BUI)) {
   const TreeNodePtr SuccTN = DT.getNode(Succ);
   assert(SuccTN &&
  "Unreachable successor found at reachable insertion");
@@ -879,7 +859,7 @@
 // the DomTree about it.
 // The check is O(N), so run it only in debug configuration.
 auto IsSuccessor = [BUI](const NodePtr SuccCandidate, const NodePtr Of) {
-  auto Successors = ChildrenGetter::Get(Of, BUI);
+  auto Successors = getChildren(Of, BUI);
   return llvm::find(Successors, SuccCandidate) != Successors.end();
 };
 (void)IsSuccessor;
@@ -967,7 +947,7 @@
 LLVM_DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN)
   << "\n");
 auto TNB = TN->getBlock();
-for (const NodePtr Pred : ChildrenGetter::Get(TNB, BUI)) {
+for (const NodePtr Pred : getChildren(TNB, BUI)) {
   LLVM_DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n");
   if (!DT.getNode(Pred)) continue;
 
Index: clang/include/clang/Analysis/Analyses/Dominators.h
===
--- clang/include/clang/Analysis/Analyses/Dominators.h
+++ clang/include/clang/Analysis/Analyses/Dominators.h
@@ -273,76 +273,6 @@
 
 namespace llvm {
 
-/// Clang's CFG contains nullpointers for unreachable succesors, e.g. when an
-/// if statement's condition is always false, it's 'then' branch is represented
-/// with a nullptr. This however will result in a nullpointer derefernece for
-/// dominator tree calculation.
-///
-/// To circumvent this, let's just crudely specialize the children getters
-/// used in LLVM's dominator tree builder.
-namespace DomTreeBuilder {
-
-using ClangCFGDomChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
- /*Inverse=*/false>;
-
-template <>
-template <>
-inline ClangCFGDomChildrenGetter::ResultTy ClangCFGDomChildrenGetter::Get(
-clang::

[clang] e22de4e - [DominatorTree] Simplify ChildrenGetter.

2020-07-28 Thread Alina Sbirlea via cfe-commits

Author: Alina Sbirlea
Date: 2020-07-28T15:44:20-07:00
New Revision: e22de4e46d1dd1aacc3a7060d24bcbe89908ba6c

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

LOG: [DominatorTree] Simplify ChildrenGetter.

Summary:
Simplify ChildrenGetter to a simple wrapper around a GraphDiff call.
GraphDiff already handles nullptr in children, so the special casing in
clang can also be removed.

Reviewers: kuhar, dblaikie

Subscribers: llvm-commits, cfe-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/Dominators.h
llvm/include/llvm/Support/GenericDomTreeConstruction.h

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/Dominators.h 
b/clang/include/clang/Analysis/Analyses/Dominators.h
index 95a661138df4..25a5ba9d83fe 100644
--- a/clang/include/clang/Analysis/Analyses/Dominators.h
+++ b/clang/include/clang/Analysis/Analyses/Dominators.h
@@ -273,76 +273,6 @@ class ControlDependencyCalculator : public ManagedAnalysis 
{
 
 namespace llvm {
 
-/// Clang's CFG contains nullpointers for unreachable succesors, e.g. when an
-/// if statement's condition is always false, it's 'then' branch is represented
-/// with a nullptr. This however will result in a nullpointer derefernece for
-/// dominator tree calculation.
-///
-/// To circumvent this, let's just crudely specialize the children getters
-/// used in LLVM's dominator tree builder.
-namespace DomTreeBuilder {
-
-using ClangCFGDomChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
- 
/*Inverse=*/false>;
-
-template <>
-template <>
-inline ClangCFGDomChildrenGetter::ResultTy ClangCFGDomChildrenGetter::Get(
-clang::CFGBlock *N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  ResultTy Ret(RChildren.begin(), RChildren.end());
-  Ret.erase(std::remove(Ret.begin(), Ret.end(), nullptr), Ret.end());
-  return Ret;
-}
-
-using ClangCFGDomReverseChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
-  
/*Inverse=*/true>;
-
-template <>
-template <>
-inline ClangCFGDomReverseChildrenGetter::ResultTy
-ClangCFGDomReverseChildrenGetter::Get(
-clang::CFGBlock *N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  ResultTy Ret(IChildren.begin(), IChildren.end());
-  Ret.erase(std::remove(Ret.begin(), Ret.end(), nullptr), Ret.end());
-  return Ret;
-}
-
-using ClangCFGPostDomChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
- 
/*Inverse=*/false>;
-
-template <>
-template <>
-inline ClangCFGPostDomChildrenGetter::ResultTy
-ClangCFGPostDomChildrenGetter::Get(
-clang::CFGBlock *N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  ResultTy Ret(RChildren.begin(), RChildren.end());
-  Ret.erase(std::remove(Ret.begin(), Ret.end(), nullptr), Ret.end());
-  return Ret;
-}
-
-using ClangCFGPostDomReverseChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
-  
/*Inverse=*/true>;
-
-template <>
-template <>
-inline ClangCFGPostDomReverseChildrenGetter::ResultTy
-ClangCFGPostDomReverseChildrenGetter::Get(
-clang::CFGBlock *N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  ResultTy Ret(IChildren.begin(), IChildren.end());
-  Ret.erase(std::remove(Ret.begin(), Ret.end(), nullptr), Ret.end());
-  return Ret;
-}
-
-} // end of namespace DomTreeBuilder
-
 //===-
 /// DominatorTree GraphTraits specialization so the DominatorTree can be
 /// iterable by generic graph iterators.

diff  --git a/llvm/include/llvm/Support/GenericDomTreeConstruction.h 
b/llvm/include/llvm/Support/GenericDomTreeConstruction.h
index 5a1f03c879db..6a9d38bceb38 100644
--- a/llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ b/llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -103,31 +103,13 @@ struct SemiNCAInfo {
 // in progress, we need this information to continue it.
   }
 
-  template  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-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

[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-28 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 281382.
asbirlea added a comment.

Renamed ChildrenGet to getChildren. The same name only exists in GraphDiff, 
it's ok to keep a consistent naming.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84713

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h

Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -103,31 +103,13 @@
 // in progress, we need this information to continue it.
   }
 
-  template  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-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) {
-  if (!BUI)
-return Get(N, Tag());
+  template 
+  static SmallVector getChildren(NodePtr N, BatchUpdatePtr BUI) {
+if (BUI)
   return BUI->PreViewCFG.template getChildren(N);
-}
-  };
+GraphDiffT GD;
+return GD.template getChildren(N);
+  }
 
   NodePtr getIDom(NodePtr BB) const {
 auto InfoIt = NodeToInfo.find(BB);
@@ -194,8 +176,7 @@
   NumToNode.push_back(BB);
 
   constexpr bool Direction = IsReverse != IsPostDom;  // XOR.
-  for (const NodePtr Succ :
-   ChildrenGetter::Get(BB, BatchUpdates)) {
+  for (const NodePtr Succ : getChildren(BB, BatchUpdates)) {
 const auto SIT = NodeToInfo.find(Succ);
 // Don't visit nodes more than once but remember to collect
 // ReverseChildren.
@@ -330,7 +311,7 @@
   // to CFG nodes within infinite loops.
   static bool HasForwardSuccessors(const NodePtr N, BatchUpdatePtr BUI) {
 assert(N && "N must be a valid node");
-return !ChildrenGetter::Get(N, BUI).empty();
+return !getChildren(N, BUI).empty();
   }
 
   static NodePtr GetEntryNode(const DomTreeT &DT) {
@@ -748,8 +729,7 @@
 //
 // Invariant: there is an optimal path from `To` to TN with the minimum
 // depth being CurrentLevel.
-for (const NodePtr Succ :
- ChildrenGetter::Get(TN->getBlock(), BUI)) {
+for (const NodePtr Succ : getChildren(TN->getBlock(), BUI)) {
   const TreeNodePtr SuccTN = DT.getNode(Succ);
   assert(SuccTN &&
  "Unreachable successor found at reachable insertion");
@@ -879,7 +859,7 @@
 // the DomTree about it.
 // The check is O(N), so run it only in debug configuration.
 auto IsSuccessor = [BUI](const NodePtr SuccCandidate, const NodePtr Of) {
-  auto Successors = ChildrenGetter::Get(Of, BUI);
+  auto Successors = getChildren(Of, BUI);
   return llvm::find(Successors, SuccCandidate) != Successors.end();
 };
 (void)IsSuccessor;
@@ -967,7 +947,7 @@
 LLVM_DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN)
   << "\n");
 auto TNB = TN->getBlock();
-for (const NodePtr Pred : ChildrenGetter::Get(TNB, BUI)) {
+for (const NodePtr Pred : getChildren(TNB, BUI)) {
   LLVM_DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n");
   if (!DT.getNode(Pred)) continue;
 
Index: clang/include/clang/Analysis/Analyses/Dominators.h
===
--- clang/include/clang/Analysis/Analyses/Dominators.h
+++ clang/include/clang/Analysis/Analyses/Dominators.h
@@ -273,76 +273,6 @@
 
 namespace llvm {
 
-/// Clang's CFG contains nullpointers for unreachable succesors, e.g. when an
-/// if statement's condition is always false, it's 'then' branch is represented
-/// with a nullptr. This however will result in a nullpointer derefernece for
-/// dominator tree calculation.
-///
-/// To circumvent this, let's just crudely specialize the children getters
-/// used in LLVM's dominator tree builder.
-namespace DomTreeBuilder {
-
-using ClangCFGDomChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
- /*Inverse=*/false>;
-
-template <>
-template <>
-inline ClangCFGDomChildrenGetter::ResultTy ClangCFGDomChildrenGetter::Get(
-clang::CFGBlock *N, std::integral_constant) {
-

[PATCH] D81442: [PowerPC] Add clang options to control MMA support

2020-07-28 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil updated this revision to Diff 281381.
bsaleil added a comment.

Update diff so it can be applied to master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81442

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-dependent-options.cpp
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCScheduleP9.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -107,6 +107,7 @@
   bool HasP10Vector;
   bool HasPrefixInstrs;
   bool HasPCRelativeMemops;
+  bool HasMMA;
   bool HasFCPSGN;
   bool HasFSQRT;
   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
@@ -260,6 +261,7 @@
   bool hasP10Vector() const { return HasP10Vector; }
   bool hasPrefixInstrs() const { return HasPrefixInstrs; }
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
+  bool hasMMA() const { return HasMMA; }
   bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -73,6 +73,7 @@
   HasP8Crypto = false;
   HasP9Vector = false;
   HasP9Altivec = false;
+  HasMMA = false;
   HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
Index: llvm/lib/Target/PowerPC/PPCScheduleP9.td
===
--- llvm/lib/Target/PowerPC/PPCScheduleP9.td
+++ llvm/lib/Target/PowerPC/PPCScheduleP9.td
@@ -41,9 +41,9 @@
   let CompleteModel = 1;
 
   // Do not support SPE (Signal Processing Engine), prefixed instructions on
-  // Power 9, paired vector mem ops, PC relative mem ops, or instructions
+  // Power 9, paired vector mem ops, MMA, PC relative mem ops, or instructions
   // introduced in ISA 3.1.
-  let UnsupportedFeatures = [HasSPE, PrefixInstrs, PairedVectorMemops,
+  let UnsupportedFeatures = [HasSPE, PrefixInstrs, PairedVectorMemops, MMA,
  PCRelativeMemops, IsISA3_1];
 }
 
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -455,6 +455,7 @@
 def PrefixInstrs : Predicate<"Subtarget->hasPrefixInstrs()">;
 def IsISA3_1 : Predicate<"Subtarget->isISA3_1()">;
 def PairedVectorMemops : Predicate<"PPCSubTarget->pairedVectorMemops()">;
+def MMA : Predicate<"PPCSubTarget->hasMMA()">;
 
 let Predicates = [PrefixInstrs] in {
   let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -238,6 +238,10 @@
   SubtargetFeature<"paired-vector-memops", "PairedVectorMemops", "true",
"32Byte load and store instructions",
[FeatureISA3_0]>;
+def FeatureMMA : SubtargetFeature<"mma", "HasMMA", "true",
+  "Enable MMA instructions",
+  [FeatureP8Vector, FeatureP9Altivec,
+   FeaturePairedVectorMemops]>;
 
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
@@ -343,7 +347,8 @@
   // still exist with the exception of those we know are Power9 specific.
   list P10AdditionalFeatures =
 [DirectivePwr10, FeatureISA3_1, FeaturePrefixInstrs,
- FeaturePCRelativeMemops, FeatureP10Vector, FeaturePairedVecto

[PATCH] D84414: [RISCV] Support Shadow Call Stack

2020-07-28 Thread Z. Zheng via Phabricator via cfe-commits
zzheng updated this revision to Diff 281377.
zzheng added a comment.

rebased..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84414

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/test/CodeGen/shadowcallstack-attr.c
  clang/test/Driver/sanitizer-ld.c
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.h
  llvm/test/CodeGen/RISCV/shadowcallstack.ll

Index: llvm/test/CodeGen/RISCV/shadowcallstack.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/shadowcallstack.ll
@@ -0,0 +1,174 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s --check-prefix=RV32
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s --check-prefix=RV64
+
+define void @f1() shadowcallstack {
+; RV32-LABEL: f1:
+; RV32:   # %bb.0:
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f1:
+; RV64:   # %bb.0:
+; RV64-NEXT:ret
+  ret void
+}
+
+declare void @foo()
+
+define void @f2() shadowcallstack {
+; RV32-LABEL: f2:
+; RV32:   # %bb.0:
+; RV32-NEXT:tail foo
+;
+; RV64-LABEL: f2:
+; RV64:   # %bb.0:
+; RV64-NEXT:tail foo
+  tail call void @foo()
+  ret void
+}
+
+declare i32 @bar()
+
+define i32 @f3() shadowcallstack {
+; RV32-LABEL: f3:
+; RV32:   # %bb.0:
+; RV32-NEXT:sw ra, 0(s2)
+; RV32-NEXT:addi s2, s2, 4
+; RV32-NEXT:addi sp, sp, -16
+; RV32-NEXT:.cfi_def_cfa_offset 16
+; RV32-NEXT:sw ra, 12(sp)
+; RV32-NEXT:.cfi_offset ra, -4
+; RV32-NEXT:call bar
+; RV32-NEXT:lw ra, 12(sp)
+; RV32-NEXT:addi sp, sp, 16
+; RV32-NEXT:addi s2, s2, -4
+; RV32-NEXT:lw ra, 0(s2)
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f3:
+; RV64:   # %bb.0:
+; RV64-NEXT:sd ra, 0(s2)
+; RV64-NEXT:addi s2, s2, 8
+; RV64-NEXT:addi sp, sp, -16
+; RV64-NEXT:.cfi_def_cfa_offset 16
+; RV64-NEXT:sd ra, 8(sp)
+; RV64-NEXT:.cfi_offset ra, -8
+; RV64-NEXT:call bar
+; RV64-NEXT:ld ra, 8(sp)
+; RV64-NEXT:addi sp, sp, 16
+; RV64-NEXT:addi s2, s2, -8
+; RV64-NEXT:ld ra, 0(s2)
+; RV64-NEXT:ret
+  %res = call i32 @bar()
+  %res1 = add i32 %res, 1
+  ret i32 %res
+}
+
+define i32 @f4() shadowcallstack {
+; RV32-LABEL: f4:
+; RV32:   # %bb.0:
+; RV32-NEXT:sw ra, 0(s2)
+; RV32-NEXT:addi s2, s2, 4
+; RV32-NEXT:addi sp, sp, -16
+; RV32-NEXT:.cfi_def_cfa_offset 16
+; RV32-NEXT:sw ra, 12(sp)
+; RV32-NEXT:sw s0, 8(sp)
+; RV32-NEXT:sw s1, 4(sp)
+; RV32-NEXT:sw s3, 0(sp)
+; RV32-NEXT:.cfi_offset ra, -4
+; RV32-NEXT:.cfi_offset s0, -8
+; RV32-NEXT:.cfi_offset s1, -12
+; RV32-NEXT:.cfi_offset s3, -16
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s3, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s1, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s0, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:add a1, s3, s1
+; RV32-NEXT:add a0, s0, a0
+; RV32-NEXT:add a0, a1, a0
+; RV32-NEXT:lw s3, 0(sp)
+; RV32-NEXT:lw s1, 4(sp)
+; RV32-NEXT:lw s0, 8(sp)
+; RV32-NEXT:lw ra, 12(sp)
+; RV32-NEXT:addi sp, sp, 16
+; RV32-NEXT:addi s2, s2, -4
+; RV32-NEXT:lw ra, 0(s2)
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f4:
+; RV64:   # %bb.0:
+; RV64-NEXT:sd ra, 0(s2)
+; RV64-NEXT:addi s2, s2, 8
+; RV64-NEXT:addi sp, sp, -32
+; RV64-NEXT:.cfi_def_cfa_offset 32
+; RV64-NEXT:sd ra, 24(sp)
+; RV64-NEXT:sd s0, 16(sp)
+; RV64-NEXT:sd s1, 8(sp)
+; RV64-NEXT:sd s3, 0(sp)
+; RV64-NEXT:.cfi_offset ra, -8
+; RV64-NEXT:.cfi_offset s0, -16
+; RV64-NEXT:.cfi_offset s1, -24
+; RV64-NEXT:.cfi_offset s3, -32
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s3, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s1, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s0, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:add a1, s3, s1
+; RV64-NEXT:add a0, s0, a0
+; RV64-NEXT:addw a0, a1, a0
+; RV64-NEXT:ld s3, 0(sp)
+; RV64-NEXT:ld s1, 8(sp)
+; RV64-NEXT:ld s0, 16(sp)
+; RV64-NEXT:ld ra, 24(sp)
+; RV64-NEXT:addi sp, sp, 32
+; RV64-NEXT:addi s2, s2, -8
+; RV64-NEXT:ld ra, 0(s2)
+; RV64-NEXT:ret
+  %res1 = call i32 @bar()
+  %res2 = call i32 @bar()
+  %res3 = call i32 @bar()
+  %res4 = call i32 @bar()
+  %res12 = add i32 %res1, %res2
+  %res34 = add i32 %res3, %res4
+  %res1234 = add i32 %res12, %res34
+  ret i32 %res1234
+}
+
+define i32 @f5() shadowcallstack nounwind {
+; RV32-LABEL: f5:
+; RV32:   # %bb.0:
+; RV32-NEXT:sw ra, 0(s2)
+; RV32-NEXT:addi s2, s2, 4
+; RV32-NEXT:addi sp, sp, -16
+; RV32-NEXT:sw ra, 12(sp)
+; RV32-NEXT:call bar
+; RV32-NEXT:lw ra, 12(sp)
+; RV32-NEXT:addi sp, sp, 

[PATCH] D84767: [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in target region.

2020-07-28 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

This patch
GPU activities:   96.99%  350.05ms10  35.005ms  1.5680us  350.00ms  
[CUDA memcpy HtoD]
before the July21 change
GPU activities:   95.33%  20.317ms 4  5.0793ms  1.6000us  20.305ms  
[CUDA memcpy HtoD]
Still more transfer than it should.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84767

___
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-28 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders updated this revision to Diff 281376.
dsanders added a comment.

Remove external- prefix


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 -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
@@ -4604,7 +4604,17 @@
   StringRef BaseName;
 
   // Dsymutil actions should use the full path.
-  if (isa(JA) || isa(JA))
+  if (isa(JA) && C.getArgs().hasArg(options::OPT_dsym_dir)) 
{
+SmallString<128> ExternalPath(
+C.getArgs().getLastArg(options::OPT_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
@@ -672,6 +672,9 @@
   HelpText<"Filename to write DOT-formatted header dependencies to">;
 def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
   Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">;
+def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,
+  Flags<[DriverOption, RenderAsInput]>,
+  HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">;
 def dumpmachine : Flag<["-"], "dumpmachine">;
 def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
 def dumpversion : Flag<["-"], "dumpversion">;


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 %

[PATCH] D84658: [clang] Overload NamedDecl::printName to provide a user-friendly name for unnamed entities

2020-07-28 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 281373.
riccibruno added a comment.

Add the forgotten context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84658

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/PrettyPrinter.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/CXX/special/class.dtor/p5-0x.cpp
  clang/test/Index/annotate-comments-typedef.m
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/c-index-api-loadTU-test.m
  clang/test/Index/c-index-getCursor-test.m
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-bitwidth.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/targeted-annotation.c
  clang/test/Index/targeted-cursor.c
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/Sema/address-packed.c
  clang/test/Sema/attr-flag-enum.c
  clang/test/Sema/transparent-union.c
  clang/test/SemaCXX/attr-unused.cpp
  clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/ms-interface.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/SemaObjCXX/arc-0x.mm
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp

Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -825,7 +825,7 @@
 | |-FieldDecl ''
 | |-FieldDecl ''
 | |-FieldDecl ''
-| `-CXXDestructorDecl '~'
+| `-CXXDestructorDecl '~(unnamed class at input.cc:9:3)'
 |-ImplicitCastExpr
 | `-DeclRefExpr 'a'
 |-DeclRefExpr 'b'
Index: clang/test/Tooling/clang-diff-ast.cpp
===
--- clang/test/Tooling/clang-diff-ast.cpp
+++ clang/test/Tooling/clang-diff-ast.cpp
@@ -56,7 +56,7 @@
   int not_initialized;
   // CHECK: CXXConstructorDecl: :X(void (char, int){{( __attribute__\(\(thiscall\)\))?}})(
   // CHECK-NEXT: ParmVarDecl: s(char)
-  // CHECK-NEXT: ParmVarDecl: (int)
+  // CHECK-NEXT: ParmVarDecl: (unnamed variable at {{.*}}:64:16 of type int)(int)
   // CHECK-NEXT: CXXCtorInitializer: Base
   // CHECK-NEXT: CXXConstructExpr
   // CHECK-NEXT: CXXCtorInitializer: m
Index: clang/test/SemaObjCXX/arc-0x.mm
===
--- clang/test/SemaObjCXX/arc-0x.mm
+++ clang/test/SemaObjCXX/arc-0x.mm
@@ -154,15 +154,17 @@
   // functions of the containing class.
   struct S0 {
 union {
-  id f0; // expected-note 6 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  id f0; // expected-note-re 6 {{of '(anonymous union at {{.*}}:156:5)' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   char f1;
 };
   };
 
   struct S1 {
 union {
-  union { // expected-note {{copy constructor of 'S1' is implicitly deleted because field '' has a deleted copy constructor}} expected-note {{copy assignment operator of 'S1' is implicitly deleted because field '' has a deleted copy assignment operator}} expected-note 4 {{'S1' is implicitly deleted because field '' has a deleted}}
-id f0; // expected-note 2 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  union {  // expected-note-re {{copy constructor of 'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at {{.*}}:164:7))' has a deleted copy constructor}}
+   // expected-note-re@-1 {{copy assignment operator of 'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at{{.*}}:164:7))' has a deleted copy assignment operator}}
+   // expected-note-re@-2 4{{'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at {{.*}}:164:7))' has a deleted}}
+id f0; // expected-note-re 2 {{of '(anonymous union at {{.*}}:164:7)' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
 char f1;
   };
   int f2;
@@ -172,7 +174,7 @@
   struct S2 {
 union {
   // FIXME: the note should say 'f0' is causing the special functions to be deleted.
-  struct { // expected-note 6 {{'S2' is implicitly deleted because variant field '' has a non-trivial}}
+  struct { // expected-note-re 6 {{of 'S2' is implicitly deleted because variant field '(unnamed field of type test_union::S2::(anonymous struct at {{.*}}:177:7))' has a non-trivial}}
 id f0;
 int f1;
   };
@@ -190,13 +192,13 @@
   S2 *x6;
 

[PATCH] D84658: [clang] Overload NamedDecl::printName to provide a user-friendly name for unnamed entities

2020-07-28 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 281371.
riccibruno edited the summary of this revision.
riccibruno added a comment.

Use a less generic name instead of `get{Open,Close}Delimiter`. I went with 
`get{Open,Close}DelimiterForUnnamedEntity` but I am happy to change it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84658

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/PrettyPrinter.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/CXX/special/class.dtor/p5-0x.cpp
  clang/test/Index/annotate-comments-typedef.m
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/c-index-api-loadTU-test.m
  clang/test/Index/c-index-getCursor-test.m
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-bitwidth.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/targeted-annotation.c
  clang/test/Index/targeted-cursor.c
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/Sema/address-packed.c
  clang/test/Sema/attr-flag-enum.c
  clang/test/Sema/transparent-union.c
  clang/test/SemaCXX/attr-unused.cpp
  clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/ms-interface.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/SemaObjCXX/arc-0x.mm
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp

Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -825,7 +825,7 @@
 | |-FieldDecl ''
 | |-FieldDecl ''
 | |-FieldDecl ''
-| `-CXXDestructorDecl '~'
+| `-CXXDestructorDecl '~(unnamed class at input.cc:9:3)'
 |-ImplicitCastExpr
 | `-DeclRefExpr 'a'
 |-DeclRefExpr 'b'
Index: clang/test/Tooling/clang-diff-ast.cpp
===
--- clang/test/Tooling/clang-diff-ast.cpp
+++ clang/test/Tooling/clang-diff-ast.cpp
@@ -56,7 +56,7 @@
   int not_initialized;
   // CHECK: CXXConstructorDecl: :X(void (char, int){{( __attribute__\(\(thiscall\)\))?}})(
   // CHECK-NEXT: ParmVarDecl: s(char)
-  // CHECK-NEXT: ParmVarDecl: (int)
+  // CHECK-NEXT: ParmVarDecl: (unnamed variable at {{.*}}:64:16 of type int)(int)
   // CHECK-NEXT: CXXCtorInitializer: Base
   // CHECK-NEXT: CXXConstructExpr
   // CHECK-NEXT: CXXCtorInitializer: m
Index: clang/test/SemaObjCXX/arc-0x.mm
===
--- clang/test/SemaObjCXX/arc-0x.mm
+++ clang/test/SemaObjCXX/arc-0x.mm
@@ -154,15 +154,17 @@
   // functions of the containing class.
   struct S0 {
 union {
-  id f0; // expected-note 6 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  id f0; // expected-note-re 6 {{of '(anonymous union at {{.*}}:156:5)' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   char f1;
 };
   };
 
   struct S1 {
 union {
-  union { // expected-note {{copy constructor of 'S1' is implicitly deleted because field '' has a deleted copy constructor}} expected-note {{copy assignment operator of 'S1' is implicitly deleted because field '' has a deleted copy assignment operator}} expected-note 4 {{'S1' is implicitly deleted because field '' has a deleted}}
-id f0; // expected-note 2 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  union {  // expected-note-re {{copy constructor of 'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at {{.*}}:164:7))' has a deleted copy constructor}}
+   // expected-note-re@-1 {{copy assignment operator of 'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at{{.*}}:164:7))' has a deleted copy assignment operator}}
+   // expected-note-re@-2 4{{'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at {{.*}}:164:7))' has a deleted}}
+id f0; // expected-note-re 2 {{of '(anonymous union at {{.*}}:164:7)' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
 char f1;
   };
   int f2;
@@ -172,7 +174,7 @@
   struct S2 {
 union {
   // FIXME: the note should say 'f0' is causing the special functions to be deleted.
-  struct { // expected-note 6 {{'S2' is implicitly deleted because variant field '' has a non-trivial}}
+  struct { // expected-note-re 6 {{of 'S2' is implicitly deleted because variant field '(unn

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

We may also need to bump both the raw and index format version with this 
change. For the profile use side, we also need to keep the hashing scheme of 
the older version (in profile-use side).  More details to come.

Many tests can also be enhanced to filter out the hash details if they are not 
part the main test.




Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:623
 // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
-// value of each BB in the CFG. The higher 32 bits record the number of edges.
+// value of each BB in the CFG. The higher 32 bits are the CR32 of the numbers
+// of selects, indirect calls, mem ops and edges.

MaskRay wrote:
> To make sure I understand: we use two CRCs instead of one CRC because we want 
> to extract low/high 32 bits for debugging purposes?
> 
> Otherwise, we can just use one CRC.
JamCRC produces a 32bit value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:660
   // information.
-  FunctionHash = (uint64_t)SIVisitor.getNumOfSelectInsts() << 56 |
- (uint64_t)ValueSites[IPVK_IndirectCallTarget].size() << 48 |
- //(uint64_t)ValueSites[IPVK_MemOPSize].size() << 40 |
- (uint64_t)MST.AllEdges.size() << 32 | JC.getCRC();
+  FunctionHash = ((uint64_t)JCH.getCRC()) << 32 | JC.getCRC();
+

Actually I think it'd be better to shift by 28 here rather than throwing out 
the top 4 bits for reservation. Also, adding would be better than or'ing. Will 
update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:623
 // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
-// value of each BB in the CFG. The higher 32 bits record the number of edges.
+// value of each BB in the CFG. The higher 32 bits are the CR32 of the numbers
+// of selects, indirect calls, mem ops and edges.

MaskRay wrote:
> To make sure I understand: we use two CRCs instead of one CRC because we want 
> to extract low/high 32 bits for debugging purposes?
> 
> Otherwise, we can just use one CRC.
JamCRC's result is 32-bit, but we have 64-bit (actually 60-bits) of spare room. 
Using more bits should decrease the chance of hash collisions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84767: [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in target region.

2020-07-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 281369.
ABataev added a comment.

Fixed ref count for base pointer + extra test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84767

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/test/env/base_ptr_ref_count.c

Index: openmp/libomptarget/test/env/base_ptr_ref_count.c
===
--- /dev/null
+++ openmp/libomptarget/test/env/base_ptr_ref_count.c
@@ -0,0 +1,51 @@
+// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 | %fcheck-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 | %fcheck-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 | %fcheck-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compile-x86_64-pc-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-x86_64-pc-linux-gnu 2>&1 | %fcheck-x86_64-pc-linux-gnu
+// RUN: %libomptarget-compile-nvptx64-nvidia-cuda && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-nvptx64-nvidia-cuda 2>&1 | %fcheck-nvptx64-nvidia-cuda
+// REQUIRES: libomptarget-debug
+
+#include 
+
+int *allocate(size_t n) {
+  int *ptr = malloc(sizeof(int) * n);
+#pragma omp target enter data map(to : ptr[:n])
+  return ptr;
+}
+
+void deallocate(int *ptr, size_t n) {
+#pragma omp target exit data map(delete : ptr[:n])
+  free(ptr);
+}
+
+#pragma omp declare target
+int *cnt;
+void foo() {
+  ++(*cnt);
+}
+#pragma omp end declare target
+
+int main(void) {
+  int *A = allocate(10);
+  int *V = allocate(10);
+  deallocate(A, 10);
+  deallocate(V, 10);
+// CHECK-NOT: RefCount=2
+  cnt = malloc(sizeof(int));
+  *cnt = 0;
+#pragma omp target map(cnt[:1])
+  foo();
+  printf("Cnt = %d.\n", *cnt);
+// CHECK: Cnt = 1.
+  *cnt = 0;
+#pragma omp target data map(cnt[:1])
+#pragma omp target
+  foo();
+  printf("Cnt = %d.\n", *cnt);
+// CHECK: Cnt = 1.
+  free(cnt);
+
+  return 0;
+}
+
+
Index: openmp/libomptarget/src/omptarget.cpp
===
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -316,6 +316,11 @@
 // may be considered a hack, we could revise the scheme in the future.
 bool UpdateRef = !(arg_types[i] & OMP_TGT_MAPTYPE_MEMBER_OF);
 if (arg_types[i] & OMP_TGT_MAPTYPE_PTR_AND_OBJ) {
+  // Without OMP_TGT_MAPTYPE_MEMBER_OF, OMP_TGT_MAPTYPE_PTR_AND_OBJ can be
+  // used only if complex data with base pointer is mapped. No need to
+  // update ref counter for the base pointer in this case.
+  UpdateRef =
+  UpdateRef && (RTLs->RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY);
   DP("Has a pointer entry: \n");
   // Base is address of pointer.
   //
@@ -872,14 +877,9 @@
   return OFFLOAD_FAIL;
 }
   }
-} else if (arg_types[i] & OMP_TGT_MAPTYPE_PTR_AND_OBJ) {
-  TgtPtrBegin = Device.getTgtPtrBegin(HstPtrBase, sizeof(void *), IsLast,
-  false, IsHostPtr);
-  TgtBaseOffset = 0; // no offset for ptrs.
-  DP("Obtained target argument " DPxMOD " from host pointer " DPxMOD " to "
- "object " DPxMOD "\n", DPxPTR(TgtPtrBegin), DPxPTR(HstPtrBase),
- DPxPTR(HstPtrBase));
 } else {
+  if (arg_types[i] & OMP_TGT_MAPTYPE_PTR_AND_OBJ)
+HstPtrBase = *reinterpret_cast(HstPtrBase);
   TgtPtrBegin = Device.getTgtPtrBegin(HstPtrBegin, arg_sizes[i], IsLast,
   false, IsHostPtr);
   TgtBaseOffset = (intptr_t)HstPtrBase - (intptr_t)HstPtrBegin;
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -310,18 +310,18 @@
 
 #ifdef CK5
 
-// CK5: [[SIZE00:@.+]] = {{.+}}constant [2 x i[[sz:64|32]]] [i{{64|32}} {{8|4}}, i{{64|32}} 4]
-// CK5: [[MTYPE00:@.+]] = {{.+}}constant [2 x i64] [i64 33, i64 17]
+// CK5: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
+// CK5: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 49]
 
 // CK5-LABEL: lvalue
 void lvalue(int *B, int l, int e) {
 
-  // CK5-DAG: call void @__tgt_target_data_update_mapper(i64 -1, i32 2, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[2 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[2 x i{{.+}}]* [[MTYPE00]]{{.+}}, i8** null)
+  // CK5-DAG: call void @__tgt_target_data_update_mapper(i64 -1, i32 1, i8** [[GEPBP:%.+]], i8

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:623
 // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
-// value of each BB in the CFG. The higher 32 bits record the number of edges.
+// value of each BB in the CFG. The higher 32 bits are the CR32 of the numbers
+// of selects, indirect calls, mem ops and edges.

To make sure I understand: we use two CRCs instead of one CRC because we want 
to extract low/high 32 bits for debugging purposes?

Otherwise, we can just use one CRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:642
 
   // Hash format for context sensitive profile. Reserve 4 bits for other
   // information.

davidxl wrote:
> The comment looks stale.
I think the 4 bits are still reserved for CSPGO. See 
https://reviews.llvm.org/rG6cdf3d8086fe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-28 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281364.
yamauchi added a comment.
Herald added subscribers: cfe-commits, dexonsmith, steven_wu.
Herald added a project: clang.

Use JamCRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 519522107823649919, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32

[PATCH] D84736: [analyzer][RFC] Handle pointer difference of ElementRegion and SymbolicRegion

2020-07-28 Thread Balázs Benics via Phabricator via cfe-commits
steakhal planned changes to this revision.
steakhal added a comment.

Thank you all for the comments.

In D84736#2179828 , @NoQ wrote:

> I think the overall idea is correct.

So I will keep going in this direction, you can expect the more complex version 
of this.
I plan to reuse this revision.

So we can formalize this logic like this: 
//for all// `MemReg`, and `Y`: `&Element{MemReg,Y,char} - &MemReg` => `Y`




Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:1059-1060
+return UnknownVal();
+  if (Optional LeftIndex = MaybeNonLocIndexOfElementRegion(LeftER))
+return LeftIndex.getValue();
+  return UnknownVal();

NoQ wrote:
> You'll have to multiply by the size of a single element - it's an index, not 
> an offset.
Nice catch.



Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:1067-1069
+llvm_unreachable(
+"TODO: return the negated value of RightIndex - figure out how 
:D\n"
+"Maybe a unary minus operator would do the job.");

NoQ wrote:
> Yeah, sounds like we'll have to stick to `UnknownVal` for now when 
> `RightIndex` is symbolic. You can easily compute unary minus for a concrete 
> index though, and that'll probably be your most important case anyway.
I managed to get around this by turning the unary minus into a binary 
substitution from zero (using `ArrayIndexTy` type).
Although I should have improved the `SimpleSValBuilder::minus` function to 
handle other svals besides concrete ints instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84736

___
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-28 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8843
 llvm::Value *&MapTypesArrayArg, llvm::Value *&MappersArrayArg,
-CGOpenMPRuntime::TargetDataInfo &Info) {
+CGOpenMPRuntime::TargetDataInfo &Info, bool ForEndCall = false) {
+  assert((!ForEndCall || Info.separateBeginEndCalls()) &&

ABataev wrote:
> Do not append param here, use the one from `Info`
`Info.SeparateBeginEndCalls` and `ForEndCall` do not represent the same thing.  
If `Info.SeparateBeginEndCalls=true`, as in `emitTargetDataCalls` below, then 
`emitOffloadingArraysArgument` is called twice with the same `Info`, once with 
`ForEndCall=false` and once with `ForEndCall=true`.


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] D84711: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

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

Thanks!


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

https://reviews.llvm.org/D84711

___
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-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8843
 llvm::Value *&MapTypesArrayArg, llvm::Value *&MappersArrayArg,
-CGOpenMPRuntime::TargetDataInfo &Info) {
+CGOpenMPRuntime::TargetDataInfo &Info, bool ForEndCall = false) {
+  assert((!ForEndCall || Info.separateBeginEndCalls()) &&

Do not append param here, use the one from `Info`


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] D84666: [NFC] Sema: use checkArgCount instead of custom checking

2020-07-28 Thread JF Bastien via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG389f009c5757: [NFC] Sema: use checkArgCount instead of 
custom checking (authored by jfb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84666

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-error.c
  clang/test/SemaOpenCL/to_addr_builtin.cl

Index: clang/test/SemaOpenCL/to_addr_builtin.cl
===
--- clang/test/SemaOpenCL/to_addr_builtin.cl
+++ clang/test/SemaOpenCL/to_addr_builtin.cl
@@ -15,7 +15,7 @@
   // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
   // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
-  // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
+  // expected-error@-5{{too many arguments to function call, expected 1, have 2}}
 #endif
 
   int x;
Index: clang/test/CodeGen/builtins-ppc-error.c
===
--- clang/test/CodeGen/builtins-ppc-error.c
+++ clang/test/CodeGen/builtins-ppc-error.c
@@ -32,16 +32,16 @@
 }
 
 void testXXPERMDI(int index) {
-  vec_xxpermdi(vsi); //expected-error {{too few arguments to function call, expected at least 3, have 1}}
-  vec_xxpermdi(vsi, vsi, 2, 4); //expected-error {{too many arguments to function call, expected at most 3, have 4}}
+  vec_xxpermdi(vsi); //expected-error {{too few arguments to function call, expected 3, have 1}}
+  vec_xxpermdi(vsi, vsi, 2, 4); //expected-error {{too many arguments to function call, expected 3, have 4}}
   vec_xxpermdi(vsi, vsi, index); //expected-error {{argument 3 to '__builtin_vsx_xxpermdi' must be a 2-bit unsigned literal (i.e. 0, 1, 2 or 3)}}
   vec_xxpermdi(1, 2, 3); //expected-error {{first two arguments to '__builtin_vsx_xxpermdi' must be vectors}}
   vec_xxpermdi(vsi, vuc, 2); //expected-error {{first two arguments to '__builtin_vsx_xxpermdi' must have the same type}}
 }
 
 void testXXSLDWI(int index) {
-  vec_xxsldwi(vsi); //expected-error {{too few arguments to function call, expected at least 3, have 1}}
-  vec_xxsldwi(vsi, vsi, 2, 4); //expected-error {{too many arguments to function call, expected at most 3, have 4}}
+  vec_xxsldwi(vsi); //expected-error {{too few arguments to function call, expected 3, have 1}}
+  vec_xxsldwi(vsi, vsi, 2, 4); //expected-error {{too many arguments to function call, expected 3, have 4}}
   vec_xxsldwi(vsi, vsi, index); //expected-error {{argument 3 to '__builtin_vsx_xxsldwi' must be a 2-bit unsigned literal (i.e. 0, 1, 2 or 3)}}
   vec_xxsldwi(1, 2, 3); //expected-error {{first two arguments to '__builtin_vsx_xxsldwi' must be vectors}}
   vec_xxsldwi(vsi, vuc, 2); //expected-error {{first two arguments to '__builtin_vsx_xxsldwi' must have the same type}}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1274,11 +1274,8 @@
 // \return True if a semantic error has been found, false otherwise.
 static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID,
 CallExpr *Call) {
-  if (Call->getNumArgs() != 1) {
-S.Diag(Call->getBeginLoc(), diag::err_opencl_builtin_to_addr_arg_num)
-<< Call->getDirectCallee() << Call->getSourceRange();
+  if (checkArgCount(S, Call, 1))
 return true;
-  }
 
   auto RT = Call->getArg(0)->getType();
   if (!RT->isPointerType() || RT->getPointeeType()
@@ -5572,21 +5569,8 @@
   if (checkVAStartABI(*this, BuiltinID, Fn))
 return true;
 
-  if (TheCall->getNumArgs() > 2) {
-Diag(TheCall->getArg(2)->getBeginLoc(),
- diag::err_typecheck_call_too_many_args)
-<< 0 /*function call*/ << 2 << TheCall->getNumArgs()
-<< Fn->getSourceRange()
-<< SourceRange(TheCall->getArg(2)->getBeginLoc(),
-   (*(TheCall->arg_end() - 1))->getEndLoc());
+  if (checkArgCount(*this, TheCall, 2))
 return true;
-  }
-
-  if (TheCall->getNumArgs() < 2) {
-return Diag(TheCall->getEndLoc(),
-diag::err_typecheck_call_too_few_args_at_least)
-   << 0 /*function call*/ << 2 << TheCall->getNumArgs();
-  }
 
   // Type-check the first argument normally.
   if (checkBuiltinArgument(*this, TheCall, 0))
@@ -5696,15 +5680,8 @@
 /// SemaBuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
 /// friends.  This is declared to take (...), so we have to check everything.
 bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
-  if (TheCall->getNumArgs() < 2)
-return Diag(TheCall->getEndLoc(), diag::err_typecheck_call

[PATCH] D84711: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-28 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


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

https://reviews.llvm.org/D84711

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


[clang] 389f009 - [NFC] Sema: use checkArgCount instead of custom checking

2020-07-28 Thread JF Bastien via cfe-commits

Author: JF Bastien
Date: 2020-07-28T13:41:06-07:00
New Revision: 389f009c5757cf09c0b2d77a15b3b541fb0f2a1c

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

LOG: [NFC] Sema: use checkArgCount instead of custom checking

 As requested in D79279.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-error.c
clang/test/SemaOpenCL/to_addr_builtin.cl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index adfd4c207da8..8093e7ed3fbe 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9724,8 +9724,6 @@ def err_opencl_block_ref_block : Error<
   "cannot refer to a block inside block">;
 
 // OpenCL v2.0 s6.13.9 - Address space qualifier functions.
-def err_opencl_builtin_to_addr_arg_num : Error<
-  "invalid number of arguments to function: %0">;
 def err_opencl_builtin_to_addr_invalid_arg : Error<
   "invalid argument %0 to function: %1, expecting a generic pointer argument">;
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 77d5f3ff816e..ccdb277dda1a 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1274,11 +1274,8 @@ static bool SemaBuiltinPipePackets(Sema &S, CallExpr 
*Call) {
 // \return True if a semantic error has been found, false otherwise.
 static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID,
 CallExpr *Call) {
-  if (Call->getNumArgs() != 1) {
-S.Diag(Call->getBeginLoc(), diag::err_opencl_builtin_to_addr_arg_num)
-<< Call->getDirectCallee() << Call->getSourceRange();
+  if (checkArgCount(S, Call, 1))
 return true;
-  }
 
   auto RT = Call->getArg(0)->getType();
   if (!RT->isPointerType() || RT->getPointeeType()
@@ -5572,21 +5569,8 @@ bool Sema::SemaBuiltinVAStart(unsigned BuiltinID, 
CallExpr *TheCall) {
   if (checkVAStartABI(*this, BuiltinID, Fn))
 return true;
 
-  if (TheCall->getNumArgs() > 2) {
-Diag(TheCall->getArg(2)->getBeginLoc(),
- diag::err_typecheck_call_too_many_args)
-<< 0 /*function call*/ << 2 << TheCall->getNumArgs()
-<< Fn->getSourceRange()
-<< SourceRange(TheCall->getArg(2)->getBeginLoc(),
-   (*(TheCall->arg_end() - 1))->getEndLoc());
+  if (checkArgCount(*this, TheCall, 2))
 return true;
-  }
-
-  if (TheCall->getNumArgs() < 2) {
-return Diag(TheCall->getEndLoc(),
-diag::err_typecheck_call_too_few_args_at_least)
-   << 0 /*function call*/ << 2 << TheCall->getNumArgs();
-  }
 
   // Type-check the first argument normally.
   if (checkBuiltinArgument(*this, TheCall, 0))
@@ -5696,15 +5680,8 @@ bool Sema::SemaBuiltinVAStartARMMicrosoft(CallExpr 
*Call) {
 /// SemaBuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
 /// friends.  This is declared to take (...), so we have to check everything.
 bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
-  if (TheCall->getNumArgs() < 2)
-return Diag(TheCall->getEndLoc(), diag::err_typecheck_call_too_few_args)
-   << 0 << 2 << TheCall->getNumArgs() /*function call*/;
-  if (TheCall->getNumArgs() > 2)
-return Diag(TheCall->getArg(2)->getBeginLoc(),
-diag::err_typecheck_call_too_many_args)
-   << 0 /*function call*/ << 2 << TheCall->getNumArgs()
-   << SourceRange(TheCall->getArg(2)->getBeginLoc(),
-  (*(TheCall->arg_end() - 1))->getEndLoc());
+  if (checkArgCount(*this, TheCall, 2))
+return true;
 
   ExprResult OrigArg0 = TheCall->getArg(0);
   ExprResult OrigArg1 = TheCall->getArg(1);
@@ -5742,15 +5719,8 @@ bool Sema::SemaBuiltinUnorderedCompare(CallExpr 
*TheCall) {
 /// to check everything. We expect the last argument to be a floating point
 /// value.
 bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) {
-  if (TheCall->getNumArgs() < NumArgs)
-return Diag(TheCall->getEndLoc(), diag::err_typecheck_call_too_few_args)
-   << 0 << NumArgs << TheCall->getNumArgs() /*function call*/;
-  if (TheCall->getNumArgs() > NumArgs)
-return Diag(TheCall->getArg(NumArgs)->getBeginLoc(),
-diag::err_typecheck_call_too_many_args)
-   << 0 /*function call*/ << NumArgs << TheCall->getNumArgs()
-   << SourceRange(TheCall->getArg(NumArgs)->getBeginLoc(),
-  (*(TheCall->arg_end() - 1))->getEndLoc());
+  if (checkArgCount(*this, TheCall, NumArgs))
+return true;
 
   // __builtin_fpclassify is the only case where NumA

[clang] 740a164 - PR46377: Fix dependence calculation for function types and typedef

2020-07-28 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-28T13:23:13-07:00
New Revision: 740a164dec483225cbd02ab6c82199e2747ffacb

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

LOG: PR46377: Fix dependence calculation for function types and typedef
types.

We previously did not treat a function type as dependent if it had a
parameter pack with a non-dependent type -- such a function type depends
on the arity of the pack so is dependent even though none of the
parameter types is dependent. In order to properly handle this, we now
treat pack expansion types as always being dependent types (depending on
at least the pack arity), and always canonically being pack expansion
types, even in the unusual case when the pattern is not a dependent
type. This does mean that we can have canonical types that are pack
expansions that contain no unexpanded packs, which is unfortunate but
not inaccurate.

We also previously did not treat a typedef type as
instantiation-dependent if its canonical type was not
instantiation-dependent. That's wrong because instantiation-dependence
is a property of the type sugar, not of the type; an
instantiation-dependent type can have a non-instantiation-dependent
canonical type.

Added: 
clang/test/SemaTemplate/alias-template-nondependent.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/TypeNodes.td
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Type.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 59e2679ddded..6c00fe86f282 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1459,8 +1459,16 @@ class ASTContext : public RefCountedBase {
   void getInjectedTemplateArgs(const TemplateParameterList *Params,
SmallVectorImpl &Args);
 
+  /// Form a pack expansion type with the given pattern.
+  /// \param NumExpansions The number of expansions for the pack, if known.
+  /// \param ExpectPackInType If \c false, we should not expect \p Pattern to
+  ///contain an unexpanded pack. This only makes sense if the pack
+  ///expansion is used in a context where the arity is inferred from
+  ///elsewhere, such as if the pattern contains a placeholder type or
+  ///if this is the canonical type of another pack expansion type.
   QualType getPackExpansionType(QualType Pattern,
-Optional NumExpansions);
+Optional NumExpansions,
+bool ExpectPackInType = true);
 
   QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
 ObjCInterfaceDecl *PrevDecl = nullptr) const;

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 9a745ef20fac..7fe652492b0e 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -4383,11 +4383,7 @@ class TypedefType : public Type {
 protected:
   friend class ASTContext; // ASTContext creates these.
 
-  TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can)
-  : Type(tc, can, can->getDependence() & ~TypeDependence::UnexpandedPack),
-Decl(const_cast(D)) {
-assert(!isa(can) && "Invalid canonical type");
-  }
+  TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can);
 
 public:
   TypedefNameDecl *getDecl() const { return Decl; }
@@ -5624,7 +5620,8 @@ class PackExpansionType : public Type, public 
llvm::FoldingSetNode {
   PackExpansionType(QualType Pattern, QualType Canon,
 Optional NumExpansions)
   : Type(PackExpansion, Canon,
- (Pattern->getDependence() | TypeDependence::Instantiation) &
+ (Pattern->getDependence() | TypeDependence::Dependent |
+  TypeDependence::Instantiation) &
  ~TypeDependence::UnexpandedPack),
 Pattern(Pattern) {
 PackExpansionTypeBits.NumExpansions =
@@ -5645,8 +5642,8 @@ class PackExpansionType : public Type, public 
llvm::FoldingSetNode {
 return None;
   }
 
-  bool isSugared() const { return !Pattern->isDependentType(); }
-  QualType desugar() const { return isSugared() ? Pattern : QualType(this, 0); 
}
+  bool isSugared() const { return false; }
+  QualType desugar() const { return QualType(this, 0); }
 
   void Profile(llvm::FoldingSetNodeID &ID) {
 Profile(ID, getPattern(), getNumExpansions());

diff  --git a/clang/include/clang/Basic/TypeNodes.td 
b/clang/includ

[PATCH] D84473: Dump Accumulator

2020-07-28 Thread Kazu Hirata via Phabricator via cfe-commits
kazu updated this revision to Diff 281344.
kazu added a comment.

Spun off the llvm-readobj bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/DumpAccumulator.h
  llvm/include/llvm/InitializePasses.h
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/DumpAccumulator.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/test/Other/new-pm-defaults.ll

Index: llvm/test/Other/new-pm-defaults.ll
===
--- llvm/test/Other/new-pm-defaults.ll
+++ llvm/test/Other/new-pm-defaults.ll
@@ -92,6 +92,8 @@
 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
 ; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module{{.*}}>
 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
+; CHECK-O-NEXT: RequireAnalysisPass
+; CHECK-O-NEXT: Running analysis: DumpAccumulator
 ; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
 ; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
 ; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module{{.*}}>
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -28,6 +28,7 @@
 MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
 MODULE_ANALYSIS("asan-globals-md", ASanGlobalsMetadataAnalysis())
 MODULE_ANALYSIS("inline-advisor", InlineAdvisorAnalysis())
+MODULE_ANALYSIS("dump-accumulator", DumpAccumulator())
 
 #ifndef MODULE_ALIAS_ANALYSIS
 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS)   \
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -31,6 +31,7 @@
 #include "llvm/Analysis/DemandedBits.h"
 #include "llvm/Analysis/DependenceAnalysis.h"
 #include "llvm/Analysis/DominanceFrontier.h"
+#include "llvm/Analysis/DumpAccumulator.h"
 #include "llvm/Analysis/FunctionPropertiesAnalysis.h"
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/IVUsers.h"
@@ -255,6 +256,10 @@
 cl::Hidden,
 cl::desc("Enable inline deferral during PGO"));
 
+cl::opt EnableDumpAccumulator("enable-dump-accumulator", cl::init(true),
+cl::Hidden,
+cl::desc("Enable the dump accumulator."));
+
 PipelineTuningOptions::PipelineTuningOptions() {
   LoopInterleaving = true;
   LoopVectorization = true;
@@ -1241,6 +1246,8 @@
 
   ModulePassManager MPM(DebugLogging);
 
+  MPM.addPass(RequireAnalysisPass());
+
   // Force any function attributes we want the rest of the pipeline to observe.
   MPM.addPass(ForceFunctionAttrsPass());
 
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -29,6 +29,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/ConstantFolding.h"
+#include "llvm/Analysis/DumpAccumulator.h"
 #include "llvm/Analysis/EHPersonalities.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/COFF.h"
@@ -106,6 +107,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/MathExtras.h"
@@ -246,6 +248,7 @@
   MachineFunctionPass::getAnalysisUsage(AU);
   AU.addRequired();
   AU.addRequired();
+  AU.addUsedIfAvailable();
 }
 
 bool AsmPrinter::doInitialization(Module &M) {
@@ -1757,6 +1760,20 @@
 }
   }
 
+  if (auto *DumpAccumulatorAnalysis =
+  getAnalysisIfAvailable()) {
+auto *DS = OutStreamer->getContext().getELFSection(
+".llvm_dump", ELF::SHT_NOTE, ELF::SHF_STRINGS);
+OutStreamer->SwitchSection(DS);
+std::string &Out = DumpAccumulatorAnalysis->GetResult(M)->Message;
+SmallVector Compressed;
+Error E = zlib::compress(Out.c_str(), Compressed);
+assert(!E);
+OutStreamer->emitULEB128IntValue(Out.size());
+OutStreamer->emitULEB128IntValue(Compressed.size());
+OutStreamer->emitBytes({Compressed.data(), Compressed.size()});
+  }
+
   // Allow the target to emit any magic that it wants at the end of the file,
   // after everything else has gone out.
   emitEndOfAsmFile(M);
Index: llvm/lib/Analysis/DumpAccumulator.cpp
===
--- /dev/null
+++ llvm/lib/Analysis/DumpAccumulator.cpp
@@ -0,0 +1,30 @@
+//===- DumpAccumulator.cpp - Dumping infrastructur

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

2020-07-28 Thread Zequan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb46176bbb094: Reland [Coverage] Add comment to skipped 
regions (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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]]|  |
+/

[clang] b46176b - Reland [Coverage] Add comment to skipped regions

2020-07-28 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2020-07-28T13:20:57-07:00
New Revision: b46176bbb094610460667edad950a9c99f844118

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

LOG: Reland [Coverage] Add comment to skipped regions

Bug filled here: https://bugs.llvm.org/show_bug.cgi?id=45757.
Add comment to skipped regions so we don't track execution count for lines 
containing only comments.

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

Added: 
compiler-rt/test/profile/coverage_comments.cpp

Modified: 
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/instrprof-set-file-object-merging.c

Removed: 




diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 5cd017fa925f..b0dd363555ab 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -419,6 +419,9 @@ class Preprocessor {
   /// The number of (LexLevel 0) preprocessor tokens.
   unsigned TokenCount = 0;
 
+  /// Preprocess every token regardless of LexLevel.
+  bool PreprocessToken = false;
+
   /// The maximum number of (LexLevel 0) tokens before issuing a -Wmax-tokens
   /// warning, or zero for unlimited.
   unsigned MaxTokens = 0;
@@ -1038,6 +1041,8 @@ class Preprocessor {
 OnToken = std::move(F);
   }
 
+  void setPreprocessToken(bool Preprocess) { PreprocessToken = Preprocess; }
+
   bool isMacroDefined(StringRef Id) {
 return isMacroDefined(&Identifiers.get(Id));
   }

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 55925110708e..5a6ce0f5dbd5 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -990,11 +990,9 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, 
StringRef InFile) {
 
   CoverageSourceInfo *CoverageInfo = nullptr;
   // Add the preprocessor callback only when the coverage mapping is generated.
-  if (CI.getCodeGenOpts().CoverageMapping) {
-CoverageInfo = new CoverageSourceInfo;
-CI.getPreprocessor().addPPCallbacks(
-
std::unique_ptr(CoverageInfo));
-  }
+  if (CI.getCodeGenOpts().CoverageMapping)
+CoverageInfo = CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks(
+CI.getPreprocessor());
 
   std::unique_ptr Result(new BackendConsumer(
   BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 78b268f423cb..9a7096b8d1d0 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -35,8 +35,35 @@ using namespace clang;
 using namespace CodeGen;
 using namespace llvm::coverage;
 
+CoverageSourceInfo *
+CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor &PP) {
+  CoverageSourceInfo *CoverageInfo = new CoverageSourceInfo();
+  PP.addPPCallbacks(std::unique_ptr(CoverageInfo));
+  PP.addCommentHandler(CoverageInfo);
+  PP.setPreprocessToken(true);
+  PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
+// Update previous token location.
+CoverageInfo->PrevTokLoc = Tok.getLocation();
+CoverageInfo->updateNextTokLoc(Tok.getLocation());
+  });
+  return CoverageInfo;
+}
+
 void CoverageSourceInfo::SourceRangeSkipped(SourceRange Range, SourceLocation) 
{
-  SkippedRanges.push_back(Ra

  1   2   3   >