[PATCH] D98438: Clang: Allow selecting the hash algorithm for file checksums in debug info.

2021-03-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2775
 def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, Group;
+def gsrc_hash_algorithm_EQ : Joined<["-"], "gsrc-hash-algorithm=">, 
Group, Flags<[CC1Option]>,
+  HelpText<"Hashing algorithm for file checksum in debug info 'md5', 'sha1', 
or 'sha256'">,

Can you please use a marshalling annotation here and remove the code in 
`CompilerInvocation.cpp`? 
https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98438

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


[PATCH] D97224: Use Address for CGBuilder's CreateAtomicRMW and CreateAtomicCmpXchg.

2021-03-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D97224#2604537 , @jyknight wrote:

>> I'm less certain about what to do with the `__atomic_*` builtins
>
> The `__atomic` builtins have already been supporting under-aligned pointers 
> all along -- and that behavior is unchanged by this patch.

How so?  Clang hasn't been passing down an alignment, which means that it's 
been building `atomicrmw` instructions with the natural alignment for the IR 
type, which means we've been assuming that all pointers have a least that 
alignment.  The LLVM documentation even says that `atomicrmw` doesn't allow 
under-alignment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97224

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


[PATCH] D95635: [CMake] Require python 3.6 if enabling LLVM test targets

2021-03-11 Thread serge via Phabricator via cfe-commits
serge-sans-paille accepted this revision.
serge-sans-paille added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for doing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[clang] 49ed303 - Revert "[OpenMP] Do not propagate match extensions to nested contexts"

2021-03-11 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2021-03-11T23:48:36-06:00
New Revision: 49ed3032ff17ad0a7a4fcd765dbbcac627ca6fa0

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

LOG: Revert "[OpenMP] Do not propagate match extensions to nested contexts"

Two tests failed for some reason, need to investigate:
  https://lab.llvm.org/buildbot/#/builders/109/builds/10399

This reverts commit ad9e98b8efa0138559eb640023695dab54967a8d.

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td
clang/lib/Parse/ParseOpenMP.cpp
llvm/lib/Frontend/OpenMP/OMPContext.cpp

Removed: 
clang/test/OpenMP/begin_declare_variant_nested_propagation.c



diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b1a80752b650..deda68b64f90 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4014,8 +4014,7 @@ The match extensions change when the *entire* context 
selector is considered a
 match for an OpenMP context. The default is ``all``, with ``none`` no trait in 
the
 selector is allowed to be in the OpenMP context, with ``any`` a single trait in
 both the selector and OpenMP context is sufficient. Only a single match
-extension trait is allowed per context selector. Note that match extensions are
-not propagated to nested selectors like the standard defines it for other 
traits.
+extension trait is allowed per context selector.
 The disable extensions remove default effects of the ``begin declare variant``
 applied to a definition. If ``disable_implicit_base`` is given, we will not
 introduce an implicit base function for a variant if no base function was

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index dd98e89313df..3de01be0db87 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -21,7 +21,6 @@
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/ADT/PointerIntPair.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/UniqueVector.h"
 #include "llvm/Frontend/OpenMP/OMPContext.h"
@@ -1464,29 +1463,7 @@ bool 
Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
   // TODO: Keep some source location in the TI to provide better diagnostics.
   // TODO: Perform some kind of equivalence check on the condition and score
   //   expressions.
-  auto StripImplementation = [](const OMPTraitSet &TSet) -> OMPTraitSet {
-if (TSet.Kind != llvm::omp::TraitSet::implementation)
-  return TSet;
-OMPTraitSet Set = TSet;
-for (OMPTraitSelector &Selector : Set.Selectors) {
-  if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
-continue;
-  // Do not propagate match extensions to nested contexts.
-  llvm::erase_if(Selector.Properties, [](const OMPTraitProperty &Property) 
{
-return (
-Property.Kind ==
-llvm::omp::TraitProperty::implementation_extension_match_any ||
-Property.Kind ==
-llvm::omp::TraitProperty::implementation_extension_match_all ||
-Property.Kind ==
-llvm::omp::TraitProperty::implementation_extension_match_none);
-  });
-  return Set;
-}
-return Set;
-  };
-  for (const OMPTraitSet &PSet : ParentTI->Sets) {
-const OMPTraitSet ParentSet = StripImplementation(PSet);
+  for (const OMPTraitSet &ParentSet : ParentTI->Sets) {
 bool MergedSet = false;
 for (OMPTraitSet &Set : TI.Sets) {
   if (Set.Kind != ParentSet.Kind)

diff  --git a/clang/test/OpenMP/begin_declare_variant_nested_propagation.c 
b/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
deleted file mode 100644
index e0dee1110922..
--- a/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 
-fms-extensions -Wno-pragma-pack %s
-// expected-no-diagnostics
-
-#pragma omp begin declare variant match(user={condition(1)}, 
device={kind(cpu)}, implementation={extension(match_any)})
-#pragma omp begin declare variant match(device = {kind(cpu, fpga)})
- this is never reached
-#pragma omp end declare variant
-#pragma omp end declare variant
-
-#pragma omp begin declare variant match(user={condition(1)}, 
device={kind(cpu)}, implementation={extension(match_any)})
-#pragma omp begin declare variant match(device = {kind(cpu, fpga)}, 
implementation={vendor(llvm)})
- this is never reached
-#pragma omp end declare variant
-#pragma omp end declare variant

diff  --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp 
b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
index 3d053c29cbdd..11d8da097c6c 100644
--- a/llvm/lib/Fronten

[clang] 0fe0d11 - Revert "[OpenMP] Introduce the `disable_selector_propagation` variant selector trait"

2021-03-11 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2021-03-11T23:48:35-06:00
New Revision: 0fe0d114e41c5e3448d88f4353b4047351f26be0

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

LOG: Revert "[OpenMP] Introduce the `disable_selector_propagation` variant 
selector trait"

Need to revert ad9e98b8efa0138559eb640023695dab54967a8d which this
commit depends on.

This reverts commit f771ef7b5f0ed260d00931cd50e6fe462edbacaf.

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td
clang/lib/Parse/ParseOpenMP.cpp
clang/test/OpenMP/begin_declare_variant_nested_propagation.c
clang/test/OpenMP/declare_variant_messages.c
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f5be90e54fb4..b1a80752b650 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4007,9 +4007,8 @@ Clang provides the following context selector extensions, 
used via
 match_all
 match_any
 match_none
-allow_templates
 disable_implicit_base
-disable_selector_propagation
+allow_templates
 
 The match extensions change when the *entire* context selector is considered a
 match for an OpenMP context. The default is ``all``, with ``none`` no trait in 
the
@@ -4026,8 +4025,7 @@ The allow extensions change when the ``begin declare 
variant`` effect is
 applied to a definition. If ``allow_templates`` is given, template function
 definitions are considered as specializations of existing or assumed template
 declarations with the same name. The template parameters for the base functions
-are used to instantiate the specialization. If ``disable_selector_propagation``
-is given, the context selector is not propagated to nested ones.
+are used to instantiate the specialization.
 
   }];
 }

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 7f4c1ba8c3ac..dd98e89313df 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -948,10 +948,6 @@ static bool checkExtensionProperty(Parser &P, 
SourceLocation Loc,
   TraitProperty::implementation_extension_disable_implicit_base)
 return true;
 
-  if (TIProperty.Kind ==
-  TraitProperty::implementation_extension_disable_selector_propagation)
-return true;
-
   if (TIProperty.Kind ==
   TraitProperty::implementation_extension_allow_templates)
 return true;
@@ -1464,11 +1460,7 @@ bool 
Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
 return false;
 
   // Merge the parent/outer trait info into the one we just parsed and diagnose
-  // problems. Can be disabled by the disable_selector_propagation extension.
-  if (ParentTI->isExtensionActive(
-  llvm::omp::TraitProperty::
-  implementation_extension_disable_selector_propagation))
-return false;
+  // problems.
   // TODO: Keep some source location in the TI to provide better diagnostics.
   // TODO: Perform some kind of equivalence check on the condition and score
   //   expressions.

diff  --git a/clang/test/OpenMP/begin_declare_variant_nested_propagation.c 
b/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
index efb5b507644a..e0dee1110922 100644
--- a/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
+++ b/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 
-fms-extensions -Wno-pragma-pack %s
+// expected-no-diagnostics
 
 #pragma omp begin declare variant match(user={condition(1)}, 
device={kind(cpu)}, implementation={extension(match_any)})
 #pragma omp begin declare variant match(device = {kind(cpu, fpga)})
@@ -11,18 +12,3 @@
  this is never reached
 #pragma omp end declare variant
 #pragma omp end declare variant
-
-#pragma omp begin declare variant 
match(implementation={extension(disable_implicit_base, 
disable_selector_propagation)})
-
- void without_implicit_base() {}
-
-#pragma omp begin declare variant match(implementation = {vendor(llvm)})
- void with_implicit_base() {}
-#pragma omp end declare variant
-
-#pragma omp end declare variant
-
- void test() {
-   without_implicit_base(); // expected-warning{{implicit declaration of 
function 'without_implicit_base' is invalid in C99}}
-   with_implicit_base();
- }

diff  --git a/clang/test/OpenMP/declare_variant_messages.c 
b/clang/test/OpenMP/declare_variant_messages.c
index e48b2ec3f368..1fad74b12d1e 100644
--- a/clang/test/OpenMP/declare_variant_messages.c
+++ b/clang/test/OpenMP/declare_variant_messages.c
@@ -170,14 +170,6 @@ void caller() {
 int conflicting_nested_score(void);
 #pragma omp end declare variant
 
-#pragma omp begin declare variant ma

[PATCH] D95765: [OpenMP] Introduce the `disable_selector_propagation` variant selector trait

2021-03-11 Thread Johannes Doerfert 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 rGb2642456abc6: [OpenMP] Introduce the 
`disable_selector_propagation` variant selector trait (authored by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D95765?vs=320361&id=330142#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95765

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/begin_declare_variant_nested_propagation.c
  clang/test/OpenMP/declare_variant_messages.c
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1057,6 +1057,7 @@
 __OMP_TRAIT_PROPERTY(implementation, extension, match_none)
 __OMP_TRAIT_PROPERTY(implementation, extension, disable_implicit_base)
 __OMP_TRAIT_PROPERTY(implementation, extension, allow_templates)
+__OMP_TRAIT_PROPERTY(implementation, extension, disable_selector_propagation)
 
 __OMP_TRAIT_SET(user)
 
Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -170,6 +170,14 @@
 int conflicting_nested_score(void);
 #pragma omp end declare variant
 
+#pragma omp begin declare variant match(implementation = {vendor(score(1) \
+ : llvm),extension(disable_selector_propagation)})
+#pragma omp declare variant(foo) match(implementation = {vendor(score(2) \
+: llvm)})
+int conflicting_nested_score_no_prop(void);
+#pragma omp end declare variant
+
+
 // FIXME: We should build the conjuction of different conditions, see also the score fixme above.
 #pragma omp begin declare variant match(user = {condition(1)})
 #pragma omp declare variant(foo) match(user = {condition(1)}) // expected-error {{nested user conditions in OpenMP context selector not supported (yet)}}
Index: clang/test/OpenMP/begin_declare_variant_nested_propagation.c
===
--- clang/test/OpenMP/begin_declare_variant_nested_propagation.c
+++ clang/test/OpenMP/begin_declare_variant_nested_propagation.c
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 -fms-extensions -Wno-pragma-pack %s
-// expected-no-diagnostics
 
 #pragma omp begin declare variant match(user={condition(1)}, device={kind(cpu)}, implementation={extension(match_any)})
 #pragma omp begin declare variant match(device = {kind(cpu, fpga)})
@@ -12,3 +11,18 @@
  this is never reached
 #pragma omp end declare variant
 #pragma omp end declare variant
+
+#pragma omp begin declare variant match(implementation={extension(disable_implicit_base, disable_selector_propagation)})
+
+ void without_implicit_base() {}
+
+#pragma omp begin declare variant match(implementation = {vendor(llvm)})
+ void with_implicit_base() {}
+#pragma omp end declare variant
+
+#pragma omp end declare variant
+
+ void test() {
+   without_implicit_base(); // expected-warning{{implicit declaration of function 'without_implicit_base' is invalid in C99}}
+   with_implicit_base();
+ }
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -948,6 +948,10 @@
   TraitProperty::implementation_extension_disable_implicit_base)
 return true;
 
+  if (TIProperty.Kind ==
+  TraitProperty::implementation_extension_disable_selector_propagation)
+return true;
+
   if (TIProperty.Kind ==
   TraitProperty::implementation_extension_allow_templates)
 return true;
@@ -1460,7 +1464,11 @@
 return false;
 
   // Merge the parent/outer trait info into the one we just parsed and diagnose
-  // problems.
+  // problems. Can be disabled by the disable_selector_propagation extension.
+  if (ParentTI->isExtensionActive(
+  llvm::omp::TraitProperty::
+  implementation_extension_disable_selector_propagation))
+return false;
   // TODO: Keep some source location in the TI to provide better diagnostics.
   // TODO: Perform some kind of equivalence check on the condition and score
   //   expressions.
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4007,8 +4007,9 @@
 match_all
 match_any
 match_none
-disable_implicit_base
 allow_templates
+disable_implicit_base
+   

[PATCH] D95764: [OpenMP] Do not propagate match extensions to nested contexts

2021-03-11 Thread Johannes Doerfert 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 rGad9e98b8efa0: [OpenMP] Do not propagate match extensions to 
nested contexts (authored by jdoerfert).
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D95764?vs=320371&id=330141#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95764

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/begin_declare_variant_nested_propagation.c
  llvm/lib/Frontend/OpenMP/OMPContext.cpp


Index: llvm/lib/Frontend/OpenMP/OMPContext.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -168,8 +168,13 @@
 // For kind "any" a single match is enough but we ignore non-matched
 // properties.
 if (MK == MK_ANY) {
-  if (WasFound)
+  if (WasFound) {
+LLVM_DEBUG(
+dbgs() << "[" << DEBUG_TYPE << "] Property "
+   << getOpenMPContextTraitPropertyName(Property, "")
+   << " was in the OpenMP context and match kind is any.\n";);
 return true;
+  }
   return None;
 }
 
Index: clang/test/OpenMP/begin_declare_variant_nested_propagation.c
===
--- /dev/null
+++ clang/test/OpenMP/begin_declare_variant_nested_propagation.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 
-fms-extensions -Wno-pragma-pack %s
+// expected-no-diagnostics
+
+#pragma omp begin declare variant match(user={condition(1)}, 
device={kind(cpu)}, implementation={extension(match_any)})
+#pragma omp begin declare variant match(device = {kind(cpu, fpga)})
+ this is never reached
+#pragma omp end declare variant
+#pragma omp end declare variant
+
+#pragma omp begin declare variant match(user={condition(1)}, 
device={kind(cpu)}, implementation={extension(match_any)})
+#pragma omp begin declare variant match(device = {kind(cpu, fpga)}, 
implementation={vendor(llvm)})
+ this is never reached
+#pragma omp end declare variant
+#pragma omp end declare variant
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -21,6 +21,7 @@
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/UniqueVector.h"
 #include "llvm/Frontend/OpenMP/OMPContext.h"
@@ -1463,7 +1464,29 @@
   // TODO: Keep some source location in the TI to provide better diagnostics.
   // TODO: Perform some kind of equivalence check on the condition and score
   //   expressions.
-  for (const OMPTraitSet &ParentSet : ParentTI->Sets) {
+  auto StripImplementation = [](const OMPTraitSet &TSet) -> OMPTraitSet {
+if (TSet.Kind != llvm::omp::TraitSet::implementation)
+  return TSet;
+OMPTraitSet Set = TSet;
+for (OMPTraitSelector &Selector : Set.Selectors) {
+  if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
+continue;
+  // Do not propagate match extensions to nested contexts.
+  llvm::erase_if(Selector.Properties, [](const OMPTraitProperty &Property) 
{
+return (
+Property.Kind ==
+llvm::omp::TraitProperty::implementation_extension_match_any ||
+Property.Kind ==
+llvm::omp::TraitProperty::implementation_extension_match_all ||
+Property.Kind ==
+llvm::omp::TraitProperty::implementation_extension_match_none);
+  });
+  return Set;
+}
+return Set;
+  };
+  for (const OMPTraitSet &PSet : ParentTI->Sets) {
+const OMPTraitSet ParentSet = StripImplementation(PSet);
 bool MergedSet = false;
 for (OMPTraitSet &Set : TI.Sets) {
   if (Set.Kind != ParentSet.Kind)
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4014,7 +4014,8 @@
 match for an OpenMP context. The default is ``all``, with ``none`` no trait in 
the
 selector is allowed to be in the OpenMP context, with ``any`` a single trait in
 both the selector and OpenMP context is sufficient. Only a single match
-extension trait is allowed per context selector.
+extension trait is allowed per context selector. Note that match extensions are
+not propagated to nested selectors like the standard defines it for other 
traits.
 The disable extensions remove default effects of the ``begin declare variant``
 applied to 

[PATCH] D94741: [Utils] Check for more global information in update_test_checks

2021-03-11 Thread Johannes Doerfert 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 rGcd1bd6e58700: [Utils] Check for more global information in 
update_test_checks (authored by jdoerfert).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D94741?vs=327988&id=330140#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94741

Files:
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.plain.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/scrub_attrs.ll.plain.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/generated_funcs.test
  llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -54,6 +54,8 @@
   help='Remove attribute annotations (#0) from the end of check line')
   parser.add_argument('--check-attributes', action='store_true',
   help='Check "Function Attributes" for functions')
+  parser.add_argument('--check-globals', action='store_true',
+  help='Check global entries (global variables, metadata, attribute sets, ...) for functions')
   parser.add_argument('tests', nargs='+')
   initial_args = common.parse_commandline_args(parser)
 
@@ -111,7 +113,7 @@
   common.debug('Extracted opt cmd: ' + opt_basename + ' ' + opt_args)
   common.debug('Extracted FileCheck prefixes: ' + str(prefixes))
 
-  raw_tool_output = common.invoke_tool(ti.args.opt_binary, opt_args, 
+  raw_tool_output = common.invoke_tool(ti.args.opt_binary, opt_args,
ti.path)
   builder.process_run_line(common.OPT_FUNCTION_RE, common.scrub_body,
   raw_tool_output, prefixes)
@@ -119,6 +121,7 @@
 func_dict = builder.finish_and_get_func_dict()
 is_in_function = False
 is_in_function_start = False
+has_checked_pre_function_globals = False
 prefix_set = set([prefix for prefixes, _ in prefix_list for prefix in prefixes])
 common.debug('Rewriting FileCheck prefixes:', str(prefix_set))
 output_lines = []
@@ -138,13 +141,17 @@
   # out all the source lines.
   common.dump_input_lines(output_lines, ti, prefix_set, ';')
 
+  args = ti.args
+  if args.check_globals:
+  common.add_global_checks(builder.global_var_dict(), ';', prefix_list, output_lines, global_vars_seen_dict, args.preserve_names, True)
+
   # Now generate all the checks.
   common.add_checks_at_end(output_lines, prefix_list, builder.func_order(),
';', lambda my_output_lines, prefixes, func:
common.add_ir_checks(my_output_lines, ';',
 prefixes,
 func_dict, func, False,
-ti.args.function_signature,
+args.function_signature,
 global_vars_seen_dict))
 else:
   # "Normal" mode.
@@ -166,20 +173,23 @@
global_vars_seen_dict)
   is_in_function_start = False
 
-if is_in_function:
-  if common.should_add_line_to_output(input_line, prefix_set):
+m = common.IR_FU

[clang] b264245 - [OpenMP] Introduce the `disable_selector_propagation` variant selector trait

2021-03-11 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2021-03-11T23:31:25-06:00
New Revision: b2642456abc6f11ef0a948332ab32c335aba1bcf

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

LOG: [OpenMP] Introduce the `disable_selector_propagation` variant selector 
trait

Nested `omp [begin|end] declare variant` inherit the selectors from
surrounding `omp (begin|end) declare variant` constructs. To stop such
propagation the user can add the `disable_selector_propagation` to the
`extension` set in the `implementation` selector.

Reviewed By: tianshilei1992

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

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td
clang/lib/Parse/ParseOpenMP.cpp
clang/test/OpenMP/begin_declare_variant_nested_propagation.c
clang/test/OpenMP/declare_variant_messages.c
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b1a80752b650..f5be90e54fb4 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4007,8 +4007,9 @@ Clang provides the following context selector extensions, 
used via
 match_all
 match_any
 match_none
-disable_implicit_base
 allow_templates
+disable_implicit_base
+disable_selector_propagation
 
 The match extensions change when the *entire* context selector is considered a
 match for an OpenMP context. The default is ``all``, with ``none`` no trait in 
the
@@ -4025,7 +4026,8 @@ The allow extensions change when the ``begin declare 
variant`` effect is
 applied to a definition. If ``allow_templates`` is given, template function
 definitions are considered as specializations of existing or assumed template
 declarations with the same name. The template parameters for the base functions
-are used to instantiate the specialization.
+are used to instantiate the specialization. If ``disable_selector_propagation``
+is given, the context selector is not propagated to nested ones.
 
   }];
 }

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index dd98e89313df..7f4c1ba8c3ac 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -948,6 +948,10 @@ static bool checkExtensionProperty(Parser &P, 
SourceLocation Loc,
   TraitProperty::implementation_extension_disable_implicit_base)
 return true;
 
+  if (TIProperty.Kind ==
+  TraitProperty::implementation_extension_disable_selector_propagation)
+return true;
+
   if (TIProperty.Kind ==
   TraitProperty::implementation_extension_allow_templates)
 return true;
@@ -1460,7 +1464,11 @@ bool 
Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
 return false;
 
   // Merge the parent/outer trait info into the one we just parsed and diagnose
-  // problems.
+  // problems. Can be disabled by the disable_selector_propagation extension.
+  if (ParentTI->isExtensionActive(
+  llvm::omp::TraitProperty::
+  implementation_extension_disable_selector_propagation))
+return false;
   // TODO: Keep some source location in the TI to provide better diagnostics.
   // TODO: Perform some kind of equivalence check on the condition and score
   //   expressions.

diff  --git a/clang/test/OpenMP/begin_declare_variant_nested_propagation.c 
b/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
index e0dee1110922..efb5b507644a 100644
--- a/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
+++ b/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 
-fms-extensions -Wno-pragma-pack %s
-// expected-no-diagnostics
 
 #pragma omp begin declare variant match(user={condition(1)}, 
device={kind(cpu)}, implementation={extension(match_any)})
 #pragma omp begin declare variant match(device = {kind(cpu, fpga)})
@@ -12,3 +11,18 @@
  this is never reached
 #pragma omp end declare variant
 #pragma omp end declare variant
+
+#pragma omp begin declare variant 
match(implementation={extension(disable_implicit_base, 
disable_selector_propagation)})
+
+ void without_implicit_base() {}
+
+#pragma omp begin declare variant match(implementation = {vendor(llvm)})
+ void with_implicit_base() {}
+#pragma omp end declare variant
+
+#pragma omp end declare variant
+
+ void test() {
+   without_implicit_base(); // expected-warning{{implicit declaration of 
function 'without_implicit_base' is invalid in C99}}
+   with_implicit_base();
+ }

diff  --git a/clang/test/OpenMP/declare_variant_messages.c 
b/clang/test/OpenMP/declare_variant_messages.c
index 1fad74b12d1e..e48b2ec3f368 100644
--- a/clang/test/OpenMP/declare_variant_messages.c
+++ 

[clang] ad9e98b - [OpenMP] Do not propagate match extensions to nested contexts

2021-03-11 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2021-03-11T23:31:21-06:00
New Revision: ad9e98b8efa0138559eb640023695dab54967a8d

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

LOG: [OpenMP] Do not propagate match extensions to nested contexts

If we have nested declare variant context, it doesn't make sense to
inherit the match extension from the parent. Instead, just skip it.

Reviewed By: JonChesterfield

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

Added: 
clang/test/OpenMP/begin_declare_variant_nested_propagation.c

Modified: 
clang/include/clang/Basic/AttrDocs.td
clang/lib/Parse/ParseOpenMP.cpp
llvm/lib/Frontend/OpenMP/OMPContext.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index deda68b64f90..b1a80752b650 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4014,7 +4014,8 @@ The match extensions change when the *entire* context 
selector is considered a
 match for an OpenMP context. The default is ``all``, with ``none`` no trait in 
the
 selector is allowed to be in the OpenMP context, with ``any`` a single trait in
 both the selector and OpenMP context is sufficient. Only a single match
-extension trait is allowed per context selector.
+extension trait is allowed per context selector. Note that match extensions are
+not propagated to nested selectors like the standard defines it for other 
traits.
 The disable extensions remove default effects of the ``begin declare variant``
 applied to a definition. If ``disable_implicit_base`` is given, we will not
 introduce an implicit base function for a variant if no base function was

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 3de01be0db87..dd98e89313df 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -21,6 +21,7 @@
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/UniqueVector.h"
 #include "llvm/Frontend/OpenMP/OMPContext.h"
@@ -1463,7 +1464,29 @@ bool 
Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
   // TODO: Keep some source location in the TI to provide better diagnostics.
   // TODO: Perform some kind of equivalence check on the condition and score
   //   expressions.
-  for (const OMPTraitSet &ParentSet : ParentTI->Sets) {
+  auto StripImplementation = [](const OMPTraitSet &TSet) -> OMPTraitSet {
+if (TSet.Kind != llvm::omp::TraitSet::implementation)
+  return TSet;
+OMPTraitSet Set = TSet;
+for (OMPTraitSelector &Selector : Set.Selectors) {
+  if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension)
+continue;
+  // Do not propagate match extensions to nested contexts.
+  llvm::erase_if(Selector.Properties, [](const OMPTraitProperty &Property) 
{
+return (
+Property.Kind ==
+llvm::omp::TraitProperty::implementation_extension_match_any ||
+Property.Kind ==
+llvm::omp::TraitProperty::implementation_extension_match_all ||
+Property.Kind ==
+llvm::omp::TraitProperty::implementation_extension_match_none);
+  });
+  return Set;
+}
+return Set;
+  };
+  for (const OMPTraitSet &PSet : ParentTI->Sets) {
+const OMPTraitSet ParentSet = StripImplementation(PSet);
 bool MergedSet = false;
 for (OMPTraitSet &Set : TI.Sets) {
   if (Set.Kind != ParentSet.Kind)

diff  --git a/clang/test/OpenMP/begin_declare_variant_nested_propagation.c 
b/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
new file mode 100644
index ..e0dee1110922
--- /dev/null
+++ b/clang/test/OpenMP/begin_declare_variant_nested_propagation.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 
-fms-extensions -Wno-pragma-pack %s
+// expected-no-diagnostics
+
+#pragma omp begin declare variant match(user={condition(1)}, 
device={kind(cpu)}, implementation={extension(match_any)})
+#pragma omp begin declare variant match(device = {kind(cpu, fpga)})
+ this is never reached
+#pragma omp end declare variant
+#pragma omp end declare variant
+
+#pragma omp begin declare variant match(user={condition(1)}, 
device={kind(cpu)}, implementation={extension(match_any)})
+#pragma omp begin declare variant match(device = {kind(cpu, fpga)}, 
implementation={vendor(llvm)})
+ this is never reached
+#pragma omp end declare variant
+#pragma omp end declare variant

diff  --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp 
b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
index 11d8da097c6c..3d053c29cbd

[clang] cd1bd6e - [Utils] Check for more global information in update_test_checks

2021-03-11 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2021-03-11T23:31:16-06:00
New Revision: cd1bd6e5870044f3e35da3f713782563e0014c5d

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

LOG: [Utils] Check for more global information in update_test_checks

This allows to check for various globals (metadata/attributes/...) and
also resolves problems with globals (metadata/attributes/...) being
reused across different prefixes.

Reviewed By: sstefan1

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

Added: 

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected

Modified: 
clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected

clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.plain.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/scrub_attrs.ll.plain.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.expected
llvm/test/tools/UpdateTestChecks/update_test_checks/generated_funcs.test
llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_test_checks.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
index 4f8f6003bfb4..b9a8d5f55dc9 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
+++ b/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
@@ -44,7 +44,7 @@ Foo::Foo(int x) : x(x) {}
 // CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
 // CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], 
align 8
 // CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** 
[[THIS_ADDR]], align 8
-// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* nonnull 
dereferenceable(4) [[THIS1]]) [[ATTR3:#.*]]
+// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* nonnull 
dereferenceable(4) [[THIS1]]) #[[ATTR3:[0-9]+]]
 // CHECK-NEXT:ret void
 //
 Foo::~Foo() {}
@@ -70,7 +70,7 @@ int Foo::function_defined_out_of_line(int arg) const { return 
x - arg; }
 // CHECK-NEXT:call void @_ZN3FooC1Ei(%class.Foo* nonnull 
dereferenceable(4) [[F]], i32 1)
 // CHECK-NEXT:[[CALL:%.*]] = call i32 
@_ZNK3Foo23function_defined_inlineEi(%class.Foo* nonnull dereferenceable(4) 
[[F]], i32 2)
 // CHECK-NEXT:[[CALL1:%.*]] = call i32 
@_ZNK3Foo28function_defined_out_of_lineEi(%class.Foo* nonnull 
dereferenceable(4) [[F]], i32 3)
-// CHECK-NEXT:call void @_ZN3FooD1Ev(%class.Foo* nonnull 
dereferenceable(4) [[F]]) [[ATTR3]]
+// CHECK-NEXT:call void @_ZN3FooD1Ev(%class.Foo* nonnull 
dereferenceable(4) [[F]]) #[[ATTR3]]
 // CHECK-NEXT:ret i32 0
 //
 int main() {

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
index cbdfff47675c..96868dd7bab1 100644
--- 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
@@ -34,7 +34,7 @@ void foo(void) {
 // OMP-NEXT:  entry:
 // OMP-NEXT:[[I:%.*]] = alloca i32, align 4
 // OMP-NEXT:store i32 0, i32* [[I]], align 4
-// OMP-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, 
...) @__kmpc_fork_call(%struct.ident_t* [[GLOB2:@.*]], i32 0, void (i32*, i32*, 
...)* bitcast (void (i32*, i32*)* @.omp_outlined. to void (i32*, i32*, ...)*))
+// OMP-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, 
...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB2:[0-9]+]], i32

[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good to me!




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:2388-2390
+  if (DebugKind > codegenoptions::LimitedDebugInfo ||
+  RD->hasAttr())
 return false;

Perfect - I love the symmetry/simplicity of this approach, easy to explain (as 
you have in the documentation) to users, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D98392: Disable Unique Internal Linkage Names for internal global vars

2021-03-11 Thread Sriraman Tallam 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 rGcdb42a4cc423: Disable unique linkage suffixes ifor global 
vars until demanglers can be fixed. (authored by tmsriram).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D98392?vs=330130&id=330136#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98392

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
  clang/test/CodeGen/unique-internal-linkage-names-dwarf.cpp
  clang/test/CodeGen/unique-internal-linkage-names.cpp

Index: clang/test/CodeGen/unique-internal-linkage-names.cpp
===
--- clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -51,12 +51,12 @@
 // PLAIN: define internal i32 @_ZL4mverv()
 // PLAIN: define internal i32 @_ZL4mverv.sse4.2()
 // PLAIN-NOT: "sample-profile-suffix-elision-policy"
-// UNIQUE: @_ZL4glob.__uniq.{{[0-9]+}} = internal global
-// UNIQUE: @_ZZ8retAnonMvE5fGlob.__uniq.{{[0-9]+}} = internal global
-// UNIQUE: @_ZN12_GLOBAL__N_16anon_mE.__uniq.{{[0-9]+}} = internal global
-// UNIQUE: define internal i32 @_ZL3foov.__uniq.{{[0-9]+}}() #[[#ATTR:]] {
-// UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.__uniq.{{[0-9]+}}
-// UNIQUE: define weak_odr i32 ()* @_ZL4mverv.__uniq.{{[0-9]+}}.resolver()
-// UNIQUE: define internal i32 @_ZL4mverv.__uniq.{{[0-9]+}}()
-// UNIQUE: define internal i32 @_ZL4mverv.__uniq.{{[0-9]+}}.sse4.2
+// UNIQUE: @_ZL4glob = internal global
+// UNIQUE: @_ZZ8retAnonMvE5fGlob = internal global
+// UNIQUE: @_ZN12_GLOBAL__N_16anon_mE = internal global
+// UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]() #[[#ATTR:]] {
+// UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.[[MODHASH]]
+// UNIQUE: define weak_odr i32 ()* @_ZL4mverv.[[MODHASH]].resolver()
+// UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]]()
+// UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]].sse4.2
 // UNIQUE: attributes #[[#ATTR]] = { {{.*}}"sample-profile-suffix-elision-policy"{{.*}} }
Index: clang/test/CodeGen/unique-internal-linkage-names-dwarf.cpp
===
--- clang/test/CodeGen/unique-internal-linkage-names-dwarf.cpp
+++ clang/test/CodeGen/unique-internal-linkage-names-dwarf.cpp
@@ -46,15 +46,15 @@
 // PLAIN-DAG: distinct !DIGlobalVariable(name: "glob_zip", linkageName: "_ZL8glob_zip"{{.*}})
 // PLAIN-DAG: distinct !DISubprogram(name: "zip", linkageName: "_ZL3zipv"{{.*}})
 
-// UNIQUE-DAG: @_ZL8glob_foo.[[MODHASH:__uniq\.[0-9]+]] = internal global i32
-// UNIQUE-DAG: define internal i32 @_ZL3foov.[[MODHASH]]()
-// UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_foo", linkageName: "_ZL8glob_foo.[[MODHASH]]"{{.*}})
+// UNIQUE-DAG: @_ZL8glob_foo = internal global i32
+// UNIQUE-DAG: define internal i32 @_ZL3foov.[[MODHASH:__uniq\.[0-9]+]]()
+// UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_foo", linkageName: "_ZL8glob_foo"{{.*}})
 // UNIQUE-DAG: distinct !DISubprogram(name: "foo", linkageName: "_ZL3foov.[[MODHASH]]"{{.*}})
-// UNIQUE-DAG: @_ZN12_GLOBAL__N_18glob_barE.[[MODHASH]] = internal global i32
+// UNIQUE-DAG: @_ZN12_GLOBAL__N_18glob_barE = internal global i32
 // UNIQUE-DAG: define internal i32 @_ZN12_GLOBAL__N_13barEv.[[MODHASH]]()
-// UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_bar", linkageName: "_ZN12_GLOBAL__N_18glob_barE.[[MODHASH]]"{{.*}})
+// UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_bar", linkageName: "_ZN12_GLOBAL__N_18glob_barE"{{.*}})
 // UNIQUE-DAG: distinct !DISubprogram(name: "bar", linkageName: "_ZN12_GLOBAL__N_13barEv.[[MODHASH]]"{{.*}})
-// UNIQUE-DAG: @_ZL8glob_zip.[[MODHASH]] = internal global i32
+// UNIQUE-DAG: @_ZL8glob_zip = internal global i32
 // UNIQUE-DAG: define internal i32 @_ZL3zipv.[[MODHASH]]()
-// UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_zip", linkageName: "_ZL8glob_zip.[[MODHASH]]"{{.*}})
+// UNIQUE-DAG: distinct !DIGlobalVariable(name: "glob_zip", linkageName: "_ZL8glob_zip"{{.*}})
 // UNIQUE-DAG: distinct !DISubprogram(name: "zip", linkageName: "_ZL3zipv.[[MODHASH]]"{{.*}})
Index: clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
===
--- clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
+++ clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
@@ -22,7 +22,7 @@
 // PLAIN: distinct !DISubprogram(name: "foo"{{.*}})
 // PLAIN-NOT: linkageName:
 //
-// UNIQUE: @_ZL4glob.[[MODHASH:__uniq.[0-9]+]] = internal global i32
-// UNIQUE: define internal i32 @_ZL3foov.[[MODHASH]]()
-// UNIQUE: distinct !DIGlobalVariable(name: "glob", linkageName: "_ZL4glob.[[M

[clang] cdb42a4 - Disable unique linkage suffixes ifor global vars until demanglers can be fixed.

2021-03-11 Thread Sriraman Tallam via cfe-commits

Author: Sriraman Tallam
Date: 2021-03-11T20:59:30-08:00
New Revision: cdb42a4cc4239c0b592fc82021c945ce02ebe5cc

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

LOG: Disable unique linkage suffixes ifor global vars until demanglers can be 
fixed.

D96109 added support for unique internal linkage names for both internal
linkage functions and global variables. There was a lot of discussion on how to
get the demangling right for functions but I completely missed the point that
demanglers do not support suffixes for global vars. For example:

$ c++filt _ZL3foo
foo
$ c++filt _ZL3foo.uniq.123
_ZL3foo.uniq.123

The demangling for functions works as expected.

I am not sure of the impact of this. I don't understand how debuggers and other
tools depend on the correctness of global variable demangling so I am
pre-emptively disabling it until we can get the demangling support added.

Importantly, uniquefying global variables is not needed right now as we do not
do profile attribution to global vars based on sampling. It was added for
completeness and so this feature is not exactly missed.

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

Added: 


Modified: 
clang/lib/AST/ItaniumMangle.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
clang/test/CodeGen/unique-internal-linkage-names-dwarf.cpp
clang/test/CodeGen/unique-internal-linkage-names.cpp

Removed: 




diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 885d9e28ee69..ba96fda6cd57 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -628,21 +628,24 @@ static bool isInternalLinkageDecl(const NamedDecl *ND) {
   return false;
 }
 
-// Check if this Decl needs a unique internal linkage name.
+// Check if this Function Decl needs a unique internal linkage name.
 bool ItaniumMangleContextImpl::isUniqueInternalLinkageDecl(
 const NamedDecl *ND) {
   if (!NeedsUniqueInternalLinkageNames || !ND)
 return false;
 
+  const auto *FD = dyn_cast(ND);
+  if (!FD)
+return false;
+
   // For C functions without prototypes, return false as their
   // names should not be mangled.
-  if (auto *FD = dyn_cast(ND)) {
-if (!FD->getType()->getAs())
-  return false;
-  }
+  if (!FD->getType()->getAs())
+return false;
 
   if (isInternalLinkageDecl(ND))
 return true;
+
   return false;
 }
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 4bf339786d42..250946bd56dd 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1175,18 +1175,13 @@ static void AppendTargetMangling(const CodeGenModule 
&CGM,
   }
 }
 
-// Returns true if GD is a function/var decl with internal linkage and
+// Returns true if GD is a function decl with internal linkage and
 // needs a unique suffix after the mangled name.
 static bool isUniqueInternalLinkageDecl(GlobalDecl GD,
 CodeGenModule &CGM) {
   const Decl *D = GD.getDecl();
-  if (!CGM.getModuleNameHash().empty() &&
-  ((isa(D) &&
-CGM.getFunctionLinkage(GD) == llvm::GlobalValue::InternalLinkage) ||
-   (isa(D) && CGM.getContext().GetGVALinkageForVariable(
-   cast(D)) == GVA_Internal)))
-return true;
-  return false;
+  return !CGM.getModuleNameHash().empty() && isa(D) &&
+ (CGM.getFunctionLinkage(GD) == llvm::GlobalValue::InternalLinkage);
 }
 
 static std::string getMangledNameImpl(CodeGenModule &CGM, GlobalDecl GD,

diff  --git a/clang/test/CodeGen/unique-internal-linkage-names-dwarf.c 
b/clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
index 916d293f2e5a..a3583426de79 100644
--- a/clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
+++ b/clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
@@ -22,7 +22,7 @@ void baz() {
 // PLAIN: distinct !DISubprogram(name: "foo"{{.*}})
 // PLAIN-NOT: linkageName:
 //
-// UNIQUE: @_ZL4glob.[[MODHASH:__uniq.[0-9]+]] = internal global i32
-// UNIQUE: define internal i32 @_ZL3foov.[[MODHASH]]()
-// UNIQUE: distinct !DIGlobalVariable(name: "glob", linkageName: 
"_ZL4glob.[[MODHASH]]"{{.*}})
+// UNIQUE: @glob = internal global i32
+// UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]()
+// UNIQUE: distinct !DIGlobalVariable(name: "glob"{{.*}})
 // UNIQUE: distinct !DISubprogram(name: "foo", linkageName: 
"_ZL3foov.[[MODHASH]]"{{.*}})

diff  --git a/clang/test/CodeGen/unique-internal-linkage-names-dwarf.cpp 
b/clang/test/CodeGen/unique-internal-linkage-names-dwarf.cpp
index 41b13754396e..37ebfe5eee17 100644
--- a/clang/test/CodeGen/unique-internal-linkage-names-dwarf.cpp
+++ b/clang/test/CodeGen/unique-internal-linkage-na

[PATCH] D95624: [OpenCL][PR48896] Fix default address space in template argument deduction

2021-03-11 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/test/SemaOpenCLCXX/address-space-templates.cl:60
+  // Preserve the address space of the type in forwarding reference.
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int &__private) 
const __generic'
+  foo4(i, [](auto&& x){;});

This check fails on 32-bit Windows platform where compiler adds  
`__attribute__((thiscall))` both constructor and call operator.

Something like this should fix the problem:

```
  // CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep 
&__private){{.*}} __generic'
  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int 
&__private){{.*}} const __generic'
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95624

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


[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Due to some complexities libc++ has dealing with the allocator, as well some 
optimizations it would be a serious undertaking to restructure libc++ to 
properly construct the types in the hash containers,
This change would be greatly simpler and much appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D98436: [Hexagon] Support inlined use of cs0 and cs1

2021-03-11 Thread Brian Cain via Phabricator via cfe-commits
bcain accepted this revision.
bcain added a comment.
This revision is now accepted and ready to land.

LGTM.  @kparzysz ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98436

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


[clang] 11b70b9 - Revert "[NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes"

2021-03-11 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2021-03-11T18:31:19-08:00
New Revision: 11b70b9e3a7458b5b78c30020b56e8ca563a4801

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

LOG: Revert "[NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear 
immutable function passes"

This reverts commit 5eaeb0fa67e57391f5584a3f67fdb131e93afda6.

It appears there are analyses that assume clearing - example:
https://lab.llvm.org/buildbot#builders/36/builds/5964

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/unittests/Analysis/CGSCCPassManagerTest.cpp

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 1e9d5d4d2629c..867203417754f 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -12,7 +12,7 @@
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
 ; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck -check-prefix=CHECK-O %s 
--dump-input=fail
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s --dump-input=fail
 
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
@@ -70,19 +70,24 @@
 ; CHECK-O: Starting CGSCC pass manager run.
 ; CHECK-O: Running pass: InlinerPass on (main)
 ; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)
-; CHECK-O: Invalidating analysis: DominatorTreeAnalysis on main
-; CHECK-O: Invalidating analysis: BasicAA on main
-; CHECK-O: Invalidating analysis: AAManager on main
+; CHECK-O: Clearing all analysis results for: main
 ; CHECK-O3: Running pass: ArgumentPromotionPass on (main)
+; CHECK-O3: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SROA on main
 ; These next two can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on main
+; CHECK-O-DAG: Running analysis: AssumptionAnalysis on main
 ; CHECK-O: Running pass: EarlyCSEPass on main
+; CHECK-O: Running analysis: TargetLibraryAnalysis on main
+; CHECK-O2: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
+; CHECK-O: Running analysis: ScopedNoAliasAA on main
+; CHECK-O: Running analysis: TypeBasedAA on main
+; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SpeculativeExecutionPass on main
 ; CHECK-O: Running pass: JumpThreadingPass on main
 ; CHECK-O: Running analysis: LazyValueAnalysis on main
@@ -91,6 +96,7 @@
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O3: Running pass: AggressiveInstCombinePass on main
 ; CHECK-O: Running pass: InstCombinePass on main
+; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running pass: LibCallsShrinkWrapPass on main
 ; CHECK-O: Running pass: TailCallElimPass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main

diff  --git a/llvm/lib/Analysis/CGSCCPassManager.cpp 
b/llvm/lib/Analysis/CGSCCPassManager.cpp
index fe7b30315f9ee..0a05c3c875e08 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -720,7 +720,7 @@ bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
   auto PAC = PA.getChecker();
   if (!PAC.preserved() && 
!PAC.preservedSet>()) {
 for (LazyCallGraph::Node &N : C)
-  FAM->invalidate(N.getFunction(), PA);
+  FAM->clear(N.getFunction(), N.getFunction().getName());
 
 return false;
   }

diff  --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp 
b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index ceaeaaf83e5d1..59ff97d0fc1a5 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1942,30 +1942,5 @@ TEST_F(CGSCCPassManagerTest, 
TestInsertionOfNewNonTrivialCallEdge) {
   ASSERT_TRUE(Ran);
 }
 
-TEST_F(CGSCCPassManagerTest, TestFunctionPassesAreQueriedForInvalidation) {
-  std::unique_ptr M = parseIR("define void @f() { ret void }");
-  CGSCCPassManager CGPM;
-  bool SCCCalled = false;
-  FunctionPassManager FPM;
-  int ImmRuns = 0;
-  FAM.registerPass([&] { return TestImmutableFunctionAnalysis(ImmRuns); });
-  FPM.addPass(RequireAnalysisPass());
-  CGPM.addPass(
-  LambdaSCCPass([&](LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
-LazyCallGraph &CG, CGSCCUpdateResult

[PATCH] D98440: [NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes

2021-03-11 Thread Mircea Trofin 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 rG5eaeb0fa67e5: [NPM][CGSCC] 
FunctionAnalysisManagerCGSCCProxy: do not clear immutable function… (authored 
by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98440

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp


Index: llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
===
--- llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1942,5 +1942,30 @@
   ASSERT_TRUE(Ran);
 }
 
+TEST_F(CGSCCPassManagerTest, TestFunctionPassesAreQueriedForInvalidation) {
+  std::unique_ptr M = parseIR("define void @f() { ret void }");
+  CGSCCPassManager CGPM;
+  bool SCCCalled = false;
+  FunctionPassManager FPM;
+  int ImmRuns = 0;
+  FAM.registerPass([&] { return TestImmutableFunctionAnalysis(ImmRuns); });
+  FPM.addPass(RequireAnalysisPass());
+  CGPM.addPass(
+  LambdaSCCPass([&](LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
+LazyCallGraph &CG, CGSCCUpdateResult &UR) {
+SCCCalled = true;
+return PreservedAnalyses::none();
+  }));
+  CGPM.addPass(createCGSCCToFunctionPassAdaptor(
+  RequireAnalysisPass()));
+  ModulePassManager MPM;
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+  MPM.run(*M, MAM);
+  ASSERT_EQ(ImmRuns, 1);
+  ASSERT_TRUE(SCCCalled);
+}
+
 #endif
 } // namespace
Index: llvm/lib/Analysis/CGSCCPassManager.cpp
===
--- llvm/lib/Analysis/CGSCCPassManager.cpp
+++ llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -720,7 +720,7 @@
   auto PAC = PA.getChecker();
   if (!PAC.preserved() && 
!PAC.preservedSet>()) {
 for (LazyCallGraph::Node &N : C)
-  FAM->clear(N.getFunction(), N.getFunction().getName());
+  FAM->invalidate(N.getFunction(), PA);
 
 return false;
   }
Index: clang/test/CodeGen/thinlto-distributed-newpm.ll
===
--- clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -12,7 +12,7 @@
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
 ; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s --dump-input=fail
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck -check-prefix=CHECK-O %s 
--dump-input=fail
 
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
@@ -70,24 +70,19 @@
 ; CHECK-O: Starting CGSCC pass manager run.
 ; CHECK-O: Running pass: InlinerPass on (main)
 ; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)
-; CHECK-O: Clearing all analysis results for: main
+; CHECK-O: Invalidating analysis: DominatorTreeAnalysis on main
+; CHECK-O: Invalidating analysis: BasicAA on main
+; CHECK-O: Invalidating analysis: AAManager on main
 ; CHECK-O3: Running pass: ArgumentPromotionPass on (main)
-; CHECK-O3: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SROA on main
 ; These next two can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on main
-; CHECK-O-DAG: Running analysis: AssumptionAnalysis on main
 ; CHECK-O: Running pass: EarlyCSEPass on main
-; CHECK-O: Running analysis: TargetLibraryAnalysis on main
-; CHECK-O2: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
-; CHECK-O: Running analysis: ScopedNoAliasAA on main
-; CHECK-O: Running analysis: TypeBasedAA on main
-; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SpeculativeExecutionPass on main
 ; CHECK-O: Running pass: JumpThreadingPass on main
 ; CHECK-O: Running analysis: LazyValueAnalysis on main
@@ -96,7 +91,6 @@
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O3: Running pass: AggressiveInstCombinePass on main
 ; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running pass: LibCallsShrinkWrapPass on main
 ; CHECK-O: Running pass: TailCallElimPass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main


Index: llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
==

[clang] 5eaeb0f - [NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes

2021-03-11 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2021-03-11T18:15:28-08:00
New Revision: 5eaeb0fa67e57391f5584a3f67fdb131e93afda6

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

LOG: [NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable 
function passes

Check with the analysis result by calling invalidate instead of clear on
the analysis manager.

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

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/unittests/Analysis/CGSCCPassManagerTest.cpp

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 867203417754..1e9d5d4d2629 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -12,7 +12,7 @@
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
 ; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s --dump-input=fail
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck -check-prefix=CHECK-O %s 
--dump-input=fail
 
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
@@ -70,24 +70,19 @@
 ; CHECK-O: Starting CGSCC pass manager run.
 ; CHECK-O: Running pass: InlinerPass on (main)
 ; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)
-; CHECK-O: Clearing all analysis results for: main
+; CHECK-O: Invalidating analysis: DominatorTreeAnalysis on main
+; CHECK-O: Invalidating analysis: BasicAA on main
+; CHECK-O: Invalidating analysis: AAManager on main
 ; CHECK-O3: Running pass: ArgumentPromotionPass on (main)
-; CHECK-O3: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SROA on main
 ; These next two can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on main
-; CHECK-O-DAG: Running analysis: AssumptionAnalysis on main
 ; CHECK-O: Running pass: EarlyCSEPass on main
-; CHECK-O: Running analysis: TargetLibraryAnalysis on main
-; CHECK-O2: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
-; CHECK-O: Running analysis: ScopedNoAliasAA on main
-; CHECK-O: Running analysis: TypeBasedAA on main
-; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SpeculativeExecutionPass on main
 ; CHECK-O: Running pass: JumpThreadingPass on main
 ; CHECK-O: Running analysis: LazyValueAnalysis on main
@@ -96,7 +91,6 @@
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O3: Running pass: AggressiveInstCombinePass on main
 ; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running pass: LibCallsShrinkWrapPass on main
 ; CHECK-O: Running pass: TailCallElimPass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main

diff  --git a/llvm/lib/Analysis/CGSCCPassManager.cpp 
b/llvm/lib/Analysis/CGSCCPassManager.cpp
index 0a05c3c875e0..fe7b30315f9e 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -720,7 +720,7 @@ bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
   auto PAC = PA.getChecker();
   if (!PAC.preserved() && 
!PAC.preservedSet>()) {
 for (LazyCallGraph::Node &N : C)
-  FAM->clear(N.getFunction(), N.getFunction().getName());
+  FAM->invalidate(N.getFunction(), PA);
 
 return false;
   }

diff  --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp 
b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index 59ff97d0fc1a..ceaeaaf83e5d 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1942,5 +1942,30 @@ TEST_F(CGSCCPassManagerTest, 
TestInsertionOfNewNonTrivialCallEdge) {
   ASSERT_TRUE(Ran);
 }
 
+TEST_F(CGSCCPassManagerTest, TestFunctionPassesAreQueriedForInvalidation) {
+  std::unique_ptr M = parseIR("define void @f() { ret void }");
+  CGSCCPassManager CGPM;
+  bool SCCCalled = false;
+  FunctionPassManager FPM;
+  int ImmRuns = 0;
+  FAM.registerPass([&] { return TestImmutableFunctionAnalysis(ImmRuns); });
+  FPM.addPass(RequireAnalysisPass());
+  CGPM.addPass(
+  LambdaSCCPass([&](LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
+LazyCallGraph &CG, CGSCCUpdateResult &UR) {
+SCCCalled = true;
+   

[clang] bd2bdad - void cast to suppress -Wunused-variable in non-asserts build

2021-03-11 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-03-11T17:51:31-08:00
New Revision: bd2bdad19e5a3bf910da7c2d1936a7e18b47c084

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

LOG: void cast to suppress -Wunused-variable in non-asserts build

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 39e0d8d5608d..4774f92a2eed 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3162,6 +3162,7 @@ Value *ScalarExprEmitter::EmitDiv(const BinOpInfo &Ops) {
 // We need to check the types of the operands of the operator to get the
 // correct matrix dimensions.
 auto *BO = cast(Ops.E);
+(void)BO;
 assert(
 isa(BO->getLHS()->getType().getCanonicalType()) &&
 "first operand must be a matrix");



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


[PATCH] D98388: [RISCV][Clang] Add RVV vle/vse intrinsic functions.

2021-03-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:225
+Ops[0] = Builder.CreateBitCast(Ops[0],
+llvm::PointerType::getUnqual(ResultType)); }],
+  ManualCodegenMask= [{

I think you can use ResultType->getPointerTo() which is a little shorter



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics/vle.c:7
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
+// RUN:   -Werror -Wall -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t

Can we use 2>&1 instead of 2>%t and skip the temporary file?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:686
+// maskedoff operand which is always in first operand.
+unsigned skew = 0;
+if (HasMaskedOffOperand)

Capitalize Skew


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98388

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


[PATCH] D98466: [WebAssembly] Remove experimental SIMD instructions

2021-03-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 330116.
tlively added a comment.

- Remove widen as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98466

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/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-prefetch-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
@@ -664,18 +664,6 @@
 # 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,0xd4,0x01]
-f32x4.qfms
-
-# CHECK: f64x2.qfma # encoding: [0xfd,0xfe,0x01]
-f64x2.qfma
-
-# CHECK: f64x2.qfms # encoding: [0xfd,0xff,0x01]
-f64x2.qfms
-
 # CHECK: i16x8.extmul_low_i8x16_s # encoding: [0xfd,0x9a,0x01]
 i16x8.extmul_low_i8x16_s
 
@@ -712,18 +700,6 @@
 # CHECK: i64x2.extmul_high_i32x4_u # encoding: [0xfd,0xd7,0x01]
 i64x2.extmul_high_i32x4_u
 
-# CHECK: i8x16.signselect # encoding: [0xfd,0x7d]
-i8x16.signselect
-
-# CHECK: i16x8.signselect # encoding: [0xfd,0x7e]
-i16x8.signselect
-
-# CHECK: i32x4.signselect # encoding: [0xfd,0x7f]
-i32x4.signselect
-
-# CHECK: i64x2.signselect # encoding: [0xfd,0x94,0x01]
-i64x2.signselect
-
 # CHECK: i16x8.extadd_pairwise_i8x16_s # encoding: [0xfd,0xc2,0x01]
 i16x8.extadd_pairwise_i8x16_s
 
@@ -736,12 +712,6 @@
 # CHECK: i32x4.extadd_pairwise_i16x8_u # encoding: [0xfd,0xa6,0x01]
 i32x4.extadd_pairwise_i16x8_u
 
-# CHECK: prefetch.t 16 # encoding: [0xfd,0xc5,0x01,0x00,0x10]
-prefetch.t 16
-
-# CHECK: prefetch.nt 16 # encoding: [0xfd,0xc6,0x01,0x00,0x10]
-prefetch.nt 16
-
 # CHECK: f64x2.convert_low_i32x4_s # encoding: [0xfd,0x53]
 f64x2.convert_low_i32x4_s
 
@@ -760,10 +730,4 @@
 # CHECK: f64x2.promote_low_f32x4 # encoding: [0xfd,0x69]
 f64x2.promote_low_f32x4
 
-# CHECK: i32x4.widen_i8x16_s 3 # encoding: [0xfd,0x67,0x03]
-i32x4.widen_i8x16_s 3
-
-# CHECK: i32x4.widen_i8x16_u 3 # encoding: [0xfd,0x68,0x03]
-i32x4.widen_i8x16_u 3
-
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-prefetch-offset.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-prefetch-offset.ll
+++ /dev/null
@@ -1,235 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -verify-machineinstrs -mattr=+simd128 | FileCheck %s
-
-; Test experimental prefetch instructions
-
-target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown"
-
-declare void @llvm.wasm.prefetch.t(i8*)
-declare void @llvm.wasm.prefetch.nt(i8*)
-@gv = global i8 0
-
-;===
-; prefetch.t
-;===
-
-define void @prefetch_t_no_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_no_offset:
-; CHECK: .functype prefetch_t_no_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  tail call void @llvm.wasm.prefetch.t(i8* %p)
-  ret void
-}
-
-define void @prefetch_t_with_folded_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_with_folded_offset:
-; CHECK: .functype prefetch_t_with_folded_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:i32.const 24
-; CHECK-NEXT:i32.add
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  %q = ptrtoint i8* %p to i32
-  %r = add nuw i32 %q, 24
-  %s = inttoptr i32 %r to i8*
-  tail call void @llvm.wasm.prefetch.t(i8* %s)
-  ret void
-}
-
-define void @prefetch_t_with_folded_gep_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_with_folded_gep_offset:
-; CHECK: .functype prefetch_t_with_folded_gep_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:i32.const 6
-; CHECK-NEXT:i32.add
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  %s = getelementptr inbounds i8, i8* %p, i32 6
-  tail call void @llvm.wasm.prefetch.t(i8* %s)
-  ret void
-}
-
-define void @prefetch_t_with_unfolded_gep_negative_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_with_unfolded_gep_negative_offset:
-; CHE

[PATCH] D98472: Emit inline implementation of __builtin__wmemchr on MSVCRT platforms.

2021-03-11 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added a reviewer: rnk.
akhuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The MSVC runtime library doesn't have a definition for wmemchr,
so provide an inline implementation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98472

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/wmemchr.c


Index: clang/test/CodeGen/wmemchr.c
===
--- /dev/null
+++ clang/test/CodeGen/wmemchr.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+
+const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
+  // CHECK: [[S:%.*]] = load
+  // CHECK: [[C:%.*]] = load
+  // CHECK: [[N:%.*]] = load
+  // CHECK: [[N0:%.*]] = icmp eq i64 [[N]], 0
+  // CHECK: br i1 [[N0]], label %[[EXIT:.*]], label %[[EQ:.*]]
+
+  // CHECK: [[EQ]]:
+  // CHECK: [[SP:%.*]] = phi i16* [ [[S]], %[[ENTRY:.*]] ], [ [[SN:.*]], 
%[[NEXT:.*]] ]
+  // CHECK: [[NP:%.*]] = phi i64 [ [[N]], %[[ENTRY]] ], [ [[NN:.*]], %[[NEXT]] 
]
+  // CHECK: [[SL:%.*]] = load i16, i16* [[SP]], align 2
+  // CHECK: [[RES:%.*]] = getelementptr inbounds i16, i16* [[SP]], i32 0
+  // CHECK: [[CMPEQ:%.*]] = icmp eq i16 [[SL]], [[C]]
+  // CHECK: br i1 [[CMPEQ]], label %[[EXIT]], label %[[LT:.*]]
+
+  // CHECK: [[NEXT]]:
+  // CHECK: [[SN]] = getelementptr inbounds i16, i16* [[SP]], i32 1
+  // CHECK: [[NN]] = sub i64 [[NP]], 1
+  // CHECK: [[NN0:%.*]] = icmp eq i64 [[NN]], 0
+  // CHECK: br i1 [[NN0]], label %[[EXIT]], label %[[EQ]]
+  //
+  // CHECK: [[EXIT]]:
+  // CHECK: [[RV:%.*]] = phi i16* [ null, %[[ENTRY]] ], [ null, %[[NEXT]] ], [ 
[[RES]], %[[EQ]] ] 
+  // CHECK: ret i16* [[RV]]
+  return __builtin_wmemchr(s, c, n);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3356,6 +3356,52 @@
 Builder.CreateMemSet(Dest, ByteVal, SizeVal, false);
 return RValue::get(Dest.getPointer());
   }
+  case Builtin::BI__builtin_wmemchr: {
+// The MSVC runtime library does not provide a definition of wmemchr, so we
+// need an inline implementation.
+if (!getTarget().getTriple().isOSMSVCRT())
+  break;
+
+llvm::Type *WCharTy = ConvertType(getContext().WCharTy);
+Value *Str = EmitScalarExpr(E->getArg(0));
+Value *Chr = EmitScalarExpr(E->getArg(1));
+Value *Size = EmitScalarExpr(E->getArg(2));
+
+BasicBlock *Entry = Builder.GetInsertBlock();
+BasicBlock *CmpEq = createBasicBlock("wmemchr.eq");
+BasicBlock *Next = createBasicBlock("wmemchr.next");
+BasicBlock *Exit = createBasicBlock("wmemchr.exit");
+Value *SizeEq0 = Builder.CreateICmpEQ(Size, ConstantInt::get(SizeTy, 0));
+Builder.CreateCondBr(SizeEq0, Exit, CmpEq);
+
+EmitBlock(CmpEq);
+PHINode *StrPhi = Builder.CreatePHI(Str->getType(), 2);
+StrPhi->addIncoming(Str, Entry);
+PHINode *SizePhi = Builder.CreatePHI(SizeTy, 2);
+SizePhi->addIncoming(Size, Entry);
+CharUnits WCharAlign =
+getContext().getTypeAlignInChars(getContext().WCharTy);
+Value *StrCh = Builder.CreateAlignedLoad(WCharTy, StrPhi, WCharAlign);
+Value *FoundChr = Builder.CreateConstInBoundsGEP1_32(WCharTy, StrPhi, 0);
+Value *StrEqChr = Builder.CreateICmpEQ(StrCh, Chr);
+Builder.CreateCondBr(StrEqChr, Exit, Next);
+
+EmitBlock(Next);
+Value *NextStr = Builder.CreateConstInBoundsGEP1_32(WCharTy, StrPhi, 1);
+Value *NextSize = Builder.CreateSub(SizePhi, ConstantInt::get(SizeTy, 1));
+Value *NextSizeEq0 =
+Builder.CreateICmpEQ(NextSize, ConstantInt::get(SizeTy, 0));
+Builder.CreateCondBr(NextSizeEq0, Exit, CmpEq);
+StrPhi->addIncoming(NextStr, Next);
+SizePhi->addIncoming(NextSize, Next);
+
+EmitBlock(Exit);
+PHINode *Ret = Builder.CreatePHI(Str->getType(), 3);
+Ret->addIncoming(llvm::Constant::getNullValue(Str->getType()), Entry);
+Ret->addIncoming(llvm::Constant::getNullValue(Str->getType()), Next);
+Ret->addIncoming(FoundChr, CmpEq);
+return RValue::get(Ret);
+  }
   case Builtin::BI__builtin_wmemcmp: {
 // The MSVC runtime library does not provide a definition of wmemcmp, so we
 // need an inline implementation.


Index: clang/test/CodeGen/wmemchr.c
===
--- /dev/null
+++ clang/test/CodeGen/wmemchr.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+
+const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
+  // CHECK: [[S:%.*]] = load
+  // CHECK: [[C:%.*]] = load
+  // CHECK: [[N:%.*]] = load
+  // CHECK: [[N0:%.*]] = icmp eq i64 [[N]], 0
+  // CHECK: br 

[PATCH] D91556: [OpenMPIRBuilder} Add capturing of parameters to pass to omp::parallel

2021-03-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: ggeorgakoudis.
jdoerfert added a comment.

In D91556#2617144 , @kiranchandramohan 
wrote:

> Ping @llitchev. Would you have time to take this forward?

I think @ggeorgakoudis is working on an alternative API solution, we might need 
to pick up the MLIR parts though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91556

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


[PATCH] D98295: [Clang] Add addrsig attribute to mark global functions/variables as address significant.

2021-03-11 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 330099.
zequanwu added a comment.

Split clang change and IR change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98295

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/attr-addrsig.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-addrsig.c

Index: clang/test/Sema/attr-addrsig.c
===
--- /dev/null
+++ clang/test/Sema/attr-addrsig.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+__attribute__((addrsig)) int i;
+
+__attribute__((addrsig)) void f();
+__attribute__((addrsig)) void g() {}
+
+struct __attribute__((addrsig)) A {}; // expected-warning {{'addrsig' attribute only applies to functions and variables}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -10,6 +10,7 @@
 // CHECK-NEXT: AVRSignal (SubjectMatchRule_function)
 // CHECK-NEXT: AbiTag (SubjectMatchRule_record_not_is_union, SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_namespace)
 // CHECK-NEXT: AcquireHandle (SubjectMatchRule_function, SubjectMatchRule_type_alias, SubjectMatchRule_variable_is_parameter)
+// CHECK-NEXT: Addrsig (SubjectMatchRule_function, SubjectMatchRule_variable)
 // CHECK-NEXT: Alias (SubjectMatchRule_function, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: AlignValue (SubjectMatchRule_variable, SubjectMatchRule_type_alias)
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
Index: clang/test/CodeGenCXX/attr-addrsig.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/attr-addrsig.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -S -emit-llvm %s -triple x86_64-unknown-linux-gnu -O2 -o - | FileCheck %s
+
+// CHECK: @i1 = {{.*}}unnamed_addr
+// CHECK-NEXT: @i2 = {{.*}}unnamed_addr
+int i1;
+int i2 = 0;
+
+// CHECK: @i3 = {{.*}}significant_addr
+// CHECK-NEXT: @i4 = {{.*}}significant_addr
+[[clang::addrsig]] int i3;
+[[clang::addrsig]] int i4 = 0;
+
+// CHECK-DAG: declare void @_Z2f1i{{.*}}unnamed_addr
+void f1(int i);
+// CHECK-DAG: define dso_local i32 @_Z2f2i{{.*}}unnamed_addr
+int f2(int i) {
+f1(i);
+return i * 2;
+}
+
+// CHECK-DAG: declare void @_Z2f3i{{.*}}significant_addr
+[[clang::addrsig]] void f3(int i);
+void f3(int i);
+// CHECK-DAG: define dso_local i32 @_Z2f4i{{.*}}significant_addr
+[[clang::addrsig]] int f4(int i) {
+f3(i);
+return i * 2;
+}
+
+
+// CHECK-DAG: declare void @_ZN1AC1Ev{{.*}}unnamed_addr
+// CHECK-DAG: declare void @_ZN1AD1Ev{{.*}}unnamed_addr
+// CHECK-DAG: declare void @_ZN1A2f1Ev{{.*}}unnamed_addr
+// CHECK-DAG: declare void @_ZN1A2f2Ev{{.*}}unnamed_addr
+
+// CHECK-DAG: declare void @_ZN1BC1Ev{{.*}}significant_addr
+// CHECK-DAG: declare void @_ZN1BD1Ev{{.*}}significant_addr
+// CHECK-DAG: declare void @_ZN1B2f1Ev{{.*}}significant_addr
+// CHECK-DAG: declare void @_ZN1B2f2Ev{{.*}}significant_addr
+struct A {
+A();
+~A();
+void f1();
+virtual void f2();
+};
+
+struct B {
+[[clang::addrsig]] B();
+[[clang::addrsig]] ~B();
+[[clang::addrsig]] void f1();
+[[clang::addrsig]] virtual void f2();
+};
+
+void test() {
+A a;
+B b;
+a.f1();
+a.f2();
+b.f1();
+b.f2();
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2054,6 +2054,9 @@
 if (MD->isVirtual())
   F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
+  if (FD->hasAttr())
+F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Significant);
+
   // Don't emit entries for function declarations in the cross-DSO mode. This
   // is handled with better precision by the receiving DSO. But if jump tables
   // are non-canonical then we need type metadata in order to produce the local
@@ -4294,6 +4297,9 @@
   if (D->hasAttr())
 AddGlobalAnnotations(D, GV);
 
+  if (D->hasAttr())
+GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Significant);
+
   // Set the llvm linkage type as appropriate.
   llvm::GlobalValue::LinkageTypes Linkage =
   getLLVMLinkageVarDefinition(D, GV->isConstant());
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -443,6 +443,18 @@
   }];
 }
 
+def AddrsigDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Functions or variables attached with ``addrsig`` will be put i

[PATCH] D98418: [OpenCL] Remove mixed signedness atomic_fetch_ from opencl-c.h

2021-03-11 Thread Stuart Brady via Phabricator via cfe-commits
stuart accepted this revision.
stuart added a comment.
This revision is now accepted and ready to land.

Looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98418

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


[PATCH] D98466: [WebAssembly] Remove experimental SIMD instructions

2021-03-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: wingo, ecnelises, sunfish, hiraditya, 
jgravelle-google, sbc100.
tlively requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Removes the instruction definitions, intrinsics, and builtins for qfma/qfms,
signselect, and prefetch instructions, which were not included in the final
WebAssembly SIMD spec.

Depends on D98457 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98466

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/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-prefetch-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
@@ -664,18 +664,6 @@
 # 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,0xd4,0x01]
-f32x4.qfms
-
-# CHECK: f64x2.qfma # encoding: [0xfd,0xfe,0x01]
-f64x2.qfma
-
-# CHECK: f64x2.qfms # encoding: [0xfd,0xff,0x01]
-f64x2.qfms
-
 # CHECK: i16x8.extmul_low_i8x16_s # encoding: [0xfd,0x9a,0x01]
 i16x8.extmul_low_i8x16_s
 
@@ -712,18 +700,6 @@
 # CHECK: i64x2.extmul_high_i32x4_u # encoding: [0xfd,0xd7,0x01]
 i64x2.extmul_high_i32x4_u
 
-# CHECK: i8x16.signselect # encoding: [0xfd,0x7d]
-i8x16.signselect
-
-# CHECK: i16x8.signselect # encoding: [0xfd,0x7e]
-i16x8.signselect
-
-# CHECK: i32x4.signselect # encoding: [0xfd,0x7f]
-i32x4.signselect
-
-# CHECK: i64x2.signselect # encoding: [0xfd,0x94,0x01]
-i64x2.signselect
-
 # CHECK: i16x8.extadd_pairwise_i8x16_s # encoding: [0xfd,0xc2,0x01]
 i16x8.extadd_pairwise_i8x16_s
 
@@ -736,12 +712,6 @@
 # CHECK: i32x4.extadd_pairwise_i16x8_u # encoding: [0xfd,0xa6,0x01]
 i32x4.extadd_pairwise_i16x8_u
 
-# CHECK: prefetch.t 16 # encoding: [0xfd,0xc5,0x01,0x00,0x10]
-prefetch.t 16
-
-# CHECK: prefetch.nt 16 # encoding: [0xfd,0xc6,0x01,0x00,0x10]
-prefetch.nt 16
-
 # CHECK: f64x2.convert_low_i32x4_s # encoding: [0xfd,0x53]
 f64x2.convert_low_i32x4_s
 
Index: llvm/test/CodeGen/WebAssembly/simd-prefetch-offset.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-prefetch-offset.ll
+++ /dev/null
@@ -1,235 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -verify-machineinstrs -mattr=+simd128 | FileCheck %s
-
-; Test experimental prefetch instructions
-
-target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown"
-
-declare void @llvm.wasm.prefetch.t(i8*)
-declare void @llvm.wasm.prefetch.nt(i8*)
-@gv = global i8 0
-
-;===
-; prefetch.t
-;===
-
-define void @prefetch_t_no_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_no_offset:
-; CHECK: .functype prefetch_t_no_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  tail call void @llvm.wasm.prefetch.t(i8* %p)
-  ret void
-}
-
-define void @prefetch_t_with_folded_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_with_folded_offset:
-; CHECK: .functype prefetch_t_with_folded_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:i32.const 24
-; CHECK-NEXT:i32.add
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  %q = ptrtoint i8* %p to i32
-  %r = add nuw i32 %q, 24
-  %s = inttoptr i32 %r to i8*
-  tail call void @llvm.wasm.prefetch.t(i8* %s)
-  ret void
-}
-
-define void @prefetch_t_with_folded_gep_offset(i8* %p) {
-; CHECK-LABEL: prefetch_t_with_folded_gep_offset:
-; CHECK: .functype prefetch_t_with_folded_gep_offset (i32) -> ()
-; CHECK-NEXT:  # %bb.0:
-; CHECK-NEXT:local.get 0
-; CHECK-NEXT:i32.const 6
-; CHECK-NEXT:i32.add
-; CHECK-NEXT:prefetch.t 0
-; CHECK-NEXT:# fallthrough-return
-  %s = getelementptr inbounds i8, i8* %p, i32 6
-  tail call void @llvm.wasm.prefetch.t(i8* %s)
-  ret void
-}
-
-define void @prefetch_t_with_unfolded_gep_negative_offset(i8* %p) {
-; CHECK-LABEL: prefe

[PATCH] D97224: Use Address for CGBuilder's CreateAtomicRMW and CreateAtomicCmpXchg.

2021-03-11 Thread James Y Knight via Phabricator via cfe-commits
jyknight updated this revision to Diff 330088.
jyknight added a comment.

Use natural alignment for `_Interlocked*` intrinsics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97224

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGen/ms-intrinsics-underaligned.c
  clang/test/CodeGen/ms-intrinsics.c
  clang/test/OpenMP/parallel_reduction_codegen.cpp

Index: clang/test/OpenMP/parallel_reduction_codegen.cpp
===
--- clang/test/OpenMP/parallel_reduction_codegen.cpp
+++ clang/test/OpenMP/parallel_reduction_codegen.cpp
@@ -198,7 +198,7 @@
 // LAMBDA: br label %[[REDUCTION_DONE]]
 // LAMBDA: [[CASE2]]
 // LAMBDA: [[G_PRIV_VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]]
-// LAMBDA: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic, align 4
+// LAMBDA: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic, align 128
 // LAMBDA: br label %[[REDUCTION_DONE]]
 // LAMBDA: [[REDUCTION_DONE]]
 // LAMBDA: ret void
@@ -255,7 +255,7 @@
 // BLOCKS: br label %[[REDUCTION_DONE]]
 // BLOCKS: [[CASE2]]
 // BLOCKS: [[G_PRIV_VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]]
-// BLOCKS: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic, align 4
+// BLOCKS: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic, align 128
 // BLOCKS: br label %[[REDUCTION_DONE]]
 // BLOCKS: [[REDUCTION_DONE]]
 // BLOCKS: ret void
@@ -771,7 +771,7 @@
 // case 2:
 // t_var += t_var_reduction;
 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]]
-// CHECK: atomicrmw add i32* [[T_VAR_REF]], i32 [[T_VAR_PRIV_VAL]] monotonic, align 4
+// CHECK: atomicrmw add i32* [[T_VAR_REF]], i32 [[T_VAR_PRIV_VAL]] monotonic, align 128
 
 // var = var.operator &(var_reduction);
 // CHECK: call void @__kmpc_critical(
@@ -801,7 +801,7 @@
 
 // t_var1 = min(t_var1, t_var1_reduction);
 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_PRIV]]
-// CHECK: atomicrmw min i32* [[T_VAR1_REF]], i32 [[T_VAR1_PRIV_VAL]] monotonic, align 4
+// CHECK: atomicrmw min i32* [[T_VAR1_REF]], i32 [[T_VAR1_PRIV_VAL]] monotonic, align 128
 
 // break;
 // CHECK: br label %[[RED_DONE]]
Index: clang/test/CodeGen/ms-intrinsics.c
===
--- clang/test/CodeGen/ms-intrinsics.c
+++ clang/test/CodeGen/ms-intrinsics.c
@@ -450,10 +450,10 @@
 // CHECK-64: [[EL:%[0-9]+]] = zext i64 %inc1 to i128
 // CHECK-64: [[EHS:%[0-9]+]] = shl nuw i128 [[EH]], 64
 // CHECK-64: [[EXP:%[0-9]+]] = or i128 [[EHS]], [[EL]]
-// CHECK-64: [[ORG:%[0-9]+]] = load i128, i128* [[CNR]], align 16
+// CHECK-64: [[ORG:%[0-9]+]] = load i128, i128* [[CNR]], align 8
 // CHECK-64: [[RES:%[0-9]+]] = cmpxchg volatile i128* [[DST]], i128 [[ORG]], i128 [[EXP]] seq_cst seq_cst, align 16
 // CHECK-64: [[OLD:%[0-9]+]] = extractvalue { i128, i1 } [[RES]], 0
-// CHECK-64: store i128 [[OLD]], i128* [[CNR]], align 16
+// CHECK-64: store i128 [[OLD]], i128* [[CNR]], align 8
 // CHECK-64: [[SUC1:%[0-9]+]] = extractvalue { i128, i1 } [[RES]], 1
 // CHECK-64: [[SUC8:%[0-9]+]] = zext i1 [[SUC1]] to i8
 // CHECK-64: ret i8 [[SUC8]]
Index: clang/test/CodeGen/ms-intrinsics-underaligned.c
===
--- /dev/null
+++ clang/test/CodeGen/ms-intrinsics-underaligned.c
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
+// RUN: -triple x86_64--windows -Oz -emit-llvm -target-feature +cx16 %s -o - \
+// RUN: | FileCheck %s
+
+// Ensure that we emit _Interlocked atomic operations specifying natural
+// alignment, even when clang's usual alignment derivation would result in a
+// lower alignment value.
+
+// intrin.h needs size_t, but -ffreestanding prevents us from getting it from
+// stddef.h.  Work around it with this typedef.
+typedef __SIZE_TYPE__ size_t;
+
+#include 
+
+#pragma pack(1)
+typedef struct {
+  char a;
+  short b;
+  long c;
+  long long d;
+  void *p;
+} X;
+
+_Static_assert(sizeof(X) == 23, "");
+_Static_assert(__alignof__(X) == 1, "");
+
+// CHECK-LABEL: @test_InterlockedExchangePointer(
+// CHECK:   atomicrmw {{.*}} align 8
+void *test_InterlockedExchangePointer(X *x) {
+  return _InterlockedExchangePointer(&x->p, 0);
+}
+
+// CHECK-LABEL: @test_InterlockedExchange8(
+// CHECK:   atomicrmw {{.*}} align 1
+char test_InterlockedExchange8(X *x) {
+  return _InterlockedExchange8(&x->a, 0);
+}
+
+// CHECK-LABEL: @test_InterlockedExchange16(
+// CHECK:   atomicrmw {{.*}} align 2
+short test_InterlockedExchange16(X *x) {
+  return _InterlockedExchange16(&x->b, 0);
+}
+
+// CHECK-LABEL: @

[PATCH] D98458: Revert "[CodeGenModule] Set dso_local for Mach-O GlobalValue"

2021-03-11 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

+ Lang, who probably has a better understanding of this, for visibility.
I don't think this should be blocked further, but he might have a chance to 
comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98458

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


[PATCH] D98458: Revert "[CodeGenModule] Set dso_local for Mach-O GlobalValue"

2021-03-11 Thread Davide Italiano via Phabricator via cfe-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98458

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


[PATCH] D98458: Revert "[CodeGenModule] Set dso_local for Mach-O GlobalValue"

2021-03-11 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

In D98458#2620731 , @MaskRay wrote:

>> Mach-O doesn't support dso_local and this change broke XNU because of the 
>> use of dso_local.
>
> Can you elaborate on the unsupportness? For example, the backend can ignore 
> dso_local if it does not want to support it.
>
> The main purpose is to reduce target differences: currently both COFF and ELF 
> can use dso_local. If Mach-O doesn't like dso_local, there is an additional 
> difference.

The model for `dso_local` is different on Mach-O. While it's a laudable goal to 
unify the three formats, we might want to consider to not push these changes 
willy-nilly.
We should consider investigating what's broken but the reality is that this 
breaks xnu so we need to revert this for the time being.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98458

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-11 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:293
+  driverPath = driverPath.substr(0, driverPath.size() - 9);
+  return driverPath.append("/../tools/flang/include/flang/");
+}

tskeith wrote:
> Does this work for an install? I think there the path would be 
> `include/flang` rather than `tools/flang/include/flang`.
You are probably right, I am giving the path w.r.t a build.  Can we make the 
assumption that there should be always an install?  Or do we determine if we 
flang-new is coming from build or install (by checking if a module file is 
present through ls)  and then set the path accordingly?


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

https://reviews.llvm.org/D97080

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-11 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:293
+  driverPath = driverPath.substr(0, driverPath.size() - 9);
+  return driverPath.append("/../tools/flang/include/flang/");
+}

Does this work for an install? I think there the path would be `include/flang` 
rather than `tools/flang/include/flang`.


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

https://reviews.llvm.org/D97080

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


[PATCH] D98459: [CodeCompletion] Don't track preferred types if code completion is disabled.

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Some of this work isn't quite trivial.

(As requested in D96058 )


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98459

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaCodeComplete.cpp

Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -381,6 +381,8 @@
 } // namespace
 
 void PreferredTypeBuilder::enterReturn(Sema &S, SourceLocation Tok) {
+  if (!Enabled)
+return;
   if (isa(S.CurContext)) {
 if (sema::BlockScopeInfo *BSI = S.getCurBlock()) {
   ComputeType = nullptr;
@@ -399,6 +401,8 @@
 }
 
 void PreferredTypeBuilder::enterVariableInit(SourceLocation Tok, Decl *D) {
+  if (!Enabled)
+return;
   auto *VD = llvm::dyn_cast_or_null(D);
   ComputeType = nullptr;
   Type = VD ? VD->getType() : QualType();
@@ -410,6 +414,8 @@
 void PreferredTypeBuilder::enterDesignatedInitializer(SourceLocation Tok,
   QualType BaseType,
   const Designation &D) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getDesignatedType(BaseType, D);
   ExpectedLoc = Tok;
@@ -417,6 +423,8 @@
 
 void PreferredTypeBuilder::enterFunctionArgument(
 SourceLocation Tok, llvm::function_ref ComputeType) {
+  if (!Enabled)
+return;
   this->ComputeType = ComputeType;
   Type = QualType();
   ExpectedLoc = Tok;
@@ -424,6 +432,8 @@
 
 void PreferredTypeBuilder::enterParenExpr(SourceLocation Tok,
   SourceLocation LParLoc) {
+  if (!Enabled)
+return;
   // expected type for parenthesized expression does not change.
   if (ExpectedLoc == LParLoc)
 ExpectedLoc = Tok;
@@ -541,6 +551,8 @@
 
 void PreferredTypeBuilder::enterBinary(Sema &S, SourceLocation Tok, Expr *LHS,
tok::TokenKind Op) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getPreferredTypeOfBinaryRHS(S, LHS, Op);
   ExpectedLoc = Tok;
@@ -548,7 +560,7 @@
 
 void PreferredTypeBuilder::enterMemAccess(Sema &S, SourceLocation Tok,
   Expr *Base) {
-  if (!Base)
+  if (!Enabled || !Base)
 return;
   // Do we have expected type for Base?
   if (ExpectedLoc != Base->getBeginLoc())
@@ -561,6 +573,8 @@
 void PreferredTypeBuilder::enterUnary(Sema &S, SourceLocation Tok,
   tok::TokenKind OpKind,
   SourceLocation OpLoc) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getPreferredTypeOfUnaryArg(S, this->get(OpLoc), OpKind);
   ExpectedLoc = Tok;
@@ -568,6 +582,8 @@
 
 void PreferredTypeBuilder::enterSubscript(Sema &S, SourceLocation Tok,
   Expr *LHS) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = S.getASTContext().IntTy;
   ExpectedLoc = Tok;
@@ -575,12 +591,16 @@
 
 void PreferredTypeBuilder::enterTypeCast(SourceLocation Tok,
  QualType CastType) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = !CastType.isNull() ? CastType.getCanonicalType() : QualType();
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterCondition(Sema &S, SourceLocation Tok) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = S.getASTContext().BoolTy;
   ExpectedLoc = Tok;
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -49,10 +49,10 @@
 }
 
 Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
-  : PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
-GreaterThanIsOperator(true), ColonIsSacred(false),
-InMessageExpression(false), TemplateParameterDepth(0),
-ParsingInObjCContainer(false) {
+: PP(pp), PreferredType(pp.isCodeCompletionEnabled()), Actions(actions),
+  Diags(PP.getDiagnostics()), GreaterThanIsOperator(true),
+  ColonIsSacred(false), InMessageExpression(false),
+  TemplateParameterDepth(0), ParsingInObjCContainer(false) {
   SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies;
   Tok.startToken();
   Tok.setKind(tok::eof);
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -286,14 +286,13 @@
   }
 };
 
-/// Keeps track of expected type during expression parsing. The type is tied to
-/// a particular token, all functions th

[PATCH] D95635: [CMake] Require python 3.6 if enabling LLVM test targets

2021-03-11 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added a comment.

In D95635#2619804 , @serge-sans-paille 
wrote:

> would it make sense to syndicate the minimal version in a single variable, 
> say `LLVM_MINIMAL_PYTHON_VERSION`, and use it in several place instead of 
> hard-coding the value across multiple files?

Done. That lets us just do the branch in one place as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D95635: [CMake] Require python 3.6 if enabling LLVM test targets

2021-03-11 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau updated this revision to Diff 330078.
ctetreau added a comment.

set a var for the minimum bound


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake
  mlir/CMakeLists.txt


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,8 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
+COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: 
${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1147,3 +1147,11 @@
   append_if(SUPPORTS_FFILE_PREFIX_MAP 
"-ffile-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS 
CMAKE_CXX_FLAGS)
   add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES)
 endif()
+
+if(LLVM_INCLUDE_TESTS)
+  # Lit test suite requires at least python 3.6
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
+else()
+  # FIXME: it is unknown if this is the actual minimum bound
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.0)
+endif()
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,8 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+COMPONENTS Interpreter)
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,8 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+  COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,8 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+  COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,8 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
+COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1147,3 +1147,11 @@
   append_if(SUPPORTS_FFILE_PREFIX_MAP "-ffile-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
   add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES)
 endif()
+
+if(LLVM_INCLUDE_TESTS)
+  # Lit test suite requires at least python 3.6
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
+else()
+  # FIXME: it is unknown if this is the actual minimum bound
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.0)
+endif()
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,8 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+COMPONENTS Interpreter)
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,8 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(P

[PATCH] D98458: Revert "[CodeGenModule] Set dso_local for Mach-O GlobalValue"

2021-03-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> Mach-O doesn't support dso_local and this change broke XNU because of the use 
> of dso_local.

Can you elaborate on the unsupportness? For example, the backend can ignore 
dso_local if it does not want to support it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98458

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


[PATCH] D98458: Revert "[CodeGenModule] Set dso_local for Mach-O GlobalValue"

2021-03-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: davide, MaskRay.
Herald added subscribers: ributzka, jkorous.
arphaman requested review of this revision.
Herald added a project: clang.

This reverts commit 809a1e0ffd7af40ee27270ff8ba2ffc927330e71 
.

  

Mach-O doesn't support dso_local and this change broke XNU because of the use 
of dso_local.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98458

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/const-init.cpp
  clang/test/CodeGenCXX/linkage.cpp
  clang/test/CodeGenCXX/type_visibility.cpp
  clang/test/CodeGenCXX/visibility.cpp

Index: clang/test/CodeGenCXX/visibility.cpp
===
--- clang/test/CodeGenCXX/visibility.cpp
+++ clang/test/CodeGenCXX/visibility.cpp
@@ -18,7 +18,7 @@
   };
   H DEFAULT a;
   X<&a> b;
-  // CHECK: _ZN6test301bE = dso_local global
+  // CHECK: _ZN6test301bE = global
   // CHECK-HIDDEN: _ZN6test301bE = hidden global
 }
 
@@ -33,7 +33,7 @@
   class DEFAULT A { };
 
   X::definition a;
-  // CHECK: @_ZN6test251aE = dso_local global
+  // CHECK: @_ZN6test251aE = global
   // CHECK-HIDDEN: @_ZN6test251aE = hidden global
 }
 
@@ -41,7 +41,7 @@
   class DEFAULT foo {
   };
   foo myvec;
-  // CHECK: @_ZN6test285myvecE = dso_local global
+  // CHECK: @_ZN6test285myvecE = global
   // CHECK-HIDDEN: @_ZN6test285myvecE = hidden global
 }
 
@@ -53,8 +53,8 @@
   DEFAULT extern RECT data_rect;
   RECT data_rect = { -1};
 #pragma GCC visibility pop
-  // CHECK: @_ZN6test299data_rectE = dso_local global
-  // CHECK-HIDDEN: @_ZN6test299data_rectE = dso_local global
+  // CHECK: @_ZN6test299data_rectE = global
+  // CHECK-HIDDEN: @_ZN6test299data_rectE = global
 }
 
 namespace test40 {
@@ -103,17 +103,17 @@
 
 // CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10
 // CHECK: @_ZN5Test71aE = hidden global
-// CHECK: @_ZN5Test71bE = dso_local global
-// CHECK: @test9_var = dso_local global
-// CHECK-HIDDEN: @test9_var = dso_local global
+// CHECK: @_ZN5Test71bE = global
+// CHECK: @test9_var = global
+// CHECK-HIDDEN: @test9_var = global
 // CHECK: @_ZN6Test121A6hiddenE = external hidden global
 // CHECK: @_ZN6Test121A7visibleE = external global
 // CHECK-HIDDEN: @_ZN6Test121A6hiddenE = external hidden global
 // CHECK-HIDDEN: @_ZN6Test121A7visibleE = external global
 // CHECK: @_ZN6Test131B1aE = hidden global
-// CHECK: @_ZN6Test131C1aE = dso_local global
+// CHECK: @_ZN6Test131C1aE = global
 // CHECK-HIDDEN: @_ZN6Test131B1aE = hidden global
-// CHECK-HIDDEN: @_ZN6Test131C1aE = dso_local global
+// CHECK-HIDDEN: @_ZN6Test131C1aE = global
 // CHECK: @_ZN6Test143varE = external global
 // CHECK-HIDDEN: @_ZN6Test143varE = external global
 // CHECK: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8]
@@ -134,8 +134,8 @@
 
   void C::D::g() {
   }
-  // CHECK: _ZTVN6test271CIiE1DE = dso_local unnamed_addr constant
-  // CHECK-HIDDEN: _ZTVN6test271CIiE1DE = dso_local unnamed_addr constant
+  // CHECK: _ZTVN6test271CIiE1DE = unnamed_addr constant
+  // CHECK-HIDDEN: _ZTVN6test271CIiE1DE = unnamed_addr constant
 }
 
 // CHECK: @_ZTVN5Test63fooE = linkonce_odr hidden unnamed_addr constant
@@ -195,7 +195,7 @@
   };
   
   // A has default visibility.
-  // CHECK-LABEL: define dso_local void @_ZN5Test41A1fEv
+  // CHECK-LABEL: define void @_ZN5Test41A1fEv
   void A::f() { } 
 }
 
@@ -209,7 +209,7 @@
   
   namespace NS {
 // g is in NS, but this NS decl is not hidden.
-// CHECK-LABEL: define dso_local void @_ZN5Test52NS1gEv
+// CHECK-LABEL: define void @_ZN5Test52NS1gEv
 void g() { }
   }
 }
@@ -268,8 +268,8 @@
 void DEFAULT test9_fun(struct A *a) { }
 struct A DEFAULT test9_var; // above
   }
-  // CHECK-LABEL: define dso_local void @test9_fun(
-  // CHECK-HIDDEN-LABEL: define dso_local void @test9_fun(
+  // CHECK-LABEL: define void @test9_fun(
+  // CHECK-HIDDEN-LABEL: define void @test9_fun(
 
   void test() {
 A a = test9_var;
@@ -285,8 +285,8 @@
 void foo(A*);
   };
 
-  // CHECK-LABEL: define dso_local void @_ZN6Test101B3fooEPNS_1AE(
-  // CHECK-HIDDEN-LABEL: define dso_local void @_ZN6Test101B3fooEPNS_1AE(
+  // CHECK-LABEL: define void @_ZN6Test101B3fooEPNS_1AE(
+  // CHECK-HIDDEN-LABEL: define void @_ZN6Test101B3fooEPNS_1AE(
   void B::foo(A*) {}
 }
 
@@ -507,7 +507,7 @@
 static void test3();
   };
 
-  // CHECK-LABEL: define dso_local void @_ZN6Test201AILj1EE5test2Ev()
+  // CHECK-LABEL: define void @_ZN6Test201AILj1EE5test2Ev()
   void A<1>::test2() {}
 
   // CHECK: declare void @_ZN6Test201AILj1EE5test3Ev()
@@ -684,8 +684,8 @@
   template<>
   void C::f() { }
 
-  // CHECK-LABEL: define dso_local void @_ZN6test261CIiE1fEv
-  // CHECK-HIDDEN-LABEL: define dso_local void @_ZN6test261CIiE1fEv
+  // CHECK-LABEL: define void @_ZN6test261CIiE1fEv
+  // CHECK-HIDDEN-LABEL: define void @_ZN6test261CIiE1fEv
 }

[PATCH] D98457: [WebAssembly] Remove unimplemented-simd target features

2021-03-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: jansvoboda11, wingo, dang, ecnelises, jfb, arphaman, 
sunfish, hiraditya, jgravelle-google, sbc100.
tlively requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Now that the WebAssembly SIMD specification is finalized and engines are
generally up-to-date, there is no need for a separate target feature for gating
SIMD instructions that engines have not implemented. With this change,
v128.const is now enabled by default with the simd128 target feature.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98457

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  clang/test/Preprocessor/wasm-target-features.c
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/test/CodeGen/WebAssembly/simd-arith.ll
  llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
  llvm/test/CodeGen/WebAssembly/simd-comparisons.ll
  llvm/test/CodeGen/WebAssembly/simd-conversions.ll
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-load-splat.ll
  llvm/test/CodeGen/WebAssembly/simd-load-store-alignment.ll
  llvm/test/CodeGen/WebAssembly/simd-noopt.ll
  llvm/test/CodeGen/WebAssembly/simd-reductions.ll
  llvm/test/CodeGen/WebAssembly/simd-select.ll
  llvm/test/CodeGen/WebAssembly/simd-sext-inreg.ll
  llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
  llvm/test/CodeGen/WebAssembly/simd.ll
  llvm/test/MC/WebAssembly/basic-assembly.s
  llvm/test/MC/WebAssembly/data-section.s
  llvm/test/MC/WebAssembly/simd-encodings.s
  llvm/test/MC/WebAssembly/type-index.s
  llvm/test/MC/WebAssembly/types.ll
  llvm/test/MC/WebAssembly/wasm64.s

Index: llvm/test/MC/WebAssembly/wasm64.s
===
--- llvm/test/MC/WebAssembly/wasm64.s
+++ llvm/test/MC/WebAssembly/wasm64.s
@@ -1,5 +1,5 @@
-# RUN: llvm-mc -triple=wasm64-unknown-unknown -mattr=+atomics,+unimplemented-simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
-# RUN: llvm-mc -triple=wasm64-unknown-unknown -filetype=obj -mattr=+atomics,+unimplemented-simd128,+nontrapping-fptoint,+exception-handling -o - < %s | obj2yaml | FileCheck %s -check-prefix=BIN
+# RUN: llvm-mc -triple=wasm64-unknown-unknown -mattr=+atomics,+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
+# RUN: llvm-mc -triple=wasm64-unknown-unknown -filetype=obj -mattr=+atomics,+simd128,+nontrapping-fptoint,+exception-handling -o - < %s | obj2yaml | FileCheck %s -check-prefix=BIN
 
 # Most of our other tests are for wasm32, this one adds some wasm64 specific tests.
 
Index: llvm/test/MC/WebAssembly/types.ll
===
--- llvm/test/MC/WebAssembly/types.ll
+++ llvm/test/MC/WebAssembly/types.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mattr=+unimplemented-simd128 -filetype=obj %s -o - | obj2yaml | FileCheck %s
+; RUN: llc -mattr=+simd128 -filetype=obj %s -o - | obj2yaml | FileCheck %s
 
 target triple = "wasm32-unknown-unknown"
 
Index: llvm/test/MC/WebAssembly/type-index.s
===
--- llvm/test/MC/WebAssembly/type-index.s
+++ llvm/test/MC/WebAssembly/type-index.s
@@ -1,6 +1,6 @@
-# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+unimplemented-simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
 # Check that it converts to .o without errors:
-# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+unimplemented-simd128,+nontrapping-fptoint,+exception-handling < %s | obj2yaml | FileCheck -check-prefix=BIN %s
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | obj2yaml | FileCheck -check-prefix=BIN %s
 
 # Minimal test for type indices in call_indirect.
 
Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -show-encoding -triple=wasm32-unknown-unknown -mattr=+unimplemented-simd128 < %s | FileCheck %s
+# RUN: llvm-mc -show-encoding -triple=wasm32-unknown-unknown -mattr=+simd128 < %s | FileCheck %s
 
 main:
 .functype main () -> ()
Index: llvm/test/MC/WebAssembly/data-section.s
===
--- llvm/test/MC/WebAssembly/data-section.s
+++ llvm/test/MC/WebAssembly/data-section.s
@@ -1,12 +1,12 @@
-# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+unimplemented-simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+simd1

[PATCH] D97857: [Matrix] Add support for matrix-by-scalar division.

2021-03-11 Thread Florian Hahn 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 rGc92ec0dd92ba: [Matrix] Add support for matrix-by-scalar 
division. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97857

Files:
  clang/docs/MatrixTypes.rst
  clang/include/clang/Basic/Features.def
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGen/matrix-type.c
  clang/test/Sema/matrix-type-operators.c
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -215,6 +215,22 @@
 return B.CreateMul(LHS, RHS);
   }
 
+  /// Divide matrix \p LHS by scalar \p RHS. If the operands are integers, \p
+  /// IsUnsigned indicates whether UDiv or SDiv should be used.
+  Value *CreateScalarDiv(Value *LHS, Value *RHS, bool IsUnsigned) {
+assert(LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy());
+assert(!isa(LHS->getType()) &&
+   "LHS Assumed to be fixed width");
+RHS =
+B.CreateVectorSplat(cast(LHS->getType())->getElementCount(),
+RHS, "scalar.splat");
+return cast(LHS->getType())
+   ->getElementType()
+   ->isFloatingPointTy()
+   ? B.CreateFDiv(LHS, RHS)
+   : (IsUnsigned ? B.CreateUDiv(LHS, RHS) : B.CreateSDiv(LHS, RHS));
+  }
+
   /// Extracts the element at (\p RowIdx, \p ColumnIdx) from \p Matrix.
   Value *CreateExtractElement(Value *Matrix, Value *RowIdx, Value *ColumnIdx,
   unsigned NumRows, Twine const &Name = "") {
Index: clang/test/Sema/matrix-type-operators.c
===
--- clang/test/Sema/matrix-type-operators.c
+++ clang/test/Sema/matrix-type-operators.c
@@ -94,6 +94,40 @@
   // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
 }
 
+void mat_scalar_divide(sx10x10_t a, sx5x10_t b, float sf, char *p) {
+  // Shape of multiplication result does not match the type of b.
+  b = a / sf;
+  // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
+  b = sf / a;
+  // expected-error@-1 {{invalid operands to binary expression ('float' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
+
+  a = a / p;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'char *')}}
+  a = p / a;
+  // expected-error@-1 {{invalid operands to binary expression ('char *' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
+
+  sf = a / sf;
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
+}
+
+void matrix_matrix_divide(sx10x10_t a, sx5x10_t b, ix10x5_t c, ix10x10_t d, float sf, char *p) {
+  // Matrix by matrix division is not supported.
+  a = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  b = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  // Check element type mismatches.
+  a = b / c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
+  d = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  p = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+}
+
 sx5x10_t get_matrix();
 
 void insert(sx5x10_t a, float f) {
Index: clang/test/CodeGen/matrix-type.c
===
--- clang/test/CodeGen/matrix-type.c
+++ clang/test/CodeGen/matrix-type.c
@@ -4,6 +4,10 @@
 #error Expected extension 'matrix_types' to be enabled
 #endif
 
+#if !__has_extension(matrix_types_scalar_division)
+#error Expected extension 'matrix_types_scalar_division' to be enabled
+#endif
+
 typedef double dx5x5_t __attribute__((matrix_type(5, 5)));
 
 // CHECK: %struct.Matrix = type { i8, [12 x float], float }
Index: clang/test/CodeGen/matrix-type-operators.c
=

[clang] c92ec0d - [Matrix] Add support for matrix-by-scalar division.

2021-03-11 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2021-03-11T22:21:23Z
New Revision: c92ec0dd92babe0519a4ff1c785154cde5696779

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

LOG: [Matrix] Add support for matrix-by-scalar division.

This patch extends the matrix spec to allow matrix-by-scalar division.

Originally support for `/` was left out to avoid ambiguity for the
matrix-matrix version of `/`, which could either be elementwise or
specified as matrix multiplication M1 * (1/M2).

For the matrix-scalar version, no ambiguity exists; `*` is also
an elementwise operation in that case. Matrix-by-scalar division
is commonly supported by systems including Matlab, Mathematica
or NumPy.

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/docs/MatrixTypes.rst
clang/include/clang/Basic/Features.def
clang/lib/AST/Type.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/matrix-type-operators.c
clang/test/CodeGen/matrix-type.c
clang/test/Sema/matrix-type-operators.c
llvm/include/llvm/IR/MatrixBuilder.h

Removed: 




diff  --git a/clang/docs/MatrixTypes.rst b/clang/docs/MatrixTypes.rst
index 5d022af44121..f0abede1ca3d 100644
--- a/clang/docs/MatrixTypes.rst
+++ b/clang/docs/MatrixTypes.rst
@@ -118,15 +118,21 @@ more explicit.
 Matrix Type Binary Operators
 
 
-Each matrix type supports the following binary operators: ``+``, ``-`` and 
``*``. The ``*``
-operator provides matrix multiplication, while ``+`` and ``-`` are performed
-element-wise. There are also scalar versions of the operators, which take a
-matrix type and the matrix element type. The operation is applied to all
-elements of the matrix using the scalar value.
-
-For ``BIN_OP`` in ``+``, ``-``, ``*`` given the expression ``M1 BIN_OP M2`` 
where
-at least one of ``M1`` or ``M2`` is of matrix type and, for `*`, the other is 
of
-a real type:
+Given two matrixes, the ``+`` and ``-`` operators perform element-wise addition
+and subtraction, while the ``*`` operator performs matrix multiplication.
+``+``, ``-``, ``*``, and ``/`` can also be used with a matrix and a scalar
+value, applying the operation to each element of the matrix.
+
+Earlier versions of this extension did not support division by a scalar.
+You can test for the availability of this feature with
+``__has_extension(matrix_types_scalar_division)``.
+
+For the expression ``M1 BIN_OP M2`` where
+* ``BIN_OP`` is one of ``+`` or ``-``, one of ``M1`` and ``M2`` is of matrix
+  type, and the other is of matrix type or real type; or
+* ``BIN_OP`` is ``*``, one of ``M1`` and ``M2`` is of matrix type, and the
+   other is of a real type; or
+* ``BIN_OP`` is ``/``, ``M1`` is of matrix type, and ``M2`` is of a real type:
 
 * The usual arithmetic conversions are applied to ``M1`` and ``M2``. [ Note: 
if ``M1`` or
   ``M2`` are of a real type, they are broadcast to matrices here. — end note ]

diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index 32830a3a532c..4f7e2db7683d 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -257,6 +257,7 @@ EXTENSION(statement_attributes_with_gnu_syntax, true)
 EXTENSION(gnu_asm, LangOpts.GNUAsm)
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
+EXTENSION(matrix_types_scalar_division, true)
 
 FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && 
LangOpts.RelativeCXXABIVTables)
 

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index e158fe0e28e4..51289ce45ab9 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2086,8 +2086,9 @@ bool Type::isUnsignedIntegerOrEnumerationType() const {
 bool Type::hasUnsignedIntegerRepresentation() const {
   if (const auto *VT = dyn_cast(CanonicalType))
 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
-  else
-return isUnsignedIntegerOrEnumerationType();
+  if (const auto *VT = dyn_cast(CanonicalType))
+return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
+  return isUnsignedIntegerOrEnumerationType();
 }
 
 bool Type::isFloatingType() const {

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 6f7e8263fa10..39e0d8d5608d 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3157,6 +3157,20 @@ Value *ScalarExprEmitter::EmitDiv(const BinOpInfo &Ops) {
 }
   }
 
+  if (Ops.Ty->isConstantMatrixType()) {
+llvm::MatrixBuilder MB(Builder);
+// We need to check the types of the operands of the operator to get the
+// correct matrix dimensions.
+auto *BO = cast(Ops.E);
+a

[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Added a couple of other folks who might have more context on the tooling 
front...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D98337: Add support for digit separators in C2x

2021-03-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98337

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


[PATCH] D97857: [Matrix] Add support for matrix-by-scalar division.

2021-03-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97857

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


[PATCH] D98450: [clang] store an identifer instead of declref for ns_error_domain attribute

2021-03-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

The original implementation of the attribute on GitHub.com/apple/llvm-project 
also used the identifier instead of the declref, so we would like to go back to 
that.


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

https://reviews.llvm.org/D98450

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


[PATCH] D98450: [clang] store an identifer instead of declref for ns_error_domain attribute

2021-03-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: steven_wu, MForster.
Herald added subscribers: ributzka, jkorous.
Herald added a reviewer: aaron.ballman.
arphaman requested review of this revision.

The attribute with declref is incompatible with Apple's SDKs, as the declref
at the point of use in the attribute might not be available due to the 
availability
annotations on the domain declaration. The users also can't fix this by applying
the availability attributes to the user of ns_error_domain as at that point the
availability diagnostic is already emitted. The use of identifier is ideal as
clang then doesn't need to do availability checking when its referenced in the 
attribute.


https://reviews.llvm.org/D98450

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/ns_error_enum.m


Index: clang/test/Sema/ns_error_enum.m
===
--- clang/test/Sema/ns_error_enum.m
+++ clang/test/Sema/ns_error_enum.m
@@ -53,7 +53,6 @@
 
 extern char *const WrongErrorDomainType;
 enum __attribute__((ns_error_domain(WrongErrorDomainType))) 
MyWrongErrorDomainType { MyWrongErrorDomain };
-// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to 
an NSString or CFString constant}}
 
 struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain 
{};
 // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
@@ -68,7 +67,7 @@
 // expected-error@-1{{'ns_error_domain' attribute takes one argument}}
 
 typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
-   // expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+   // expected-error@-1{{domain argument 'InvalidDomain' does not refer to 
global constant}}
MyErrFirstInvalid,
MyErrSecondInvalid,
 };
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5510,28 +5510,28 @@
 }
 
 static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &AL) {
-  auto *E = AL.getArgAsExpr(0);
-  auto Loc = E ? E->getBeginLoc() : AL.getLoc();
+  IdentifierLoc *IdentLoc = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr;
+  if (!IdentLoc || !IdentLoc->Ident) {
+// Try to locate the argument directly
+SourceLocation Loc = AL.getLoc();
+if (AL.isArgExpr(0) && AL.getArgAsExpr(0))
+  Loc = AL.getArgAsExpr(0)->getBeginLoc();
 
-  auto *DRE = dyn_cast(AL.getArgAsExpr(0));
-  if (!DRE) {
 S.Diag(Loc, diag::err_nserrordomain_invalid_decl) << 0;
 return;
   }
 
-  auto *VD = dyn_cast(DRE->getDecl());
-  if (!VD) {
-S.Diag(Loc, diag::err_nserrordomain_invalid_decl) << 1 << DRE->getDecl();
+  // Verify that the identifier is a valid decl in the C decl namespace
+  LookupResult LR(S, DeclarationName(IdentLoc->Ident), SourceLocation(),
+  Sema::LookupNameKind::LookupOrdinaryName);
+  if (!S.LookupName(LR, S.TUScope) || !LR.getAsSingle()) {
+S.Diag(IdentLoc->Loc, diag::err_nserrordomain_invalid_decl)
+<< 1 << IdentLoc->Ident;
 return;
   }
 
-  if (!isNSStringType(VD->getType(), S.Context) &&
-  !isCFStringType(VD->getType(), S.Context)) {
-S.Diag(Loc, diag::err_nserrordomain_wrong_type) << VD;
-return;
-  }
-
-  D->addAttr(::new (S.Context) NSErrorDomainAttr(S.Context, AL, VD));
+  D->addAttr(::new (S.Context)
+ NSErrorDomainAttr(S.Context, AL, IdentLoc->Ident));
 }
 
 static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9683,8 +9683,6 @@
   " attributes">;
 def err_nserrordomain_invalid_decl : Error<
   "domain argument %select{|%1 }0does not refer to global constant">;
-def err_nserrordomain_wrong_type : Error<
-  "domain argument %0 does not point to an NSString or CFString constant">;
 
 def warn_nsconsumed_attribute_mismatch : Warning<
   err_nsconsumed_attribute_mismatch.Text>, InGroup;
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1967,7 +1967,7 @@
 def NSErrorDomain : InheritableAttr {
   let Spellings = [GNU<"ns_error_domain">];
   let Subjects = SubjectList<[Enum], ErrorDiag>;
-  let Args = [DeclArgument];
+  let Args = [IdentifierArgument<"ErrorDomain">];
   let Documentation = [NSErrorDomainDocs];
 }
 


Index: clang/test/Sema/ns_error_enum.m
===
--- clang/test/Sema/ns_error_enum.m
+++ clang/test/Sema/ns_error_enum.m
@@ -53,7 +53,6 @@
 
 extern char *cons

[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-11 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330049.
arnamoy10 added a comment.

Modifying the algo of default search path extraction for supporting Windows 
platforms.


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -82,6 +84,8 @@
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/test/Driver/Inputs/iso_fortran_env.mod
===
--- /dev/null
+++ flang/test/Driver/Inputs/iso_for

[PATCH] D98440: [NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes

2021-03-11 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

In D98440#2620437 , @aeubanks wrote:

> This doesn't break the pipeline tests in llvm/test/Other?
> Running check-llvm with expensive checks is probably a good idea to see if 
> there are any weird issues.

Done - nothing else broke, indeed.

> Otherwise seems fine to me.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98440

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


[PATCH] D98440: [NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes

2021-03-11 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 330057.
mtrofin marked an inline comment as done.
mtrofin added a comment.

feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98440

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp


Index: llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
===
--- llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1942,5 +1942,30 @@
   ASSERT_TRUE(Ran);
 }
 
+TEST_F(CGSCCPassManagerTest, TestFunctionPassesAreQueriedForInvalidation) {
+  std::unique_ptr M = parseIR("define void @f() { ret void }");
+  CGSCCPassManager CGPM;
+  bool SCCCalled = false;
+  FunctionPassManager FPM;
+  int ImmRuns = 0;
+  FAM.registerPass([&] { return TestImmutableFunctionAnalysis(ImmRuns); });
+  FPM.addPass(RequireAnalysisPass());
+  CGPM.addPass(
+  LambdaSCCPass([&](LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
+LazyCallGraph &CG, CGSCCUpdateResult &UR) {
+SCCCalled = true;
+return PreservedAnalyses::none();
+  }));
+  CGPM.addPass(createCGSCCToFunctionPassAdaptor(
+  RequireAnalysisPass()));
+  ModulePassManager MPM;
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+  MPM.run(*M, MAM);
+  ASSERT_EQ(ImmRuns, 1);
+  ASSERT_TRUE(SCCCalled);
+}
+
 #endif
 } // namespace
Index: llvm/lib/Analysis/CGSCCPassManager.cpp
===
--- llvm/lib/Analysis/CGSCCPassManager.cpp
+++ llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -720,7 +720,7 @@
   auto PAC = PA.getChecker();
   if (!PAC.preserved() && 
!PAC.preservedSet>()) {
 for (LazyCallGraph::Node &N : C)
-  FAM->clear(N.getFunction(), N.getFunction().getName());
+  FAM->invalidate(N.getFunction(), PA);
 
 return false;
   }
Index: clang/test/CodeGen/thinlto-distributed-newpm.ll
===
--- clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -12,7 +12,7 @@
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
 ; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s --dump-input=fail
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck -check-prefix=CHECK-O %s 
--dump-input=fail
 
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
@@ -70,24 +70,19 @@
 ; CHECK-O: Starting CGSCC pass manager run.
 ; CHECK-O: Running pass: InlinerPass on (main)
 ; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)
-; CHECK-O: Clearing all analysis results for: main
+; CHECK-O: Invalidating analysis: DominatorTreeAnalysis on main
+; CHECK-O: Invalidating analysis: BasicAA on main
+; CHECK-O: Invalidating analysis: AAManager on main
 ; CHECK-O3: Running pass: ArgumentPromotionPass on (main)
-; CHECK-O3: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SROA on main
 ; These next two can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on main
-; CHECK-O-DAG: Running analysis: AssumptionAnalysis on main
 ; CHECK-O: Running pass: EarlyCSEPass on main
-; CHECK-O: Running analysis: TargetLibraryAnalysis on main
-; CHECK-O2: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
-; CHECK-O: Running analysis: ScopedNoAliasAA on main
-; CHECK-O: Running analysis: TypeBasedAA on main
-; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SpeculativeExecutionPass on main
 ; CHECK-O: Running pass: JumpThreadingPass on main
 ; CHECK-O: Running analysis: LazyValueAnalysis on main
@@ -96,7 +91,6 @@
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O3: Running pass: AggressiveInstCombinePass on main
 ; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running pass: LibCallsShrinkWrapPass on main
 ; CHECK-O: Running pass: TailCallElimPass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main


Index: llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
===
--- llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ llvm/unittests/Analysis/CGSCCPassManagerTest.c

[PATCH] D98061: [InstrProfiling] Generate runtime hook for ELF platforms

2021-03-11 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG87fd09b25f88: [InstrProfiling] Generate runtime hook for ELF 
platforms (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98061

Files:
  clang/docs/UsersManual.rst
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/test/Driver/coverage-ld.c
  clang/test/Driver/fuchsia.c
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/linkage.ll
  llvm/test/Instrumentation/InstrProfiling/profiling.ll

Index: llvm/test/Instrumentation/InstrProfiling/profiling.ll
===
--- llvm/test/Instrumentation/InstrProfiling/profiling.ll
+++ llvm/test/Instrumentation/InstrProfiling/profiling.ll
@@ -1,14 +1,11 @@
 ; RUN: opt < %s -mtriple=x86_64 -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,ELF,ELF_GENERIC
 ; RUN: opt < %s -mtriple=x86_64-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,ELF_LINUX
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,MACHO
-; RUN: opt < %s -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,WIN
+; RUN: opt < %s -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=CHECK,COFF
 
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s
 
-; ELF_GENERIC: @__llvm_profile_runtime = external global i32
-; ELF_LINUX-NOT: @__llvm_profile_runtime
 ; MACHO: @__llvm_profile_runtime = external global i32
-; WIN: @__llvm_profile_runtime = external global i32
 
 @__profn_foo = hidden constant [3 x i8] c"foo"
 ; CHECK-NOT: __profn_foo
@@ -21,8 +18,8 @@
 ; ELF:   @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_foo = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_foo = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_foo = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_foo = internal {{.*}}, section ".lprfd$M", align 8
 define void @foo() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -32,8 +29,8 @@
 ; ELF:   @__profd_bar = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_bar = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_bar = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_bar = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_bar = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_bar = internal global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_bar = internal {{.*}}, section ".lprfd$M", align 8
 define void @bar() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_bar, i32 0, i32 0), i64 0, i32 1, i32 0)
   ret void
@@ -43,8 +40,8 @@
 ; ELF:   @__profd_baz = hidden {{.*}}, section "__llvm_prf_data", comdat, align 8
 ; MACHO: @__profc_baz = hidden global [3 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 ; MACHO: @__profd_baz = hidden {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
-; WIN:   @__profc_baz = internal global [3 x i64] zeroinitializer, section ".lprfc$M", align 8
-; WIN:   @__profd_baz = internal {{.*}}, section ".lprfd$M", align 8
+; COFF:   @__profc_baz = internal global [3 x i64] zeroinitializer, section ".lprfc$M", align 8
+; COFF:   @__profd_baz = internal {{.*}}, section ".lprfd$M", align 8
 define void @baz() {
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 0)
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_baz, i32 0, i32 0), i64 0, i32 3, i32 1)
@@ -54,12 +51,14 @@
 
 declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
 
-; ELF:   @llvm.compiler.used = appending global {{.*}} @__llvm_profile_runtime {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz
+; ELF:   @__llvm_profile_runtime = external global i32
+; COFF:  @__llvm_profile_runtime = external global i32
+
+; ELF:   @llvm.compiler.used = appending global {{.*}} @__profd_foo {{.*}} @__profd_bar {{.*}} @__profd_baz {{.*}} @__llvm_profile_runtime
 ; MACHO:

[clang] 87fd09b - [InstrProfiling] Generate runtime hook for ELF platforms

2021-03-11 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-03-11T12:29:01-08:00
New Revision: 87fd09b25f8892e07b7ba11525baa9c3ec3e5d3f

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

LOG: [InstrProfiling] Generate runtime hook for ELF platforms

When using -fprofile-list to selectively apply instrumentation only
to certain files or functions, we may end up with a binary that doesn't
have any counters in the case where no files were selected. However,
because on Linux and Fuchsia, we pass -u__llvm_profile_runtime, the
runtime would still be pulled in and incur some non-trivial overhead,
especially in the case when the continuous or runtime counter relocation
mode is being used. A better way would be to pull in the profile runtime
only when needed by declaring the __llvm_profile_runtime symbol in the
translation unit only when needed.

This approach was already used prior to 9a041a75221ca, but we changed it
to always generate the __llvm_profile_runtime due to a TAPI limitation.
Since TAPI is only used on Mach-O platforms, we could use the early
emission of __llvm_profile_runtime there, and on other platforms we
could change back to the earlier approach where the symbol is generated
later only when needed. We can stop passing -u__llvm_profile_runtime to
the linker on Linux and Fuchsia since the generated undefined symbol in
each translation unit that needed it serves the same purpose.

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

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Fuchsia.h
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/test/Driver/coverage-ld.c
clang/test/Driver/fuchsia.c
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/linkage.ll
llvm/test/Instrumentation/InstrProfiling/profiling.ll

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 28de4e3aac6f..8a369c88c2a5 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2301,6 +2301,14 @@ In these cases, you can use the flag 
``-fno-profile-instr-generate`` (or
 Note that these flags should appear after the corresponding profile
 flags to have an effect.
 
+.. note::
+
+  When none of the translation units inside a binary is instrumented, in the
+  case of ELF and COFF binary format the profile runtime will not be linked
+  into the binary and no profile will be produced, while in the case of Mach-O
+  the profile runtime will be linked and profile will be produced but there
+  will not be any counters.
+
 Instrumenting only selected files or functions
 ^^
 

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 8e086010a984..4b27a102f218 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -394,13 +394,3 @@ SanitizerMask Fuchsia::getDefaultSanitizers() const {
   }
   return Res;
 }
-
-void Fuchsia::addProfileRTLibs(const llvm::opt::ArgList &Args,
-   llvm::opt::ArgStringList &CmdArgs) const {
-  // Add linker option -u__llvm_profile_runtime to cause runtime
-  // initialization module to be linked in.
-  if (needsProfileRT(Args))
-CmdArgs.push_back(Args.MakeArgString(
-Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
-  ToolChain::addProfileRTLibs(Args, CmdArgs);
-}

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.h 
b/clang/lib/Driver/ToolChains/Fuchsia.h
index 07adf9b7101d..1a0263ce3393 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.h
+++ b/clang/lib/Driver/ToolChains/Fuchsia.h
@@ -71,9 +71,6 @@ class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain {
   SanitizerMask getSupportedSanitizers() const override;
   SanitizerMask getDefaultSanitizers() const override;
 
-  void addProfileRTLibs(const llvm::opt::ArgList &Args,
-llvm::opt::ArgStringList &CmdArgs) const override;
-
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
   CXXStdlibType

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index ad98013dd4f0..5f5b069fe2df 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -925,16 +925,6 @@ SanitizerMask Linux::getSupportedSanitizers() const {
   return Res;
 }
 
-void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const {
-  // Add linker option -u__llvm_profile_runtime to cause runtime
-  // initialization module to be linked in.
-  if (needsProfileRT(Args))
-CmdArgs.push_back(

[PATCH] D98440: [NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes

2021-03-11 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

This doesn't break the pipeline tests in llvm/test/Other?
Running check-llvm with expensive checks is probably a good idea to see if 
there are any weird issues.

Otherwise seems fine to me.




Comment at: llvm/unittests/Analysis/CGSCCPassManagerTest.cpp:1948
+  CGSCCPassManager CGPM;
+  bool SCCCalled = false;
+  FunctionPassManager FPM;

assert this is true at the end?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98440

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


[PATCH] D98165: [clangd] Make ProjectAwareIndex optionally sync

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc9c09632f1a: [clangd] Make ProjectAwareIndex optionally 
sync (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98165

Files:
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/ProjectAware.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
@@ -33,11 +33,11 @@
 }
 
 TEST(ProjectAware, Test) {
-  IndexFactory Gen = [](const Config::ExternalIndexSpec &, AsyncTaskRunner &) {
+  IndexFactory Gen = [](const Config::ExternalIndexSpec &, AsyncTaskRunner *) {
 return createIndex();
   };
 
-  auto Idx = createProjectAwareIndex(std::move(Gen));
+  auto Idx = createProjectAwareIndex(std::move(Gen), true);
   FuzzyFindRequest Req;
   Req.Query = "1";
   Req.AnyScope = true;
@@ -54,12 +54,12 @@
 
 TEST(ProjectAware, CreatedOnce) {
   unsigned InvocationCount = 0;
-  IndexFactory Gen = [&](const Config::ExternalIndexSpec &, AsyncTaskRunner &) {
+  IndexFactory Gen = [&](const Config::ExternalIndexSpec &, AsyncTaskRunner *) {
 ++InvocationCount;
 return createIndex();
   };
 
-  auto Idx = createProjectAwareIndex(std::move(Gen));
+  auto Idx = createProjectAwareIndex(std::move(Gen), true);
   // No invocation at start.
   EXPECT_EQ(InvocationCount, 0U);
   FuzzyFindRequest Req;
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -537,7 +537,7 @@
 
 std::unique_ptr
 loadExternalIndex(const Config::ExternalIndexSpec &External,
-  AsyncTaskRunner &Tasks) {
+  AsyncTaskRunner *Tasks) {
   switch (External.Kind) {
   case Config::ExternalIndexSpec::Server:
 log("Associating {0} with remote index at {1}.", External.MountPoint,
@@ -552,13 +552,11 @@
   if (auto Idx = loadIndex(File, /*UseDex=*/true))
 PlaceHolder->reset(std::move(Idx));
 };
-// FIXME: The signature should contain a null-able TaskRunner istead, and
-// the task should be scheduled accordingly.
-if (Sync) {
-  IndexLoadTask();
+if (Tasks) {
+  Tasks->runAsync("Load-index:" + External.Location,
+  std::move(IndexLoadTask));
 } else {
-  Tasks.runAsync("Load-index:" + External.Location,
- std::move(IndexLoadTask));
+  IndexLoadTask();
 }
 return std::move(NewIndex);
   }
@@ -806,7 +804,7 @@
   }
 #endif
   Opts.BackgroundIndex = EnableBackgroundIndex;
-  auto PAI = createProjectAwareIndex(loadExternalIndex);
+  auto PAI = createProjectAwareIndex(loadExternalIndex, Sync);
   if (StaticIdx) {
 IdxStack.emplace_back(std::move(StaticIdx));
 IdxStack.emplace_back(
Index: clang-tools-extra/clangd/index/ProjectAware.h
===
--- clang-tools-extra/clangd/index/ProjectAware.h
+++ clang-tools-extra/clangd/index/ProjectAware.h
@@ -19,15 +19,16 @@
 
 /// A functor to create an index for an external index specification. Functor
 /// should perform any high latency operation in a separate thread through
-/// AsyncTaskRunner.
+/// AsyncTaskRunner, if set.
 using IndexFactory = std::function(
-const Config::ExternalIndexSpec &, AsyncTaskRunner &)>;
+const Config::ExternalIndexSpec &, AsyncTaskRunner *)>;
 
 /// Returns an index that answers queries using external indices. IndexFactory
-/// specifies how to generate an index from an external source.
+/// specifies how to generate an index from an external source. If \p Sync is
+/// set, index won't own any asnyc task runner.
 /// IndexFactory must be injected because this code cannot depend on the remote
 /// index client.
-std::unique_ptr createProjectAwareIndex(IndexFactory);
+std::unique_ptr createProjectAwareIndex(IndexFactory, bool Sync);
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/index/ProjectAware.cpp
===
--- clang-tools-extra/clangd/index/ProjectAware.cpp
+++ clang-tools-extra/clangd/index/ProjectAware.cpp
@@ -57,7 +57,10 @@
   llvm::unique_function
   indexedFiles() const override;
 
-  ProjectAwareIndex(IndexFactory Gen) : Gen(std::move(Gen)) {}
+  ProjectAwareIndex(IndexFactory Gen, bool Sync) : Gen(std::move(Gen)) {
+if (!Sync)
+  Tasks = std::make_unique();
+  }
 
 private:
   // Returns the index associated with curr

[PATCH] D98037: [clangd] Add config block for Completion and option for AllScopes

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac292dafa776: [clangd] Add config block for Completion and 
option for AllScopes (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98037

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -10,10 +10,12 @@
 #include "ConfigFragment.h"
 #include "ConfigTesting.h"
 #include "Protocol.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Testing/Support/SupportHelpers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -164,6 +166,35 @@
   EXPECT_THAT(*Results[0].Index.External.getValue()->Server, Val("bar"));
 }
 
+TEST(ParseYAML, AllScopes) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+Completion:
+  AllScopes: True
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  ASSERT_EQ(Results.size(), 1u);
+  EXPECT_THAT(Results[0].Completion.AllScopes, llvm::ValueIs(Val(true)));
+}
+
+TEST(ParseYAML, AllScopesWarn) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+Completion:
+  AllScopes: $diagrange[[Truex]]
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(AllOf(DiagMessage("AllScopes should be a boolean"),
+DiagKind(llvm::SourceMgr::DK_Warning),
+DiagPos(YAML.range("diagrange").start),
+DiagRange(YAML.range("diagrange");
+  ASSERT_EQ(Results.size(), 1u);
+  EXPECT_THAT(Results[0].Completion.AllScopes, testing::Eq(llvm::None));
+}
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -443,6 +443,22 @@
   ASSERT_FALSE(Conf.Index.External);
 #endif
 }
+
+TEST_F(ConfigCompileTests, AllScopes) {
+  // Defaults to true.
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_TRUE(Conf.Completion.AllScopes);
+
+  Frag = {};
+  Frag.Completion.AllScopes = false;
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_FALSE(Conf.Completion.AllScopes);
+
+  Frag = {};
+  Frag.Completion.AllScopes = true;
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_TRUE(Conf.Completion.AllScopes);
+}
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -623,6 +623,7 @@
 if (!EnableBackgroundIndex) {
   BGPolicy = Config::BackgroundPolicy::Skip;
 }
+
 Frag = [=](const config::Params &, Config &C) {
   if (CDBSearch)
 C.CompileFlags.CDBSearch = *CDBSearch;
@@ -630,6 +631,8 @@
 C.Index.External = *IndexSpec;
   if (BGPolicy)
 C.Index.Background = *BGPolicy;
+  if (AllScopesCompletion.getNumOccurrences())
+C.Completion.AllScopes = AllScopesCompletion;
   return true;
 };
   }
@@ -827,7 +830,6 @@
 Opts.CodeComplete.IncludeIndicator.NoInsert.clear();
   }
   Opts.CodeComplete.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
-  Opts.CodeComplete.AllScopes = AllScopesCompletion;
   Opts.CodeComplete.RunParser = CodeCompletionParse;
   Opts.CodeComplete.RankingModel = RankingModel;
 
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -63,6 +63,7 @@
 Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.handle("Style", [&](Node &N) { parse(F.Style, N); });
 Dict.handle("Diagnostics", [&](Node &N) { parse(F.Diagnostics, N); });
+Dict.handle("Completion", [&](Node &N) { parse(F.Completion, N); });
 Dict.parse(N);
 return !(N.failed()

[clang-tools-extra] dc9c096 - [clangd] Make ProjectAwareIndex optionally sync

2021-03-11 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-11T20:30:35+01:00
New Revision: dc9c09632f1a8cbb0f44a7025ab7b9e516b9d859

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

LOG: [clangd] Make ProjectAwareIndex optionally sync

Depends on D98029.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/ProjectAware.cpp
clang-tools-extra/clangd/index/ProjectAware.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/ProjectAware.cpp 
b/clang-tools-extra/clangd/index/ProjectAware.cpp
index 80ebaf903b4c..a6cdc86fdc24 100644
--- a/clang-tools-extra/clangd/index/ProjectAware.cpp
+++ b/clang-tools-extra/clangd/index/ProjectAware.cpp
@@ -57,7 +57,10 @@ class ProjectAwareIndex : public SymbolIndex {
   llvm::unique_function
   indexedFiles() const override;
 
-  ProjectAwareIndex(IndexFactory Gen) : Gen(std::move(Gen)) {}
+  ProjectAwareIndex(IndexFactory Gen, bool Sync) : Gen(std::move(Gen)) {
+if (!Sync)
+  Tasks = std::make_unique();
+  }
 
 private:
   // Returns the index associated with current context, if any.
@@ -68,7 +71,7 @@ class ProjectAwareIndex : public SymbolIndex {
   mutable llvm::DenseMap>
   IndexForSpec;
-  mutable AsyncTaskRunner Tasks;
+  mutable std::unique_ptr Tasks;
 
   const IndexFactory Gen;
 };
@@ -131,14 +134,15 @@ SymbolIndex *ProjectAwareIndex::getIndex() const {
   std::lock_guard Lock(Mu);
   auto Entry = IndexForSpec.try_emplace(External, nullptr);
   if (Entry.second)
-Entry.first->getSecond() = Gen(External, Tasks);
+Entry.first->getSecond() = Gen(External, Tasks.get());
   return Entry.first->second.get();
 }
 } // namespace
 
-std::unique_ptr createProjectAwareIndex(IndexFactory Gen) {
+std::unique_ptr createProjectAwareIndex(IndexFactory Gen,
+ bool Sync) {
   assert(Gen);
-  return std::make_unique(std::move(Gen));
+  return std::make_unique(std::move(Gen), Sync);
 }
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/index/ProjectAware.h 
b/clang-tools-extra/clangd/index/ProjectAware.h
index af98ba612751..888ef3add2eb 100644
--- a/clang-tools-extra/clangd/index/ProjectAware.h
+++ b/clang-tools-extra/clangd/index/ProjectAware.h
@@ -19,15 +19,16 @@ namespace clangd {
 
 /// A functor to create an index for an external index specification. Functor
 /// should perform any high latency operation in a separate thread through
-/// AsyncTaskRunner.
+/// AsyncTaskRunner, if set.
 using IndexFactory = std::function(
-const Config::ExternalIndexSpec &, AsyncTaskRunner &)>;
+const Config::ExternalIndexSpec &, AsyncTaskRunner *)>;
 
 /// Returns an index that answers queries using external indices. IndexFactory
-/// specifies how to generate an index from an external source.
+/// specifies how to generate an index from an external source. If \p Sync is
+/// set, index won't own any asnyc task runner.
 /// IndexFactory must be injected because this code cannot depend on the remote
 /// index client.
-std::unique_ptr createProjectAwareIndex(IndexFactory);
+std::unique_ptr createProjectAwareIndex(IndexFactory, bool Sync);
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 3c5b6473be0d..c48821cba2c7 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -537,7 +537,7 @@ const char TestScheme::TestDir[] = "/clangd-test";
 
 std::unique_ptr
 loadExternalIndex(const Config::ExternalIndexSpec &External,
-  AsyncTaskRunner &Tasks) {
+  AsyncTaskRunner *Tasks) {
   switch (External.Kind) {
   case Config::ExternalIndexSpec::Server:
 log("Associating {0} with remote index at {1}.", External.MountPoint,
@@ -552,13 +552,11 @@ loadExternalIndex(const Config::ExternalIndexSpec 
&External,
   if (auto Idx = loadIndex(File, /*UseDex=*/true))
 PlaceHolder->reset(std::move(Idx));
 };
-// FIXME: The signature should contain a null-able TaskRunner istead, and
-// the task should be scheduled accordingly.
-if (Sync) {
-  IndexLoadTask();
+if (Tasks) {
+  Tasks->runAsync("Load-index:" + External.Location,
+  std::move(IndexLoadTask));
 } else {
-  Tasks.runAsync("Load-index:" + External.Location,
- std::move(IndexLoadTask));
+  IndexLoadTask();
 }
 return std::move(NewIndex);
   }
@@ -806,7 +804,7 @@ clangd accepts flags on the commandline, and in the 
CLANGD_FLAGS environment var
   }
 #endif
   Opts.Backgro

[clang-tools-extra] ac292da - [clangd] Add config block for Completion and option for AllScopes

2021-03-11 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-11T20:30:35+01:00
New Revision: ac292dafa776fa9ee18d38d60c7de2da58f939f0

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

LOG: [clangd] Add config block for Completion and option for AllScopes

Depends on D98029

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index df3dd363800a..164e387bd454 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -362,6 +362,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
 ParseInput.Index = Index;
 
 CodeCompleteOpts.MainFileSignals = IP->Signals;
+CodeCompleteOpts.AllScopes = Config::current().Completion.AllScopes;
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 CodeCompleteResult Result = clangd::codeComplete(

diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 391632cb086a..7064edd76b8f 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -106,6 +106,13 @@ struct Config {
 // ::). All nested namespaces are affected as well.
 std::vector FullyQualifiedNamespaces;
   } Style;
+
+  /// Configures code completion feature.
+  struct {
+/// Whether code completion includes results that are not visible in 
current
+/// scopes.
+bool AllScopes = true;
+  } Completion;
 };
 
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index dadc578c3a81..9aed3c4679f5 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -192,6 +192,7 @@ struct FragmentCompiler {
 compile(std::move(F.CompileFlags));
 compile(std::move(F.Index));
 compile(std::move(F.Diagnostics));
+compile(std::move(F.Completion));
   }
 
   void compile(Fragment::IfBlock &&F) {
@@ -463,6 +464,15 @@ struct FragmentCompiler {
 }
   }
 
+  void compile(Fragment::CompletionBlock &&F) {
+if (F.AllScopes) {
+  Out.Apply.push_back(
+  [AllScopes(**F.AllScopes)](const Params &, Config &C) {
+C.Completion.AllScopes = AllScopes;
+  });
+}
+  }
+
   constexpr static llvm::SourceMgr::DiagKind Error = llvm::SourceMgr::DK_Error;
   constexpr static llvm::SourceMgr::DiagKind Warning =
   llvm::SourceMgr::DK_Warning;

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index c36b07f5e8e2..1365ed4c1037 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -238,6 +238,14 @@ struct Fragment {
 std::vector> FullyQualifiedNamespaces;
   };
   StyleBlock Style;
+
+  /// Describes code completion preferences.
+  struct CompletionBlock {
+/// Whether code completion should include suggestions from scopes that are
+/// not visible. The required scope prefix will be inserted.
+llvm::Optional> AllScopes;
+  };
+  CompletionBlock Completion;
 };
 
 } // namespace config

diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index 348ee9dd1f75..d50c01168a8d 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -63,6 +63,7 @@ class Parser {
 Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.handle("Style", [&](Node &N) { parse(F.Style, N); });
 Dict.handle("Diagnostics", [&](Node &N) { parse(F.Diagnostics, N); });
+Dict.handle("Completion", [&](Node &N) { parse(F.Completion, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }
@@ -165,6 +166,19 @@ class Parser {
 Dict.parse(N);
   }
 
+  void parse(Fragment::CompletionBlock &F, Node &N) {
+DictParser Dict("Completion", this);
+Dict.handle("AllScopes", [&](Node &N) {
+  if (auto Value = scalarValue(N, "AllScopes")) {
+if (auto AllScopes = llvm::yaml::parseBool(**Value))
+  F.AllScopes = *AllScopes;
+else
+  warning("AllScopes should be a boolean", N);
+  }
+});
+Dict.parse(N);
+  }
+
   // Helper for parsing mapping nodes (diction

[PATCH] D98037: [clangd] Add config block for Completion and option for AllScopes

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 330036.
kadircet marked an inline comment as done.
kadircet added a comment.

- Update comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98037

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -10,10 +10,12 @@
 #include "ConfigFragment.h"
 #include "ConfigTesting.h"
 #include "Protocol.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Testing/Support/SupportHelpers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -164,6 +166,35 @@
   EXPECT_THAT(*Results[0].Index.External.getValue()->Server, Val("bar"));
 }
 
+TEST(ParseYAML, AllScopes) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+Completion:
+  AllScopes: True
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  ASSERT_EQ(Results.size(), 1u);
+  EXPECT_THAT(Results[0].Completion.AllScopes, llvm::ValueIs(Val(true)));
+}
+
+TEST(ParseYAML, AllScopesWarn) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+Completion:
+  AllScopes: $diagrange[[Truex]]
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(AllOf(DiagMessage("AllScopes should be a boolean"),
+DiagKind(llvm::SourceMgr::DK_Warning),
+DiagPos(YAML.range("diagrange").start),
+DiagRange(YAML.range("diagrange");
+  ASSERT_EQ(Results.size(), 1u);
+  EXPECT_THAT(Results[0].Completion.AllScopes, testing::Eq(llvm::None));
+}
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -443,6 +443,22 @@
   ASSERT_FALSE(Conf.Index.External);
 #endif
 }
+
+TEST_F(ConfigCompileTests, AllScopes) {
+  // Defaults to true.
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_TRUE(Conf.Completion.AllScopes);
+
+  Frag = {};
+  Frag.Completion.AllScopes = false;
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_FALSE(Conf.Completion.AllScopes);
+
+  Frag = {};
+  Frag.Completion.AllScopes = true;
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_TRUE(Conf.Completion.AllScopes);
+}
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -623,6 +623,7 @@
 if (!EnableBackgroundIndex) {
   BGPolicy = Config::BackgroundPolicy::Skip;
 }
+
 Frag = [=](const config::Params &, Config &C) {
   if (CDBSearch)
 C.CompileFlags.CDBSearch = *CDBSearch;
@@ -630,6 +631,8 @@
 C.Index.External = *IndexSpec;
   if (BGPolicy)
 C.Index.Background = *BGPolicy;
+  if (AllScopesCompletion.getNumOccurrences())
+C.Completion.AllScopes = AllScopesCompletion;
   return true;
 };
   }
@@ -827,7 +830,6 @@
 Opts.CodeComplete.IncludeIndicator.NoInsert.clear();
   }
   Opts.CodeComplete.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
-  Opts.CodeComplete.AllScopes = AllScopesCompletion;
   Opts.CodeComplete.RunParser = CodeCompletionParse;
   Opts.CodeComplete.RankingModel = RankingModel;
 
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -63,6 +63,7 @@
 Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.handle("Style", [&](Node &N) { parse(F.Style, N); });
 Dict.handle("Diagnostics", [&](Node &N) { parse(F.Diagnostics, N); });
+Dict.handle("Completion", [&](Node &N) { parse(F.Completion, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }
@@ -165,6 +166,19 @@
 Dict.parse(N);
   }
 
+  void parse(Fragment::CompletionBlock &F, Node 

[PATCH] D98436: [Hexagon] Support inlined use of cs0 and cs1

2021-03-11 Thread Sid Manning via Phabricator via cfe-commits
sidneym updated this revision to Diff 330032.
sidneym added a comment.

Same patch, just added full context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98436

Files:
  clang/lib/Basic/Targets/Hexagon.cpp
  llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
  llvm/test/CodeGen/Hexagon/namedreg.ll


Index: llvm/test/CodeGen/Hexagon/namedreg.ll
===
--- llvm/test/CodeGen/Hexagon/namedreg.ll
+++ llvm/test/CodeGen/Hexagon/namedreg.ll
@@ -4,10 +4,29 @@
   %0 = call i32 @llvm.read_register.i32(metadata !0)
   ret i32 %0
 }
-
 declare i32 @llvm.read_register.i32(metadata) #1
 
+define dso_local i32 @rcs0() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !1)
+  ret i32 %0
+}
+
+define dso_local i32 @rcs1() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !2)
+  ret i32 %0
+}
+
+
+
 !llvm.named.register.r19 = !{!0}
+!llvm.named.register.cs0 = !{!1}
+!llvm.named.register.cs1 = !{!2}
 
 !0 = !{!"r19"}
+!1 = !{!"cs0"}
+!2 = !{!"cs1"}
 ; CHECK: r0 = r19
+; CHECK: r0 = cs0
+; CHECK: r0 = cs1
Index: llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
===
--- llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -308,6 +308,8 @@
  .Case("m1", Hexagon::M1)
  .Case("usr", Hexagon::USR)
  .Case("ugp", Hexagon::UGP)
+ .Case("cs0", Hexagon::CS0)
+ .Case("cs1", Hexagon::CS1)
  .Default(Register());
   if (Reg)
 return Reg;
Index: clang/lib/Basic/Targets/Hexagon.cpp
===
--- clang/lib/Basic/Targets/Hexagon.cpp
+++ clang/lib/Basic/Targets/Hexagon.cpp
@@ -136,7 +136,7 @@
 "r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
 "r27", "r28", "r29", "r30", "r31", "p0",  "p1",  "p2",  "p3",
-"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp",
+"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp", "cs0", "cs1",
 "r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
 "r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
 "r31:30"


Index: llvm/test/CodeGen/Hexagon/namedreg.ll
===
--- llvm/test/CodeGen/Hexagon/namedreg.ll
+++ llvm/test/CodeGen/Hexagon/namedreg.ll
@@ -4,10 +4,29 @@
   %0 = call i32 @llvm.read_register.i32(metadata !0)
   ret i32 %0
 }
-
 declare i32 @llvm.read_register.i32(metadata) #1
 
+define dso_local i32 @rcs0() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !1)
+  ret i32 %0
+}
+
+define dso_local i32 @rcs1() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !2)
+  ret i32 %0
+}
+
+
+
 !llvm.named.register.r19 = !{!0}
+!llvm.named.register.cs0 = !{!1}
+!llvm.named.register.cs1 = !{!2}
 
 !0 = !{!"r19"}
+!1 = !{!"cs0"}
+!2 = !{!"cs1"}
 ; CHECK: r0 = r19
+; CHECK: r0 = cs0
+; CHECK: r0 = cs1
Index: llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
===
--- llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -308,6 +308,8 @@
  .Case("m1", Hexagon::M1)
  .Case("usr", Hexagon::USR)
  .Case("ugp", Hexagon::UGP)
+ .Case("cs0", Hexagon::CS0)
+ .Case("cs1", Hexagon::CS1)
  .Default(Register());
   if (Reg)
 return Reg;
Index: clang/lib/Basic/Targets/Hexagon.cpp
===
--- clang/lib/Basic/Targets/Hexagon.cpp
+++ clang/lib/Basic/Targets/Hexagon.cpp
@@ -136,7 +136,7 @@
 "r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
 "r27", "r28", "r29", "r30", "r31", "p0",  "p1",  "p2",  "p3",
-"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp",
+"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp", "cs0", "cs1",
 "r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
 "r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
 "r31:30"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98037: [clangd] Add config block for Completion and option for AllScopes

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



Comment at: clang-tools-extra/clangd/ConfigFragment.h:244
+  struct CompletionBlock {
+/// Whether code completion should include results from scopes that are not
+/// visible.

Maybe s/results/suggestions/, emphasizing that these are going to be guesses?

Consider also "The required scope prefix will be inserted."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98037

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


[PATCH] D98440: [NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes

2021-03-11 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin created this revision.
mtrofin added reviewers: asbirlea, aeubanks.
Herald added subscribers: steven_wu, hiraditya.
mtrofin requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Check with the analysis result by calling invalidate instead of clear on
the analysis manager.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98440

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp


Index: llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
===
--- llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1942,5 +1942,29 @@
   ASSERT_TRUE(Ran);
 }
 
+TEST_F(CGSCCPassManagerTest, TestFunctionPassesAreQueriedForInvalidation) {
+  std::unique_ptr M = parseIR("define void @f() { ret void }");
+  CGSCCPassManager CGPM;
+  bool SCCCalled = false;
+  FunctionPassManager FPM;
+  int ImmRuns = 0;
+  FAM.registerPass([&] { return TestImmutableFunctionAnalysis(ImmRuns); });
+  FPM.addPass(RequireAnalysisPass());
+  CGPM.addPass(
+  LambdaSCCPass([&](LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
+LazyCallGraph &CG, CGSCCUpdateResult &UR) {
+SCCCalled = true;
+return PreservedAnalyses::none();
+  }));
+  CGPM.addPass(createCGSCCToFunctionPassAdaptor(
+  RequireAnalysisPass()));
+  ModulePassManager MPM;
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+  MPM.run(*M, MAM);
+  ASSERT_EQ(ImmRuns, 1);
+}
+
 #endif
 } // namespace
Index: llvm/lib/Analysis/CGSCCPassManager.cpp
===
--- llvm/lib/Analysis/CGSCCPassManager.cpp
+++ llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -720,7 +720,7 @@
   auto PAC = PA.getChecker();
   if (!PAC.preserved() && 
!PAC.preservedSet>()) {
 for (LazyCallGraph::Node &N : C)
-  FAM->clear(N.getFunction(), N.getFunction().getName());
+  FAM->invalidate(N.getFunction(), PA);
 
 return false;
   }
Index: clang/test/CodeGen/thinlto-distributed-newpm.ll
===
--- clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -12,7 +12,7 @@
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
 ; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s --dump-input=fail
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck -check-prefix=CHECK-O %s 
--dump-input=fail
 
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
@@ -70,24 +70,19 @@
 ; CHECK-O: Starting CGSCC pass manager run.
 ; CHECK-O: Running pass: InlinerPass on (main)
 ; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)
-; CHECK-O: Clearing all analysis results for: main
+; CHECK-O: Invalidating analysis: DominatorTreeAnalysis on main
+; CHECK-O: Invalidating analysis: BasicAA on main
+; CHECK-O: Invalidating analysis: AAManager on main
 ; CHECK-O3: Running pass: ArgumentPromotionPass on (main)
-; CHECK-O3: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SROA on main
 ; These next two can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on main
-; CHECK-O-DAG: Running analysis: AssumptionAnalysis on main
 ; CHECK-O: Running pass: EarlyCSEPass on main
-; CHECK-O: Running analysis: TargetLibraryAnalysis on main
-; CHECK-O2: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
-; CHECK-O: Running analysis: ScopedNoAliasAA on main
-; CHECK-O: Running analysis: TypeBasedAA on main
-; CHECK-O: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O: Running pass: SpeculativeExecutionPass on main
 ; CHECK-O: Running pass: JumpThreadingPass on main
 ; CHECK-O: Running analysis: LazyValueAnalysis on main
@@ -96,7 +91,6 @@
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O3: Running pass: AggressiveInstCombinePass on main
 ; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running pass: LibCallsShrinkWrapPass on main
 ; CHECK-O: Running pass: TailCallElimPass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main


Index: llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
===

[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-11 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330023.
arnamoy10 added a comment.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Updating the patch to make -pedantic and -f2018 behave the same way, also 
updated the test case accordingly.


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

https://reviews.llvm.org/D97119

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/std2018.f90

Index: flang/test/Driver/std2018.f90
===
--- /dev/null
+++ flang/test/Driver/std2018.f90
@@ -0,0 +1,44 @@
+! Ensure argument -std=f2018 works as expected.
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang-new -fsyntax-only -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang-new -fsyntax-only -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %f18 -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %f18 -fsyntax-only -Mstandard %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: not %flang-new -fsyntax-only -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang_fc1 -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: not %flang_fc1 -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH WRONG
+!-
+! WRONG: Only -std=f2018 is allowed currently.
+
+subroutine foo2()
+do 01 m=1,2
+  select case (m)
+  case default
+print*, "default", m
+  case (1)
+print*, "start"
+01end select
+end subroutine
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -368,6 +368,30 @@
 res.frontendOpts().features_.Enable(
 Fortran::common::LanguageFeature::OpenMP);
   }
+  if (args.hasArg(clang::driver::options::OPT_fopenmp)) {
+res.frontendOpts().features_.Enable(
+Fortran::common::LanguageFeature::OpenMP);
+  }
+
+  //-fpedantic
+  if (args.hasArg(clang::driver::options::OPT_pedantic)) {
+res.set_EnableConformanceChecks();
+  }
+  // -std=f2018.  Current behaviour is same as -fpedantic
+  // TODO: Set proper options when more fortran standards
+  // are supported.
+  if (args.hasArg(clang::driver::options::OPT_std_EQ)) {
+auto standard = args.getLastArgValue(clang::driver::options::OPT_std_EQ);
+// We only allow f2018 as the given standard
+if (standard.equals("f2018")) {
+  res.set_EnableConformanceChecks();
+} else {
+  const unsigned diagID =
+  diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
+  "Only -std=f2018 is allowed currently.");
+  diags.Report(diagID);
+}
+  }
   return;
 }
 
@@ -508,6 +532,11 @@
 
   if (frontendOptions.instrumentedParse_)
 fortranOptions.instrumentedParse = true;
+
+  // Set the standard
+  if (EnableConformanceChecks_) {
+fortranOptions.features.WarnOnAllNonstandard();
+  }
 }
 
 void CompilerInvocation::setSemanticsOpts(
Index: flang/include/flang/Frontend/CompilerInvocation.h
===
--- flang/include/flang/Frontend/CompilerInvocation.h
+++ flang/include/flang/Frontend/CompilerInvocation.h
@@ -74,6 +74,8 @@
   // Fortran Dialect options
   Fortran::common::IntrinsicTypeDefaultKinds defaultKinds_;
 
+  bool EnableConformanceChecks_ = false;
+
 public:
   CompilerInvocation() = default;
 
@@ -111,6 +113,9 @@
   llvm::ArrayRef commandLineArgs,
   clang::DiagnosticsEngine &diags);
 
+  // Enables the std=f2018 conformance check
+  void set_EnableConformanceChecks() { EnableConformanceChecks_ = true; }
+
   /// Useful setters
   void SetModuleDir(std::string &moduleDir) { moduleDir_ = moduleDir; }
 
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cp

[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-11 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a reviewer: EricWF.
akhuang added a subscriber: EricWF.
akhuang added a comment.

@EricWF, comments on using this attribute in libc++ vs fixing the code 
otherwise?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D98438: Clang: Allow selecting the hash algorithm for file checksums in debug info.

2021-03-11 Thread Arlo Siemsen via Phabricator via cfe-commits
arlosi created this revision.
Herald added subscribers: jansvoboda11, dexonsmith, dang.
arlosi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds clang-cl support for the /ZH: option used to select MD5, SHA1,
or SHA_256 hashing algorithms in debug info.

Previously only the MD5 algorithm was supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98438

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

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1928,6 +1928,20 @@
   else if (Args.hasArg(options::OPT_fno_finite_loops))
 Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Never;
 
+  if (Arg *A = Args.getLastArg(OPT_gsrc_hash_algorithm_EQ)) {
+unsigned Val = llvm::StringSwitch(A->getValue())
+   .Case("md5", CodeGenOptions::CSK_MD5)
+   .Case("sha1", CodeGenOptions::CSK_SHA1)
+   .Case("sha256", CodeGenOptions::CSK_SHA256)
+   .Default(~0U);
+if (Val == ~0U)
+  Diags.Report(diag::err_drv_invalid_value)
+  << A->getAsString(Args) << A->getValue();
+else
+  Opts.setDebugSrcHashAlgorithm(
+  static_cast(Val));
+  }
+
   return Success && Diags.getNumErrors() == NumErrorsBefore;
 }
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7107,6 +7107,19 @@
   D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << GuardArgs;
 }
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_ZH)) {
+StringRef Val = A->getValue();
+if (Val.equals("MD5")) {
+  CmdArgs.push_back("-gsrc-hash-algorithm=md5");
+} else if (Val.equals("SHA1")) {
+  CmdArgs.push_back("-gsrc-hash-algorithm=sha1");
+} else if (Val.equals("SHA_256")) {
+  CmdArgs.push_back("-gsrc-hash-algorithm=sha256");
+} else {
+  D.Diag(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
+}
+  }
 }
 
 const char *Clang::getBaseInputName(const ArgList &Args,
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -572,8 +572,9 @@
   void CreateCompileUnit();
 
   /// Compute the file checksum debug info for input file ID.
-  Optional
-  computeChecksum(FileID FID, SmallString<32> &Checksum) const;
+  /// Storage of the checksum string is owned by the caller.
+  Optional>
+  computeChecksum(FileID FID, SmallString<64> &Checksum) const;
 
   /// Get the source of the given file ID.
   Optional getSource(const SourceManager &SM, FileID FID);
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -44,9 +44,13 @@
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/SHA1.h"
+#include "llvm/Support/SHA256.h"
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/raw_ostream.h"
 using namespace clang;
 using namespace clang::CodeGen;
 
@@ -361,10 +365,12 @@
   return StringRef();
 }
 
-Optional
-CGDebugInfo::computeChecksum(FileID FID, SmallString<32> &Checksum) const {
+Optional>
+CGDebugInfo::computeChecksum(FileID FID, SmallString<64> &Checksum) const {
   Checksum.clear();
 
+  llvm::DIFile::ChecksumKind CSKind;
+  Optional> CSInfo;
   if (!CGM.getCodeGenOpts().EmitCodeView &&
   CGM.getCodeGenOpts().DwarfVersion < 5)
 return None;
@@ -374,14 +380,42 @@
   if (!MemBuffer)
 return None;
 
-  llvm::MD5 Hash;
-  llvm::MD5::MD5Result Result;
-
-  Hash.update(MemBuffer->getBuffer());
-  Hash.final(Result);
+  switch (CGM.getCodeGenOpts().getDebugSrcHashAlgorithm()) {
+  case clang::CodeGenOptions::CSK_MD5: {
+CSKind = llvm::DIFile::CSK_MD5;
+llvm::MD5 Hash;
+llvm::MD5::MD5Result Result;
+Hash.update(MemBuffer->getBuffer());
+Hash.final(Result);
+Checksum = Result.digest();
+break;
+  }
+  case clang::CodeGenOptions::CSK_SHA1: {
+CSKind = llvm::DIFile::CSK_SHA1;
+llvm::SHA1 Hash;
+Hash.update(MemBuffer->getBuffer());
+StringRef Result = Hash.final();
+llvm::raw_svector_ostream Res(Checksum);
+for (int i = 0; i < 20; ++i)
+  Res << llvm::format("%.2x", static_cast(Result[

[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d8a9190db19: [Driver] Drop $sysroot/usr special case from 
Gentoo gcc-config detection (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1934,13 +1934,10 @@
   // Typically /usr.
   AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);
 }
-  }
 
-  // Try to respect gcc-config on Gentoo. However, do that only
-  // if --gcc-toolchain is not provided or equal to the Gentoo install
-  // in /usr. This avoids accidentally enforcing the system GCC version
-  // when using a custom toolchain.
-  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+// Try to respect gcc-config on Gentoo if --gcc-toolchain is not provided.
+// This avoids accidentally enforcing the system GCC version when using a
+// custom toolchain.
 SmallVector GentooTestTriples;
 // Try to match an exact triple as target triple first.
 // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1934,13 +1934,10 @@
   // Typically /usr.
   AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);
 }
-  }
 
-  // Try to respect gcc-config on Gentoo. However, do that only
-  // if --gcc-toolchain is not provided or equal to the Gentoo install
-  // in /usr. This avoids accidentally enforcing the system GCC version
-  // when using a custom toolchain.
-  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+// Try to respect gcc-config on Gentoo if --gcc-toolchain is not provided.
+// This avoids accidentally enforcing the system GCC version when using a
+// custom toolchain.
 SmallVector GentooTestTriples;
 // Try to match an exact triple as target triple first.
 // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8d8a919 - [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-11T10:13:01-08:00
New Revision: 8d8a9190db19b487198680adab9a6ca173f20bb3

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

LOG: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

If --gcc-toolchain is specified, we should detect GCC installation there, and 
suppress other directories for detection.

Reviewed By: mgorny, manojgupta

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 3d88053c6b08..fbf2f29e0514 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1934,13 +1934,10 @@ void Generic_GCC::GCCInstallationDetector::init(
   // Typically /usr.
   AddDefaultGCCPrefixes(TargetTriple, Prefixes, D.SysRoot);
 }
-  }
 
-  // Try to respect gcc-config on Gentoo. However, do that only
-  // if --gcc-toolchain is not provided or equal to the Gentoo install
-  // in /usr. This avoids accidentally enforcing the system GCC version
-  // when using a custom toolchain.
-  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+// Try to respect gcc-config on Gentoo if --gcc-toolchain is not provided.
+// This avoids accidentally enforcing the system GCC version when using a
+// custom toolchain.
 SmallVector GentooTestTriples;
 // Try to match an exact triple as target triple first.
 // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for



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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D97894#2620077 , @manojgupta wrote:

> @MaskRay I have verified that Chrome OS builds are not affected by this 
> change.

Thank you for testing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta accepted this revision.
manojgupta added a comment.

@MaskRay I have verified that Chrome OS builds are not affected by this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Thank you for updating this @arnamoy10 !




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:26
 #include "llvm/Support/raw_ostream.h"
+
+#include "llvm/Support/FileSystem.h"

Not needed



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:292
+  std::string driverPath = llvm::sys::fs::getMainExecutable(nullptr, nullptr);
+  driverPath = driverPath.substr(0, driverPath.find_last_of("/\\"));
+  return driverPath.append("/../tools/flang/include/flang/");

This will not work on Windows, will it? I couldn't find any API to deal with 
this in a OS-agnostic way. Perhaps just remove 9 characters at the end? Or use 
`#ifndef _WIN32`?



Comment at: flang/test/Driver/Inputs/ieee_arithmetic.mod:1
+! DUMMY module
+module ieee_arithmetic

I think that currently the contents of this file are not relevant. So I would 
limit it to some helpful comment, e.g.:
```
Added for testing purposes. The contents of this file are currently not 
relevant.
```


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

https://reviews.llvm.org/D97080

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


[PATCH] D98436: [Hexagon] Support inlined use of cs0 and cs1

2021-03-11 Thread Sid Manning via Phabricator via cfe-commits
sidneym created this revision.
sidneym added reviewers: bcain, kparzysz.
Herald added a subscriber: hiraditya.
sidneym requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Allow inline assembly to reference cs0 and cs1 registers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98436

Files:
  clang/lib/Basic/Targets/Hexagon.cpp
  llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
  llvm/test/CodeGen/Hexagon/namedreg.ll


Index: llvm/test/CodeGen/Hexagon/namedreg.ll
===
--- llvm/test/CodeGen/Hexagon/namedreg.ll
+++ llvm/test/CodeGen/Hexagon/namedreg.ll
@@ -4,10 +4,29 @@
   %0 = call i32 @llvm.read_register.i32(metadata !0)
   ret i32 %0
 }
-
 declare i32 @llvm.read_register.i32(metadata) #1
 
+define dso_local i32 @rcs0() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !1)
+  ret i32 %0
+}
+
+define dso_local i32 @rcs1() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !2)
+  ret i32 %0
+}
+
+
+
 !llvm.named.register.r19 = !{!0}
+!llvm.named.register.cs0 = !{!1}
+!llvm.named.register.cs1 = !{!2}
 
 !0 = !{!"r19"}
+!1 = !{!"cs0"}
+!2 = !{!"cs1"}
 ; CHECK: r0 = r19
+; CHECK: r0 = cs0
+; CHECK: r0 = cs1
Index: llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
===
--- llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -308,6 +308,8 @@
  .Case("m1", Hexagon::M1)
  .Case("usr", Hexagon::USR)
  .Case("ugp", Hexagon::UGP)
+ .Case("cs0", Hexagon::CS0)
+ .Case("cs1", Hexagon::CS1)
  .Default(Register());
   if (Reg)
 return Reg;
Index: clang/lib/Basic/Targets/Hexagon.cpp
===
--- clang/lib/Basic/Targets/Hexagon.cpp
+++ clang/lib/Basic/Targets/Hexagon.cpp
@@ -136,7 +136,7 @@
 "r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
 "r27", "r28", "r29", "r30", "r31", "p0",  "p1",  "p2",  "p3",
-"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp",
+"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp", "cs0", "cs1",
 "r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
 "r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
 "r31:30"


Index: llvm/test/CodeGen/Hexagon/namedreg.ll
===
--- llvm/test/CodeGen/Hexagon/namedreg.ll
+++ llvm/test/CodeGen/Hexagon/namedreg.ll
@@ -4,10 +4,29 @@
   %0 = call i32 @llvm.read_register.i32(metadata !0)
   ret i32 %0
 }
-
 declare i32 @llvm.read_register.i32(metadata) #1
 
+define dso_local i32 @rcs0() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !1)
+  ret i32 %0
+}
+
+define dso_local i32 @rcs1() #0 {
+entry:
+  %0 = call i32 @llvm.read_register.i32(metadata !2)
+  ret i32 %0
+}
+
+
+
 !llvm.named.register.r19 = !{!0}
+!llvm.named.register.cs0 = !{!1}
+!llvm.named.register.cs1 = !{!2}
 
 !0 = !{!"r19"}
+!1 = !{!"cs0"}
+!2 = !{!"cs1"}
 ; CHECK: r0 = r19
+; CHECK: r0 = cs0
+; CHECK: r0 = cs1
Index: llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
===
--- llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -308,6 +308,8 @@
  .Case("m1", Hexagon::M1)
  .Case("usr", Hexagon::USR)
  .Case("ugp", Hexagon::UGP)
+ .Case("cs0", Hexagon::CS0)
+ .Case("cs1", Hexagon::CS1)
  .Default(Register());
   if (Reg)
 return Reg;
Index: clang/lib/Basic/Targets/Hexagon.cpp
===
--- clang/lib/Basic/Targets/Hexagon.cpp
+++ clang/lib/Basic/Targets/Hexagon.cpp
@@ -136,7 +136,7 @@
 "r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
 "r27", "r28", "r29", "r30", "r31", "p0",  "p1",  "p2",  "p3",
-"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp",
+"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp", "cs0", "cs1",
 "r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
 "r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
 "r31:30"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98037: [clangd] Add config block for Completion and option for AllScopes

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98037

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


[PATCH] D98165: [clangd] Make ProjectAwareIndex optionally sync

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98165

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


[PATCH] D98433: [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Is there something else that I should test?




Comment at: clang/lib/Parse/ParseExprCXX.cpp:1447
+std::vector EmptyParamInfo;
+ParseLambdaSpecifiers(/*LParenLoc=*/NoLoc, /*RParenLoc=*/NoLoc,
+  EmptyParamInfo, /*EllipsisLoc=*/NoLoc);

I'm not sure what I should do with `LParenLoc` and `RParenLoc`. Any idea?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[PATCH] D97857: [Matrix] Add support for matrix-by-scalar division.

2021-03-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 33.
fhahn added a comment.

Thank you very much John! I applied your suggestions to the wording and removed 
the unneeded language feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97857

Files:
  clang/docs/MatrixTypes.rst
  clang/include/clang/Basic/Features.def
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGen/matrix-type.c
  clang/test/Sema/matrix-type-operators.c
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -215,6 +215,22 @@
 return B.CreateMul(LHS, RHS);
   }
 
+  /// Divide matrix \p LHS by scalar \p RHS. If the operands are integers, \p
+  /// IsUnsigned indicates whether UDiv or SDiv should be used.
+  Value *CreateScalarDiv(Value *LHS, Value *RHS, bool IsUnsigned) {
+assert(LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy());
+assert(!isa(LHS->getType()) &&
+   "LHS Assumed to be fixed width");
+RHS =
+B.CreateVectorSplat(cast(LHS->getType())->getElementCount(),
+RHS, "scalar.splat");
+return cast(LHS->getType())
+   ->getElementType()
+   ->isFloatingPointTy()
+   ? B.CreateFDiv(LHS, RHS)
+   : (IsUnsigned ? B.CreateUDiv(LHS, RHS) : B.CreateSDiv(LHS, RHS));
+  }
+
   /// Extracts the element at (\p RowIdx, \p ColumnIdx) from \p Matrix.
   Value *CreateExtractElement(Value *Matrix, Value *RowIdx, Value *ColumnIdx,
   unsigned NumRows, Twine const &Name = "") {
Index: clang/test/Sema/matrix-type-operators.c
===
--- clang/test/Sema/matrix-type-operators.c
+++ clang/test/Sema/matrix-type-operators.c
@@ -94,6 +94,40 @@
   // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
 }
 
+void mat_scalar_divide(sx10x10_t a, sx5x10_t b, float sf, char *p) {
+  // Shape of multiplication result does not match the type of b.
+  b = a / sf;
+  // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
+  b = sf / a;
+  // expected-error@-1 {{invalid operands to binary expression ('float' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
+
+  a = a / p;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'char *')}}
+  a = p / a;
+  // expected-error@-1 {{invalid operands to binary expression ('char *' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
+
+  sf = a / sf;
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
+}
+
+void matrix_matrix_divide(sx10x10_t a, sx5x10_t b, ix10x5_t c, ix10x10_t d, float sf, char *p) {
+  // Matrix by matrix division is not supported.
+  a = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  b = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  // Check element type mismatches.
+  a = b / c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
+  d = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+
+  p = a / a;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
+}
+
 sx5x10_t get_matrix();
 
 void insert(sx5x10_t a, float f) {
Index: clang/test/CodeGen/matrix-type.c
===
--- clang/test/CodeGen/matrix-type.c
+++ clang/test/CodeGen/matrix-type.c
@@ -4,6 +4,10 @@
 #error Expected extension 'matrix_types' to be enabled
 #endif
 
+#if !__has_extension(matrix_types_scalar_division)
+#error Expected extension 'matrix_types_scalar_division' to be enabled
+#endif
+
 typedef double dx5x5_t __attribute__((matrix_type(5, 5)));
 
 // CHECK: %struct.Matrix = type { i8, [12 x float], float }
Index: clang/test/CodeGen/matrix-type-operators.c
===
--- clang/test/CodeGen/matrix-typ

[PATCH] D98433: [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 329998.
curdeius added a comment.

Revert unintended changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -63,7 +63,7 @@
 
  C++2b (tentatively C++23)
  -std=c++2b
- No
+ Partial
 
 
 
@@ -1276,7 +1276,7 @@
 
   Make () in lambdas optional in all cases
   https://wg21.link/p1102r2";>P1102R2
-  No
+  Clang 13
 
 
 
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
+
+auto L0 = [] constexpr {};
+auto L1 = [] mutable {};
+auto L2 = [] noexcept {};
+auto L3 = [] constexpr mutable {};
+auto L4 = [] mutable constexpr {};
+auto L5 = [] constexpr mutable noexcept {};
+auto L6 = [s = 1] mutable {};
+auto L7 = [s = 1] constexpr mutable noexcept {};
+auto L8 = [] -> bool { return true; };
+auto L9 = [] { return true; };
+auto L10 = [] noexcept { return true; };
+auto L11 = [] -> bool { return true; };
+auto L12 = [] consteval {};
+auto L13 = [] requires requires() { true; }
+{};
+auto L15 = [] [[maybe_unused]]{};
+
+auto XL0 = [] mutable constexpr mutable {};// expected-error{{cannot appear multiple times}}
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -688,9 +688,9 @@
 /// ParseLambdaExpression - Parse a C++11 lambda expression.
 ///
 ///   lambda-expression:
-/// lambda-introducer lambda-declarator[opt] compound-statement
+/// lambda-introducer lambda-declarator compound-statement
 /// lambda-introducer '<' template-parameter-list '>'
-/// lambda-declarator[opt] compound-statement
+/// lambda-declarator compound-statement
 ///
 ///   lambda-introducer:
 /// '[' lambda-capture[opt] ']'
@@ -722,9 +722,13 @@
 /// '&' identifier initializer
 ///
 ///   lambda-declarator:
-/// '(' parameter-declaration-clause ')' attribute-specifier[opt]
-///   'mutable'[opt] exception-specification[opt]
-///   trailing-return-type[opt]
+/// lambda-specifiers [C++2b]
+/// '(' parameter-declaration-clause ')' lambda-specifiers
+/// requires-clause[opt]
+///
+///   lambda-specifiers:
+/// decl-specifier-seq[opt] noexcept-specifier[opt]
+/// attribute-specifier-seq[opt] trailing-return-type[opt]
 ///
 ExprResult Parser::ParseLambdaExpression() {
   // Parse lambda-introducer.
@@ -1315,11 +1319,92 @@
 
   TypeResult TrailingReturnType;
   SourceLocation TrailingReturnTypeLoc;
+
+  auto ParseLambdaSpecifiers =
+  [&](SourceLocation LParenLoc, SourceLocation RParenLoc,
+  MutableArrayRef ParamInfo,
+  SourceLocation EllipsisLoc) {
+SourceLocation DeclEndLoc = RParenLoc;
+
+// GNU-style attributes must be parsed before the mutable specifier to
+// be compatible with GCC. MSVC-style attributes must be parsed before
+// the mutable specifier to be compatible with MSVC.
+MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attr);
+
+// Parse mutable-opt and/or constexpr-opt or consteval-opt, and update
+// the DeclEndLoc.
+SourceLocation MutableLoc;
+SourceLocation ConstexprLoc;
+SourceLocation ConstevalLoc;
+tryConsumeLambdaSpecifierToken(*this, MutableLoc, ConstexprLoc,
+   ConstevalLoc, DeclEndLoc);
+
+addConstexprToLambdaDeclSpecifier(*this, ConstexprLoc, DS);
+addConstevalToLambdaDeclSpecifier(*this, ConstevalLoc, DS);
+// Parse exception-specification[opt].
+ExceptionSpecificationType ESpecType = EST_None;
+SourceRange ESpecRange;
+SmallVector DynamicExceptions;
+SmallVector DynamicExceptionRanges;
+ExprResult NoexceptExpr;
+CachedTokens *ExceptionSpecTokens;
+ESpecType = tryParseExceptionSpecification(
+/*Delayed=*/false, ESpecRange, DynamicExceptions,
+DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
+
+if (ESpecType != EST_None)
+  DeclEndLoc = ESpecRange.getEnd();
+
+// Parse attribute-specifier[opt].
+MaybeParseCXX11Attributes(Attr, &DeclEndLoc);
+
+// Parse OpenCL addr space attribu

[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-03-11 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

@NoQ, I am using `trackExpressionValue` to add intersetingness to the 
`InnerPointerVal`. That solves the original problem. However, it is causing the 
**MoveChecker** to add extra warnings to use-after-move cases. Essentially, 
when a `unique_ptr` is moved and subsequently used, it triggers two warnings - 
one from `SmartPointerModelling` and another from `MoveChecker`. It seems to me 
that two separate checkers are tracking the same bug - use after move. 
So should I make another patch to modify `SmartPointerModelling` to not emit 
warnings on use after move (instead just leaving the GDM updating code)? Or is 
there a better solution to this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183

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


[PATCH] D98433: [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-11 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: rsmith, aaron.ballman, faisalv.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- http://eel.is/c++draft/expr.prim.lambda
- http://wg21.link/P1102


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98433

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -63,7 +63,7 @@
 
  C++2b (tentatively C++23)
  -std=c++2b
- No
+ Partial
 
 
 
@@ -1276,7 +1276,7 @@
 
   Make () in lambdas optional in all cases
   https://wg21.link/p1102r2";>P1102R2
-  No
+  Clang 13
 
 
 
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
+
+auto L0 = [] constexpr {};
+auto L1 = [] mutable {};
+auto L2 = [] noexcept {};
+auto L3 = [] constexpr mutable {};
+auto L4 = [] mutable constexpr {};
+auto L5 = [] constexpr mutable noexcept {};
+auto L6 = [s = 1] mutable {};
+auto L7 = [s = 1] constexpr mutable noexcept {};
+auto L8 = [] -> bool { return true; };
+auto L9 = [] { return true; };
+auto L10 = [] noexcept { return true; };
+auto L11 = [] -> bool { return true; };
+auto L12 = [] consteval {};
+auto L13 = [] requires requires() { true; }
+{};
+auto L15 = [] [[maybe_unused]]{};
+
+auto XL0 = [] mutable constexpr mutable {};// expected-error{{cannot appear multiple times}}
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -688,9 +688,9 @@
 /// ParseLambdaExpression - Parse a C++11 lambda expression.
 ///
 ///   lambda-expression:
-/// lambda-introducer lambda-declarator[opt] compound-statement
+/// lambda-introducer lambda-declarator compound-statement
 /// lambda-introducer '<' template-parameter-list '>'
-/// lambda-declarator[opt] compound-statement
+/// lambda-declarator compound-statement
 ///
 ///   lambda-introducer:
 /// '[' lambda-capture[opt] ']'
@@ -722,9 +722,13 @@
 /// '&' identifier initializer
 ///
 ///   lambda-declarator:
-/// '(' parameter-declaration-clause ')' attribute-specifier[opt]
-///   'mutable'[opt] exception-specification[opt]
-///   trailing-return-type[opt]
+/// lambda-specifiers [C++2b]
+/// '(' parameter-declaration-clause ')' lambda-specifiers
+/// requires-clause[opt]
+///
+///   lambda-specifiers:
+/// decl-specifier-seq[opt] noexcept-specifier[opt]
+/// attribute-specifier-seq[opt] trailing-return-type[opt]
 ///
 ExprResult Parser::ParseLambdaExpression() {
   // Parse lambda-introducer.
@@ -1315,11 +1319,92 @@
 
   TypeResult TrailingReturnType;
   SourceLocation TrailingReturnTypeLoc;
+
+  auto ParseLambdaSpecifiers =
+  [&](SourceLocation LParenLoc, SourceLocation RParenLoc,
+  MutableArrayRef ParamInfo,
+  SourceLocation EllipsisLoc) {
+SourceLocation DeclEndLoc = RParenLoc;
+
+// GNU-style attributes must be parsed before the mutable specifier to
+// be compatible with GCC. MSVC-style attributes must be parsed before
+// the mutable specifier to be compatible with MSVC.
+MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attr);
+
+// Parse mutable-opt and/or constexpr-opt or consteval-opt, and update
+// the DeclEndLoc.
+SourceLocation MutableLoc;
+SourceLocation ConstexprLoc;
+SourceLocation ConstevalLoc;
+tryConsumeLambdaSpecifierToken(*this, MutableLoc, ConstexprLoc,
+   ConstevalLoc, DeclEndLoc);
+
+addConstexprToLambdaDeclSpecifier(*this, ConstexprLoc, DS);
+addConstevalToLambdaDeclSpecifier(*this, ConstevalLoc, DS);
+// Parse exception-specification[opt].
+ExceptionSpecificationType ESpecType = EST_None;
+SourceRange ESpecRange;
+SmallVector DynamicExceptions;
+SmallVector DynamicExceptionRanges;
+ExprResult NoexceptExpr;
+CachedTokens *ExceptionSpecTokens;
+ESpecType = tryParseExceptionSpecification(
+/*Delayed=*/false, ESpecRange, DynamicExceptions,
+DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
+
+if (ESpecType != EST_None)
+  DeclEndLoc = ESpecRange.getEnd();
+
+// Parse attribute-specifier[

[PATCH] D98414: [clangd] Turn off implicit cancellation based on client capabilities

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/ClangdServer.h:153
+/// to cancel. Clients that always cancel stale requests should clear this.
+bool ImplicitCancellation = true;
+

sammccall wrote:
> kadircet wrote:
> > this makes sense as is, but i wonder if we should lift this to LSPServer 
> > instead.
> > 
> > 3.17 specs also introduce `retryOnContentModified`, which is supposed to be 
> > a list of RPC names. so if we decide to take that into account, rather than 
> > deciding on what's "transient" ourselves, having all of this hardcoded in 
> > clangdserver would be limiting. 
> > 
> > We can accept a cancellation policy on all of the ClangdServer endpoints, 
> > have some sensible defaults in clangdlspserver, enable those to be 
> > overwritten by client specs on initialize. (or if we don't want to make 
> > them part of the signature i suppose we can make use of config/context, but 
> > ... yikes). WDYT?
> I thought about this, but I don't think it's better...
> 
>  - it's complicated and boilerplatey with the method names, way out of 
> proportion to the value here
>  - I think "will the client take care of cancellation" is actually the more 
> pertinent question rather than "will the client retry if we cancel"
>  - we want to disable this (entirely) in C++ embedders, and a boolean option 
> is the simplest way to do that.
> we want to disable this (entirely) in C++ embedders, and a boolean option is 
> the simplest way to do that.

i think it should be okay for embedders to specify what behavior they want per 
action, but i agree with the other two points. thanks for the explanation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98414

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


[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-03-11 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 329989.
RedDocMD added a comment.

Calling trackExpressionValue to mark InnerPointerVal as interesting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp


Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -464,7 +464,7 @@
 if (&BR.getBugType() != smartptr::getNullDereferenceBugType() ||
 !BR.isInteresting(ThisRegion))
   return;
-if (!State->assume(InnerPointerVal.castAs(), true))
+if (!BR.isInteresting(InnerPointerVal) || 
!BR.isInteresting(InnerPointerVal.getAsSymbol()))
   return;
 if (ThisRegion->canPrintPretty()) {
   OS << "Obtained null inner pointer from";
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
@@ -87,7 +87,12 @@
   auto R = std::make_unique(NullDereferenceBugType,
 OS.str(), ErrNode);
   R->markInteresting(DerefRegion);
-  C.emitReport(std::move(R));
+  const Expr *BugExpr = Call.getOriginExpr();
+  const ProgramStateRef State = C.getState();
+  if (const ExplodedNode *E = C.generateNonFatalErrorNode(State)) {
+bugreporter::trackExpressionValue(E, BugExpr, *R);
+C.emitReport(std::move(R));
+  }
 }
 
 void SmartPtrChecker::explainDereference(llvm::raw_ostream &OS,


Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -464,7 +464,7 @@
 if (&BR.getBugType() != smartptr::getNullDereferenceBugType() ||
 !BR.isInteresting(ThisRegion))
   return;
-if (!State->assume(InnerPointerVal.castAs(), true))
+if (!BR.isInteresting(InnerPointerVal) || !BR.isInteresting(InnerPointerVal.getAsSymbol()))
   return;
 if (ThisRegion->canPrintPretty()) {
   OS << "Obtained null inner pointer from";
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
@@ -87,7 +87,12 @@
   auto R = std::make_unique(NullDereferenceBugType,
 OS.str(), ErrNode);
   R->markInteresting(DerefRegion);
-  C.emitReport(std::move(R));
+  const Expr *BugExpr = Call.getOriginExpr();
+  const ProgramStateRef State = C.getState();
+  if (const ExplodedNode *E = C.generateNonFatalErrorNode(State)) {
+bugreporter::trackExpressionValue(E, BugExpr, *R);
+C.emitReport(std::move(R));
+  }
 }
 
 void SmartPtrChecker::explainDereference(llvm::raw_ostream &OS,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98424: [clangd] Reject renames to non-identifier characters

2021-03-11 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 accepted this revision.
usaxena95 added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.




Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:466
+case InvalidName::BadIdentifier:
+  return "the chosen name \"{0}\" is not a valid identifier";
 }

Please format the string with `Reason.Details`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98424

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


[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 329982.
ASDenysPetrov added a comment.

Updated.

In D96090#2618410 , @NoQ wrote:

> In all cases we're supposed to have an **original** type, whether we need it 
> or not. Simply because we're simulating a typed language. If we don't have it 
> it's a bug.

I agree. That's how `evalCastFromNonLoc` and `evalCastFromLoc` work now. 
Finally I want to replace them along with passing a correct **original** type. 
This is just one another step closer to this direction. I don't want patches be 
too comlicated.

>> Some cases can extract the type from `SVal`
>
> Which is generally impossible because integral casts aren't modeled correctly.

Maybe I'm missing smth, But how about this:

  QualType T = V.castAs().getSymbol()->getType();
  QualType T = 
cast(V.castAs().getAsRegion()).getSymbol()->getType();
  // Belowees are not exact types but well narrowed information which can be 
sufficient.
  V.castAs() <-> OriginalTy->isIntegralOrEnumerationType() 
  V.castAs() | V.castAs() | 
V.castAs() <-> Loc::isLocType(CastTy)
  V.castAs() <-> OriginalTy->isMemberPointerType() 
 (I guess)
  ...

> None of these ideal situations leave room for an API that receives the type 
> //optionally//.

I've returned back `OriginalTy` param from a **default** to a **regular** one 
as @steakhal advised in D96090#261 
.


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

https://reviews.llvm.org/D96090

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp

Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -394,48 +394,6 @@
   return UnknownVal();
 }
 
-static bool hasSameUnqualifiedPointeeType(QualType ty1, QualType ty2) {
-  return ty1->getPointeeType().getCanonicalType().getTypePtr() ==
- ty2->getPointeeType().getCanonicalType().getTypePtr();
-}
-
-/// CastRetrievedVal - Used by subclasses of StoreManager to implement
-///  implicit casts that arise from loads from regions that are reinterpreted
-///  as another region.
-SVal StoreManager::CastRetrievedVal(SVal V, const TypedValueRegion *R,
-QualType castTy) {
-  if (castTy.isNull() || V.isUnknownOrUndef())
-return V;
-
-  // The dispatchCast() call below would convert the int into a float.
-  // What we want, however, is a bit-by-bit reinterpretation of the int
-  // as a float, which usually yields nothing garbage. For now skip casts
-  // from ints to floats.
-  // TODO: What other combinations of types are affected?
-  if (castTy->isFloatingType()) {
-SymbolRef Sym = V.getAsSymbol();
-if (Sym && !Sym->getType()->isFloatingType())
-  return UnknownVal();
-  }
-
-  // When retrieving symbolic pointer and expecting a non-void pointer,
-  // wrap them into element regions of the expected type if necessary.
-  // SValBuilder::dispatchCast() doesn't do that, but it is necessary to
-  // make sure that the retrieved value makes sense, because there's no other
-  // cast in the AST that would tell us to cast it to the correct pointer type.
-  // We might need to do that for non-void pointers as well.
-  // FIXME: We really need a single good function to perform casts for us
-  // correctly every time we need it.
-  if (castTy->isPointerType() && !castTy->isVoidPointerType())
-if (const auto *SR = dyn_cast_or_null(V.getAsRegion())) {
-  QualType sr = SR->getSymbol()->getType();
-  if (!hasSameUnqualifiedPointeeType(sr, castTy))
-  return loc::MemRegionVal(castRegion(SR, castTy));
-}
-
-  return svalBuilder.dispatchCast(V, castTy);
-}
-
 SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) {
   if (Base.isUnknownOrUndef())
 return Base;
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -65,12 +65,12 @@
 // Transfer function for Casts.
 //===--===//
 
+// FIXME: This function should be eliminated and replaced with `evalCast`
 SVal SimpleSValBuilder::dispatchCast(SVal Val, QualType CastTy) {
-  assert(Val.getAs() || Val.getAs());
-  return Val.getAs() ? evalCastFromLoc(Val.castAs(), CastTy)
-   : evalCastFromNonLoc(Val.castAs(), CastTy);
+  return evalCast(Val, CastTy, QualType{});
 }
 
+// FIXME: This function should be eliminated and replaced with `evalCast`
 SVal SimpleSValBuilder::evalCastFromNonLoc(NonLoc val

[PATCH] D95635: [CMake] Require python 3.6 if enabling LLVM test targets

2021-03-11 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

would it make sense to syndicate the minimal version in a single variable, say 
`LLVM_MINIMAL_PYTHON_VERSION`, and use it in several place instead of 
hard-coding the value across multiple files?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-11 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 329976.
arnamoy10 added a comment.

Clang-formatting


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -82,6 +84,8 @@
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/test/Driver/Inputs/iso_fortran_env.mod
===
--- /dev/null
+++ flang/test/Driver/Inputs/iso_fortran_env.mod
@@ -0,0 +1,6 @@
+! DUMMY module
+module iso_fortran_env
+u

[PATCH] D86855: Convert __m64 intrinsics to unconditionally use SSE2 instead of MMX instructions.

2021-03-11 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Ping, thanks!

Or, if you have suggestions on how to make it easier to review, I'd be open to 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86855

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


[PATCH] D98429: [clang-format] Add new option to clang-format: SpaceBeforeForLoopSemiColon

2021-03-11 Thread Nathan Hjelm via Phabricator via cfe-commits
hjelmn created this revision.
hjelmn added reviewers: krasimir, djasper.
hjelmn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The option SpaceBeforeForLoopSemiColon controls whether clang-format puts
a space before the semi-colons in a for loop. When disabled (default) there
is no change to the current behavior. When enabled clang-format will put a
space before semi-colons in for loops:

enabled:

for (int i = 0 ; i < 10 ; ++i) {}

disabled:

for (int i = 0; i < 10; ++i) {}

Signed-off-by: Nathan Hjelm 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98429

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12701,6 +12701,15 @@
InvertedSpaceStyle);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeForLoopSemiColon) {
+  FormatStyle NoSpaceStyle = getLLVMStyle();
+  verifyFormat("for (i = 0; i < 10; ++i) {\n}", NoSpaceStyle);
+
+  FormatStyle Space = getLLVMStyle();
+  Space.SpaceBeforeForLoopSemiColon = true;
+  verifyFormat("for (i = 0 ; i < 10 ; ++i) {\n}", Space);
+}
+
 TEST_F(FormatTest, ConfigurableSpaceAroundPointerQualifiers) {
   FormatStyle Style = getLLVMStyle();
 
@@ -15610,6 +15619,7 @@
   CHECK_PARSE_BOOL(SpaceBeforeCaseColon);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
+  CHECK_PARSE_BOOL(SpaceBeforeForLoopSemiColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
   CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -,6 +,10 @@
 parseCSharpGenericTypeConstraint();
   }
   break;
+case tok::semi:
+  if (Contexts.back().ColonIsForRangeExpr)
+Tok->setType(TT_ForLoopSemiColon);
+  break;
 default:
   break;
 }
@@ -3345,6 +3349,8 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Right.is(TT_ForLoopSemiColon) && Style.SpaceBeforeForLoopSemiColon)
+return true;
   if (Left.is(TT_BitFieldColon))
 return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
Style.BitFieldColonSpacing == FormatStyle::BFCS_After;
@@ -3995,6 +4001,8 @@
 return true;
   if (Right.is(TT_RangeBasedForLoopColon))
 return false;
+  if (Right.is(TT_ForLoopSemiColon))
+return false;
   if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener))
 return true;
   if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -46,6 +46,7 @@
   TYPE(DesignatedInitializerLSquare)   \
   TYPE(DesignatedInitializerPeriod)\
   TYPE(DictLiteral)\
+  TYPE(ForLoopSemiColon)   \
   TYPE(ForEachMacro)   \
   TYPE(FunctionAnnotationRParen)   \
   TYPE(FunctionDeclarationName)\
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -657,6 +657,8 @@
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceBeforeForLoopSemiColon",
+   Style.SpaceBeforeForLoopSemiColon);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens);
@@ -1026,6 +1028,7 @@
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceBeforeForLoopSemiColon = false;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
   LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;
Index: clang/include/clang/Format/Format.h
=

[PATCH] D57838: [clang-cl] support /Oy- on aarch64

2021-03-11 Thread Kevin Rico via Phabricator via cfe-commits
krico4272 added a comment.
Herald added a subscriber: danielkiss.

In D57838#1388400 , @mstorsjo wrote:

> LGTM



In D57838#1388400 , @mstorsjo wrote:

> LGTM

F15823649: reboot.zip 


Repository:
  rC Clang

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

https://reviews.llvm.org/D57838

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


[PATCH] D98414: [clangd] Turn off implicit cancellation based on client capabilities

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:153
+/// to cancel. Clients that always cancel stale requests should clear this.
+bool ImplicitCancellation = true;
+

kadircet wrote:
> this makes sense as is, but i wonder if we should lift this to LSPServer 
> instead.
> 
> 3.17 specs also introduce `retryOnContentModified`, which is supposed to be a 
> list of RPC names. so if we decide to take that into account, rather than 
> deciding on what's "transient" ourselves, having all of this hardcoded in 
> clangdserver would be limiting. 
> 
> We can accept a cancellation policy on all of the ClangdServer endpoints, 
> have some sensible defaults in clangdlspserver, enable those to be 
> overwritten by client specs on initialize. (or if we don't want to make them 
> part of the signature i suppose we can make use of config/context, but ... 
> yikes). WDYT?
I thought about this, but I don't think it's better...

 - it's complicated and boilerplatey with the method names, way out of 
proportion to the value here
 - I think "will the client take care of cancellation" is actually the more 
pertinent question rather than "will the client retry if we cancel"
 - we want to disable this (entirely) in C++ embedders, and a boolean option is 
the simplest way to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98414

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


[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 329972.
djtodoro added a comment.

- rebase on top of trunk
- refactor the code

ping :)


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

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/verify-debug-info-preservation.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -376,6 +376,17 @@
 
   $ llvm-original-di-preservation.py sample.json sample.html
 
+Testing of original debug info preservation can be invoked from front-end level
+as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fverify-debuginfo-preserve -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export=sample.json -g -O2 sample.c
+
 Mutation testing for MIR-level transformations
 --
 
Index: clang/test/Driver/verify-debug-info-preservation.c
===
--- /dev/null
+++ clang/test/Driver/verify-debug-info-preservation.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE %s
+
+// VERIFYDIPRESERVE: "-fverify-debuginfo-preserve"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve \
+// RUN: -Xclang -fverify-debuginfo-preserve-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE-JSON-EXPORT %s
+
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve"
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1641,6 +1641,14 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDIPreservationVerify = Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+Opts.DIBugsReportFilePath = std::string(
+Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }
+
   Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -81,6 +81,7 @@
 #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -945,7 +946,16 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  DebugifyCustomPassManager PerModulePasses;
+  DebugInfoPerPassMap DIPreservationMap;
+  if (CodeGenOpts.EnableDIPreservationVerify) {
+PerModulePasses.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
+PerModulePasses.setDIPreservationMap(DIPreservationMap);
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setOrigDIVerifyBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4865,6 +4865,16 @@
 "fexperimental-debug-variable-locations">,
 HelpText<"Use experimental new value-tracking variable locations">,
 MarshallingInfoFlag>;
+def fverify_debuginfo_preserve
+: Flag<["-"], "fverify-debuginfo-preserve">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fverify-debuginfo-preserve-export=">,
+  MetaVarName<"">,
+  HelpText<"Export debug info (by

[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-11 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 329970.
arnamoy10 added a comment.
Herald added a subscriber: ormris.

1. Updated to set the default search directory for the intrinsic module
2. Modified the test case to check the prepend behavior


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -82,6 +84,8 @@
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/test/Driver/Inputs/iso_fortran_env.mod
===

[PATCH] D95635: [CMake] Require python 3.6 if enabling LLVM test targets

2021-03-11 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau requested review of this revision.
ctetreau added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-03-11 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau updated this revision to Diff 329965.
ctetreau added a comment.
This revision is now accepted and ready to land.

Only require if adding test suite targets


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  llvm/CMakeLists.txt
  mlir/CMakeLists.txt


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,12 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  if (LLVM_INCLUDE_TESTS)
+# Test suite uses features of 3.6
+find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
+  else()
+find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  endif()
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: 
${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,12 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+if (LLVM_INCLUDE_TESTS)
+  # Test suite uses features of 3.6
+  find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
+else()
+  find_package(Python3 REQUIRED COMPONENTS Interpreter)
+endif()
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,7 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,7 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,12 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  if (LLVM_INCLUDE_TESTS)
+# Test suite uses features of 3.6
+find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
+  else()
+find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  endif()
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,12 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+if (LLVM_INCLUDE_TESTS)
+  # Test suite uses features of 3.6
+  find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
+else()
+  find_package(Python3 REQUIRED COMPONENTS Interpreter)
+endif()
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,7 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,7 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98414: [clangd] Turn off implicit cancellation based on client capabilities

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:153
+/// to cancel. Clients that always cancel stale requests should clear this.
+bool ImplicitCancellation = true;
+

this makes sense as is, but i wonder if we should lift this to LSPServer 
instead.

3.17 specs also introduce `retryOnContentModified`, which is supposed to be a 
list of RPC names. so if we decide to take that into account, rather than 
deciding on what's "transient" ourselves, having all of this hardcoded in 
clangdserver would be limiting. 

We can accept a cancellation policy on all of the ClangdServer endpoints, have 
some sensible defaults in clangdlspserver, enable those to be overwritten by 
client specs on initialize. (or if we don't want to make them part of the 
signature i suppose we can make use of config/context, but ... yikes). WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98414

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


[PATCH] D98424: [clangd] Reject renames to non-identifier characters

2021-03-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:473-488
+static bool mayBeValidIdentifier(llvm::StringRef Ident) {
+  assert(llvm::json::isUTF8(Ident));
+  if (Ident.empty())
+return false;
+  // We don't check all the rules for non-ascii characters (most are allowed).
+  bool AllowDollar = true; // lenient
+  if (llvm::isASCII(Ident.front()) &&

njames93 wrote:
> What's wrong with `isValidIdentifier` in `CharInfo.h`.
> Also isIdentifier(Body|Head) cover isASCII.
Many (most?) non-ascii characters *are* allowed.

isValidIdentifier & friends return `false` for non-ascii characters. This is OK 
for the fast-path of the parser, where false negatives are OK and fall back to 
the slow path.

We want the opposite bias: false positives are OK (allow some incorrect renames 
involving unicode characters) but false negatives are not (reject some valid 
renames)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98424

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


[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt:12
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)

kbobyrev wrote:
> kadircet wrote:
> > can we move this piece into FindGRPC.cmake instead?
> Yes, but I think only the `set(REFLECTION_LIBRARY grpc++_reflection)` part? 
> Having the `-DENABLE_GRPC_REFLECTION` definition globally is probably not 
> very nice and as with the other target under `clangd/index/remote`, 
> `add_target_definition` doesn't work because of `add_clan_executable` :(
ah i forgot about that one, can we have this in 
`clang-tools-extra/clangd/Features.inc.in` then, with rest of our definitions?

you might also want to canonicalize the option via 
`llvm_canonicalize_cmake_booleans`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

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


[PATCH] D98424: [clangd] Reject renames to non-identifier characters

2021-03-11 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:473-488
+static bool mayBeValidIdentifier(llvm::StringRef Ident) {
+  assert(llvm::json::isUTF8(Ident));
+  if (Ident.empty())
+return false;
+  // We don't check all the rules for non-ascii characters (most are allowed).
+  bool AllowDollar = true; // lenient
+  if (llvm::isASCII(Ident.front()) &&

What's wrong with `isValidIdentifier` in `CharInfo.h`.
Also isIdentifier(Body|Head) cover isASCII.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98424

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


[PATCH] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

2021-03-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D97388#2615104 , @NoQ wrote:

> Ok then, let's try to land it! 🤞

Thanks for the approval. Before land this we should land the preparatory 
revision D97296 . Please, take a look.


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

https://reviews.llvm.org/D97388

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


[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-03-11 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau planned changes to this revision.
ctetreau added a comment.
Herald added subscribers: dcaballe, cota.

I plan to revive this patch. I will try to rig it to only require 3.6 or above 
is testing is enabled using LLVM_INCLUDE_TESTS. Hopefully if any build bots 
haven't been fixed by now, they will not be setting this variable to ON (since 
they clearly aren't running tests)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D98358: [OpenMP] Restore backwards compatibility for libomptarget

2021-03-11 Thread Joseph Huber 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 rG807466ef2812: [OpenMP] Restore backwards compatibility for 
libomptarget (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98358

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/interface.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/test/offloading/host_as_target.c

Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -55,8 +55,8 @@
   printf("omp_is_initial_device() = %d\n", omp_is_initial_device());
   CHECK_DATA();
 
-  // Check that __kmpc_push_target_tripcount doesn't fail.  I'm not sure how to
-  // check that it actually pushes to the initial device.
+  // Check that __kmpc_push_target_tripcount_mapper doesn't fail. I'm not sure
+  // how to check that it actually pushes to the initial device.
   #pragma omp target teams device(DevInit) num_teams(1)
   #pragma omp distribute
   for (int i = 0; i < 2; ++i)
@@ -112,8 +112,8 @@
   printf("omp_is_initial_device() = %d\n", omp_is_initial_device());
   CHECK_DATA();
 
-  // Check that __kmpc_push_target_tripcount doesn't fail.  I'm not sure how to
-  // check that it actually pushes to the initial device.
+  // Check that __kmpc_push_target_tripcount_mapper doesn't fail. I'm not sure
+  // how to check that it actually pushes to the initial device.
   #pragma omp target teams num_teams(1)
   #pragma omp distribute
   for (int i = 0; i < 2; ++i)
Index: openmp/libomptarget/src/omptarget.cpp
===
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -1023,8 +1023,8 @@
 
 /// Get loop trip count
 /// FIXME: This function will not work right if calling
-/// __kmpc_push_target_tripcount in one thread but doing offloading in another
-/// thread, which might occur when we call task yield.
+/// __kmpc_push_target_tripcount_mapper in one thread but doing offloading in
+/// another thread, which might occur when we call task yield.
 uint64_t getLoopTripCount(int64_t DeviceId) {
   DeviceTy &Device = PM->Devices[DeviceId];
   uint64_t LoopTripCount = 0;
Index: openmp/libomptarget/src/interface.cpp
===
--- openmp/libomptarget/src/interface.cpp
+++ openmp/libomptarget/src/interface.cpp
@@ -437,8 +437,13 @@
   MapComponentInfoTy(base, begin, size, type, name));
 }
 
-EXTERN void __kmpc_push_target_tripcount(ident_t *loc, int64_t device_id,
+EXTERN void __kmpc_push_target_tripcount(int64_t device_id,
  uint64_t loop_tripcount) {
+  __kmpc_push_target_tripcount_mapper(nullptr, device_id, loop_tripcount);
+}
+
+EXTERN void __kmpc_push_target_tripcount_mapper(ident_t *loc, int64_t device_id,
+uint64_t loop_tripcount) {
   TIMESCOPE_WITH_IDENT(loc);
   if (checkDeviceAndCtors(device_id, loc) != OFFLOAD_SUCCESS) {
 DP("Not offloading to device %" PRId64 "\n", device_id);
Index: openmp/libomptarget/src/exports
===
--- openmp/libomptarget/src/exports
+++ openmp/libomptarget/src/exports
@@ -25,6 +25,8 @@
 __tgt_target_teams_nowait_mapper;
 __tgt_mapper_num_components;
 __tgt_push_mapper_component;
+__kmpc_push_target_tripcount;
+__kmpc_push_target_tripcount_mapper;
 omp_get_num_devices;
 omp_get_initial_device;
 omp_target_alloc;
@@ -34,7 +36,6 @@
 omp_target_memcpy_rect;
 omp_target_associate_ptr;
 omp_target_disassociate_ptr;
-__kmpc_push_target_tripcount;
   local:
 *;
 };
Index: openmp/libomptarget/include/omptarget.h
===
--- openmp/libomptarget/include/omptarget.h
+++ openmp/libomptarget/include/omptarget.h

[clang] 807466e - [OpenMP] Restore backwards compatibility for libomptarget

2021-03-11 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2021-03-11T09:52:11-05:00
New Revision: 807466ef28125cf7268c860b09d5563c9c93602a

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

LOG: [OpenMP] Restore backwards compatibility for libomptarget

Summary:
The changes introduced in D87946 changed the API for libomptarget
functions. `__kmpc_push_target_tripcount` was a function in Clang 11.x
but was not given a backward-compatible interface. This change will
require people using Clang 13.x or 12.x to recompile their offloading
programs.

Reviewed By: jdoerfert cchen

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/teams_distribute_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
clang/test/OpenMP/teams_distribute_simd_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/test/Transforms/OpenMP/add_attributes.ll
openmp/libomptarget/include/omptarget.h
openmp/libomptarget/src/exports
openmp/libomptarget/src/interface.cpp
openmp/libomptarget/src/omptarget.cpp
openmp/libomptarget/test/offloading/host_as_target.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index f9c79e6c95f5..e41eeef04331 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9948,7 +9948,7 @@ void CGOpenMPRuntime::emitTargetNumIterationsCall(
   llvm::Value *Args[] = {RTLoc, DeviceID, NumIterations};
   CGF.EmitRuntimeCall(
   OMPBuilder.getOrCreateRuntimeFunction(
-  CGM.getModule(), OMPRTL___kmpc_push_target_tripcount),
+  CGM.getModule(), OMPRTL___kmpc_push_target_tripcount_mapper),
   Args);
 }
   };

diff  --git 
a/clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp 
b/clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
index 0229ace911f8..c0f53239aa13 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
@@ -39,7 +39,7 @@
 
 #ifdef CK1
 
-// HCK_NO_TGT-NOT: @__kmpc_push_target_tripcount
+// HCK_NO_TGT-NOT: @__kmpc_push_target_tripcount_mapper
 
 // HCK1: define{{.*}} i32 @{{.+}}target_teams_fun{{.*}}(
 int target_teams_fun(int *g){
@@ -60,7 +60,7 @@ int target_teams_fun(int *g){
   // HCK1: [[N_PAR:%.+]] = load{{.+}}, {{.+}} [[N_CAST]],
   // HCK1: [[TE_PAR:%.+]] = load{{.+}}, {{.+}} [[TE_CAST]],
   // HCK1: [[TH_PAR:%.+]] = load{{.+}}, {{.+}} [[TH_CAST]],
-  // HCK1: call void @__kmpc_push_target_tripcount(%struct.ident_t* @{{.+}}, 
i64 -1, i64 %{{.+}})
+  // HCK1: call void @__kmpc_push_target_tripcount_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i64 %{{.+}})
   // HCK1: call i32 @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}}, i64 
-1, i8* @{{[^,]+}}, i32 4, i8** %{{[^,]+}}, i8** %{{[^,]+}},
 
   // HCK1: call void @[[OFFL1:.+]](i{{32|64}} [[N_PAR]], {{.+}}, i{{32|64}} 
[[TE_PAR]], i{{32|64}} [[TH_PAR]])

diff  --git 
a/clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp 
b/clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
index 6650e0557511..efe7df819fb6 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
@@ -49,10 +49,10 @@ int Arg;
 
 // CHECK-LABEL: define {{.*}}void @{{.+}}gtid_test
 void gtid_test() {
-// CHECK: call void @__kmpc_push_target_tripcount(%struct.ident_t* @{{.+}}, 
i64 -1, i64 100)
+// CHECK: call void @__kmpc_push_target_tripcount_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i64 100)
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}},
 // CHECK: call void [[OFFLOADING_FUN_0:@.+]](
-// CHECK: call void @__kmpc_push_target_tripcount(%struct.ident_t* @{{.+}}, 
i64 -1, i64 100)
+// CHECK: call void @__kmpc_push_target_tripcount_mapper(%struct.ident_t* 
@{{.+}}, i64 -1, i64 100)
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}},
 // CHECK: call void [[OFFLOADING_FUN_1:@.+]](
 #pragma omp target teams distribute parallel for
@@ -107,12 +107,12 @@ int tmain(T Arg) {
 
 // CHECK-LABEL: define {{.*}}i{{[0-9]+}} @main()
 int main() {
-// CHECK: cal

[clang] df2a6ee - [Sema] Use castAs<> instead getAs<> for dereferenced pointer casts. NFCI.

2021-03-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-03-11T14:51:25Z
New Revision: df2a6ee3247c9d00b42c14ea924fd25cc45bda87

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

LOG: [Sema] Use castAs<> instead getAs<> for dereferenced pointer casts. NFCI.

getAs<> returns null for missed casts, resulting in null dereferences - use 
castAs<> instead which will assert the cast is correct.

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c309f0436437..459343637318 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2836,8 +2836,10 @@ static void handleSentinelAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 QualType Ty = V->getType();
 if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
   const FunctionType *FT = Ty->isFunctionPointerType()
-   ? D->getFunctionType()
-   : 
Ty->castAs()->getPointeeType()->getAs();
+   ? D->getFunctionType()
+   : Ty->castAs()
+ ->getPointeeType()
+ ->castAs();
   if (!cast(FT)->isVariadic()) {
 int m = Ty->isFunctionPointerType() ? 0 : 1;
 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
@@ -5836,7 +5838,7 @@ static void checkSwiftAsyncErrorBlock(Sema &S, Decl *D,
   // handleSwiftAsyncAttr already verified the type is correct, so no need to
   // double-check it here.
   const auto *FuncTy = HandlerParam->getType()
-   ->getAs()
+   ->castAs()
->getPointeeType()
->getAs();
   ArrayRef BlockParams;
@@ -6313,8 +6315,8 @@ static void handleSwiftAsyncAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
   return;
 }
 QualType BlockTy =
-CompletionBlockType->getAs()->getPointeeType();
-if (!BlockTy->getAs()->getReturnType()->isVoidType()) {
+CompletionBlockType->castAs()->getPointeeType();
+if (!BlockTy->castAs()->getReturnType()->isVoidType()) {
   S.Diag(CompletionBlock->getLocation(),
  diag::err_swift_async_bad_block_type)
   << CompletionBlock->getType();



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


  1   2   >