[PATCH] D98774: [AST] De-duplicate empty node introspection

2021-04-22 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaee6c86c4dc7: [AST] De-duplicate empty node introspection 
(authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D98774?vs=331300&id=339559#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98774

Files:
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/lib/Tooling/EmptyNodeIntrospection.inc.in

Index: clang/lib/Tooling/EmptyNodeIntrospection.inc.in
===
--- /dev/null
+++ clang/lib/Tooling/EmptyNodeIntrospection.inc.in
@@ -0,0 +1,44 @@
+//===- EmptyNodeIntrospection.inc.in --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+namespace clang {
+namespace tooling {
+bool NodeIntrospection::hasIntrospectionSupport() { return false; }
+
+NodeLocationAccessors NodeIntrospection::GetLocations(clang::Stmt const *) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(clang::Decl const *) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::CXXCtorInitializer const *) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::NestedNameSpecifierLoc const&) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::TemplateArgumentLoc const&) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::CXXBaseSpecifier const*) {
+  return {};
+}
+NodeLocationAccessors NodeIntrospection::GetLocations(
+clang::TypeLoc const&) {
+  return {};
+}
+NodeLocationAccessors
+NodeIntrospection::GetLocations(clang::DynTypedNode const &) {
+  return {};
+}
+} // namespace tooling
+} // namespace clang
Index: clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
===
--- clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -4,7 +4,8 @@
 import os
 import sys
 import json
-
+import filecmp
+import shutil
 import argparse
 
 class Generator(object):
@@ -326,13 +327,16 @@
   help='Read API description from FILE', metavar='FILE')
 parser.add_argument('--output-file', help='Generate output in FILEPATH',
   metavar='FILEPATH')
-parser.add_argument('--empty-implementation',
+parser.add_argument('--use-empty-implementation',
   help='Generate empty implementation',
   action="store", type=int)
+parser.add_argument('--empty-implementation',
+  help='Copy empty implementation from FILEPATH',
+  action="store", metavar='FILEPATH')
 
 options = parser.parse_args()
 
-use_empty_implementation = options.empty_implementation
+use_empty_implementation = options.use_empty_implementation
 
 if (not use_empty_implementation
 and not os.path.exists(options.json_input_path)):
@@ -346,47 +350,9 @@
 use_empty_implementation = True
 
 if use_empty_implementation:
-with open(os.path.join(os.getcwd(),
-  options.output_file), 'w') as f:
-f.write("""
-namespace clang {
-namespace tooling {
-
-bool NodeIntrospection::hasIntrospectionSupport() { return false; }
-
-NodeLocationAccessors NodeIntrospection::GetLocations(clang::Stmt const *) {
-  return {};
-}
-NodeLocationAccessors NodeIntrospection::GetLocations(clang::Decl const *) {
-  return {};
-}
-NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::CXXCtorInitializer const *) {
-  return {};
-}
-NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::NestedNameSpecifierLoc const&) {
-  return {};
-}
-NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::TemplateArgumentLoc const&) {
-  return {};
-}
-NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::CXXBaseSpecifier const*) {
-  return {};
-}
-NodeLocationAccessors NodeIntrospection::GetLocations(
-clang::TypeLoc const&) {
-  return {};
-}
-NodeLocationAccessors
-NodeIntrospection::GetLocations(clang::DynTypedNode const &) {
-  return {};
-}
-} // namespace tooling
-} // namespace clang
-""")
+if not os.path.exists(options.output_file) or \
+not filecmp.cmp(options.empty_implementation, options.output_file):
+shutil.copyfile(options.empty_implementation, options.output_file)
 sys.exit(0)
 
 templateClasses = []
Index: clang/lib/Tooling/CMakeLists.txt
===

[PATCH] D98774: [AST] De-duplicate empty node introspection

2021-04-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D98774#2701853 , @thakis wrote:

> I think it is? https://llvm.org/docs/GettingStarted.html#software lists it at 
> least.

Thanks, I'll look into that soon and see how the buildbots respond.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98774

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


[PATCH] D101049: [AST] Add DeclarationNameInfo to node introspection

2021-04-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: njames93.
Herald added a subscriber: mgrang.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101049

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/lib/Tooling/EmptyNodeIntrospection.inc.in
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -216,6 +216,9 @@
 STRING_LOCATION_STDPAIR(MethodDecl, getEndLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getInnerLocStart()),
 STRING_LOCATION_STDPAIR(MethodDecl, getLocation()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getOuterLocStart()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getBeginLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getEndLoc()),
@@ -305,6 +308,7 @@
 llvm::makeArrayRef(ExpectedRanges),
   (ArrayRef>{
 STRING_LOCATION_STDPAIR(MethodDecl, getExceptionSpecSourceRange()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getParametersSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getLocalSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getLocalSourceRange()),
@@ -1401,3 +1405,148 @@
   TL, getAs().getParensRange(;
 }
 #endif
+
+TEST(Introspection, SourceLocations_DeclarationNameInfo_Dtor) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+class Foo
+{
+  ~Foo() {}
+};
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(cxxDestructorDecl(hasName("~Foo")).bind("dtor"))), TU,
+  Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *Dtor = BoundNodes[0].getNodeAs("dtor");
+  auto NI = Dtor->getNameInfo();
+  auto Result = NodeIntrospection::GetLocations(NI);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  llvm::sort(ExpectedLocations);
+
+  EXPECT_EQ(
+  llvm::makeArrayRef(ExpectedLocations),
+  (ArrayRef>{
+  STRING_LOCATION_STDPAIR((&NI), getBeginLoc()),
+  STRING_LOCATION_STDPAIR((&NI), getEndLoc()),
+  STRING_LOCATION_STDPAIR((&NI), getLoc()),
+  STRING_LOCATION_STDPAIR((&NI), getNamedTypeInfo()
+ ->getTypeLoc()
+ .getAs()
+ .getNameLoc()),
+  STRING_LOCATION_STDPAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getBeginLoc()),
+  STRING_LOCATION_STDPAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getEndLoc())}));
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(
+  ExpectedRanges,
+  UnorderedElementsAre(
+  STRING_LOCATION_PAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getLocalSourceRange()),
+  STRING_LOCATION_PAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getSourceRange()),
+  STRING_LOCATION_PAIR((&NI), getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_DeclarationNameInfo_ConvOp) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+class Foo
+{
+  bool operator==(const Foo&) const { return false; }
+};
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(cxxMethodDecl().bind("opeq"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *Opeq = BoundNodes[0].getNodeAs("opeq");
+  auto NI = Opeq->getNameInfo();
+  auto Result = NodeIntrospection::GetLocations(NI);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  llvm::sort(ExpectedLocations);
+
+  EXPECT_EQ(llvm::makeArrayRef(ExpectedLocations),
+(ArrayRef>{
+STRING_LOCATION_STDPAIR((&NI), getBeginLoc()),
+STRING_LOCATION_STDPAIR((&NI), getEndLoc()),
+STRING_LOCATION_STDPAIR((&NI

[PATCH] D101049: [AST] Add DeclarationNameInfo to node introspection

2021-04-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 339563.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101049

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/lib/Tooling/EmptyNodeIntrospection.inc.in
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -216,6 +216,9 @@
 STRING_LOCATION_STDPAIR(MethodDecl, getEndLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getInnerLocStart()),
 STRING_LOCATION_STDPAIR(MethodDecl, getLocation()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getBeginLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getEndLoc()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getOuterLocStart()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getBeginLoc()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getEndLoc()),
@@ -305,6 +308,7 @@
 llvm::makeArrayRef(ExpectedRanges),
   (ArrayRef>{
 STRING_LOCATION_STDPAIR(MethodDecl, getExceptionSpecSourceRange()),
+STRING_LOCATION_STDPAIR(MethodDecl, getNameInfo().getSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getParametersSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getLocalSourceRange()),
 STRING_LOCATION_STDPAIR(MethodDecl, getQualifierLoc().getPrefix().getLocalSourceRange()),
@@ -1401,3 +1405,148 @@
   TL, getAs().getParensRange(;
 }
 #endif
+
+TEST(Introspection, SourceLocations_DeclarationNameInfo_Dtor) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+class Foo
+{
+  ~Foo() {}
+};
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(cxxDestructorDecl(hasName("~Foo")).bind("dtor"))), TU,
+  Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *Dtor = BoundNodes[0].getNodeAs("dtor");
+  auto NI = Dtor->getNameInfo();
+  auto Result = NodeIntrospection::GetLocations(NI);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  llvm::sort(ExpectedLocations);
+
+  EXPECT_EQ(
+  llvm::makeArrayRef(ExpectedLocations),
+  (ArrayRef>{
+  STRING_LOCATION_STDPAIR((&NI), getBeginLoc()),
+  STRING_LOCATION_STDPAIR((&NI), getEndLoc()),
+  STRING_LOCATION_STDPAIR((&NI), getLoc()),
+  STRING_LOCATION_STDPAIR((&NI), getNamedTypeInfo()
+ ->getTypeLoc()
+ .getAs()
+ .getNameLoc()),
+  STRING_LOCATION_STDPAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getBeginLoc()),
+  STRING_LOCATION_STDPAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getEndLoc())}));
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(
+  ExpectedRanges,
+  UnorderedElementsAre(
+  STRING_LOCATION_PAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getLocalSourceRange()),
+  STRING_LOCATION_PAIR(
+  (&NI), getNamedTypeInfo()->getTypeLoc().getSourceRange()),
+  STRING_LOCATION_PAIR((&NI), getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_DeclarationNameInfo_ConvOp) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+class Foo
+{
+  bool operator==(const Foo&) const { return false; }
+};
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(cxxMethodDecl().bind("opeq"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *Opeq = BoundNodes[0].getNodeAs("opeq");
+  auto NI = Opeq->getNameInfo();
+  auto Result = NodeIntrospection::GetLocations(NI);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  llvm::sort(ExpectedLocations);
+
+  EXPECT_EQ(llvm::makeArrayRef(ExpectedLocations),
+(ArrayRef>{
+STRING_LOCATION_STDPAIR((&NI), getBeginLoc()),
+STRING_LOCATION_STDPAIR((&NI), getEndLoc()),
+STRING_LOCATION_STDPAIR((&NI), getLoc())}));
+
+  auto ExpectedRanges = FormatExpected(Result.Rang

[PATCH] D100972: [clang-tidy] cppcoreguidelines-avoid-non-const-global-variables: add fixes to checks

2021-04-22 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann updated this revision to Diff 339565.
mgartmann added a comment.

- Renamed `printCleanedType()` to `cleanType()`
- Extended `cleanType()` to also remove `(anonymous)` from a type
- Made `hasSpaceAfterType()` more error-robust.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100972

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
@@ -2,20 +2,25 @@
 
 int nonConstInt = 0;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int nonConstInt = 0;
 
 int &nonConstIntReference = nonConstInt;
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: variable 'nonConstIntReference' provides global access to a non-const object; consider making the referenced data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int &nonConstIntReference = nonConstInt;
 
 int *pointerToNonConstInt = &nonConstInt;
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: variable 'pointerToNonConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
 // CHECK-MESSAGES: :[[@LINE-2]]:6: warning: variable 'pointerToNonConstInt' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int *const pointerToNonConstInt = &nonConstInt;
 
 int *const constPointerToNonConstInt = &nonConstInt;
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'constPointerToNonConstInt' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int *const constPointerToNonConstInt = &nonConstInt;
 
 namespace namespace_name {
 int nonConstNamespaceInt = 0;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int nonConstNamespaceInt = 0;
 
 const int constNamespaceInt = 0;
 } // namespace namespace_name
@@ -24,6 +29,7 @@
 
 const int *pointerToConstInt = &constInt;
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'pointerToConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int *const pointerToConstInt = &constInt;
 
 const int *const constPointerToConstInt = &constInt;
 
@@ -39,6 +45,7 @@
 namespace {
 int nonConstAnonymousNamespaceInt = 0;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstAnonymousNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int nonConstAnonymousNamespaceInt = 0;
 } // namespace
 
 class DummyClass {
@@ -53,27 +60,35 @@
 
 DummyClass nonConstClassInstance;
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'nonConstClassInstance' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const DummyClass nonConstClassInstance;
 
 DummyClass *pointerToNonConstDummyClass = &nonConstClassInstance;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'pointerToNonConstDummyClass' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
 // CHECK-MESSAGES: :[[@LINE-2]]:13: warning: variable 'pointerToNonConstDummyClass' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const DummyClass *const pointerToNonConstDummyClass = &nonConstClassInstance;
 
 DummyClass &referenceToNonConstDummyClass = nonConstClassInstance;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'referenceToNonConstDummyClass' provides global access to a non-const object; consider making the referenced data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHE

[clang] 5e50f47 - [AST] Add clarification comment

2021-04-22 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-22T12:51:25+01:00
New Revision: 5e50f473d9597e8d14bda2f8659f512376ed9027

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

LOG: [AST] Add clarification comment

Added: 


Modified: 
clang/include/clang/Tooling/NodeIntrospection.h

Removed: 




diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
index a04c08823339..9fe10c659243 100644
--- a/clang/include/clang/Tooling/NodeIntrospection.h
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -67,6 +67,10 @@ struct RangeLessThan {
 
 } // namespace internal
 
+// Note that this container stores unique results in a deterministic, but
+// unspecified order.  Clients which desire a particular order, such as
+// alphabetical, should sort results after retrieval, because the order
+// is dependent on how the LocationCalls are formatted.
 template 
 using UniqueMultiMap = std::set, internal::RangeLessThan>;
 



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


[PATCH] D100976: [OpenCL] Simplify use of C11 atomic types

2021-04-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/Parser/opencl-atomics-cl20.cl:7-8
 
-#ifdef EXT
-#pragma OPENCL EXTENSION cl_khr_int64_base_atomics:enable
-#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics:enable
-#pragma OPENCL EXTENSION cl_khr_fp64:enable
-#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
-// expected-warning@-2{{OpenCL extension 'cl_khr_fp64' is core feature or 
supported optional core feature - ignoring}}
-#endif
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#define LANG_VER_OK
 #endif

azabaznov wrote:
> Mauby simply //-DLANG_VER_OK// when running tests?
I think defining it in the test source is better for future modifications. Then 
we could add as many extra RUN lines as possible without the need to pass extra 
-D flag. Also it is kind of redundant since we already have the language 
version defined while parsing.



Comment at: clang/test/Parser/opencl-atomics-cl20.cl:51-56
+// expected-error@-21 {{expected ';' after expression}}
+// expected-error@-22 {{use of undeclared identifier 's'}}
+// expected-error@-22 {{unknown type name 'atomic_intptr_t'; did you mean 
'atomic_int'?}}
+// expected-note@* {{'atomic_int' declared here}}
+// expected-error@-23 {{unknown type name 'atomic_uintptr_t'; did you mean 
'atomic_uint'?}}
+// expected-note@* {{'atomic_uint' declared here}}

azabaznov wrote:
> Well, this is exactly what I was afraid of last time, see 
> https://reviews.llvm.org/D97058#2602677. Is this for sure a right way to go 
> forward? Also, **declared //here//** for implicit type definitions is pretty 
> confusing. Maybe a way the diagnostics showed here is just a bug?
This is a standard diagnostic from clang fixit if the typename is similar to 
any it can find in a symbol table of valid identifiers.


```
opencl-atomics-cl20.cl:31:3 error: unknown type name 'atomic_intptr_t'; did you 
mean 'atomic_int'?
atomic_intptr_t ip;
^~~
atomic_int
note: 'atomic_uint' declared here
```

For such implicit typedefs we won't be able to display the source locations as 
there is no physical source. However this can occur in any kernel code compiled 
with type names similar to those defined by implicit typedefs i.e. I am not 
changing this in the patch. 

https://godbolt.org/z/j7vn6d4Kh

But I agree that this is not ideal - we could solve it by not printing such 
hints at all if source location doesn't exist but this would probably need to 
be agreed with the community as this should probably be done for all languages. 
We could create a clang bug to follow up on this? 


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

https://reviews.llvm.org/D100976

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


[PATCH] D100984: [OpenCL] Remove the need for subgroupd extension pragma in enqueue kernel builtins

2021-04-22 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

> Btw I am not suggesting removing the pragma. We will still have to parse it 
> for backward compatibility. I am only dropping the requirement of using it in 
> order to call get_kernel_max_sub_group_size_for_ndrange or 
> get_kernel_sub_group_count_for_ndrange when the extension is supported. 
> Because I don't see why this would be needed especially that all other 
> functions from subgroups can be called without the pragma 
> https://godbolt.org/z/MYavchPT3.

Oh! I didn't get that! I see another one https://godbolt.org/z/3GPW31W9c, 
https://godbolt.org/z/dYasedxjx. This is also fixed with your patch, right?

> Btw the newer extension specs don't contain the pragma e.g. 
> https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#_extended_subgroup_functions

Indeed... No wording about pragma even in OpenCL C 2.0...

> Right now we have the following in the docs: 
> https://clang.llvm.org/docs/OpenCLSupport.html#implementation-guidelines
>
>> Note that some legacy extensions (published prior to OpenCL 3.0) still 
>> provide some non-conformant functionality for pragmas e.g. add diagnostics 
>> on the use of types or functions. This functionality is not guaranteed to 
>> remain in future releases. However, any future changes should not affect 
>> backward compatibility.
>
> This is not quite deprecation but it makes it clear that the behavior can 
> change as soon as backward compatibility is preserved.
>
> Would you like us to add or ammend anything?

I think this fine for this change since the patch doesn't change anything but 
fixes a bug.


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

https://reviews.llvm.org/D100984

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


[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-04-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D100980#2708012 , @azabaznov wrote:

> Same as for https://reviews.llvm.org/D100984, `cl_khr_fp64` wasn't always 
> core and thus it requires pragma for OpenCL C < 1.2 versions.
>
> //9.3 Double Precision Floating-Point, OpenCL C 1.0// 
> (https://www.khronos.org/registry/OpenCL/specs/opencl-1.0.pdf):
>
>   OpenCL 1.0 adds support for double precision floating-point as an optional 
> extension. An application that wants to use double will need to include the 
> #pragma OPENCL EXTENSION cl_khr_fp64 : enable directive before any double 
> precision data type is declared in the kernel code.

Ok, we can change to check for

  S.getOpenCLOptions().isAvailable("cl_khr_fp64", S.getLangOpts())

instead of `isSupported` but out of curiosity considering that we have failed 
to implement the extension pragmas anyway (see description in 
https://reviews.llvm.org/D100976) do you think it is valuable to keep this 
behavior at all? It would be like doing something partially correct but not 
fully correct.

The reason why I would prefer to avoid unnecessary uses of prgmas is that they 
are confusing and inconsistent so the less of them we have the easier it is for 
the developers and users of clang.


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

https://reviews.llvm.org/D100980

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


[PATCH] D100984: [OpenCL] Remove the need for subgroupd extension pragma in enqueue kernel builtins

2021-04-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D100984#2708168 , @azabaznov wrote:

>> Btw I am not suggesting removing the pragma. We will still have to parse it 
>> for backward compatibility. I am only dropping the requirement of using it 
>> in order to call get_kernel_max_sub_group_size_for_ndrange or 
>> get_kernel_sub_group_count_for_ndrange when the extension is supported. 
>> Because I don't see why this would be needed especially that all other 
>> functions from subgroups can be called without the pragma 
>> https://godbolt.org/z/MYavchPT3.
>
> Oh! I didn't get that! I see another one https://godbolt.org/z/3GPW31W9c, 
> https://godbolt.org/z/dYasedxjx. This is also fixed with your patch, right?

True, I have forgotten about those. :)


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

https://reviews.llvm.org/D100984

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


[clang] 850e01a - [clang][deps] Check extra args in tests

2021-04-22 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-22T14:10:08+02:00
New Revision: 850e01a34d47954ed5cebbd4aa98e8efd711cd19

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

LOG: [clang][deps] Check extra args in tests

These flags are being generated by `clang-scan-deps` and it makes sense to 
ensure it keeps doing so.

Added: 


Modified: 
clang/test/ClangScanDeps/modules-full.cpp

Removed: 




diff  --git a/clang/test/ClangScanDeps/modules-full.cpp 
b/clang/test/ClangScanDeps/modules-full.cpp
index 5c3e53610e5a8..b4252c5c4f609 100644
--- a/clang/test/ClangScanDeps/modules-full.cpp
+++ b/clang/test/ClangScanDeps/modules-full.cpp
@@ -39,8 +39,10 @@
 // CHECK-NEXT:   "command-line": [
 // CHECK-NEXT: "-cc1",
 // CHECK:  "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
+// CHECK:  "-emit-module",
 // CHECK:  
"-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
 // CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fmodule-name=header1",
 // CHECK:  "-fno-implicit-modules",
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
@@ -55,7 +57,9 @@
 // CHECK-NEXT:   "clang-modulemap-file": 
"[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
 // CHECK-NEXT: "-cc1",
+// CHECK:  "-emit-module",
 // CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fmodule-name=header1",
 // CHECK:  "-fno-implicit-modules",
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H2:[A-Z0-9]+]]",
@@ -70,7 +74,9 @@
 // CHECK-NEXT:   "clang-modulemap-file": 
"[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:   "command-line": [
 // CHECK-NEXT: "-cc1",
+// CHECK:  "-emit-module",
 // CHECK-NOT:  "-fimplicit-module-maps",
+// CHECK:  "-fmodule-name=header2",
 // CHECK:  "-fno-implicit-modules",
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",



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


[PATCH] D101051: [clang][deps] Only generate absolute paths when asked to

2021-04-22 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: Bigcheese.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add option to `clang-scan-deps` to enable/disable generation of command-line 
arguments with absolute paths. This is essentially a revert of D100533 
, but with improved naming and added test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101051

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-full.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -138,6 +138,20 @@
 llvm::cl::init(ScanningOutputFormat::Make),
 llvm::cl::cat(DependencyScannerCategory));
 
+// Note: This is only useful when experimenting with explicit modules during
+//   development. Build tools are not expected to use the absolute paths
+//   generated in this mode, since they point into module cache. Instead,
+//   build tools are expected to customize the paths via the `LookupPCMPath`
+//   and `LookupModuleDeps` callbacks when using the C++ API, or append them
+//   to the command-line generated without absolute paths.
+static llvm::cl::opt GenerateAbsolutePathArgs(
+"generate-absolute-path-args",
+llvm::cl::desc(
+"With '-format experimental-full', include arguments containing "
+"absolute paths in the generated command lines: '-fmodule-file=', "
+"'-o', '-fmodule-map-file='."),
+llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
+
 llvm::cl::opt
 NumThreads("j", llvm::cl::Optional,
llvm::cl::desc("Number of worker threads to use (default: use "
@@ -260,11 +274,14 @@
   Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
 }
 
-ID.AdditonalCommandLine = FD.getAdditionalCommandLine(
-[&](ModuleID MID) { return lookupPCMPath(MID); },
-[&](ModuleID MID) -> const ModuleDeps & {
-  return lookupModuleDeps(MID);
-});
+ID.AdditionalCommandLine =
+GenerateAbsolutePathArgs
+? FD.getAdditionalCommandLine(
+  [&](ModuleID MID) { return lookupPCMPath(MID); },
+  [&](ModuleID MID) -> const ModuleDeps & {
+return lookupModuleDeps(MID);
+  })
+: FD.getAdditionalCommandLine();
 
 Inputs.push_back(std::move(ID));
   }
@@ -295,11 +312,14 @@
   {"file-deps", toJSONSorted(MD.FileDeps)},
   {"clang-module-deps", toJSONSorted(MD.ClangModuleDeps)},
   {"clang-modulemap-file", MD.ClangModuleMapFile},
-  {"command-line", MD.getFullCommandLine(
-   [&](ModuleID MID) { return lookupPCMPath(MID); },
-   [&](ModuleID MID) -> const ModuleDeps & {
- return lookupModuleDeps(MID);
-   })},
+  {"command-line",
+   GenerateAbsolutePathArgs
+   ? MD.getFullCommandLine(
+ [&](ModuleID MID) { return lookupPCMPath(MID); },
+ [&](ModuleID MID) -> const ModuleDeps & {
+   return lookupModuleDeps(MID);
+ })
+   : MD.getFullCommandLine()},
   };
   OutModules.push_back(std::move(O));
 }
@@ -311,7 +331,7 @@
   {"clang-context-hash", I.ContextHash},
   {"file-deps", I.FileDeps},
   {"clang-module-deps", toJSONSorted(I.ModuleDeps)},
-  {"command-line", I.AdditonalCommandLine},
+  {"command-line", I.AdditionalCommandLine},
   };
   TUs.push_back(std::move(O));
 }
@@ -358,7 +378,7 @@
 std::string ContextHash;
 std::vector FileDeps;
 std::vector ModuleDeps;
-std::vector AdditonalCommandLine;
+std::vector AdditionalCommandLine;
   };
 
   std::mutex Lock;
Index: clang/test/ClangScanDeps/modules-full.cpp
===
--- clang/test/ClangScanDeps/modules-full.cpp
+++ clang/test/ClangScanDeps/modules-full.cpp
@@ -13,12 +13,17 @@
 // RUN: echo %t.dir > %t.result
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format experimental-full \
 // RUN:   -mode preprocess-minimized-sources >> %t.result
-// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
-
+// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK,CHECK-NO-ABS %s
+//
+// RUN: echo %t.dir > %t.res

[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

2021-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 339578.
vsavchenko added a comment.

Minor fix in comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/diagnostics/deref-track-symbolic-region.cpp
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/placement-new.cpp
  clang/test/Analysis/retain-release-path-notes.m
  clang/test/Analysis/uninit-const.c
  clang/test/Analysis/uninit-const.cpp

Index: clang/test/Analysis/uninit-const.cpp
===
--- clang/test/Analysis/uninit-const.cpp
+++ clang/test/Analysis/uninit-const.cpp
@@ -63,9 +63,9 @@
 }
 
 void f6_1(void) {
-  int t; // expected-note{{'t' declared without an initial value}}
+  int t;   // expected-note{{'t' declared without an initial value}}
   int p = f6_1_sub(t); //expected-warning {{Assigned value is garbage or undefined}}
-   //expected-note@-1 {{Passing value via 1st parameter 'p'}}
+   //expected-note@-1 {{Passing 't' via 1st parameter 'p'}}
//expected-note@-2 {{Calling 'f6_1_sub'}}
//expected-note@-3 {{Returning from 'f6_1_sub'}}
//expected-note@-4 {{Assigned value is garbage or undefined}}
@@ -75,9 +75,9 @@
 
 void f6_2(void) {
   int t;   //expected-note {{'t' declared without an initial value}}
-  int &p = t;  //expected-note {{'p' initialized here}}
-  int &s = p;  //expected-note {{'s' initialized here}}
-  int &q = s;  //expected-note {{'q' initialized here}}
+  int &p = t;  //expected-note {{'p' initialized to the value of 't'}}
+  int &s = p;  //expected-note {{'s' initialized to the value of 'p'}}
+  int &q = s;  //expected-note {{'q' initialized to the value of 's'}}
   doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
//expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
Index: clang/test/Analysis/uninit-const.c
===
--- clang/test/Analysis/uninit-const.c
+++ clang/test/Analysis/uninit-const.c
@@ -37,7 +37,7 @@
 void f_1_1(void) {
   int t; // expected-note {{'t' declared without an initial value}}
   int *tp1 = &t; // expected-note {{'tp1' initialized here}}
-  int* tp2 = tp1;// expected-note {{'tp2' initialized here}}
+  int *tp2 = tp1;// expected-note {{'tp2' initialized to the value of 'tp1'}}
   doStuff_pointerToConstInt(tp2);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -53,7 +53,7 @@
 // expected-note@-1{{Calling 'f_2_sub'}}
 // expected-note@-2{{Returning from 'f_2_sub'}}
 // expected-note@-3{{'p' initialized here}}
-  int* tp = p; // expected-note {{'tp' initialized here}}
+  int *tp = p;  // expected-note {{'tp' initialized to the value of 'p'}}
   doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}}
   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -70,7 +70,7 @@
 
 void f_5(void) {
   int ta[5];   // expected-note {{'ta' initialized here}}
-  int* tp = ta;// expected-note {{'tp' initialized here}}
+  int *tp = ta;// expected-note {{'tp' initialized to the value of 'ta'}}
   doStuff_pointerToConstInt(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -107,7 +107,7 @@
 
 void f_9(void) {
   int a[6];// expected-note {{'a' initialized here}}
-  int const *ptau = a; // expected-note {{'ptau' initialized here}}
+  int const *ptau = a; // expected-note {{'ptau' initialized to the value of 'a'}}
   doStuff_arrayOfConstInt(ptau);// expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -339,7 +339,7 @@
// expected-note@216 {{Returning pointer (loaded from 'self')}}

[PATCH] D101052: [OpenCL] allow pipe as a valid identifier prior to OpenCL 2.0

2021-04-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: svenvh, azabaznov.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

pipe has not been a reserved keyword in the earlier OpenCL standards
https://www.khronos.org/registry/OpenCL/specs/opencl-1.2.pdf
 however we failed to allow its use as an identifier in the original 
implememntation.

This patch fixes the issue and improves testing.

Btw I feel we have a spec issue in the unified spec 
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#keywords
 because it doesn't say that the pipe is reserved only from OpenCL 2.0?


https://reviews.llvm.org/D101052

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl


Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,3 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 
-void foo(read_only pipe int p); // expected-error {{expected parameter 
declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+void foo(read_only pipe int p);
+// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
+// expected-error@-2 {{access qualifier can only be used for pipe and image 
type}}
+// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+
+// 'pipe' should be accepted as an identifier.
+typedef int pipe;
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3943,6 +3943,7 @@
 // OpenCL 2.0 and later define this keyword. OpenCL 1.2 and earlier
 // should support the "pipe" word as identifier.
 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
+Tok.setKind(tok::identifier);
 goto DoneWithDeclSpec;
   }
   isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);


Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,3 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 
-void foo(read_only pipe int p); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+void foo(read_only pipe int p);
+// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
+// expected-error@-2 {{access qualifier can only be used for pipe and image type}}
+// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+
+// 'pipe' should be accepted as an identifier.
+typedef int pipe;
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3943,6 +3943,7 @@
 // OpenCL 2.0 and later define this keyword. OpenCL 1.2 and earlier
 // should support the "pipe" word as identifier.
 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
+Tok.setKind(tok::identifier);
 goto DoneWithDeclSpec;
   }
   isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100972: [clang-tidy] cppcoreguidelines-avoid-non-const-global-variables: add fixes to checks

2021-04-22 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann updated this revision to Diff 339574.
mgartmann added a comment.

Fixed one-off error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100972

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
@@ -2,20 +2,25 @@
 
 int nonConstInt = 0;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int nonConstInt = 0;
 
 int &nonConstIntReference = nonConstInt;
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: variable 'nonConstIntReference' provides global access to a non-const object; consider making the referenced data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int &nonConstIntReference = nonConstInt;
 
 int *pointerToNonConstInt = &nonConstInt;
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: variable 'pointerToNonConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
 // CHECK-MESSAGES: :[[@LINE-2]]:6: warning: variable 'pointerToNonConstInt' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int *const pointerToNonConstInt = &nonConstInt;
 
 int *const constPointerToNonConstInt = &nonConstInt;
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'constPointerToNonConstInt' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int *const constPointerToNonConstInt = &nonConstInt;
 
 namespace namespace_name {
 int nonConstNamespaceInt = 0;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int nonConstNamespaceInt = 0;
 
 const int constNamespaceInt = 0;
 } // namespace namespace_name
@@ -24,6 +29,7 @@
 
 const int *pointerToConstInt = &constInt;
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'pointerToConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int *const pointerToConstInt = &constInt;
 
 const int *const constPointerToConstInt = &constInt;
 
@@ -39,6 +45,7 @@
 namespace {
 int nonConstAnonymousNamespaceInt = 0;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstAnonymousNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const int nonConstAnonymousNamespaceInt = 0;
 } // namespace
 
 class DummyClass {
@@ -53,27 +60,35 @@
 
 DummyClass nonConstClassInstance;
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'nonConstClassInstance' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const DummyClass nonConstClassInstance;
 
 DummyClass *pointerToNonConstDummyClass = &nonConstClassInstance;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'pointerToNonConstDummyClass' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
 // CHECK-MESSAGES: :[[@LINE-2]]:13: warning: variable 'pointerToNonConstDummyClass' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const DummyClass *const pointerToNonConstDummyClass = &nonConstClassInstance;
 
 DummyClass &referenceToNonConstDummyClass = nonConstClassInstance;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'referenceToNonConstDummyClass' provides global access to a non-const object; consider making the referenced data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-FIXES: const DummyClass &referenceToNonConstDummyClass = nonConstClassInstance;
 
 int *nonConstPointerToMember = &nonConstClassInstance.n

[clang] 5780dbe - [-Wcalled-once] Do not run analysis on Obj-C++

2021-04-22 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-04-22T15:20:52+03:00
New Revision: 5780dbeee6480fdceae66fb57dcc7bd1cfcda5c9

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

LOG: [-Wcalled-once] Do not run analysis on Obj-C++

Objective-C++ is not yet suppoerted.

rdar://76729552

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

Added: 


Modified: 
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/test/SemaObjCXX/warn-called-once.mm

Removed: 




diff  --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp 
b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index bcd6a00d7ba5a..aa2602c8d9256 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2403,7 +2403,7 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
   }
 
   // Check for violations of "called once" parameter properties.
-  if (S.getLangOpts().ObjC &&
+  if (S.getLangOpts().ObjC && !S.getLangOpts().CPlusPlus &&
   shouldAnalyzeCalledOnceParameters(Diags, D->getBeginLoc())) {
 if (AC.getCFG()) {
   CalledOnceCheckReporter Reporter(S, IPData->CalledOnceData);

diff  --git a/clang/test/SemaObjCXX/warn-called-once.mm 
b/clang/test/SemaObjCXX/warn-called-once.mm
index 312da27d9ae32..3763a9b219f24 100644
--- a/clang/test/SemaObjCXX/warn-called-once.mm
+++ b/clang/test/SemaObjCXX/warn-called-once.mm
@@ -1,7 +1,13 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wcompletion-handler %s
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wcompletion-handler %s
 
 // expected-no-diagnostics
 
 class HasCtor {
   HasCtor(void *) {}
 };
+
+void double_call_one_block(void (^completionHandler)(void)) {
+  completionHandler();
+  completionHandler();
+  // no-warning - we don't support C++/Obj-C++ yet
+}



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


[PATCH] D100955: [-Wcalled-once] Do not run analysis on Obj-C++

2021-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5780dbeee648: [-Wcalled-once] Do not run analysis on Obj-C++ 
(authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100955

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaObjCXX/warn-called-once.mm


Index: clang/test/SemaObjCXX/warn-called-once.mm
===
--- clang/test/SemaObjCXX/warn-called-once.mm
+++ clang/test/SemaObjCXX/warn-called-once.mm
@@ -1,7 +1,13 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wcompletion-handler %s
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wcompletion-handler %s
 
 // expected-no-diagnostics
 
 class HasCtor {
   HasCtor(void *) {}
 };
+
+void double_call_one_block(void (^completionHandler)(void)) {
+  completionHandler();
+  completionHandler();
+  // no-warning - we don't support C++/Obj-C++ yet
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2403,7 +2403,7 @@
   }
 
   // Check for violations of "called once" parameter properties.
-  if (S.getLangOpts().ObjC &&
+  if (S.getLangOpts().ObjC && !S.getLangOpts().CPlusPlus &&
   shouldAnalyzeCalledOnceParameters(Diags, D->getBeginLoc())) {
 if (AC.getCFG()) {
   CalledOnceCheckReporter Reporter(S, IPData->CalledOnceData);


Index: clang/test/SemaObjCXX/warn-called-once.mm
===
--- clang/test/SemaObjCXX/warn-called-once.mm
+++ clang/test/SemaObjCXX/warn-called-once.mm
@@ -1,7 +1,13 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wcompletion-handler %s
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wcompletion-handler %s
 
 // expected-no-diagnostics
 
 class HasCtor {
   HasCtor(void *) {}
 };
+
+void double_call_one_block(void (^completionHandler)(void)) {
+  completionHandler();
+  completionHandler();
+  // no-warning - we don't support C++/Obj-C++ yet
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2403,7 +2403,7 @@
   }
 
   // Check for violations of "called once" parameter properties.
-  if (S.getLangOpts().ObjC &&
+  if (S.getLangOpts().ObjC && !S.getLangOpts().CPlusPlus &&
   shouldAnalyzeCalledOnceParameters(Diags, D->getBeginLoc())) {
 if (AC.getCFG()) {
   CalledOnceCheckReporter Reporter(S, IPData->CalledOnceData);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101054: [AST] Sort introspection results without instantiating other data

2021-04-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: njames93.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Avoid string allocation in particular, but also avoid attempting to
impose any particular ordering based on formatted results.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101054

Files:
  clang/lib/Tooling/NodeIntrospection.cpp


Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -41,6 +41,23 @@
 }
 
 namespace internal {
+
+static bool locationCallLessThan(const LocationCall *LHS,
+ const LocationCall *RHS) {
+  if (!LHS && !RHS)
+return false;
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  auto compareResult = LHS->name().compare(RHS->name());
+  if (compareResult < 0)
+return true;
+  if (compareResult > 0)
+return false;
+  return locationCallLessThan(LHS->on(), RHS->on());
+}
+
 bool RangeLessThan::operator()(
 std::pair const &LHS,
 std::pair const &RHS) const {
@@ -54,15 +71,13 @@
   else if (LHS.first.getEnd() != RHS.first.getEnd())
 return false;
 
-  return LocationCallFormatterCpp::format(*LHS.second) <
- LocationCallFormatterCpp::format(*RHS.second);
+  return locationCallLessThan(LHS.second.get(), RHS.second.get());
 }
 bool RangeLessThan::operator()(
 std::pair const &LHS,
 std::pair const &RHS) const {
   if (LHS.first == RHS.first)
-return LocationCallFormatterCpp::format(*LHS.second) <
-   LocationCallFormatterCpp::format(*RHS.second);
+return locationCallLessThan(LHS.second.get(), RHS.second.get());
   return LHS.first < RHS.first;
 }
 } // namespace internal


Index: clang/lib/Tooling/NodeIntrospection.cpp
===
--- clang/lib/Tooling/NodeIntrospection.cpp
+++ clang/lib/Tooling/NodeIntrospection.cpp
@@ -41,6 +41,23 @@
 }
 
 namespace internal {
+
+static bool locationCallLessThan(const LocationCall *LHS,
+ const LocationCall *RHS) {
+  if (!LHS && !RHS)
+return false;
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  auto compareResult = LHS->name().compare(RHS->name());
+  if (compareResult < 0)
+return true;
+  if (compareResult > 0)
+return false;
+  return locationCallLessThan(LHS->on(), RHS->on());
+}
+
 bool RangeLessThan::operator()(
 std::pair const &LHS,
 std::pair const &RHS) const {
@@ -54,15 +71,13 @@
   else if (LHS.first.getEnd() != RHS.first.getEnd())
 return false;
 
-  return LocationCallFormatterCpp::format(*LHS.second) <
- LocationCallFormatterCpp::format(*RHS.second);
+  return locationCallLessThan(LHS.second.get(), RHS.second.get());
 }
 bool RangeLessThan::operator()(
 std::pair const &LHS,
 std::pair const &RHS) const {
   if (LHS.first == RHS.first)
-return LocationCallFormatterCpp::format(*LHS.second) <
-   LocationCallFormatterCpp::format(*RHS.second);
+return locationCallLessThan(LHS.second.get(), RHS.second.get());
   return LHS.first < RHS.first;
 }
 } // namespace internal
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93325: Add srcloc output to clang-query

2021-04-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 339583.
steveire added a comment.
Herald added a subscriber: mgrang.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93325

Files:
  clang-tools-extra/clang-query/CMakeLists.txt
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/Query.h
  clang-tools-extra/clang-query/QueryParser.cpp
  clang-tools-extra/clang-query/QuerySession.h
  clang-tools-extra/unittests/clang-query/QueryParserTest.cpp

Index: clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
===
--- clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
+++ clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
@@ -218,7 +218,7 @@
   EXPECT_EQ("output", Comps[0].DisplayText);
 
   Comps = QueryParser::complete("enable output ", 14, QS);
-  ASSERT_EQ(4u, Comps.size());
+  ASSERT_EQ(5u, Comps.size());
 
   EXPECT_EQ("diag ", Comps[0].TypedText);
   EXPECT_EQ("diag", Comps[0].DisplayText);
@@ -226,8 +226,10 @@
   EXPECT_EQ("print", Comps[1].DisplayText);
   EXPECT_EQ("detailed-ast ", Comps[2].TypedText);
   EXPECT_EQ("detailed-ast", Comps[2].DisplayText);
-  EXPECT_EQ("dump ", Comps[3].TypedText);
-  EXPECT_EQ("dump", Comps[3].DisplayText);
+  EXPECT_EQ("srcloc ", Comps[3].TypedText);
+  EXPECT_EQ("srcloc", Comps[3].DisplayText);
+  EXPECT_EQ("dump ", Comps[4].TypedText);
+  EXPECT_EQ("dump", Comps[4].DisplayText);
 
   Comps = QueryParser::complete("set traversal ", 14, QS);
   ASSERT_EQ(2u, Comps.size());
Index: clang-tools-extra/clang-query/QuerySession.h
===
--- clang-tools-extra/clang-query/QuerySession.h
+++ clang-tools-extra/clang-query/QuerySession.h
@@ -25,14 +25,15 @@
 public:
   QuerySession(llvm::ArrayRef> ASTs)
   : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
-DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
-Terminate(false), TK(TK_AsIs) {}
+DetailedASTOutput(false), SrcLocOutput(false), BindRoot(true),
+PrintMatcher(false), Terminate(false), TK(TK_AsIs) {}
 
   llvm::ArrayRef> ASTs;
 
   bool PrintOutput;
   bool DiagOutput;
   bool DetailedASTOutput;
+  bool SrcLocOutput;
 
   bool BindRoot;
   bool PrintMatcher;
Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -108,6 +108,7 @@
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
  .Case("detailed-ast", OK_DetailedAST)
+ .Case("srcloc", OK_SrcLoc)
  .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
@@ -123,6 +124,8 @@
 return new QueryType(&QuerySession::DiagOutput);
   case OK_Print:
 return new QueryType(&QuerySession::PrintOutput);
+  case OK_SrcLoc:
+return new QueryType(&QuerySession::SrcLocOutput);
   }
 
   llvm_unreachable("Invalid output kind");
Index: clang-tools-extra/clang-query/Query.h
===
--- clang-tools-extra/clang-query/Query.h
+++ clang-tools-extra/clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST, OK_SrcLoc };
 
 enum QueryKind {
   QK_Invalid,
Index: clang-tools-extra/clang-query/Query.cpp
===
--- clang-tools-extra/clang-query/Query.cpp
+++ clang-tools-extra/clang-query/Query.cpp
@@ -12,6 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/TextDiagnostic.h"
+#include "clang/Tooling/NodeIntrospection.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang::ast_matchers;
@@ -66,6 +67,8 @@
 "Diagnostic location for bound nodes.\n"
 "  detailed-ast  "
 "Detailed AST output for bound nodes.\n"
+"  srcloc"
+"Source locations and ranges for bound nodes.\n"
 "  dump  "
 "Detailed AST output for bound nodes (alias of detailed-ast).\n\n";
   return true;
@@ -86,6 +89,92 @@
   }
 };
 
+void dumpLocations(llvm::raw_ostream &OS, DynTypedNode Node, ASTContext &Ctx,
+   const DiagnosticsEngine &Diags, SourceManager const &SM) {
+  auto Locs = clang::tooling::NodeIntrospection::GetLocations(Node);
+
+  auto printLocations = [](auto &OS, auto Iter, auto End) {
+auto CommonEntry = Iter->first;
+auto Scout = Iter;
+SmallVector LocationStrings;
+while (Scout->first == CommonEntry) {
+  Loca

[clang] 6ad7e87 - clang: libstdc++ LWM is 4.8.3

2021-04-22 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-04-22T05:26:07-07:00
New Revision: 6ad7e87806c0af774cf2f8880694f79259925979

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

LOG: clang: libstdc++ LWM is 4.8.3

Document oldest libstdc++ as 4.8.3, remove a hack for a 4.6 issue.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/Toolchain.rst
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ad7ff71802ddc..a11d60cadb042 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -117,9 +117,16 @@ C Language Changes in Clang
 C++ Language Changes in Clang
 -
 
+- The oldest supported GNU libstdc++ is now 4.8.3 (released 2014-05-22).
+  Clang workarounds for bugs in earlier versions have been removed.
+
 - ...
 
-C++1z Feature Support
+C++20 Feature Support
+^
+...
+
+C++2b Feature Support
 ^
 ...
 

diff  --git a/clang/docs/Toolchain.rst b/clang/docs/Toolchain.rst
index da65f14597b17..9c4099e15c98c 100644
--- a/clang/docs/Toolchain.rst
+++ b/clang/docs/Toolchain.rst
@@ -340,9 +340,10 @@ You can instruct Clang to use libc++ with the 
``-stdlib=libc++`` flag.
 libstdc++ (GNU)
 ^^^
 
-`libstdc++ `_ is GCC's 
implementation
-of the C++ standard library. Clang supports a wide range of versions of
-libstdc++, from around version 4.2 onwards, and will implicitly work around
-some bugs in older versions of libstdc++.
+`libstdc++ `_ is GCC's
+implementation of the C++ standard library. Clang supports libstdc++
+4.8.3 (released 2014-05-22) and later. Historically Clang implemented
+workarounds for issues discovered in libstdc++, and these are removed
+as fixed libstdc++ becomes sufficiently old.
 
 You can instruct Clang to use libstdc++ with the ``-stdlib=libstdc++`` flag.

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 7a5f66d31105a..06ff38808ac85 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -10874,26 +10874,6 @@ static void DiagnoseNamespaceInlineMismatch(Sema &S, 
SourceLocation KeywordLoc,
 NamespaceDecl *PrevNS) {
   assert(*IsInline != PrevNS->isInline());
 
-  // HACK: Work around a bug in libstdc++4.6's , where
-  // std::__atomic[0,1,2] are defined as non-inline namespaces, then reopened 
as
-  // inline namespaces, with the intention of bringing names into namespace 
std.
-  //
-  // We support this just well enough to get that case working; this is not
-  // sufficient to support reopening namespaces as inline in general.
-  if (*IsInline && II && II->getName().startswith("__atomic") &&
-  S.getSourceManager().isInSystemHeader(Loc)) {
-// Mark all prior declarations of the namespace as inline.
-for (NamespaceDecl *NS = PrevNS->getMostRecentDecl(); NS;
- NS = NS->getPreviousDecl())
-  NS->setInline(*IsInline);
-// Patch up the lookup table for the containing namespace. This isn't 
really
-// correct, but it's good enough for this particular case.
-for (auto *I : PrevNS->decls())
-  if (auto *ND = dyn_cast(I))
-PrevNS->getParent()->makeDeclVisibleInContext(ND);
-return;
-  }
-
   if (PrevNS->isInline())
 // The user probably just forgot the 'inline', so suggest that it
 // be added back.

diff  --git a/clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp 
b/clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp
index 4e4523f853228..d519f7877da1e 100644
--- a/clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp
+++ b/clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp
@@ -7,29 +7,28 @@
 // namespace to be converted from non-inline to inline in this one specific
 // case.
 
+// the last 4.6 release was 2013, so the hack is removed.  This checks __atomic
+// is not special.
 #ifdef BE_THE_HEADER
 
 #pragma clang system_header
 
 namespace std {
-  namespace __atomic0 {
-typedef int foobar;
-  }
-  namespace __atomic1 {
-typedef void foobar;
-  }
+namespace __atomic0 { // expected-note {{previous definition}}
+typedef int foobar;
+} // namespace __atomic0
+namespace __atomic1 {
+typedef void foobar;
+} // namespace __atomic1
 
-  inline namespace __atomic0 {}
-}
+inline namespace __atomic0 {} // expected-error {{cannot be reopened as 
inline}}
+} // namespace std
 
 #else
 
 #define BE_THE_HEADER
 #include "libstdcxx_atomic_ns_hack.cpp"
 
-std::foobar fb;
-
-using T = void; // expected-note {{here}}
-using T = std::foobar; // expected-error {{
diff erent typ

[PATCH] D100465: clang: Remove __atomic libstdc++ hack

2021-04-22 Thread Nathan Sidwell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ad7e87806c0: clang: libstdc++ LWM is 4.8.3 (authored by 
urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100465

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/Toolchain.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp

Index: clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp
===
--- clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp
+++ clang/test/SemaCXX/libstdcxx_atomic_ns_hack.cpp
@@ -7,29 +7,28 @@
 // namespace to be converted from non-inline to inline in this one specific
 // case.
 
+// the last 4.6 release was 2013, so the hack is removed.  This checks __atomic
+// is not special.
 #ifdef BE_THE_HEADER
 
 #pragma clang system_header
 
 namespace std {
-  namespace __atomic0 {
-typedef int foobar;
-  }
-  namespace __atomic1 {
-typedef void foobar;
-  }
+namespace __atomic0 { // expected-note {{previous definition}}
+typedef int foobar;
+} // namespace __atomic0
+namespace __atomic1 {
+typedef void foobar;
+} // namespace __atomic1
 
-  inline namespace __atomic0 {}
-}
+inline namespace __atomic0 {} // expected-error {{cannot be reopened as inline}}
+} // namespace std
 
 #else
 
 #define BE_THE_HEADER
 #include "libstdcxx_atomic_ns_hack.cpp"
 
-std::foobar fb;
-
-using T = void; // expected-note {{here}}
-using T = std::foobar; // expected-error {{different types ('std::foobar' (aka 'int') vs 'void')}}
+std::foobar fb; // expected-error {{no type named 'foobar' in namespace}}
 
 #endif
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -10874,26 +10874,6 @@
 NamespaceDecl *PrevNS) {
   assert(*IsInline != PrevNS->isInline());
 
-  // HACK: Work around a bug in libstdc++4.6's , where
-  // std::__atomic[0,1,2] are defined as non-inline namespaces, then reopened as
-  // inline namespaces, with the intention of bringing names into namespace std.
-  //
-  // We support this just well enough to get that case working; this is not
-  // sufficient to support reopening namespaces as inline in general.
-  if (*IsInline && II && II->getName().startswith("__atomic") &&
-  S.getSourceManager().isInSystemHeader(Loc)) {
-// Mark all prior declarations of the namespace as inline.
-for (NamespaceDecl *NS = PrevNS->getMostRecentDecl(); NS;
- NS = NS->getPreviousDecl())
-  NS->setInline(*IsInline);
-// Patch up the lookup table for the containing namespace. This isn't really
-// correct, but it's good enough for this particular case.
-for (auto *I : PrevNS->decls())
-  if (auto *ND = dyn_cast(I))
-PrevNS->getParent()->makeDeclVisibleInContext(ND);
-return;
-  }
-
   if (PrevNS->isInline())
 // The user probably just forgot the 'inline', so suggest that it
 // be added back.
Index: clang/docs/Toolchain.rst
===
--- clang/docs/Toolchain.rst
+++ clang/docs/Toolchain.rst
@@ -340,9 +340,10 @@
 libstdc++ (GNU)
 ^^^
 
-`libstdc++ `_ is GCC's implementation
-of the C++ standard library. Clang supports a wide range of versions of
-libstdc++, from around version 4.2 onwards, and will implicitly work around
-some bugs in older versions of libstdc++.
+`libstdc++ `_ is GCC's
+implementation of the C++ standard library. Clang supports libstdc++
+4.8.3 (released 2014-05-22) and later. Historically Clang implemented
+workarounds for issues discovered in libstdc++, and these are removed
+as fixed libstdc++ becomes sufficiently old.
 
 You can instruct Clang to use libstdc++ with the ``-stdlib=libstdc++`` flag.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -117,9 +117,16 @@
 C++ Language Changes in Clang
 -
 
+- The oldest supported GNU libstdc++ is now 4.8.3 (released 2014-05-22).
+  Clang workarounds for bugs in earlier versions have been removed.
+
 - ...
 
-C++1z Feature Support
+C++20 Feature Support
+^
+...
+
+C++2b Feature Support
 ^
 ...
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-04-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Could you check that it does not break the tests from 
https://github.com/clang-ykt/omptests? IIRC, "ref" was introduced to fix a bug 
with too early optimizations of the declare target variables defined in other 
modules. Check `t-same-name-definitions` especially, though I'm not sure that 
exactly this test caused adding of `$ref`s.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2999-3000
 if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
-  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
-  OffloadingEntriesNum);
 auto &Entry =

Why did you decide to drop this?



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1736
   SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
-  ConsumeAnyToken();
-  for (auto &MTLocDecl : DeclareTargetDecls) {

Looks like it is still required to consume `tok::annot_pragma_openmp_end`



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1742
+Sema::DeclareTargetContextInfo::MapInfo MI{MT, NameInfo.getLoc()};
+bool FirstMapping = DTCI.ExplicitlyMapped.insert({ND, MI}).second;
+if (!FirstMapping)

`try_emplace(ND, MI)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D100776: [clang/Basic] Make TargetInfo.h not use DataLayout again

2021-04-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

rnk, echristo: can we go ahead here?


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

https://reviews.llvm.org/D100776

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


[clang] 6f48d6a - [AST] Make comment a bit more specific

2021-04-22 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-22T13:40:56+01:00
New Revision: 6f48d6a9df69b489a741e3f8f72a4559c033b23c

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

LOG: [AST] Make comment a bit more specific

Added: 


Modified: 
clang/include/clang/Tooling/NodeIntrospection.h

Removed: 




diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
index 9fe10c659243..7e0d5e8d14f5 100644
--- a/clang/include/clang/Tooling/NodeIntrospection.h
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -68,9 +68,10 @@ struct RangeLessThan {
 } // namespace internal
 
 // Note that this container stores unique results in a deterministic, but
-// unspecified order.  Clients which desire a particular order, such as
-// alphabetical, should sort results after retrieval, because the order
-// is dependent on how the LocationCalls are formatted.
+// the location calls are in an unspecified order.  Clients which desire
+// a particular order for the location calls, such as alphabetical,
+// should sort results after retrieval, because the order is dependent
+// on how the LocationCalls are formatted.
 template 
 using UniqueMultiMap = std::set, internal::RangeLessThan>;
 



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


[PATCH] D98774: [AST] De-duplicate empty node introspection

2021-04-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D98774#2708108 , @steveire wrote:

> In D98774#2701853 , @thakis wrote:
>
>> I think it is? https://llvm.org/docs/GettingStarted.html#software lists it 
>> at least.
>
> Thanks, I'll look into that soon and see how the buildbots respond.

I looked into a bit too, and at least gen_decision_forest in clang-tools-extra 
uses python without a guard. See 
clang-tools-extra/clangd/quality/CompletionModel.cmake and 
clang-tools-extra/clangd/CMakeLists.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98774

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


[PATCH] D101043: [OpenCL] Drop extension pragma handling for extension types/declarations

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Did you check whether this patch will cause regression in OpenCL conformance 
tests? If not, I am OK with it.


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

https://reviews.llvm.org/D101043

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


[PATCH] D101059: [X86][AMX] Add description for AMX new interface.

2021-04-22 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke created this revision.
LuoYuanke requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101059

Files:
  clang/lib/Headers/amxintrin.h

Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -30,7 +30,7 @@
 /// config and the tile data, and the tiles are zeroed. Any invalid
 /// configurations will result in #GP fault.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  LDTILECFG  instruction.
 ///
@@ -46,7 +46,7 @@
 /// palette, the number of bytes per row, and the number of rows. If tiles
 /// are not configured, all zeroes will be stored to memory.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  STTILECFG  instruction.
 ///
@@ -60,7 +60,7 @@
 /// Release the tile configuration to return to the init state, which
 /// releases all storage it currently holds.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILERELEASE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS_TILE _tile_release(void) {
@@ -71,7 +71,7 @@
 /// destination tile "dst" using the tile configuration previously configured
 /// via "_tile_loadconfig".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILELOADD  instruction.
 ///
@@ -91,7 +91,7 @@
 /// that the data will likely not be reused in the near future and the data
 /// caching can be optimized accordingly.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILELOADDT1  instruction.
 ///
@@ -109,7 +109,7 @@
 /// "stride" using the tile configuration previously configured via
 /// "_tile_loadconfig".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILESTORED  instruction.
 ///
@@ -124,7 +124,7 @@
 
 /// Zero the tile specified by "tdest".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILEZERO  instruction.
 ///
@@ -138,7 +138,7 @@
 /// results. Sum these 4 results with the corresponding 32-bit integer in "dst",
 /// and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBSSD  instruction.
 ///
@@ -157,7 +157,7 @@
 /// 32-bit results. Sum these 4 results with the corresponding 32-bit integer
 /// in "dst", and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBSUD  instruction.
 ///
@@ -176,7 +176,7 @@
 /// results. Sum these 4 results with the corresponding 32-bit integer in "dst",
 /// and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBUSD  instruction.
 ///
@@ -195,7 +195,7 @@
 /// 32-bit results. Sum these 4 results with the corresponding 32-bit integer in
 /// "dst", and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBUUD  instruction.
 ///
@@ -213,7 +213,7 @@
 /// elements with elements in "dst", and store the 32-bit result back to tile
 /// "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBF16PS  instruction.
 ///
@@ -226,8 +226,12 @@
 #define _tile_dpbf16ps(dst, src0, src1)\
   __builtin_ia32_tdpbf16ps((dst), (src0), (src1))
 
+/// AMX tile register size can be configured, the maximum size is 16x64=1024
+/// bytes. Since there is no 2D type in llvm IR, we use vector type to
+/// represent 2D tile and the fixed size is maximum amx tile register size.
 typedef int _tile1024i __attribute__((__vector_size__(1024), __aligned__(64)));
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_loadd_internal(unsigned short m, unsigned short n, const void *base,
  __SIZE_TYPE__ stride) {
@@ -235,30 +239,35 @@
  (__SIZE_TYPE__)(stride));
 }
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_dpbssd_internal(unsigned short m, unsigned short n, unsigned short k,
   _tile1024i dst, _tile1024i src1, _tile1024i src2) {
   return __builtin_ia32_tdpbssd_internal(m, n, k, dst, src1, src2);
 }
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_dpbsud_internal(unsigned short m, unsigned short n, unsigned short k,
   _tile1024i dst, _tile1024i src1, _tile1024i src2) {
   return __builtin_ia32_tdpbsud_internal(m, n, k, 

[PATCH] D101052: [OpenCL] allow pipe as a valid identifier prior to OpenCL 2.0

2021-04-22 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D101052

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


[PATCH] D101059: [X86][AMX] Add description for AMX new interface.

2021-04-22 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 339597.
LuoYuanke added a comment.

Fix some descriptions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101059

Files:
  clang/lib/Headers/amxintrin.h

Index: clang/lib/Headers/amxintrin.h
===
--- clang/lib/Headers/amxintrin.h
+++ clang/lib/Headers/amxintrin.h
@@ -30,7 +30,7 @@
 /// config and the tile data, and the tiles are zeroed. Any invalid
 /// configurations will result in #GP fault.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  LDTILECFG  instruction.
 ///
@@ -46,7 +46,7 @@
 /// palette, the number of bytes per row, and the number of rows. If tiles
 /// are not configured, all zeroes will be stored to memory.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  STTILECFG  instruction.
 ///
@@ -60,7 +60,7 @@
 /// Release the tile configuration to return to the init state, which
 /// releases all storage it currently holds.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILERELEASE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS_TILE _tile_release(void) {
@@ -71,7 +71,7 @@
 /// destination tile "dst" using the tile configuration previously configured
 /// via "_tile_loadconfig".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILELOADD  instruction.
 ///
@@ -91,7 +91,7 @@
 /// that the data will likely not be reused in the near future and the data
 /// caching can be optimized accordingly.
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILELOADDT1  instruction.
 ///
@@ -109,7 +109,7 @@
 /// "stride" using the tile configuration previously configured via
 /// "_tile_loadconfig".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILESTORED  instruction.
 ///
@@ -124,7 +124,7 @@
 
 /// Zero the tile specified by "tdest".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TILEZERO  instruction.
 ///
@@ -138,7 +138,7 @@
 /// results. Sum these 4 results with the corresponding 32-bit integer in "dst",
 /// and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBSSD  instruction.
 ///
@@ -157,7 +157,7 @@
 /// 32-bit results. Sum these 4 results with the corresponding 32-bit integer
 /// in "dst", and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBSUD  instruction.
 ///
@@ -176,7 +176,7 @@
 /// results. Sum these 4 results with the corresponding 32-bit integer in "dst",
 /// and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBUSD  instruction.
 ///
@@ -195,7 +195,7 @@
 /// 32-bit results. Sum these 4 results with the corresponding 32-bit integer in
 /// "dst", and store the 32-bit result back to tile "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBUUD  instruction.
 ///
@@ -213,7 +213,7 @@
 /// elements with elements in "dst", and store the 32-bit result back to tile
 /// "dst".
 ///
-/// \headerfile 
+/// \headerfile 
 ///
 /// This intrinsic corresponds to the  TDPBF16PS  instruction.
 ///
@@ -226,8 +226,12 @@
 #define _tile_dpbf16ps(dst, src0, src1)\
   __builtin_ia32_tdpbf16ps((dst), (src0), (src1))
 
+/// AMX tile register size can be configured, the maximum size is 16x64=1024
+/// bytes. Since there is no 2D type in llvm IR, we use vector type to
+/// represent 2D tile and the fixed size is maximum amx tile register size.
 typedef int _tile1024i __attribute__((__vector_size__(1024), __aligned__(64)));
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_loadd_internal(unsigned short m, unsigned short n, const void *base,
  __SIZE_TYPE__ stride) {
@@ -235,30 +239,35 @@
  (__SIZE_TYPE__)(stride));
 }
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_dpbssd_internal(unsigned short m, unsigned short n, unsigned short k,
   _tile1024i dst, _tile1024i src1, _tile1024i src2) {
   return __builtin_ia32_tdpbssd_internal(m, n, k, dst, src1, src2);
 }
 
+/// This is internal intrinsic. C/C++ user should avoid calling it directly.
 static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8
 _tile_dpbsud_internal(unsigned short m, unsigned short n, unsigned short k,
   _tile1024i dst, _tile1024i src1, _tile1024i src2) {
   return __builtin_ia32_tdpbsud_

[PATCH] D101043: [OpenCL] Drop extension pragma handling for extension types/declarations

2021-04-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D101043#2708358 , @yaxunl wrote:

> Did you check whether this patch will cause regression in OpenCL conformance 
> tests? If not, I am OK with it.

This change has no impact on CTS as CTS has never had negative compiler tests 
i.e. checking that the compiler rejects certain kernels. This change doesn't 
break existing kernels i.e. it only allows to compile extra kernels i.e. 
without the use of pragmas enable/disable when non-native compiler types or 
functions are called.

CTS only mainly uses `#pragma OPENCL EXTENSION * : enable` and there is only 
one occurrence of  `#pragma OPENCL EXTENSION * : disable` that only checks that 
the pragmas are accepted, there are no other relevant checks in the tests.


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

https://reviews.llvm.org/D101043

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


[PATCH] D101060: [Analyzer][StdLibraryFunctionsChecker] Describe arg constraints

2021-04-22 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: steakhal, NoQ, vsavchenko.
Herald added subscribers: ASDenysPetrov, Charusso, gamesh411, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In this patch, I provide a detailed explanation for each argument
constraint. This explanation is added in an extra 'note' tag, which is
displayed alongside the warning.
Since these new notes describe clearly the constraint, there is no need
to provide the number of the argument (e.g. 'Arg3') within the warning.
However, I decided to keep the name of the constraint in the warning (but
this could be a subject of discussion) in order to be able to identify
the different kind of constraint violations easily in a bug database
(e.g. CodeChecker).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101060

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp

Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -14,5 +14,6 @@
 
 void test_arg_constraint_on_fun_with_default_param() {
   __defaultparam(nullptr); // \
-  // expected-warning{{Function argument constraint is not satisfied}}
+  // expected-warning{{Function argument constraint is not satisfied}} \
+  // expected-note{{}}
 }
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -30,7 +30,9 @@
 void test_alnum_concrete(int v) {
   int ret = isalnum(256); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   (void)ret;
 }
@@ -54,7 +56,9 @@
 
 int ret = isalnum(x); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 
 (void)ret;
@@ -66,7 +70,9 @@
 void test_toupper_concrete(int v) {
   int ret = toupper(256); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   (void)ret;
 }
@@ -90,7 +96,9 @@
 
 int ret = toupper(x); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 
 (void)ret;
@@ -102,7 +110,9 @@
 void test_tolower_concrete(int v) {
   int ret = tolower(256); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   (void)ret;
 }
@@ -126,7 +136,9 @@
 
 int ret = tolower(x); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 
 (void)ret;
@@ -138,7 +150,9 @@
 void test_toascii_concrete(int v) {
   int ret = toascii(256); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   (void)ret;
 }
@@ -162,7 +176,9 @@
 
 int ret = toascii(x); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 
 (void)ret;
@@ -175,7 +191,9 

[PATCH] D101060: [Analyzer][StdLibraryFunctionsChecker] Describe arg constraints

2021-04-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1
-//=== StdLibraryFunctionsChecker.cpp - Model standard functions -*- C++ 
-*-===//
 //

upsz


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101060

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


[PATCH] D100611: [RISCV] Add new attribute __clang_riscv_builtin_alias for intrinsics.

2021-04-22 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 339602.
HsiangKai added a comment.

Add clang attribute `clang_builtin_alias`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100611

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

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
@@ -142,6 +142,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -target-feature +experimental-v \
+// RUN:   %s -o - \
+// RUN:   | FileCheck %s
+
+#include 
+
+#define __rvv_generic \
+static inline __attribute__((__always_inline__, __nodebug__))
+
+__rvv_generic
+__attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
+vint8m1_t vadd_generic (vint8m1_t op0, vint8m1_t op1, size_t op2);
+
+// CHECK-LABEL: @test(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[OP0_ADDR:%.*]] = alloca , align 1
+// CHECK-NEXT:[[OP1_ADDR:%.*]] = alloca , align 1
+// CHECK-NEXT:[[VL_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[RET:%.*]] = alloca , align 1
+// CHECK-NEXT:store  [[OP0:%.*]], * [[OP0_ADDR]], align 1
+// CHECK-NEXT:store  [[OP1:%.*]], * [[OP1_ADDR]], align 1
+// CHECK-NEXT:store i64 [[VL:%.*]], i64* [[VL_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load , * [[OP0_ADDR]], align 1
+// CHECK-NEXT:[[TMP1:%.*]] = load , * [[OP1_ADDR]], align 1
+// CHECK-NEXT:[[TMP2:%.*]] = load i64, i64* [[VL_ADDR]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = call  @llvm.riscv.vadd.nxv8i8.nxv8i8.i64( [[TMP0]],  [[TMP1]], i64 [[TMP2]])
+// CHECK-NEXT:store  [[TMP3]], * [[RET]], align 1
+// CHECK-NEXT:[[TMP4:%.*]] = load , * [[RET]], align 1
+// CHECK-NEXT:ret  [[TMP4]]
+//
+vint8m1_t test(vint8m1_t op0, vint8m1_t op1, size_t vl) {
+  vint8m1_t ret = vadd_generic(op0, op1, vl);
+  return ret;
+}
Index: clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
@@ -0,0 +1,19 @@
+// REQUIRES: riscv-registered-target
+// RUN: not %clang_cc1 -triple riscv64 -fsyntax-only -verify \
+// RUN:   -target-feature +experimental-v %s 2>&1 \
+// RUN: | FileCheck %s
+
+#include 
+
+#define __rvv_generic \
+static inline __attribute__((__always_inline__, __nodebug__))
+
+__rvv_generic
+__attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
+vint8m1_t vadd_generic (vint8m1_t op0, vint8m1_t op1, size_t op2);
+
+// CHECK: passing 'vint8m2_t' (aka '__rvv_int8m2_t') to parameter of incompatible type 'vint8m1_t'
+vint8m2_t test(vint8m2_t op0, vint8m2_t op1, size_t vl) {
+  vint8m2_t ret = vadd_generic(op0, op1, vl);
+  return ret;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5120,6 +5120,7 @@
 #define GET_SVE_BUILTINS
 #define BUILTIN(name, types, attr) case SVE::BI##name:
 #include "clang/Basic/arm_sve_builtins.inc"
+#undef BUILTIN
 return true;
   }
 }
@@ -5146,6 +5147,44 @@
   D->addAttr(::new (S.Context) ArmBuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static bool RISCVAliasValid(unsigned BuiltinID, StringRef AliasName) {
+  switch (BuiltinID) {
+  default:
+return false;
+#define BUILTIN(ID, TYPE, ATTRS) case RISCV::BI##ID:
+#include "clang/Basic/BuiltinsRISCV.def"
+#undef BUILTIN
+return true;
+  }
+}
+
+static void handleBuiltinAliasAttr(Sema &S, Decl *D,
+const ParsedAttr &AL) {
+  if (!AL.isArgIdent(0)) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_n_t

[PATCH] D101060: [Analyzer][StdLibraryFunctionsChecker] Describe arg constraints

2021-04-22 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 339603.
martong marked an inline comment as not done.
martong added a comment.

- Put back first line
- Remove wrong comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101060

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp

Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -14,5 +14,6 @@
 
 void test_arg_constraint_on_fun_with_default_param() {
   __defaultparam(nullptr); // \
-  // expected-warning{{Function argument constraint is not satisfied}}
+  // expected-warning{{Function argument constraint is not satisfied}} \
+  // expected-note{{}}
 }
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -30,7 +30,9 @@
 void test_alnum_concrete(int v) {
   int ret = isalnum(256); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   (void)ret;
 }
@@ -54,7 +56,9 @@
 
 int ret = isalnum(x); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 
 (void)ret;
@@ -66,7 +70,9 @@
 void test_toupper_concrete(int v) {
   int ret = toupper(256); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   (void)ret;
 }
@@ -90,7 +96,9 @@
 
 int ret = toupper(x); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 
 (void)ret;
@@ -102,7 +110,9 @@
 void test_tolower_concrete(int v) {
   int ret = tolower(256); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   (void)ret;
 }
@@ -126,7 +136,9 @@
 
 int ret = tolower(x); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 
 (void)ret;
@@ -138,7 +150,9 @@
 void test_toascii_concrete(int v) {
   int ret = toascii(256); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
   (void)ret;
 }
@@ -162,7 +176,9 @@
 
 int ret = toascii(x); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 
 (void)ret;
@@ -175,7 +191,9 @@
 void test_notnull_concrete(FILE *fp) {
   fread(0, sizeof(int), 10, fp); // \
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{}} \
   // bugpath-note{{Function argument constraint is not satisfied}}
 }
 void test_notnull_symbolic(FILE *fp, int *buf) {
@@ -191,7 +209,9 @@
 // bugpath-note{{Taking true branch}}
 fread(buf, sizeof(int), 10, fp); // \
 // report-warning{{Function argument constraint is not satisfied}} \
+// report-note{{}} \
 // bugpath-warning{{Function argument constraint is not satisfied}} \
+// bugpath-note{{}} \
 // bugpath-note{{F

[PATCH] D101043: [OpenCL] Drop extension pragma handling for extension types/declarations

2021-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


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

https://reviews.llvm.org/D101043

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


[PATCH] D93031: Enable fexec-charset option

2021-04-22 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D93031#2706660 , @cor3ntin wrote:

>>> We should use the original source form of the string literal when 
>>> pretty-printing a `StringLiteral` or `CharacterLiteral`; there are a bunch 
>>> of UTF-8 assumptions baked into `StmtPrinter` that will need revisiting. 
>>> And we'll need to modify the handful of places that put the contents of 
>>> `StringLiteral`s into diagnostics (`#warning`, `#error`, `static_assert`) 
>>> and make them use a different `ConversionState`, since our assumption is 
>>> that diagnostic output should be in UTF-8.
>>
>> Yes, these are some of the complications we will need to visit in later 
>> patches. We may need to somehow save the original string or reverse the 
>> translation.
>
> The operation is destructive and therefore cannot be reverted.
> So I do believe the correct behavior here would indeed be to keep the 
> original spelling around - with *some* of phase 5 applied (replacement of 
> UCNs and replacement of numeric escape sequences).
> An alternative would be to do the conversion lazily when the strings are 
> evaluated, rather than during lexing, although that might be more involved

Thanks for the input! I agree doing the conversion lazily will help avoid 
hitting these issues since we push translation to a later stage but as you 
mentioned it will be more involved. I think keeping the original spelling might 
be the best solution. We can make a extra member in StringLiteralParser to save 
the string prior to translation. But we would need to go through each use of 
StringLiteralParser and save the original encoding (possibly print it in the 
.ll file along with the translated string or as an attribute?). Let me know 
what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D99877: [Clang] Allow processing of attributes on statements by plugins

2021-04-22 Thread Josh Junon via Phabricator via cfe-commits
Qix- abandoned this revision.
Qix- added a comment.

Closing in favor of more complete plugin attribute changes discussed in IRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99877

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


[PATCH] D99861: [Clang] Record tokens in attribute arguments for user-defined C++/C2x attributes

2021-04-22 Thread Josh Junon via Phabricator via cfe-commits
Qix- abandoned this revision.
Qix- added a comment.

Closing in favor of more complete plugin attribute changes discussed in IRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99861

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


[PATCH] D101060: [Analyzer][StdLibraryFunctionsChecker] Describe arg constraints

2021-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Great job! Thanks!




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:338-339
 }
+llvm_unreachable("The constraint must be either a concrete value or "
+ "encoded in an argument.");
   }();

Just a thought here, maybe we should assert `SizeArgN` instead then?



Comment at: 
clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp:32
+__buf_size_arg_constraint_concrete(buf); // \
+// expected-note{{The size of the 0th arg should be equal to or less than 
the value of 10}} \
+// expected-warning{{}}

Oof, I do understand that we are devs and enumerate things starting from 0. But 
this is supposed to be human-readable and humans start counting from 1.



Comment at: clang/test/Analysis/std-c-library-functions-arg-constraints.c:33
   // report-warning{{Function argument constraint is not satisfied}} \
+  // report-note{{}} \
   // bugpath-warning{{Function argument constraint is not satisfied}} \

What's up with these?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101060

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


[PATCH] D100611: [Clang] Add clang attribute `clang_builtin_alias`.

2021-04-22 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 339606.
HsiangKai added a comment.

Update test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100611

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

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
@@ -22,6 +22,7 @@
 // CHECK-NEXT: Assumption (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: BPFPreserveAccessIndex (SubjectMatchRule_record)
+// CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function)
 // CHECK-NEXT: CFAuditedTransfer (SubjectMatchRule_function)
 // CHECK-NEXT: CFConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: CFICanonicalJumpTable (SubjectMatchRule_function)
Index: clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -target-feature +experimental-v \
+// RUN:   %s -o - \
+// RUN:   | FileCheck %s
+
+#include 
+
+#define __rvv_generic \
+static inline __attribute__((__always_inline__, __nodebug__))
+
+__rvv_generic
+__attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
+vint8m1_t vadd_generic (vint8m1_t op0, vint8m1_t op1, size_t op2);
+
+// CHECK-LABEL: @test(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[OP0_ADDR:%.*]] = alloca , align 1
+// CHECK-NEXT:[[OP1_ADDR:%.*]] = alloca , align 1
+// CHECK-NEXT:[[VL_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[RET:%.*]] = alloca , align 1
+// CHECK-NEXT:store  [[OP0:%.*]], * [[OP0_ADDR]], align 1
+// CHECK-NEXT:store  [[OP1:%.*]], * [[OP1_ADDR]], align 1
+// CHECK-NEXT:store i64 [[VL:%.*]], i64* [[VL_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load , * [[OP0_ADDR]], align 1
+// CHECK-NEXT:[[TMP1:%.*]] = load , * [[OP1_ADDR]], align 1
+// CHECK-NEXT:[[TMP2:%.*]] = load i64, i64* [[VL_ADDR]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = call  @llvm.riscv.vadd.nxv8i8.nxv8i8.i64( [[TMP0]],  [[TMP1]], i64 [[TMP2]])
+// CHECK-NEXT:store  [[TMP3]], * [[RET]], align 1
+// CHECK-NEXT:[[TMP4:%.*]] = load , * [[RET]], align 1
+// CHECK-NEXT:ret  [[TMP4]]
+//
+vint8m1_t test(vint8m1_t op0, vint8m1_t op1, size_t vl) {
+  vint8m1_t ret = vadd_generic(op0, op1, vl);
+  return ret;
+}
Index: clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
@@ -0,0 +1,19 @@
+// REQUIRES: riscv-registered-target
+// RUN: not %clang_cc1 -triple riscv64 -fsyntax-only -verify \
+// RUN:   -target-feature +experimental-v %s 2>&1 \
+// RUN: | FileCheck %s
+
+#include 
+
+#define __rvv_generic \
+static inline __attribute__((__always_inline__, __nodebug__))
+
+__rvv_generic
+__attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1)))
+vint8m1_t vadd_generic (vint8m1_t op0, vint8m1_t op1, size_t op2);
+
+// CHECK: passing 'vint8m2_t' (aka '__rvv_int8m2_t') to parameter of incompatible type 'vint8m1_t'
+vint8m2_t test(vint8m2_t op0, vint8m2_t op1, size_t vl) {
+  vint8m2_t ret = vadd_generic(op0, op1, vl);
+  return ret;
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5120,6 +5120,7 @@
 #define GET_SVE_BUILTINS
 #define BUILTIN(name, types, attr) case SVE::BI##name:
 #include "clang/Basic/arm_sve_builtins.inc"
+#undef BUILTIN
 return true;
   }
 }
@@ -5146,6 +5147,44 @@
   D->addAttr(::new (S.Context) ArmBuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static bool RISCVAliasValid(unsigned BuiltinID, StringRef AliasName) {
+  switch (BuiltinID) {
+  default:
+  

[PATCH] D100968: Update shebang for clang-format-diff script to python3.

2021-04-22 Thread Paula Toth 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 rG71e80386d0fe: Update shebang for clang-format-diff script to 
python3. (authored by PaulkaToast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100968

Files:
  clang/tools/clang-format/clang-format-diff.py


Index: clang/tools/clang-format/clang-format-diff.py
===
--- clang/tools/clang-format/clang-format-diff.py
+++ clang/tools/clang-format/clang-format-diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- clang-format-diff.py - ClangFormat Diff Reformatter *- python 
-*--===#
 #


Index: clang/tools/clang-format/clang-format-diff.py
===
--- clang/tools/clang-format/clang-format-diff.py
+++ clang/tools/clang-format/clang-format-diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- clang-format-diff.py - ClangFormat Diff Reformatter *- python -*--===#
 #
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 71e8038 - Update shebang for clang-format-diff script to python3.

2021-04-22 Thread Paula Toth via cfe-commits

Author: Paula Toth
Date: 2021-04-22T06:47:51-07:00
New Revision: 71e80386d0fe7f7a2f997271ce5d492d5e8686c2

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

LOG: Update shebang for clang-format-diff script to python3.

Different distributions have different strategies migrating the `python` 
symlink. Debian and its derivatives provide `python-is-python2` and 
`python-is-python3`. If neither is installed, the user gets no 
`/usr/bin/python`. The clang-format-diff script and consequently `arc diff` can 
thus fail with a python not found error.  Since we require python greater than 
3.6 as part of llvm prerequisites 
(https://llvm.org/docs/GettingStarted.html#software), let's go ahead and update 
this shebang.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/tools/clang-format/clang-format-diff.py

Removed: 




diff  --git a/clang/tools/clang-format/clang-format-
diff .py b/clang/tools/clang-format/clang-format-
diff .py
index efed8168cc505..4edc0b2e19c29 100755
--- a/clang/tools/clang-format/clang-format-
diff .py
+++ b/clang/tools/clang-format/clang-format-
diff .py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- clang-format-
diff .py - ClangFormat Diff Reformatter *- python -*--===#
 #



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


[clang] 4138e7b - [OpenCL] Add missing C++ legacy atomics with generic

2021-04-22 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-04-22T15:08:36+01:00
New Revision: 4138e7bd7692c27a4959191939bba899b4f240da

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

LOG: [OpenCL] Add missing C++ legacy atomics with generic

https://reviews.llvm.org/D62335 added some C++ for OpenCL specific
builtins to opencl-c.h, but these were not mirrored to the TableGen
builtin functions yet.

The TableGen builtins machinery does not have dedicated version
handling for C++ for OpenCL at the moment: all builtin versioning is
tied to `LangOpts.OpenCLVersion` (i.e., the OpenCL C version).  As a
workaround, to add builtins that are only available in C++ for OpenCL,
we define a function extension guarded by the __cplusplus macro.

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

Fixes PR50041.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 5a9d9822dbfe3..eb8034ee630ce 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -82,6 +82,9 @@ def FuncExtKhrMipmapImage: 
FunctionExtension<"cl_khr_mipmap_imag
 def FuncExtKhrMipmapImageWrites  : 
FunctionExtension<"cl_khr_mipmap_image_writes">;
 def FuncExtKhrGlMsaaSharing  : 
FunctionExtension<"cl_khr_gl_msaa_sharing">;
 
+// Not a real extension, but a workaround to add C++ for OpenCL specific 
builtins.
+def FuncExtOpenCLCxx : FunctionExtension<"__cplusplus">;
+
 // Multiple extensions
 def FuncExtKhrMipmapWritesAndWrite3d : 
FunctionExtension<"cl_khr_mipmap_image_writes cl_khr_3d_image_writes">;
 
@@ -1077,6 +1080,17 @@ foreach AS = [GlobalAS, LocalAS] in {
 }
   }
 }
+
+let Extension = FuncExtOpenCLCxx in {
+  foreach Type = [Int, UInt] in {
+foreach name = ["atomic_add", "atomic_sub", "atomic_xchg",
+"atomic_min", "atomic_max", "atomic_and",
+"atomic_or", "atomic_xor"] in {
+  def : Builtin, GenericAS>, 
Type]>;
+}
+  }
+}
+
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 let MinVersion = CL20 in {
   def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 36bdcffbeca48..32457eb939c03 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -122,6 +122,17 @@ void test_atomic_fetch(volatile __generic atomic_int 
*a_int,
 }
 #endif
 
+// Test old atomic overloaded with generic address space in C++ for OpenCL.
+#if __OPENCL_C_VERSION__ >= 200
+void test_legacy_atomics_cpp(__generic volatile unsigned int *a) {
+  atomic_add(a, 1);
+#if !defined(__cplusplus)
+  // expected-error@-2{{no matching function for call to 'atomic_add'}}
+  // expected-note@-3 4 {{candidate function not viable}}
+#endif
+}
+#endif
+
 kernel void basic_conversion() {
   float f;
   char2 c2;



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


[PATCH] D100935: [OpenCL] Add missing C++ legacy atomics with generic

2021-04-22 Thread Sven van Haastregt 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 rG4138e7bd7692: [OpenCL] Add missing C++ legacy atomics with 
generic (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100935

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -122,6 +122,17 @@
 }
 #endif
 
+// Test old atomic overloaded with generic address space in C++ for OpenCL.
+#if __OPENCL_C_VERSION__ >= 200
+void test_legacy_atomics_cpp(__generic volatile unsigned int *a) {
+  atomic_add(a, 1);
+#if !defined(__cplusplus)
+  // expected-error@-2{{no matching function for call to 'atomic_add'}}
+  // expected-note@-3 4 {{candidate function not viable}}
+#endif
+}
+#endif
+
 kernel void basic_conversion() {
   float f;
   char2 c2;
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -82,6 +82,9 @@
 def FuncExtKhrMipmapImageWrites  : 
FunctionExtension<"cl_khr_mipmap_image_writes">;
 def FuncExtKhrGlMsaaSharing  : 
FunctionExtension<"cl_khr_gl_msaa_sharing">;
 
+// Not a real extension, but a workaround to add C++ for OpenCL specific 
builtins.
+def FuncExtOpenCLCxx : FunctionExtension<"__cplusplus">;
+
 // Multiple extensions
 def FuncExtKhrMipmapWritesAndWrite3d : 
FunctionExtension<"cl_khr_mipmap_image_writes cl_khr_3d_image_writes">;
 
@@ -1077,6 +1080,17 @@
 }
   }
 }
+
+let Extension = FuncExtOpenCLCxx in {
+  foreach Type = [Int, UInt] in {
+foreach name = ["atomic_add", "atomic_sub", "atomic_xchg",
+"atomic_min", "atomic_max", "atomic_and",
+"atomic_or", "atomic_xor"] in {
+  def : Builtin, GenericAS>, 
Type]>;
+}
+  }
+}
+
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 let MinVersion = CL20 in {
   def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -122,6 +122,17 @@
 }
 #endif
 
+// Test old atomic overloaded with generic address space in C++ for OpenCL.
+#if __OPENCL_C_VERSION__ >= 200
+void test_legacy_atomics_cpp(__generic volatile unsigned int *a) {
+  atomic_add(a, 1);
+#if !defined(__cplusplus)
+  // expected-error@-2{{no matching function for call to 'atomic_add'}}
+  // expected-note@-3 4 {{candidate function not viable}}
+#endif
+}
+#endif
+
 kernel void basic_conversion() {
   float f;
   char2 c2;
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -82,6 +82,9 @@
 def FuncExtKhrMipmapImageWrites  : FunctionExtension<"cl_khr_mipmap_image_writes">;
 def FuncExtKhrGlMsaaSharing  : FunctionExtension<"cl_khr_gl_msaa_sharing">;
 
+// Not a real extension, but a workaround to add C++ for OpenCL specific builtins.
+def FuncExtOpenCLCxx : FunctionExtension<"__cplusplus">;
+
 // Multiple extensions
 def FuncExtKhrMipmapWritesAndWrite3d : FunctionExtension<"cl_khr_mipmap_image_writes cl_khr_3d_image_writes">;
 
@@ -1077,6 +1080,17 @@
 }
   }
 }
+
+let Extension = FuncExtOpenCLCxx in {
+  foreach Type = [Int, UInt] in {
+foreach name = ["atomic_add", "atomic_sub", "atomic_xchg",
+"atomic_min", "atomic_max", "atomic_and",
+"atomic_or", "atomic_xor"] in {
+  def : Builtin, GenericAS>, Type]>;
+}
+  }
+}
+
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 let MinVersion = CL20 in {
   def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, MemoryScope]>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 362958a - [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-22 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-04-22T15:28:04+01:00
New Revision: 362958ac7346ba3539f819e9fe93d2529caad1e8

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

LOG: [C++4OpenCL] Add extra diagnostics for kernel argument types

Add restrictions on type layout (PR48099):
- Types passed by pointer or reference must be standard layout types.
- Types passed by value must be POD types.

Patch by olestrohm (Ole Strohm)!

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaOpenCLCXX/invalid-kernel.clcpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d1dc9db5abd7f..8a718249d8549 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8648,7 +8648,7 @@ static bool isOpenCLSizeDependentType(ASTContext &C, 
QualType Ty) {
 }
 
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
-  if (PT->isPointerType()) {
+  if (PT->isPointerType() || PT->isReferenceType()) {
 QualType PointeeType = PT->getPointeeType();
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
@@ -8665,6 +8665,15 @@ static OpenCLParamType getOpenCLKernelParameterType(Sema 
&S, QualType PT) {
 
   return PtrPtrKernelParam;
 }
+
+// C++ for OpenCL v1.0 s2.4:
+// Moreover the types used in parameters of the kernel functions must be:
+// Standard layout types for pointer parameters. The same applies to
+// reference if an implementation supports them in kernel parameters.
+if (S.getLangOpts().OpenCLCPlusPlus && !PointeeType->isAtomicType() &&
+!PointeeType->isVoidType() && !PointeeType->isStandardLayoutType())
+  return InvalidKernelParam;
+
 return PtrKernelParam;
   }
 
@@ -8689,9 +8698,6 @@ static OpenCLParamType getOpenCLKernelParameterType(Sema 
&S, QualType PT) {
   PT->isHalfType())
 return InvalidKernelParam;
 
-  if (PT->isRecordType())
-return RecordKernelParam;
-
   // Look into an array argument to check if it has a forbidden type.
   if (PT->isArrayType()) {
 const Type *UnderlyingTy = PT->getPointeeOrArrayElementType();
@@ -8701,6 +8707,17 @@ static OpenCLParamType getOpenCLKernelParameterType(Sema 
&S, QualType PT) {
 return getOpenCLKernelParameterType(S, QualType(UnderlyingTy, 0));
   }
 
+  // C++ for OpenCL v1.0 s2.4:
+  // Moreover the types used in parameters of the kernel functions must be:
+  // Trivial and standard-layout types C++17 [basic.types] (plain old data
+  // types) for parameters passed by value;
+  if (S.getLangOpts().OpenCLCPlusPlus && !PT->isOpenCLSpecificType() &&
+  !PT.isPODType(S.Context))
+return InvalidKernelParam;
+
+  if (PT->isRecordType())
+return RecordKernelParam;
+
   return ValidKernelParam;
 }
 

diff  --git a/clang/test/SemaOpenCLCXX/invalid-kernel.clcpp 
b/clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
index 2cbfffd5a00e9..977d487928b65 100644
--- a/clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
+++ b/clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
@@ -5,6 +5,7 @@ struct C {
 };
 
 template 
+//expected-error@+1{{'T' cannot be used as the type of a kernel parameter}}
 kernel void templ(T par) { //expected-error{{kernel functions cannot be used 
in a template declaration, instantiation or specialization}}
 }
 
@@ -15,3 +16,58 @@ kernel void bar(int par) { //expected-error{{kernel 
functions cannot be used in
 kernel void foo(int); //expected-note{{previous declaration is here}}
 
 kernel void foo(float); //expected-error{{conflicting types for 'foo'}}
+
+kernel void int_v(int in);
+kernel void int_p(__global int *in);
+kernel void int_r(__global int &in);
+kernel void int_p_p(__global int *__global *in);
+kernel void int_p_r(__global int *__global &in);
+kernel void int_p_p_r(__global int *__global *__global &in);
+
+// expected-error@+1{{'__private atomic_int' (aka '__private _Atomic(int)') 
cannot be used as the type of a kernel parameter}}
+kernel void k_atomic_v(atomic_int in);
+kernel void k_atomic_p(__global atomic_int *in);
+kernel void k_atomic_r(__global atomic_int &in);
+
+kernel void k_pipe(read_only pipe int in, write_only pipe int out);
+kernel void k_sampler(sampler_t in);
+kernel void k_void(__global void *in);
+
+typedef int int4 __attribute__((ext_vector_type(4)));
+
+kernel void int4_v(int4 in);
+kernel void int4_p(__global int4 *in);
+kernel void int4_p_p(__global int4 *__global *in);
+kernel void int4_r(__global int4 &in);
+
+struct POD {
+  int a;
+  int b;
+};
+
+kernel void pod_v(POD in) {}
+kernel void pod_p(__global POD *in) {}
+kernel void pod_p_p(__global POD *__global *in) {}
+kernel void pod_r(__global POD &in) {}
+
+struct 

[PATCH] D100471: [C++4OpenCL] Add extra diagnostics for kernel argument types

2021-04-22 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG362958ac7346: [C++4OpenCL] Add extra diagnostics for kernel 
argument types (authored by Anastasia).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100471

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCLCXX/invalid-kernel.clcpp

Index: clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
===
--- clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
+++ clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
@@ -5,6 +5,7 @@
 };
 
 template 
+//expected-error@+1{{'T' cannot be used as the type of a kernel parameter}}
 kernel void templ(T par) { //expected-error{{kernel functions cannot be used in a template declaration, instantiation or specialization}}
 }
 
@@ -15,3 +16,58 @@
 kernel void foo(int); //expected-note{{previous declaration is here}}
 
 kernel void foo(float); //expected-error{{conflicting types for 'foo'}}
+
+kernel void int_v(int in);
+kernel void int_p(__global int *in);
+kernel void int_r(__global int &in);
+kernel void int_p_p(__global int *__global *in);
+kernel void int_p_r(__global int *__global &in);
+kernel void int_p_p_r(__global int *__global *__global &in);
+
+// expected-error@+1{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
+kernel void k_atomic_v(atomic_int in);
+kernel void k_atomic_p(__global atomic_int *in);
+kernel void k_atomic_r(__global atomic_int &in);
+
+kernel void k_pipe(read_only pipe int in, write_only pipe int out);
+kernel void k_sampler(sampler_t in);
+kernel void k_void(__global void *in);
+
+typedef int int4 __attribute__((ext_vector_type(4)));
+
+kernel void int4_v(int4 in);
+kernel void int4_p(__global int4 *in);
+kernel void int4_p_p(__global int4 *__global *in);
+kernel void int4_r(__global int4 &in);
+
+struct POD {
+  int a;
+  int b;
+};
+
+kernel void pod_v(POD in) {}
+kernel void pod_p(__global POD *in) {}
+kernel void pod_p_p(__global POD *__global *in) {}
+kernel void pod_r(__global POD &in) {}
+
+struct StandardLayout {
+  int a;
+  int b;
+  StandardLayout(int a, int b) : a(a), b(b) {}
+};
+
+kernel void standard_v(StandardLayout in) {} //expected-error{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
+kernel void standard_p(__global StandardLayout *in) {}
+kernel void standard_p_p(__global StandardLayout *__global *in) {}
+kernel void standard_r(__global StandardLayout &in) {}
+
+struct Trivial {
+  int a;
+private:
+  int b;
+};
+
+kernel void trivial_v(Trivial in) {} //expected-error{{'__private Trivial' cannot be used as the type of a kernel parameter}}
+kernel void trivial_p(__global Trivial *in) {} //expected-error{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
+kernel void trivial_p_p(__global Trivial *__global *in) {} //expected-error{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
+kernel void trivial_r(__global Trivial &in) {} //expected-error{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8648,7 +8648,7 @@
 }
 
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
-  if (PT->isPointerType()) {
+  if (PT->isPointerType() || PT->isReferenceType()) {
 QualType PointeeType = PT->getPointeeType();
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
@@ -8665,6 +8665,15 @@
 
   return PtrPtrKernelParam;
 }
+
+// C++ for OpenCL v1.0 s2.4:
+// Moreover the types used in parameters of the kernel functions must be:
+// Standard layout types for pointer parameters. The same applies to
+// reference if an implementation supports them in kernel parameters.
+if (S.getLangOpts().OpenCLCPlusPlus && !PointeeType->isAtomicType() &&
+!PointeeType->isVoidType() && !PointeeType->isStandardLayoutType())
+  return InvalidKernelParam;
+
 return PtrKernelParam;
   }
 
@@ -8689,9 +8698,6 @@
   PT->isHalfType())
 return InvalidKernelParam;
 
-  if (PT->isRecordType())
-return RecordKernelParam;
-
   // Look into an array argument to check if it has a forbidden type.
   if (PT->isArrayType()) {
 const Type *UnderlyingTy = PT->getPointeeOrArrayElementType();
@@ -8701,6 +8707,17 @@
 return getOpenCLKernelParameterType(S, QualType(UnderlyingTy, 0));
   }
 
+  // C++ for OpenCL v1.0 s2.4:
+  // Moreover the types used in parameters of the kernel functions must be:
+  // Trivial and standard-layout types C++17 [basic.types] (plain old data
+  // types) for parameters passed by value;
+  if (S.getLangOpts()

[PATCH] D100860: [C++4OpenCL] Add missing OpenCL specific diagnostics in templates

2021-04-22 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

> I've left the check during parsing as well, because it provides slightly 
> better error messages

Do you have an example of what error messages get worse if you remove the 
parsing check?  Just wondering if there is an easy way to fix that and avoid 
having the check twice.


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

https://reviews.llvm.org/D100860

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


[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

2021-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 339625.
whisperity added a comment.

**NFC** Fix the header guard name lint again, hopefully to the proper value 
this time. I forgot the `CHECK` out of it...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-suspicious-call-argument.cpp
@@ -0,0 +1,477 @@
+// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t -- -- -std=c++11
+
+void foo_1(int aa, int bb) {}
+
+void foo_2(int source, int aa) {}
+
+void foo_3(int valToRet, int aa) {}
+
+void foo_4(int pointer, int aa) {}
+
+void foo_5(int aa, int bb, int cc, ...) {}
+
+void foo_6(const int dd, bool &ee) {}
+
+void foo_7(int aa, int bb, int cc, int ff = 7) {}
+
+void foo_8(int frobble1, int frobble2) {}
+
+// Test functions for convertible argument--parameter types.
+void fun(const int &m);
+void fun2() {
+  int m = 3;
+  fun(m);
+}
+
+// Test cases for parameters of const reference and value.
+void value_const_reference(int ll, const int &kk);
+
+void const_ref_value_swapped() {
+  const int &kk = 42;
+  const int &ll = 42;
+  value_const_reference(kk, ll);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'kk' (passed to 'll') looks like it might be swapped with the 2nd, 'll' (passed to 'kk') [readability-suspicious-call-argument]
+  // CHECK-MESSAGES: :[[@LINE-7]]:6: note: in the call to 'value_const_reference', declared here
+}
+
+// Const, non const references.
+void const_nonconst_parameters(const int &mm, int &nn);
+
+void const_nonconst_swap1() {
+  const int &nn = 42;
+  int mm;
+  // Do not check, because non-const reference parameter cannot bind to const reference argument.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap3() {
+  const int nn = 42;
+  int m = 42;
+  int &mm = m;
+  // Do not check, const int does not bind to non const reference.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap2() {
+  int nn;
+  int mm;
+  // Check for swapped arguments. (Both arguments are non-const.)
+  const_nonconst_parameters(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+void const_nonconst_pointers(const int *mm, int *nn);
+void const_nonconst_pointers2(const int *mm, const int *nn);
+
+void const_nonconst_pointers_swapped() {
+  int *mm;
+  const int *nn;
+  const_nonconst_pointers(nn, mm);
+}
+
+void const_nonconst_pointers_swapped2() {
+  const int *mm;
+  int *nn;
+  const_nonconst_pointers2(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'nn' (passed to 'mm') looks like it might be swapped with the 2nd, 'mm' (passed to 'nn')
+}
+
+// Test cases for pointers and arrays.
+void pointer_array_parameters(
+int *pp, int qq[4]);
+
+void pointer_array_swap() {
+  int qq[5];
+  int *pp;
+  // Check for swapped arguments. An array implicitly converts to a pointer.
+  pointer_array_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'qq' (passed to 'pp') looks like it might be swapped with the 2nd, 'pp' (passed to 'qq')
+}
+
+// Test cases for multilevel pointers.
+void multilevel_pointer_parameters(int *const **pp,
+   const int *const *volatile const *qq);
+void multilevel_pointer_parameters2(
+char *nn, char *volatile *const *const *const *const &mm);
+
+typedef float T;
+typedef T *S;
+typedef S *const volatile R;
+typedef R *Q;
+typedef Q *P;
+typedef P *O;
+void multilevel_pointer_parameters3(float **const volatile ***rr, O &ss);
+
+void multilevel_pointer_swap() {
+  int *const **qq;
+  int *const **pp;
+  multilevel_pointer_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'qq' (passed to 'pp') looks like it might be swapped with the 2nd, 'pp' 

[PATCH] D68891: Remove unnecessary triple from test

2021-04-22 Thread Yuki Okushi via Phabricator via cfe-commits
JohnTitor added a comment.

Ping @cfe-commits


Repository:
  rC Clang

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

https://reviews.llvm.org/D68891

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


[PATCH] D101070: Make `llvm_install_symlink` robust with respect to absolute dirs.

2021-04-22 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 created this revision.
Herald added a subscriber: mgorny.
Ericson2314 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

If `CMAKE_INSTALL_BINDIR` is a different absolute path per project, as
it is with NixOS when we install every package to its own prefix, the
old way fails when the downstream packages try to install symlinks in
the now-immutable `LLVM_TOOLS_INSTALL_DIR`.

The new way ensures the downstream projects' prefixes will be used
instead, as desired.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101070

Files:
  clang/cmake/modules/AddClang.cmake
  flang/cmake/modules/AddFlang.cmake
  lld/cmake/modules/AddLLD.cmake
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1875,7 +1875,7 @@
 
 endfunction()
 
-function(llvm_install_symlink name dest)
+function(llvm_install_symlink name dest output_dir)
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
   foreach(path ${CMAKE_MODULE_PATH})
 if(EXISTS ${path}/LLVMInstallSymlink.cmake)
@@ -1898,7 +1898,7 @@
   set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
 
   install(SCRIPT ${INSTALL_SYMLINK}
-  CODE "install_symlink(${full_name} ${full_dest} 
${LLVM_TOOLS_INSTALL_DIR})"
+  CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
   COMPONENT ${component})
 
   if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
@@ -1981,7 +1981,8 @@
 endif()
 
 if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND 
LLVM_BUILD_TOOLS)
-  llvm_install_symlink(${link_name} ${target})
+  GNUInstallDirs_get_absolute_install_dir(output_dir 
LLVM_TOOLS_INSTALL_DIR)
+  llvm_install_symlink(${link_name} ${target} ${output_dir})
 endif()
   endif()
 endfunction()
Index: lld/cmake/modules/AddLLD.cmake
===
--- lld/cmake/modules/AddLLD.cmake
+++ lld/cmake/modules/AddLLD.cmake
@@ -69,5 +69,5 @@
 macro(add_lld_symlink name dest)
   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
   # Always generate install targets
-  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+  llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} 
ALWAYS_GENERATE)
 endmacro()
Index: flang/cmake/modules/AddFlang.cmake
===
--- flang/cmake/modules/AddFlang.cmake
+++ flang/cmake/modules/AddFlang.cmake
@@ -134,6 +134,6 @@
 macro(add_flang_symlink name dest)
   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
   # Always generate install targets
-  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+  llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} 
ALWAYS_GENERATE)
 endmacro()
 
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -185,7 +185,7 @@
 macro(add_clang_symlink name dest)
   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
   # Always generate install targets
-  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+  llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} 
ALWAYS_GENERATE)
 endmacro()
 
 function(clang_target_link_libraries target type)


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1875,7 +1875,7 @@
 
 endfunction()
 
-function(llvm_install_symlink name dest)
+function(llvm_install_symlink name dest output_dir)
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
   foreach(path ${CMAKE_MODULE_PATH})
 if(EXISTS ${path}/LLVMInstallSymlink.cmake)
@@ -1898,7 +1898,7 @@
   set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
 
   install(SCRIPT ${INSTALL_SYMLINK}
-  CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})"
+  CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
   COMPONENT ${component})
 
   if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
@@ -1981,7 +1981,8 @@
 endif()
 
 if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
-  llvm_install_symlink(${link_name} ${target})
+  GNUInstallDirs_get_absolute_install_dir(output_dir LLVM_TOOLS_INSTALL_DIR)
+  llvm_install_symlink(${link_name} ${target} ${output_dir})
 endif()
   endif()
 endfunction()
Index: lld/cmake/modules/AddLLD.cmake
===
--- lld/cmake/modules/AddLLD.cmake
+++ lld/cmake/modules/AddLLD.cmake
@@ -69,5 +69,5 @@
 macro(add_lld_symlink name dest)
   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENER

[clang] 3a46667 - [PowerPC] Add vec_roundm as alias for vec_floor in altivec.h

2021-04-22 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-04-22T10:30:59-05:00
New Revision: 3a466670595a9d4d41b1e221ac0f76183c5d096b

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

LOG: [PowerPC] Add vec_roundm as alias for vec_floor in altivec.h

Add the overloads for compatibility with XLC.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 878fe666dad5..8486f97d2fa2 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -3729,6 +3729,15 @@ static __inline__ vector double __ATTRS_o_ai 
vec_floor(vector double __a) {
 }
 #endif
 
+/* vec_roundm */
+static __inline__ vector float __ATTRS_o_ai vec_roundm(vector float __a) {
+  return vec_floor(__a);
+}
+
+static __inline__ vector double __ATTRS_o_ai vec_roundm(vector double __a) {
+  return vec_floor(__a);
+}
+
 /* vec_vrfim */
 
 static __inline__ vector float __attribute__((__always_inline__))

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index 5389979722d8..94924237ce2c 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -773,6 +773,14 @@ void test1() {
 
   res_vd = vec_floor(vd);
 // CHECK: call <2 x double> @llvm.floor.v2f64(<2 x double> %{{[0-9]+}})
+// CHECK-LE: call <2 x double> @llvm.floor.v2f64(<2 x double> %{{[0-9]+}})
+
+  res_vf = vec_roundm(vf);
+// CHECK: call <4 x float> @llvm.floor.v4f32(<4 x float> %{{[0-9]+}})
+// CHECK-LE: call <4 x float> @llvm.floor.v4f32(<4 x float> %{{[0-9]+}})
+
+  res_vd = vec_roundm(vd);
+// CHECK: call <2 x double> @llvm.floor.v2f64(<2 x double> %{{[0-9]+}})
 // CHECK-LE: call <2 x double> @llvm.floor.v2f64(<2 x double> %{{[0-9]+}})
 
   res_vf = vec_madd(vf, vf, vf);



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


[clang] 51692c6 - [PowerPC] Add missing VSX guard for vec_roundm with vector double

2021-04-22 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-04-22T10:30:59-05:00
New Revision: 51692c6c630dfa9521af47b3c0c14d9f05f25375

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

LOG: [PowerPC] Add missing VSX guard for vec_roundm with vector double

The guard was missed in the previous commit.

Added: 


Modified: 
clang/lib/Headers/altivec.h

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 8486f97d2fa2..b806aa9a55ce 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -3734,9 +3734,11 @@ static __inline__ vector float __ATTRS_o_ai 
vec_roundm(vector float __a) {
   return vec_floor(__a);
 }
 
+#ifdef __VSX__
 static __inline__ vector double __ATTRS_o_ai vec_roundm(vector double __a) {
   return vec_floor(__a);
 }
+#endif
 
 /* vec_vrfim */
 



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


[clang] 1550c47 - [PowerPC] Add vec_roundp as alias for vec_ceil

2021-04-22 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-04-22T10:30:59-05:00
New Revision: 1550c47c18f05800b20af071da50881ffd996254

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

LOG: [PowerPC] Add vec_roundp as alias for vec_ceil

Add the overloads for compatibility with XLC.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index b806aa9a55ce..a47d5f90dbe2 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -1627,6 +1627,17 @@ static __inline__ vector double __ATTRS_o_ai 
vec_ceil(vector double __a) {
 }
 #endif
 
+/* vec_roundp */
+static __inline__ vector float __ATTRS_o_ai vec_roundp(vector float __a) {
+  return vec_ceil(__a);
+}
+
+#ifdef __VSX__
+static __inline__ vector double __ATTRS_o_ai vec_roundp(vector double __a) {
+  return vec_ceil(__a);
+}
+#endif
+
 /* vec_vrfip */
 
 static __inline__ vector float __attribute__((__always_inline__))

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index 94924237ce2c..87cd776e2694 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -278,6 +278,14 @@ void test1() {
 
   res_vf = vec_ceil(vf);
 // CHECK: call <4 x float> @llvm.ceil.v4f32(<4 x float> %{{[0-9]*}})
+// CHECK-LE: call <4 x float> @llvm.ceil.v4f32(<4 x float> %{{[0-9]*}})
+
+  res_vd = vec_roundp(vd);
+// CHECK: call <2 x double> @llvm.ceil.v2f64(<2 x double> %{{[0-9]*}})
+// CHECK-LE: call <2 x double> @llvm.ceil.v2f64(<2 x double> %{{[0-9]*}})
+
+  res_vf = vec_roundp(vf);
+// CHECK: call <4 x float> @llvm.ceil.v4f32(<4 x float> %{{[0-9]*}})
 // CHECK-LE: call <4 x float> @llvm.ceil.v4f32(<4 x float> %{{[0-9]*}})
 
   res_vbll = vec_cmpeq(vd, vd);



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


[clang] a1d325a - [PowerPC] Add vec_roundz as alias for vec_trunc in altivec.h

2021-04-22 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-04-22T10:31:00-05:00
New Revision: a1d325af6708ebd8ac9efb8d2d148f16feeda3fd

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

LOG: [PowerPC] Add vec_roundz as alias for vec_trunc in altivec.h

Add the overloads for compatibility with XLC.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index a47d5f90dbe2..1ffc46988721 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -12145,6 +12145,17 @@ static __inline__ vector double __ATTRS_o_ai 
vec_trunc(vector double __a) {
 }
 #endif
 
+/* vec_roundz */
+static __inline__ vector float __ATTRS_o_ai vec_roundz(vector float __a) {
+  return vec_trunc(__a);
+}
+
+#ifdef __VSX__
+static __inline__ vector double __ATTRS_o_ai vec_roundz(vector double __a) {
+  return vec_trunc(__a);
+}
+#endif
+
 /* vec_vrfiz */
 
 static __inline__ vector float __attribute__((__always_inline__))

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index 87cd776e2694..ad27b823bcda 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -1151,6 +1151,14 @@ void test1() {
 
   res_vd = vec_trunc(vd);
 // CHECK: call <2 x double> @llvm.trunc.v2f64(<2 x double> %{{[0-9]+}})
+// CHECK-LE: call <2 x double> @llvm.trunc.v2f64(<2 x double> %{{[0-9]+}})
+
+  res_vf = vec_roundz(vf);
+// CHECK: call <4 x float> @llvm.trunc.v4f32(<4 x float> %{{[0-9]+}})
+// CHECK-LE: call <4 x float> @llvm.trunc.v4f32(<4 x float> %{{[0-9]+}})
+
+  res_vd = vec_roundz(vd);
+// CHECK: call <2 x double> @llvm.trunc.v2f64(<2 x double> %{{[0-9]+}})
 // CHECK-LE: call <2 x double> @llvm.trunc.v2f64(<2 x double> %{{[0-9]+}})
 
   /* vec_vor */



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


[clang] a0e6189 - [PowerPC] Add vec_xlds to altivec.h

2021-04-22 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-04-22T10:31:00-05:00
New Revision: a0e6189712297fd9a25723384039418bc68e8e9f

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

LOG: [PowerPC] Add vec_xlds to altivec.h

Add these overloads for compatibility with XLC. This is a doubleword
load-and-splat.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 1ffc46988721..e48650602c78 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -17405,6 +17405,24 @@ vec_xl_zext(ptr
diff _t __offset, const unsigned long long *__pointer) {
 
 #endif
 
+/* vec_xlds */
+#ifdef __VSX__
+static __inline__ vector signed long long __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const signed long long *__ptr) {
+  signed long long *__addr = (signed char *)__ptr + __offset;
+  return (vector signed long long) *__addr;
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const unsigned long long *__ptr) {
+  unsigned long long *__addr = (signed char *)__ptr + __offset;
+  return (unaligned_vec_ull) *__addr;
+}
+
+static __inline__ vector double __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const double *__ptr) {
+  double *__addr = (signed char *)__ptr + __offset;
+  return (unaligned_vec_double) *__addr;
+}
+#endif
+
 /* vec_xst */
 
 #define vec_xstd2 vec_xst

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index ad27b823bcda..f77cd5a1528d 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -1948,6 +1948,30 @@ res_vd = vec_xl_be(sll, ad);
 // CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 1
 // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
 
+res_vsll = vec_xlds(sll, asll);
+// CHECK: load i64
+// CHECK: insertelement <2 x i64>
+// CHECK: shufflevector <2 x i64>
+// CHECK-LE: load i64
+// CHECK-LE: insertelement <2 x i64>
+// CHECK-LE: shufflevector <2 x i64>
+
+res_vull = vec_xlds(sll, aull);
+// CHECK: load i64
+// CHECK: insertelement <2 x i64>
+// CHECK: shufflevector <2 x i64>
+// CHECK-LE: load i64
+// CHECK-LE: insertelement <2 x i64>
+// CHECK-LE: shufflevector <2 x i64>
+
+res_vd = vec_xlds(sll, ad);
+// CHECK: load double
+// CHECK: insertelement <2 x double>
+// CHECK: shufflevector <2 x double>
+// CHECK-LE: load double
+// CHECK-LE: insertelement <2 x double>
+// CHECK-LE: shufflevector <2 x double>
+
 vec_xst_be(vsll, sll, asll);
 // CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 1
 // CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* 
%{{[0-9]+}})



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


[clang] e43963d - [PowerPC] Add vec_load_splats to altivec.h

2021-04-22 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-04-22T10:31:00-05:00
New Revision: e43963db24f68582edba8b227432714c60eac0c9

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

LOG: [PowerPC] Add vec_load_splats to altivec.h

Add these overloads for compatibility with XLC. This is a word
load-and-splat.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index e48650602c78..48b43cb78374 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -17407,20 +17407,60 @@ vec_xl_zext(ptr
diff _t __offset, const unsigned long long *__pointer) {
 
 /* vec_xlds */
 #ifdef __VSX__
-static __inline__ vector signed long long __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const signed long long *__ptr) {
+static __inline__ vector signed long long __ATTRS_o_ai
+vec_xlds(ptr
diff _t __offset, const signed long long *__ptr) {
   signed long long *__addr = (signed char *)__ptr + __offset;
   return (vector signed long long) *__addr;
 }
 
-static __inline__ vector unsigned long long __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const unsigned long long *__ptr) {
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_xlds(ptr
diff _t __offset, const unsigned long long *__ptr) {
   unsigned long long *__addr = (signed char *)__ptr + __offset;
   return (unaligned_vec_ull) *__addr;
 }
 
-static __inline__ vector double __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const double *__ptr) {
+static __inline__ vector double __ATTRS_o_ai vec_xlds(ptr
diff _t __offset,
+  const double *__ptr) {
   double *__addr = (signed char *)__ptr + __offset;
   return (unaligned_vec_double) *__addr;
 }
+
+/* vec_load_splats */
+static __inline__ vector signed int __ATTRS_o_ai
+vec_load_splats(signed long long __offset, const signed int *__ptr) {
+  signed int *__addr = (signed char *)__ptr + __offset;
+  return (vector signed int)*__addr;
+}
+
+static __inline__ vector signed int __ATTRS_o_ai
+vec_load_splats(unsigned long long __offset, const signed int *__ptr) {
+  signed int *__addr = (signed char *)__ptr + __offset;
+  return (vector signed int)*__addr;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_load_splats(signed long long __offset, const unsigned int *__ptr) {
+  unsigned int *__addr = (signed char *)__ptr + __offset;
+  return (vector unsigned int)*__addr;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_load_splats(unsigned long long __offset, const unsigned int *__ptr) {
+  unsigned int *__addr = (signed char *)__ptr + __offset;
+  return (vector unsigned int)*__addr;
+}
+
+static __inline__ vector float __ATTRS_o_ai
+vec_load_splats(signed long long __offset, const float *__ptr) {
+  float *__addr = (signed char *)__ptr + __offset;
+  return (vector float)*__addr;
+}
+
+static __inline__ vector float __ATTRS_o_ai
+vec_load_splats(unsigned long long __offset, const float *__ptr) {
+  float *__addr = (signed char *)__ptr + __offset;
+  return (vector float)*__addr;
+}
 #endif
 
 /* vec_xst */

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index f77cd5a1528d..a8eaf341e8fc 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -1972,6 +1972,54 @@ res_vd = vec_xlds(sll, ad);
 // CHECK-LE: insertelement <2 x double>
 // CHECK-LE: shufflevector <2 x double>
 
+res_vsll = vec_load_splats(sll, asi);
+// CHECK: load i32
+// CHECK: insertelement <4 x i32>
+// CHECK: shufflevector <4 x i32>
+// CHECK-LE: load i32
+// CHECK-LE: insertelement <4 x i32>
+// CHECK-LE: shufflevector <4 x i32>
+
+res_vsll = vec_load_splats(ull, asi);
+// CHECK: load i32
+// CHECK: insertelement <4 x i32>
+// CHECK: shufflevector <4 x i32>
+// CHECK-LE: load i32
+// CHECK-LE: insertelement <4 x i32>
+// CHECK-LE: shufflevector <4 x i32>
+
+res_vsll = vec_load_splats(sll, aui);
+// CHECK: load i32
+// CHECK: insertelement <4 x i32>
+// CHECK: shufflevector <4 x i32>
+// CHECK-LE: load i32
+// CHECK-LE: insertelement <4 x i32>
+// CHECK-LE: shufflevector <4 x i32>
+
+res_vsll = vec_load_splats(ull, aui);
+// CHECK: load i32
+// CHECK: insertelement <4 x i32>
+// CHECK: shufflevector <4 x i32>
+// CHECK-LE: load i32
+// CHECK-LE: insertelement <4 x i32>
+// CHECK-LE: shufflevector <4 x i32>
+
+res_vsll = vec_load_splats(sll, af);
+// CHECK: load float
+// CHECK: insertelement <4 x float>
+// CHECK: shufflevector <4 x float>
+// CHECK-LE: load float
+// CHECK-LE: insertelement <4 x float>
+// CHECK-LE: shufflevector <4 x float>
+
+res_vsll = vec_load_splats(ull, af);
+// CHECK: load float
+// CHECK: insertelement <4 x float>
+// CHECK: shuffleve

[clang] 1cc1d9d - [PowerPC] Add vec_vclz as an alias for vec_cntlz in altivec.h

2021-04-22 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-04-22T10:31:00-05:00
New Revision: 1cc1d9db286c7fbd0ff0a0757c2da2a5a6fc54a8

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

LOG: [PowerPC] Add vec_vclz as an alias for vec_cntlz in altivec.h

Another addition for compatibility with XLC. The functions have the
same overloads so just add it as a preprocessor define.

Added: 


Modified: 
clang/lib/Headers/altivec.h

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 48b43cb78374..4eac243ef2d5 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -2400,6 +2400,7 @@ vec_popcnt(vector unsigned long long __a) {
   return __builtin_altivec_vpopcntd(__a);
 }
 
+#define vec_vclz vec_cntlz
 /* vec_cntlz */
 
 static __inline__ vector signed char __ATTRS_o_ai



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


[clang] 7a5641d - [PowerPC] Add missing casts for vec_xlds and vec_load_splats

2021-04-22 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-04-22T10:31:00-05:00
New Revision: 7a5641d651963e91b05f25667df6cc694503248f

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

LOG: [PowerPC] Add missing casts for vec_xlds and vec_load_splats

The previous commits just missed some pointer casts and ended up
producing warnings.

Added: 


Modified: 
clang/lib/Headers/altivec.h

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 4eac243ef2d5..57d7828f5285 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -17410,56 +17410,56 @@ vec_xl_zext(ptr
diff _t __offset, const unsigned long long *__pointer) {
 #ifdef __VSX__
 static __inline__ vector signed long long __ATTRS_o_ai
 vec_xlds(ptr
diff _t __offset, const signed long long *__ptr) {
-  signed long long *__addr = (signed char *)__ptr + __offset;
+  signed long long *__addr = (signed long long*)((signed char *)__ptr + 
__offset);
   return (vector signed long long) *__addr;
 }
 
 static __inline__ vector unsigned long long __ATTRS_o_ai
 vec_xlds(ptr
diff _t __offset, const unsigned long long *__ptr) {
-  unsigned long long *__addr = (signed char *)__ptr + __offset;
+  unsigned long long *__addr = (unsigned long long *)((signed char *)__ptr + 
__offset);
   return (unaligned_vec_ull) *__addr;
 }
 
 static __inline__ vector double __ATTRS_o_ai vec_xlds(ptr
diff _t __offset,
   const double *__ptr) {
-  double *__addr = (signed char *)__ptr + __offset;
+  double *__addr = (double*)((signed char *)__ptr + __offset);
   return (unaligned_vec_double) *__addr;
 }
 
 /* vec_load_splats */
 static __inline__ vector signed int __ATTRS_o_ai
 vec_load_splats(signed long long __offset, const signed int *__ptr) {
-  signed int *__addr = (signed char *)__ptr + __offset;
+  signed int *__addr = (signed int*)((signed char *)__ptr + __offset);
   return (vector signed int)*__addr;
 }
 
 static __inline__ vector signed int __ATTRS_o_ai
 vec_load_splats(unsigned long long __offset, const signed int *__ptr) {
-  signed int *__addr = (signed char *)__ptr + __offset;
+  signed int *__addr = (signed int*)((signed char *)__ptr + __offset);
   return (vector signed int)*__addr;
 }
 
 static __inline__ vector unsigned int __ATTRS_o_ai
 vec_load_splats(signed long long __offset, const unsigned int *__ptr) {
-  unsigned int *__addr = (signed char *)__ptr + __offset;
+  unsigned int *__addr = (unsigned int*)((signed char *)__ptr + __offset);
   return (vector unsigned int)*__addr;
 }
 
 static __inline__ vector unsigned int __ATTRS_o_ai
 vec_load_splats(unsigned long long __offset, const unsigned int *__ptr) {
-  unsigned int *__addr = (signed char *)__ptr + __offset;
+  unsigned int *__addr = (unsigned int*)((signed char *)__ptr + __offset);
   return (vector unsigned int)*__addr;
 }
 
 static __inline__ vector float __ATTRS_o_ai
 vec_load_splats(signed long long __offset, const float *__ptr) {
-  float *__addr = (signed char *)__ptr + __offset;
+  float *__addr = (float*)((signed char *)__ptr + __offset);
   return (vector float)*__addr;
 }
 
 static __inline__ vector float __ATTRS_o_ai
 vec_load_splats(unsigned long long __offset, const float *__ptr) {
-  float *__addr = (signed char *)__ptr + __offset;
+  float *__addr = (float*)((signed char *)__ptr + __offset);
   return (vector float)*__addr;
 }
 #endif



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


[PATCH] D91054: [Clang][OpenMP] Frontend work for sections - D89671

2021-04-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

What is missing or not working in the IRBuilder impl that prevents us from 
turning it on by default?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91054

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


[PATCH] D91054: [Clang][OpenMP] Frontend work for sections - D89671

2021-04-22 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag added a comment.

In D91054#2708873 , @jdoerfert wrote:

> What is missing or not working in the IRBuilder impl that prevents us from 
> turning it on by default?

Per the `TODO` in this patch (`CGStmtOpenMP.cpp - 3775`), 
`PrivatizationCallback` is not working right now.
I can't think of anything else. The test cases are all working so there's that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91054

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


[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: yaxunl, t-tye, kzhuravl, ronlieb, b-sumner, 
pdhaliwal.
Herald added subscribers: kerbowa, tpr, dstuttard, nhaehnle, jvesely.
JonChesterfield requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

[clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

Separates detection of deprecated or invalid code object version from
returning the version. Written to avoid any behaviour change.

Precursor to a revision of D98746 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101077

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/HIP.cpp

Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -112,7 +112,7 @@
   // for backward compatibility. For code object version 4 and greater, the
   // offload kind in bundle ID is 'hipv4'.
   std::string OffloadKind = "hip";
-  if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+  if (getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
 OffloadKind = OffloadKind + "v4";
   for (const auto &II : Inputs) {
 const auto* A = II.getAction();
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -138,9 +138,11 @@
 void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, bool IsLTO);
 
-unsigned getOrCheckAMDGPUCodeObjectVersion(const Driver &D,
-   const llvm::opt::ArgList &Args,
-   bool Diagnose = false);
+void checkAMDGPUCodeObjectVersion(const Driver &D,
+  const llvm::opt::ArgList &Args);
+
+unsigned getAMDGPUCodeObjectVersion(const Driver &D,
+const llvm::opt::ArgList &Args);
 
 void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1573,22 +1573,42 @@
   }
 }
 
-unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
-const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
+void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
+ const llvm::opt::ArgList &Args) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
 
   // Emit warnings for legacy options even if they are overridden.
-  if (Diagnose) {
-if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
-<< "-mcode-object-version=2";
+  if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
+  << "-mcode-object-version=2";
 
-if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
-  D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
-<< "-mcode-object-version=3";
+  if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
+D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
+  << "-mcode-object-version=3";
+
+  // The last of -mcode-object-v3, -mno-code-object-v3 and
+  // -mcode-object-version= wins.
+  if (auto *CodeObjArg =
+  Args.getLastArg(options::OPT_mcode_object_v3_legacy,
+  options::OPT_mno_code_object_v3_legacy,
+  options::OPT_mcode_object_version_EQ)) {
+
+if (CodeObjArg->getOption().getID() ==
+options::OPT_mcode_object_version_EQ) {
+  unsigned CodeObjVer = MaxCodeObjVer;
+  auto Remnant =
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
+  if (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer)
+D.Diag(diag::err_drv_invalid_int_value)
+<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+}
   }
+}
+
+unsigned tools::getAMDGPUCodeObjectVersion(const Driver &D,
+   const llvm::opt::ArgList &Args) {
+  unsigned CodeObjVer = 4; // default
 
   // The last of -mcode-object-v3, -mno-code-object-v3 and
   // -mcode-object-versi

[PATCH] D100981: Delete le32/le64 targets

2021-04-22 Thread Andrew Adams via Phabricator via cfe-commits
abadams added a comment.

In D100981#2706899 , @dschuff wrote:

> Thanks. I had heard in the past that there were some other folks who had used 
> le32/le64 as a "generic" target (in fact that's why it's named so 
> generically, rather than being called "pnacl" or similar) but I haven't heard 
> of anything recently, and as you can see nobody has upstreamed any support 
> for other OS or target specializations or asked to collaborate on it. 
> Practically speaking even a target that wants fairly generic bitcode would 
> probably want its own triple, so unless this removal captures someone's 
> attention who wants to keep maintaining it, this should be fine to remove.

I think that was us, the Halide language. Any suggested alternative for us to 
use now? This does indeed break all our llvm usage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100981

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-04-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added a comment.

In D101030#2708277 , @ABataev wrote:

> Could you check that it does not break the tests from 
> https://github.com/clang-ykt/omptests? IIRC, "ref" was introduced to fix a 
> bug with too early optimizations of the declare target variables defined in 
> other modules. Check `t-same-name-definitions` especially, though I'm not 
> sure that exactly this test caused adding of `$ref`s.

I did run that test, works fine. The "$ref"s are still generated, except if you 
don't have a host version of a variable. Without it, there is no reason to have 
a ref because you cannot actually address the device version.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2999-3000
 if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
-  initializeTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
-  OffloadingEntriesNum);
 auto &Entry =

ABataev wrote:
> Why did you decide to drop this?
Because a missing host version should mean we do not create a region entry. 
Take a look at all the
situations in `clang/test/OpenMP/declare_target_only_one_side_compilation.cpp` 
for which we are missing a host entry. None of them should create a region 
entry info.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:1736
   SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
-  ConsumeAnyToken();
-  for (auto &MTLocDecl : DeclareTargetDecls) {

ABataev wrote:
> Looks like it is still required to consume `tok::annot_pragma_openmp_end`
That's done in the caller now because the clauses are not always parsed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1597
+
+if (CodeObjArg->getOption().getID() ==
+options::OPT_mcode_object_version_EQ) {

This would probably be more useful if it diagnosed an invalid argument even 
when overridden by a legacy option. This patch preserves the existing behaviour.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1626
 } else {
-  auto Remnant =
-  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
-  if (Diagnose &&
-  (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > 
MaxCodeObjVer))
-D.Diag(diag::err_drv_invalid_int_value)
-<< CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
 }

getAsInteger writes to CodeObjVer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077

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


[PATCH] D101023: [Driver] Specify -ccc-install-dir for linux-cross test

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/linux-cross.cpp:5
 // RUN: %clang -### %s --target=x86_64-linux-gnu 
--sysroot=%S/Inputs/debian_multiarch_tree \
-// RUN:   -resource-dir=%S/Inputs/resource_dir --stdlib=platform 
--rtlib=platform 2>&1 | FileCheck %s --check-prefix=DEBIAN_X86_64
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin 
-resource-dir=%S/Inputs/resource_dir \
+// RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s 
--check-prefix=DEBIAN_X86_64

Can you add a comment what happens without `-ccc-install-dir`?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101023

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-04-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2134-2151
+Sema::DeclareTargetContextInfo *DTCI =
+new Sema::DeclareTargetContextInfo(DKind, DTLoc);
+if (HasClauses)
+  ParseOMPDeclareTargetClauses(*DTCI);
 
 // Skip the last annot_pragma_openmp_end.
 ConsumeAnyToken();

Add a RAII to control these new/delete or just create local var


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/AST/Type.h:493
+   // Default is a superset of SYCL address spaces.
+   (A == LangAS::Default &&
+(B == LangAS::sycl_private || B == LangAS::sycl_local ||

bader wrote:
> Anastasia wrote:
> > bader wrote:
> > > Anastasia wrote:
> > > > Ok if you allow implicit conversions both ways then this condition 
> > > > should be extended to also contain all named address spaces in `A` and 
> > > > `Default` in `B`. But actually, could you simplify by checking that you 
> > > > have `Default` on either side, so something like 
> > > > 
> > > > 
> > > > ```
> > > > (A == LangAS::Default || B == LangAS::Default)
> > > > ```
> > > > ?
> > > > Ok if you allow implicit conversions both ways then this condition 
> > > > should be extended to also contain all named address spaces in `A` and 
> > > > `Default` in `B`. But actually, could you simplify by checking that you 
> > > > have `Default` on either side, so something like 
> > > > 
> > > > 
> > > > ```
> > > > (A == LangAS::Default || B == LangAS::Default)
> > > > ```
> > > > ?
> > > 
> > > According to the comment above `isAddressSpaceSupersetOf` function 
> > > definition.
> > > ```
> > >   /// Returns true if address space A is equal to or a superset of B.
> > > ```
> > > 
> > > `(A == LangAS::Default || B == LangAS::Default)` <- this change makes 
> > > `Default` address space a superset of all address spaces including 
> > > OpenCL, which we were trying to avoid with adding SYCL address spaces. 
> > > Another problem with this code is that make `Default` a **sub-set** of 
> > > named address spaces (like `sycl_local`), which is not right.
> > > If I understand it correctly defining "isSupersSetOf" relation is enough 
> > > for the rest of framework to enable conversions. Am I right?
> > > (A == LangAS::Default || B == LangAS::Default) <- this change makes 
> > > Default address space a superset of all address spaces including OpenCL.
> > 
> > I see, yes this will break pretty much everything unless we guard by SYCL 
> > mode. But I don't think it is good to go this route though.
> > 
> > > Another problem with this code is that make Default a sub-set of named 
> > > address spaces (like sycl_local), which is not right.
> > 
> > Well, if you need implicit conversions to work both ways as you have 
> > written in the documentation then you don't really have a true 
> > super-/subsets between the named address spaces and the default one. They 
> > appear to be equivalent.
> > 
> > ```
> > SYCL mode enables both explicit and implicit conversion to/from the default 
> > address space from/to
> > the address space-attributed type.
> > ```
> > 
> > So do you actually need something like this to work?
> > 
> > ```
> > int * genptr = ...;
> > __private int * privptr = genptr:
> > ```
> > 
> > 
> I looked though the code base and I see that explicit cast is used when raw 
> pointer is casted to address space annotated type. I think we can always use 
> explicit cast from `Default` to named address space instead of implicit cast. 
> It might be even useful to avoid unintended implicit casts causing UB.
> @keryell, @Naghasan, what do you think if we update 
> https://reviews.llvm.org/D99488 to disallow implicit casts from `Default` to 
> named address space? I think it should be okay considering that current 
> implementation doesn't use this type of casts (and I can't come up with a use 
> case for it).
> 
> Meanwhile I've added checks for that to 
> clang/test/SemaSYCL/address-space-conversions.cpp.
Do you still plan to wait for extra input or otherwise we could just update the 
documentation for now?

If you discover that you need to allow the reverse conversions later it should 
not be problematic to add since it won't break anyone's code. It will only 
allow more code to compile!



Comment at: clang/lib/Basic/Targets/SPIR.h:140
+// space must be compatible with the generic address space
+return LangAS::sycl_global;
+  }

bader wrote:
> Anastasia wrote:
> > This needs a language guard too?
> I can re-write this method to avoid using language address space:
> 
> ```
>   llvm::Optional getConstantAddressSpace() const override {
> return getLangASFromTargetAS(1);
>   }
> ```
> 
> Does it look okay to you?
> 
> I don't think we need a language guard here as this hook is already guarded 
> by users. E.g. 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenModule.cpp#L4137-L4159.
> Adding language guards for `TargetInfo::getConstantAddressSpace` method will 
> require API change similar to `adjust` method i.e. explicit `LangOptions` 
> type parameter.
Well, OpenCL is not the only language mode though so it generally is an ABI 
change. But also there are seem to be other uses of this function, for example 
in `CGExpr.cpp` that are not guarded by the language mode and there it seems 
li

[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-22 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 339626.
Ericson2314 added a comment.

Recombind revisions, need to convert everything at once


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

Files:
  clang-tools-extra/clang-doc/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/modularize/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  clang/utils/hmaptool/CMakeLists.txt
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/tools/f18/CMakeLists.txt
  flang/tools/flang-driver/CMakeLists.txt
  libc/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/include/CMakeLists.txt
  libcxx/src/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/tools/lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  openmp/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt
  openmp/tools/multiplex/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/lib/External/CMakeLists.txt
  pstl/CMakeLists.txt

Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -7,6 +7,8 @@
 #===--===##
 cmake_minimum_required(VERSION 3.13.4)
 
+include(GNUInstallDirs)
+
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
 string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
@@ -86,10 +88,10 @@
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
 DESTINATION lib/cmake/ParallelSTL)
 install(DIRECTORY include/
-DESTINATION include
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 PATTERN "*.in" EXCLUDE)
 install(FILES "${PSTL_CONFIG_SITE_PATH}"
-DESTINATION include)
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 add_custom_target(install-pstl
   COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)
Index: polly/lib/External/CMakeLists.txt
===
--- polly/lib/External/CMakeLists.txt
+++ polly/lib/External/CMakeLists.txt
@@ -290,7 +290,7 @@
 install(DIRECTORY
   ${ISL_SOURCE_DIR}/include/
   ${ISL_BINARY_DIR}/include/
-  DESTINATION include/polly
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
   FILES_MATCHING
   PATTERN "*.h"
   PATTERN "CMakeFiles" EXCLUDE
Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -83,14 +83,15 @@
 set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
 set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+get_filename_component(base_includedir "${CMAKE_INSTALL_INCLUDEDIR}" ABSOLUTE BASE_DIR "${POLLY_INSTALL_PREFIX}")
 if (POLLY_BUNDLED_ISL)
   set(POLLY_CONFIG_INCLUDE_DIRS
-"${POLLY_INSTALL_PREFIX}/include"
-"${POLLY_INSTALL_PREFIX}/include/polly"
+"${base_includedir}"
+"${base_includedir}/polly"
 )
 else()
   set(POLLY_CONFIG_INCLUDE_DIRS
-"${POLLY_INSTALL_PREFIX}/include"
+"${base_includedir}"
 ${ISL_INCLUDE_DIRS}
 )
 endif()
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -2,7 +2,11 @@
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   pro

[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-22 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 339639.
Ericson2314 added a comment.

Resplit on @LebedevRI's advice that it's OK if not all patches build alone


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

Files:
  clang-tools-extra/clang-doc/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/clang-include-fixer/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/modularize/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  clang/utils/hmaptool/CMakeLists.txt
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/tools/f18/CMakeLists.txt
  flang/tools/flang-driver/CMakeLists.txt
  libc/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/include/CMakeLists.txt
  libcxx/src/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/tools/lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  openmp/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt
  openmp/tools/multiplex/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/lib/External/CMakeLists.txt
  pstl/CMakeLists.txt

Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -7,6 +7,8 @@
 #===--===##
 cmake_minimum_required(VERSION 3.13.4)
 
+include(GNUInstallDirs)
+
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
 string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
@@ -86,10 +88,10 @@
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
 DESTINATION lib/cmake/ParallelSTL)
 install(DIRECTORY include/
-DESTINATION include
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 PATTERN "*.in" EXCLUDE)
 install(FILES "${PSTL_CONFIG_SITE_PATH}"
-DESTINATION include)
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 add_custom_target(install-pstl
   COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)
Index: polly/lib/External/CMakeLists.txt
===
--- polly/lib/External/CMakeLists.txt
+++ polly/lib/External/CMakeLists.txt
@@ -290,7 +290,7 @@
 install(DIRECTORY
   ${ISL_SOURCE_DIR}/include/
   ${ISL_BINARY_DIR}/include/
-  DESTINATION include/polly
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
   FILES_MATCHING
   PATTERN "*.h"
   PATTERN "CMakeFiles" EXCLUDE
Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -83,14 +83,15 @@
 set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
 set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+get_filename_component(base_includedir "${CMAKE_INSTALL_INCLUDEDIR}" ABSOLUTE BASE_DIR "${POLLY_INSTALL_PREFIX}")
 if (POLLY_BUNDLED_ISL)
   set(POLLY_CONFIG_INCLUDE_DIRS
-"${POLLY_INSTALL_PREFIX}/include"
-"${POLLY_INSTALL_PREFIX}/include/polly"
+"${base_includedir}"
+"${base_includedir}/polly"
 )
 else()
   set(POLLY_CONFIG_INCLUDE_DIRS
-"${POLLY_INSTALL_PREFIX}/include"
+"${base_includedir}"
 ${ISL_INCLUDE_DIRS}
 )
 endif()
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -2,7 +2,11 @@
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   project(Polly)
   cmake_minimum_required(VERSION 3.13.4)
+endif()
+
+include(GNUInstallDirs)
 
+if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
@@ -122,13 +126,13 @@
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/
-DESTINATION include
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 FILES_MATCHING
 PATTERN 

[PATCH] D100826: [Debug-Info][NFC] add -gstrict-dwarf support in backend

2021-04-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.

Sounds good - probably only need one test file, rather than two - can put a 
bunch of strict-dwarf related testing in that one file (& honestly, maybe don't 
even need to test every DWARF attribute gets the right handling if the handling 
is generic/applies across all the attributes)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100826

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


[PATCH] D69498: IR: Invert convergent attribute handling

2021-04-22 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D69498#2707100 , @sameerds wrote:

>>> 1. The meaning of the `convergent` attribute has always been 
>>> target-dependent.
>>> 2. Dependence on TTI is not a real cost at all. We may eventually update 
>>> every use of isConvergent() to depend on a check for divergence. The check 
>>> for TTI is only the first step towards that.
>>
>> The core IR semantics must *not* depend on target interpretation. convergent 
>> has never been target dependent, and was defined in an abstract way. Only 
>> certain targets will really care, but we cannot directly define it to mean 
>> what we want it to mean for particular targets
>
> My bad. I should have said "the implementation of convergent" is target 
> dependent. But even that is not precise enough. It is more correct to say 
> that the convergent attribute can be implemented inside LLVM by depending on 
> TTI so that it only impacts targets that have divergence. This dependence is 
> not new; it's merely missing because the current uses of convergent 
> pessimistically assume divergent control flow on targets.

You're still saying the same thing. This needs to be defined generically. 
Frontends don't *have* to to anything, they'll just get the assumed convergent 
behavior by default. Either frontends could always add noconvergent to avoid 
any possible optimization hit, or we could have a pass add noconvergent 
depending on the target. I don't want to change the interpretation of core 
attributes based on the target


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

https://reviews.llvm.org/D69498

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


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2021-04-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Ping @arthur.j.odwyer




Comment at: clang/include/clang/Basic/DiagnosticGroups.td:158
+def DeprecatedCopy : DiagGroup<"deprecated-copy", 
[DeprecatedCopyUserProvided]>;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor", 
[DeprecatedCopyDtorUserProvided]>;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;

Quuxplusone wrote:
> xbolva00 wrote:
> > Quuxplusone wrote:
> > > If we're going to provide these options at all, I think it would be more 
> > > grammatical to call them `-Wdeprecated-copy-with-deleted-copy` and 
> > > `-Wdeprecated-copy-with-deleted-dtor`.
> > > 
> > > The existing code is already confusing by talking about a "copy dtor" as 
> > > if that's a thing; I think it makes it even worse to talk about 
> > > "deprecated copy user provided," since the actually deprecated thing is 
> > > the //implicitly generated// copy.
> > > 
> > > I get that we're trying to be terse, and also somewhat hierarchical in 
> > > putting all the `-Wdeprecated-copy`-related warnings under 
> > > `-Wdeprecated-copy-foo-bar`; but the current names are too far into the 
> > > ungrammatical realm for me personally.
> > Yeah, better names are welcome :)
> Do the current names match existing practice in GCC or anything?
> I continue to opine that these options are poorly named. My best suggestion is
> `deprecated-copy`, `deprecated-copy-with-dtor`, 
> `deprecated-copy-with-deleted-copy`, `deprecated-copy-with-deleted-dtor` — 
> operating on the (wrong?) assumption that absolutely the only difference 
> between "user-declared" and "user-provided" corresponds to "user-declared as 
> deleted."
> 
> Even if everything else remains the same, the internal identifier 
> `warn_deprecated_copy_dtor_operation_user_provided` should certainly be 
> `warn_deprecated_copy_operation_dtor_user_provided` — the phrase that goes 
> together is "copy operation", not "dtor operation".
> 
> Your "deprecated-dtor-user-provided.cpp" passes 
> `-Wdeprecated-copy-dtor-user-provided`, but the message text talks about 
> "user-//declared//." Shouldn't the spelling of the option reflect the wording 
> of the message text? This isn't important from the POV of someone who's just 
> going to look at the message text and fix their code, but it's important from 
> the POV of someone who's going to use `-Wno-` and wants to know exactly which 
> bad situations they're ignoring. (Also, the name of the file should match the 
> spelling of the option.)
Yeah, deprecated-copy and deprecated-copy-dtor is already defined by GCC.

I think deprecated-copy-user-provided-copy and 
deprecated-copy-user-provided-dtor could be good solution here, it is also 
quite easy to follow implementation of the checking logic in Sema with these 
names.


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

https://reviews.llvm.org/D79714

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


[PATCH] D101037: [clang-tidy] Change shebang from python to python3

2021-04-22 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

I also have this patch https://reviews.llvm.org/D100692 which changes 
run-clang-tidy.py this way as well, specifically because it utilizes some 
python3 features in shutil.which


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101037

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


[PATCH] D100981: Delete le32/le64 targets

2021-04-22 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

Any chance that this could be (temporarily) reverted? This will break literally 
all Halide compilation; we're working on a fix on our side, but it would be 
nice to have a few days to be sure we have it right, and I suspect there's no 
urgency to removing this right now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100981

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


[PATCH] D101043: [OpenCL] Drop extension pragma handling for extension types/declarations

2021-04-22 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

Reasoning and strategy looks sensible to me. I'm not formally approving the 
patch because I feel I'm not familiar enough with the code base to do that.


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

https://reviews.llvm.org/D101043

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


[PATCH] D100860: [C++4OpenCL] Add missing OpenCL specific diagnostics in templates

2021-04-22 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm added a comment.

The only ones that change (in the test cases at least) are as follows:
Here Old is with the current change, and New is with the call to 
`diagnoseOpenCLTypes` at parsing removed.

In `event_t.cl`, `event_t glb_evt;` in program scope has this difference:

  Old:
the '__private event_t' type cannot be used to declare a program scope 
variable
  New:
program scope variable must reside in constant address space

In `template-opencl-types.clcpp`, `__local event_t e;` inside a function has 
this difference:

  Old:
the event_t type can only be used with __private address space qualifier
  New:
non-kernel function variable cannot be declared in local address space

The first on explains that `event_t` can't be used in program scope at all, 
which is better I think.
However the second error actually gets slightly better.

I think these errors are primarily emitted between the two checks, so I don't 
know if it's easy to put the check somewhere that gives better results.


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

https://reviews.llvm.org/D100860

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

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



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2134-2151
+Sema::DeclareTargetContextInfo *DTCI =
+new Sema::DeclareTargetContextInfo(DKind, DTLoc);
+if (HasClauses)
+  ParseOMPDeclareTargetClauses(*DTCI);
 
 // Skip the last annot_pragma_openmp_end.
 ConsumeAnyToken();

ABataev wrote:
> Add a RAII to control these new/delete or just create local var
Local variable and RAII do not always work, there is a delete in the 
`end_declare_target` below as well.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-04-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D99741#2701918 , @craig.topper 
wrote:

> In D99741#2701398 , @thakis wrote:
>
 I think maybe reverting is not a good idea if we have a good progress on 
 this slow down issue.
>>>
>>> Yes, if we can fix the regression in a few days, then all is good.
>>
>> Another ping here. check-clang is down to 5 min now, but it's still a 11% 
>> regression (used to be 4.5 min, went to 5.5 min, now 5 min).
>
> https://reviews.llvm.org/D100611 has not landed yet. Is the 5 min number with 
> or without that patch?

Without. I'm just looking at my bot cycle times. Ok, let's wait for that to 
play out :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D100985: [OpenCL] Remove pragma requirement for functions from Arm dot extension

2021-04-22 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D100985

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


[PATCH] D100860: [C++4OpenCL] Add missing OpenCL specific diagnostics in templates

2021-04-22 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D100860#2709057 , @olestrohm wrote:

> The first on explains that `event_t` can't be used in program scope at all, 
> which is better I think.

Agreed, removing the parser check gives a worse diagnostic here.

The underlying problem might actually be that the diagnostic for program scope 
variables is firing too early.  I tried to address a similar issue with D53705 
, which got stalled unfortunately.  Perhaps we 
should revisit that and try to see if postponing the program scope variable 
diagnostic allows us to remove the parser check without getting a worse 
diagnostic.


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

https://reviews.llvm.org/D100860

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


[PATCH] D100981: Delete le32/le64 targets

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.
Herald added a subscriber: tmatheson.

In D100981#2709044 , @srj wrote:

> Any chance that this could be (temporarily) reverted? This will break 
> literally all Halide compilation; we're working on a fix on our side, but it 
> would be nice to have a few days to be sure we have it right, and I suspect 
> there's no urgency to removing this right now.

Will https://github.com/halide/Halide/pull/5934 take longer? If it does, I can 
temporarily revert this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100981

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


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2021-04-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone accepted this revision.
Quuxplusone added a comment.
This revision is now accepted and ready to land.

The new individual test files are awesome. :)
The name of the `-W` options still aren't perfect IMHO, but maybe it will never 
be perfect, and meanwhile everything else looks great.




Comment at: clang/include/clang/Basic/DiagnosticGroups.td:158
+def DeprecatedCopy : DiagGroup<"deprecated-copy", 
[DeprecatedCopyUserProvided]>;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor", 
[DeprecatedCopyDtorUserProvided]>;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;

xbolva00 wrote:
> Quuxplusone wrote:
> > xbolva00 wrote:
> > > Quuxplusone wrote:
> > > > If we're going to provide these options at all, I think it would be 
> > > > more grammatical to call them `-Wdeprecated-copy-with-deleted-copy` and 
> > > > `-Wdeprecated-copy-with-deleted-dtor`.
> > > > 
> > > > The existing code is already confusing by talking about a "copy dtor" 
> > > > as if that's a thing; I think it makes it even worse to talk about 
> > > > "deprecated copy user provided," since the actually deprecated thing is 
> > > > the //implicitly generated// copy.
> > > > 
> > > > I get that we're trying to be terse, and also somewhat hierarchical in 
> > > > putting all the `-Wdeprecated-copy`-related warnings under 
> > > > `-Wdeprecated-copy-foo-bar`; but the current names are too far into the 
> > > > ungrammatical realm for me personally.
> > > Yeah, better names are welcome :)
> > Do the current names match existing practice in GCC or anything?
> > I continue to opine that these options are poorly named. My best suggestion 
> > is
> > `deprecated-copy`, `deprecated-copy-with-dtor`, 
> > `deprecated-copy-with-deleted-copy`, `deprecated-copy-with-deleted-dtor` — 
> > operating on the (wrong?) assumption that absolutely the only difference 
> > between "user-declared" and "user-provided" corresponds to "user-declared 
> > as deleted."
> > 
> > Even if everything else remains the same, the internal identifier 
> > `warn_deprecated_copy_dtor_operation_user_provided` should certainly be 
> > `warn_deprecated_copy_operation_dtor_user_provided` — the phrase that goes 
> > together is "copy operation", not "dtor operation".
> > 
> > Your "deprecated-dtor-user-provided.cpp" passes 
> > `-Wdeprecated-copy-dtor-user-provided`, but the message text talks about 
> > "user-//declared//." Shouldn't the spelling of the option reflect the 
> > wording of the message text? This isn't important from the POV of someone 
> > who's just going to look at the message text and fix their code, but it's 
> > important from the POV of someone who's going to use `-Wno-` and wants to 
> > know exactly which bad situations they're ignoring. (Also, the name of the 
> > file should match the spelling of the option.)
> Yeah, deprecated-copy and deprecated-copy-dtor is already defined by GCC.
> 
> I think deprecated-copy-user-provided-copy and 
> deprecated-copy-user-provided-dtor could be good solution here, it is also 
> quite easy to follow implementation of the checking logic in Sema with these 
> names.
@xbolva00: I suggested `-Wdeprecated-copy-with-user-provided-copy`; you've got 
`-Wdeprecated-copy-user-provided-copy`. Could I persuade you to use the 
`-with-` versions?
I suppose where it really matters is `-Wdeprecated-copy-dtor` (what is a "copy 
destructor"?), but that's for GCC compatibility, so we can't change it. Right?



Comment at: clang/test/SemaCXX/deprecated-copy-dtor.cpp:2
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -verify
+

I think it's extremely unfortunate that `-Wdeprecated-copy-dtor` is not a 
subset of `-Wdeprecated-copy`. But again, GCC-compatibility binds our hands 
here AFAIK. https://godbolt.org/z/3r3ddvTfG


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

https://reviews.llvm.org/D79714

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


[PATCH] D100981: Delete le32/le64 targets

2021-04-22 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

In D100981#2709205 , @MaskRay wrote:

> In D100981#2709044 , @srj wrote:
>
>> Any chance that this could be (temporarily) reverted? This will break 
>> literally all Halide compilation; we're working on a fix on our side, but it 
>> would be nice to have a few days to be sure we have it right, and I suspect 
>> there's no urgency to removing this right now.
>
> Will https://github.com/halide/Halide/pull/5934 take longer? If it does, I 
> can temporarily revert this.

Yeah, the first simple attempt in https://github.com/halide/Halide/pull/5934 
doesn't work (many things are broken). Temporarily reverting this would be a 
huge huge favor to us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100981

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


[clang] ef5e7f9 - Temporarily revert the code part of D100981 "Delete le32/le64 targets"

2021-04-22 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-04-22T10:18:44-07:00
New Revision: ef5e7f90ea4d5063ce68b952c5de473e610afc02

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

LOG: Temporarily revert the code part of D100981 "Delete le32/le64 targets"

This partially reverts commit 77ac823fd285973cfb3517932c09d82e6a32f46d.

Halide uses le32/le64 (https://github.com/halide/Halide/pull/5934).
Temporarily brings back the code part to give them some time for migration.

Added: 
clang/lib/Basic/Targets/Le64.cpp
clang/lib/Basic/Targets/Le64.h

Modified: 
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
llvm/include/llvm/ADT/Triple.h
llvm/lib/Support/Triple.cpp
llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn

Removed: 




diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 4199d4d01b9dd..a3a8f8d68962b 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -77,6 +77,7 @@ add_clang_library(clangBasic
   Targets/BPF.cpp
   Targets/Hexagon.cpp
   Targets/Lanai.cpp
+  Targets/Le64.cpp
   Targets/M68k.cpp
   Targets/MSP430.cpp
   Targets/Mips.cpp

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 685700fbd22d4..8df5cb7a3a61a 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -21,6 +21,7 @@
 #include "Targets/BPF.h"
 #include "Targets/Hexagon.h"
 #include "Targets/Lanai.h"
+#include "Targets/Le64.h"
 #include "Targets/M68k.h"
 #include "Targets/MSP430.h"
 #include "Targets/Mips.h"
@@ -313,6 +314,17 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
   return new M68kTargetInfo(Triple, Opts);
 }
 
+  case llvm::Triple::le32:
+switch (os) {
+case llvm::Triple::NaCl:
+  return new NaClTargetInfo(Triple, Opts);
+default:
+  return nullptr;
+}
+
+  case llvm::Triple::le64:
+return new Le64TargetInfo(Triple, Opts);
+
   case llvm::Triple::ppc:
 if (Triple.isOSDarwin())
   return new DarwinPPC32TargetInfo(Triple, Opts);

diff  --git a/clang/lib/Basic/Targets/Le64.cpp 
b/clang/lib/Basic/Targets/Le64.cpp
new file mode 100644
index 0..498dd33a03d17
--- /dev/null
+++ b/clang/lib/Basic/Targets/Le64.cpp
@@ -0,0 +1,37 @@
+//===--- Le64.cpp - Implement Le64 target feature support 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements Le64 TargetInfo objects.
+//
+//===--===//
+
+#include "Le64.h"
+#include "Targets.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetBuiltins.h"
+
+using namespace clang;
+using namespace clang::targets;
+
+const Builtin::Info Le64TargetInfo::BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#include "clang/Basic/BuiltinsLe64.def"
+};
+
+ArrayRef Le64TargetInfo::getTargetBuiltins() const {
+  return {};
+}
+
+void Le64TargetInfo::getTargetDefines(const LangOptions &Opts,
+  MacroBuilder &Builder) const {
+  DefineStd(Builder, "unix", Opts);
+  defineCPUMacros(Builder, "le64", /*Tuning=*/false);
+  Builder.defineMacro("__ELF__");
+}

diff  --git a/clang/lib/Basic/Targets/Le64.h b/clang/lib/Basic/Targets/Le64.h
new file mode 100644
index 0..253d5681abc2e
--- /dev/null
+++ b/clang/lib/Basic/Targets/Le64.h
@@ -0,0 +1,63 @@
+//===--- Le64.h - Declare Le64 target feature support ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file declares Le64 TargetInfo objects.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_LE64_H
+#define LLVM_CLANG_LIB_BASIC_TARGETS_LE64_H
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Compiler.h"
+
+namespace clang {
+namespace targets {
+
+class LLVM_LIBRARY_VISIBILITY Le64TargetInfo : public TargetInfo {
+ 

[PATCH] D100124: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions

2021-04-22 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

In D100124#2707731 , @steffenlarsen 
wrote:

>> Do you know if any existing code already uses the __nvvm_* builtins for 
>> cp.async? In other words, does nvcc provide them already or is it something 
>> we're free to name as we wish? I do not see any relevant intrinsics 
>> mentioned in NVVM IR spec: 
>> https://docs.nvidia.com/cuda/nvvm-ir-spec/index.html and I don't think 
>> NVCC's builtins are publicly documented anywhere.
>
> I don't know of any yet. We will be using these in the relatively near 
> future, but we can still change them no problem. However, the intrinsic and 
> builtin naming for NVVM and NVPTX seems a bit inconsistent so it may be a 
> long discussion (or maybe not.)

LLVM uses different intrinsic names, mostly for historic reasons -- NVVM 
implements their own without upstreaming them back to LLVM and meanwhile LLVM 
grew its own set. So far I haven't seen any practical cases where that might've 
been an issue. I think NVIDIA folks popped up on a review *once* when they 
thought that an intrinsic we were about to introduce might've clashed with one 
of theirs, but they prompty disappeared when it turned out not to be the case.  
The bottom line is that effectively intrinsic names in LLVM and NVVM are 
independent, though we should take care not to introduce identically named ones 
with different parameters or functionality.

Clang builtins are a bit different. Clang needs to compile CUDA headers and 
those  do use __nvvm builtinns, so clang must also provide those. NVIDIA does 
not document NVCC's compiler builtins, so if they are not used in CUDA headers, 
we have no idea whether relevant ones already exist. It would be great to stay 
in sync and make end-users code more portable across clang/NVCC, but there's 
not much we can do about that at the moment. The risk there is that if NVCC 
eventually introduces a builtin with the name we've used, but with a different 
arguments or functionality, that would be a bit of an annoyance for the users.


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

https://reviews.llvm.org/D100124

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-22 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

This change broke multi-stage builds (even if AMDGPU is disabled as a target). 
The problem is that clang/tools/amdgpu-arch/AMDGPUArch.cpp can't find hsa.h. Is 
there a quick fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D101087: [OpenCL] Introduce new method for validating OpenCL target

2021-04-22 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov created this revision.
azabaznov added reviewers: Anastasia, svenvh.
Herald added subscribers: ldrumm, jfb, yaxunl, jvesely.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Language options are not available when a target is being created,
thus, a new method is introduced. Also, some refactoring is done,
such as removing OpenCL feature macros setting from TargetInfo.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101087

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Misc/nvptx.unsupported_core.cl
  clang/test/Misc/r600.unsupported_core.cl

Index: clang/test/Misc/r600.unsupported_core.cl
===
--- /dev/null
+++ clang/test/Misc/r600.unsupported_core.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple r600-unknown-unknown -Wpedantic-core-features %s 2> %t
+// RUN: FileCheck < %t %s
+
+// CHECK: cl_khr_byte_addressable_store is a core feature in this OpenCL version but not supported on this target
+// CHECK: cl_khr_global_int32_base_atomics is a core feature in this OpenCL version but not supported on this target
+// CHECK: cl_khr_global_int32_extended_atomics is a core feature in this OpenCL version but not supported on this target
+// CHECK: cl_khr_local_int32_base_atomics is a core feature in this OpenCL version but not supported on this target
+// CHECK: cl_khr_local_int32_extended_atomics is a core feature in this OpenCL version but not supported on this target
+// CHECK: cl_khr_3d_image_writes is a core feature in this OpenCL version but not supported on this target
Index: clang/test/Misc/nvptx.unsupported_core.cl
===
--- /dev/null
+++ clang/test/Misc/nvptx.unsupported_core.cl
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple nvptx-unknown-unknown -Wpedantic-core-features %s 2> %t
+// RUN: FileCheck < %t %s
+
+// CHECK: cl_khr_3d_image_writes is a core feature in this OpenCL version but not supported on this target
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -601,6 +601,34 @@
 Builder.defineMacro("__cpp_coroutines", "201703L");
 }
 
+/// InitializeOpenCLFeatureTestMacros - Define OpenCL macros based on target
+/// settings and language version
+void InitializeOpenCLFeatureTestMacros(const TargetInfo &TI,
+   const LangOptions &Opts,
+   MacroBuilder &Builder) {
+  const llvm::StringMap &OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
+  // FIXME: OpenCL options which affect language semantics/syntax
+  // should be moved into LangOptions, thus macro definitions of
+  // such options is better to be done in clang::InitializePreprocessor.
+  auto defineOpenCLExtMacro = [&](llvm::StringRef Name, unsigned AvailVer,
+  unsigned CoreVersions,
+  unsigned OptionalVersions) {
+// Check if extension is supported by target and is available in this
+// OpenCL version
+if (TI.hasFeatureEnabled(OpenCLFeaturesMap, Name) &&
+OpenCLOptions::OpenCLOptionInfo(false, AvailVer, CoreVersions,
+OptionalVersions)
+.isAvailableIn(Opts))
+  Builder.defineMacro(Name);
+  };
+#define OPENCL_GENERIC_EXTENSION(Ext, WithPragma, Avail, Core, Opt)\
+  defineOpenCLExtMacro(#Ext, Avail, Core, Opt);
+#include "clang/Basic/OpenCLExtensions.def"
+
+  // Assume compiling for FULL profile
+  Builder.defineMacro("__opencl_c_int64");
+}
+
 static void InitializePredefinedMacros(const TargetInfo &TI,
const LangOptions &LangOpts,
const FrontendOptions &FEOpts,
@@ -1138,7 +1166,7 @@
 
   // OpenCL definitions.
   if (LangOpts.OpenCL) {
-TI.getOpenCLFeatureDefines(LangOpts, Builder);
+InitializeOpenCLFeatureTestMacros(TI, LangOpts, Builder);
 
 if (TI.getTriple().isSPIR())
   Builder.defineMacro("__IMAGE_SUPPORT__");
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -133,6 +133,11 @@
 // FIXME: can we disable FEnvAccess?
   }
 
+  // We should do it here because target knows nothing about
+  // language options when it's being created.
+  if (getLangOpts().OpenCL)
+ 

[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2021-04-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:158
+def DeprecatedCopy : DiagGroup<"deprecated-copy", 
[DeprecatedCopyUserProvided]>;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor", 
[DeprecatedCopyDtorUserProvided]>;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;

Quuxplusone wrote:
> xbolva00 wrote:
> > Quuxplusone wrote:
> > > xbolva00 wrote:
> > > > Quuxplusone wrote:
> > > > > If we're going to provide these options at all, I think it would be 
> > > > > more grammatical to call them `-Wdeprecated-copy-with-deleted-copy` 
> > > > > and `-Wdeprecated-copy-with-deleted-dtor`.
> > > > > 
> > > > > The existing code is already confusing by talking about a "copy dtor" 
> > > > > as if that's a thing; I think it makes it even worse to talk about 
> > > > > "deprecated copy user provided," since the actually deprecated thing 
> > > > > is the //implicitly generated// copy.
> > > > > 
> > > > > I get that we're trying to be terse, and also somewhat hierarchical 
> > > > > in putting all the `-Wdeprecated-copy`-related warnings under 
> > > > > `-Wdeprecated-copy-foo-bar`; but the current names are too far into 
> > > > > the ungrammatical realm for me personally.
> > > > Yeah, better names are welcome :)
> > > Do the current names match existing practice in GCC or anything?
> > > I continue to opine that these options are poorly named. My best 
> > > suggestion is
> > > `deprecated-copy`, `deprecated-copy-with-dtor`, 
> > > `deprecated-copy-with-deleted-copy`, `deprecated-copy-with-deleted-dtor` 
> > > — operating on the (wrong?) assumption that absolutely the only 
> > > difference between "user-declared" and "user-provided" corresponds to 
> > > "user-declared as deleted."
> > > 
> > > Even if everything else remains the same, the internal identifier 
> > > `warn_deprecated_copy_dtor_operation_user_provided` should certainly be 
> > > `warn_deprecated_copy_operation_dtor_user_provided` — the phrase that 
> > > goes together is "copy operation", not "dtor operation".
> > > 
> > > Your "deprecated-dtor-user-provided.cpp" passes 
> > > `-Wdeprecated-copy-dtor-user-provided`, but the message text talks about 
> > > "user-//declared//." Shouldn't the spelling of the option reflect the 
> > > wording of the message text? This isn't important from the POV of someone 
> > > who's just going to look at the message text and fix their code, but it's 
> > > important from the POV of someone who's going to use `-Wno-` and wants to 
> > > know exactly which bad situations they're ignoring. (Also, the name of 
> > > the file should match the spelling of the option.)
> > Yeah, deprecated-copy and deprecated-copy-dtor is already defined by GCC.
> > 
> > I think deprecated-copy-user-provided-copy and 
> > deprecated-copy-user-provided-dtor could be good solution here, it is also 
> > quite easy to follow implementation of the checking logic in Sema with 
> > these names.
> @xbolva00: I suggested `-Wdeprecated-copy-with-user-provided-copy`; you've 
> got `-Wdeprecated-copy-user-provided-copy`. Could I persuade you to use the 
> `-with-` versions?
> I suppose where it really matters is `-Wdeprecated-copy-dtor` (what is a 
> "copy destructor"?), but that's for GCC compatibility, so we can't change it. 
> Right?
I can use with “-with” and create alias for -Wdeprecated-copy-dtor to keep gcc 
compatibility :)


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

https://reviews.llvm.org/D79714

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


[PATCH] D101000: Coverage: Document how to collect a profile without a filesystem

2021-04-22 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

This looks great, thanks.


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

https://reviews.llvm.org/D101000

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


[PATCH] D96524: [OpenCL] Add support of OpenCL C 3.0 __opencl_c_fp64

2021-04-22 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

Please see https://reviews.llvm.org/D101087.

I think unifying with target features requires more effort than it seemed 
because target features are declared in LLVM (see for example //AMDGPUFeatureKV 
// in //AMDGPUGenSubtargetInfo.inc//, //llvm/lib/Target/AMDGPU/AMDGPU.td//)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96524

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


[PATCH] D100981: Delete le32/le64 targets

2021-04-22 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Would it make sense for you to to upstream an LLVM target such as le32-halide? 
(Or perhaps even arm32-halide or some other?) Then you'd actually have more 
control over your own codegen, datalayout, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100981

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


[PATCH] D101089: [OpenCL] Document legacy atomics with generic address space

2021-04-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: svenvh.
Herald added subscribers: ebevhan, jfb, yaxunl.
Anastasia requested review of this revision.

There were multiple requests from the developers to allow this functionality in 
OpenCL 
https://github.com/KhronosGroup/OpenCL-Docs/issues/66

and this can be supported already in some tool flows i.e. using SPIRV-LLVM 
Translator. 
However, there hasn't been enough progress on the core spec side.

Therefore, I suggest documenting this as a clang extension for now.


https://reviews.llvm.org/D101089

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1813,6 +1813,20 @@
   #pragma OPENCL EXTENSION __cl_clang_variadic_functions : disable
   void bar(int a, ...); // error - variadic prototype is not allowed
 
+Legacy 1.x atomics with generic address space
+-
+
+Clang allows use of atomic functions from earlier than OpenCL 2.0
+standard with generic address space pointer in C++ for OpenCL mode. 
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  void foo(__generic volatile unsigned int* a) {
+atomic_add(a, 1);
+  }
+
 Builtin Functions
 =
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1813,6 +1813,20 @@
   #pragma OPENCL EXTENSION __cl_clang_variadic_functions : disable
   void bar(int a, ...); // error - variadic prototype is not allowed
 
+Legacy 1.x atomics with generic address space
+-
+
+Clang allows use of atomic functions from earlier than OpenCL 2.0
+standard with generic address space pointer in C++ for OpenCL mode. 
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  void foo(__generic volatile unsigned int* a) {
+atomic_add(a, 1);
+  }
+
 Builtin Functions
 =
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101037: [clang-tidy] Change shebang from python to python3

2021-04-22 Thread Tom Lokovic via Phabricator via cfe-commits
tdl-g accepted this revision.
tdl-g added a comment.
This revision is now accepted and ready to land.

I'll defer to the consensus on 
https://lists.llvm.org/pipermail/cfe-dev/2021-April/068047.html regarding 
whether or not there are gotchas for requiring python3,, but assuming tests 
have confirmed that each of these scripts are python3 compatible, this seems 
reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101037

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-22 Thread Alexey Bader via Phabricator via cfe-commits
bader marked 2 inline comments as done.
bader added inline comments.



Comment at: clang/include/clang/AST/Type.h:493
+   // Default is a superset of SYCL address spaces.
+   (A == LangAS::Default &&
+(B == LangAS::sycl_private || B == LangAS::sycl_local ||

Anastasia wrote:
> bader wrote:
> > Anastasia wrote:
> > > bader wrote:
> > > > Anastasia wrote:
> > > > > Ok if you allow implicit conversions both ways then this condition 
> > > > > should be extended to also contain all named address spaces in `A` 
> > > > > and `Default` in `B`. But actually, could you simplify by checking 
> > > > > that you have `Default` on either side, so something like 
> > > > > 
> > > > > 
> > > > > ```
> > > > > (A == LangAS::Default || B == LangAS::Default)
> > > > > ```
> > > > > ?
> > > > > Ok if you allow implicit conversions both ways then this condition 
> > > > > should be extended to also contain all named address spaces in `A` 
> > > > > and `Default` in `B`. But actually, could you simplify by checking 
> > > > > that you have `Default` on either side, so something like 
> > > > > 
> > > > > 
> > > > > ```
> > > > > (A == LangAS::Default || B == LangAS::Default)
> > > > > ```
> > > > > ?
> > > > 
> > > > According to the comment above `isAddressSpaceSupersetOf` function 
> > > > definition.
> > > > ```
> > > >   /// Returns true if address space A is equal to or a superset of B.
> > > > ```
> > > > 
> > > > `(A == LangAS::Default || B == LangAS::Default)` <- this change makes 
> > > > `Default` address space a superset of all address spaces including 
> > > > OpenCL, which we were trying to avoid with adding SYCL address spaces. 
> > > > Another problem with this code is that make `Default` a **sub-set** of 
> > > > named address spaces (like `sycl_local`), which is not right.
> > > > If I understand it correctly defining "isSupersSetOf" relation is 
> > > > enough for the rest of framework to enable conversions. Am I right?
> > > > (A == LangAS::Default || B == LangAS::Default) <- this change makes 
> > > > Default address space a superset of all address spaces including OpenCL.
> > > 
> > > I see, yes this will break pretty much everything unless we guard by SYCL 
> > > mode. But I don't think it is good to go this route though.
> > > 
> > > > Another problem with this code is that make Default a sub-set of named 
> > > > address spaces (like sycl_local), which is not right.
> > > 
> > > Well, if you need implicit conversions to work both ways as you have 
> > > written in the documentation then you don't really have a true 
> > > super-/subsets between the named address spaces and the default one. They 
> > > appear to be equivalent.
> > > 
> > > ```
> > > SYCL mode enables both explicit and implicit conversion to/from the 
> > > default address space from/to
> > > the address space-attributed type.
> > > ```
> > > 
> > > So do you actually need something like this to work?
> > > 
> > > ```
> > > int * genptr = ...;
> > > __private int * privptr = genptr:
> > > ```
> > > 
> > > 
> > I looked though the code base and I see that explicit cast is used when raw 
> > pointer is casted to address space annotated type. I think we can always 
> > use explicit cast from `Default` to named address space instead of implicit 
> > cast. It might be even useful to avoid unintended implicit casts causing UB.
> > @keryell, @Naghasan, what do you think if we update 
> > https://reviews.llvm.org/D99488 to disallow implicit casts from `Default` 
> > to named address space? I think it should be okay considering that current 
> > implementation doesn't use this type of casts (and I can't come up with a 
> > use case for it).
> > 
> > Meanwhile I've added checks for that to 
> > clang/test/SemaSYCL/address-space-conversions.cpp.
> Do you still plan to wait for extra input or otherwise we could just update 
> the documentation for now?
> 
> If you discover that you need to allow the reverse conversions later it 
> should not be problematic to add since it won't break anyone's code. It will 
> only allow more code to compile!
Okay. I'll update the document right away.



Comment at: clang/lib/Basic/Targets/SPIR.h:140
+// space must be compatible with the generic address space
+return LangAS::sycl_global;
+  }

Anastasia wrote:
> bader wrote:
> > Anastasia wrote:
> > > This needs a language guard too?
> > I can re-write this method to avoid using language address space:
> > 
> > ```
> >   llvm::Optional getConstantAddressSpace() const override {
> > return getLangASFromTargetAS(1);
> >   }
> > ```
> > 
> > Does it look okay to you?
> > 
> > I don't think we need a language guard here as this hook is already guarded 
> > by users. E.g. 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenModule.cpp#L4137-L4159.
> > Adding language guards for `TargetInfo::getConstantAddressSpace` method 
> > will require API c

[clang] 37e1458 - [NFC] Remove reference to file deleted by D100981.

2021-04-22 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2021-04-22T10:40:18-07:00
New Revision: 37e1458128556ae153313cdb7e085907dff5bb8b

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

LOG: [NFC] Remove reference to file deleted by D100981.

Added: 


Modified: 
clang/lib/Basic/Targets/Le64.cpp
clang/lib/Basic/Targets/Le64.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/Le64.cpp 
b/clang/lib/Basic/Targets/Le64.cpp
index 498dd33a03d1..5c961ff81e05 100644
--- a/clang/lib/Basic/Targets/Le64.cpp
+++ b/clang/lib/Basic/Targets/Le64.cpp
@@ -19,12 +19,6 @@
 using namespace clang;
 using namespace clang::targets;
 
-const Builtin::Info Le64TargetInfo::BuiltinInfo[] = {
-#define BUILTIN(ID, TYPE, ATTRS)   
\
-  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
-#include "clang/Basic/BuiltinsLe64.def"
-};
-
 ArrayRef Le64TargetInfo::getTargetBuiltins() const {
   return {};
 }

diff  --git a/clang/lib/Basic/Targets/Le64.h b/clang/lib/Basic/Targets/Le64.h
index 253d5681abc2..13a0b04d9f09 100644
--- a/clang/lib/Basic/Targets/Le64.h
+++ b/clang/lib/Basic/Targets/Le64.h
@@ -22,7 +22,6 @@ namespace clang {
 namespace targets {
 
 class LLVM_LIBRARY_VISIBILITY Le64TargetInfo : public TargetInfo {
-  static const Builtin::Info BuiltinInfo[];
 
 public:
   Le64TargetInfo(const llvm::Triple &Triple, const TargetOptions &)



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


[PATCH] D101023: [Driver] Specify -ccc-install-dir for linux-cross test

2021-04-22 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 339716.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101023

Files:
  clang/test/Driver/linux-cross.cpp


Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -2,7 +2,8 @@
 
 /// Test native x86-64 in the tree.
 // RUN: %clang -### %s --target=x86_64-linux-gnu 
--sysroot=%S/Inputs/debian_multiarch_tree \
-// RUN:   -resource-dir=%S/Inputs/resource_dir --stdlib=platform 
--rtlib=platform 2>&1 | FileCheck %s --check-prefix=DEBIAN_X86_64
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin 
-resource-dir=%S/Inputs/resource_dir \
+// RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s 
--check-prefix=DEBIAN_X86_64
 // DEBIAN_X86_64:  "-resource-dir" "[[RESOURCE:[^"]+]]"
 // DEBIAN_X86_64:  "-internal-isystem"
 // DEBIAN_X86_64-SAME: {{^}} 
"[[SYSROOT:[^"]+]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10"
@@ -11,6 +12,8 @@
 // DEBIAN_X86_64-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
 // DEBIAN_X86_64-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
 // DEBIAN_X86_64-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
+/// We set explicit -ccc-install-dir ensure that Clang does not pick up extra
+/// library directories which may be present in some build configuration.
 // DEBIAN_X86_64:  "-L
 // DEBIAN_X86_64-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
 /// Debian patches MULTILIB_OSDIRNAMES (../lib64 -> ../lib), so gcc uses 'lib' 
instead of 'lib64'.
@@ -28,7 +31,8 @@
 
 /// Test -m32.
 // RUN: %clang -### %s --target=x86_64-linux-gnu -m32 
--sysroot=%S/Inputs/debian_multiarch_tree \
-// RUN:   -resource-dir=%S/Inputs/resource_dir --stdlib=platform 
--rtlib=platform 2>&1 | FileCheck %s --check-prefix=DEBIAN_X86_64_M32
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin 
-resource-dir=%S/Inputs/resource_dir \
+// RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s 
--check-prefix=DEBIAN_X86_64_M32
 // DEBIAN_X86_64_M32:  "-resource-dir" "[[RESOURCE:[^"]+]]"
 // DEBIAN_X86_64_M32:  "-internal-isystem"
 // DEBIAN_X86_64_M32-SAME: {{^}} 
"[[SYSROOT:[^"]+]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10"
@@ -51,7 +55,8 @@
 
 /// Test native GCC installation on Debian i386.
 // RUN: %clang -### %s --target=i686-linux-gnu 
--sysroot=%S/Inputs/debian_i386_tree \
-// RUN:   -resource-dir=%S/Inputs/resource_dir --stdlib=platform 
--rtlib=platform 2>&1 | FileCheck %s --check-prefix=DEBIAN_I686
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin 
-resource-dir=%S/Inputs/resource_dir \
+// RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s 
--check-prefix=DEBIAN_I686
 // DEBIAN_I686:  "-resource-dir" "[[RESOURCE:[^"]+]]"
 // DEBIAN_I686:  "-internal-isystem"
 // DEBIAN_I686-SAME: {{^}} 
"[[SYSROOT:[^"]+]]/usr/lib/gcc/i686-linux-gnu/10/../../../../include/c++/10"
@@ -75,7 +80,8 @@
 
 /// Test -m64 on Debian i386.
 // RUN: %clang -### %s --target=i686-linux-gnu 
--sysroot=%S/Inputs/debian_i386_tree -m64 \
-// RUN:   -resource-dir=%S/Inputs/resource_dir --stdlib=platform 
--rtlib=platform 2>&1 | FileCheck %s --check-prefix=DEBIAN_I686_M64
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin 
-resource-dir=%S/Inputs/resource_dir \
+// RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s 
--check-prefix=DEBIAN_I686_M64
 // DEBIAN_I686_M64:  "-resource-dir" "[[RESOURCE:[^"]+]]"
 // DEBIAN_I686_M64:  "-internal-isystem"
 // DEBIAN_I686_M64-SAME: {{^}} 
"[[SYSROOT:[^"]+]]/usr/lib/gcc/i686-linux-gnu/10/../../../../include/c++/10"
@@ -100,7 +106,8 @@
 
 /// Test a cross compiler.
 // RUN: %clang -### %s --target=aarch64-linux-gnu 
--sysroot=%S/Inputs/debian_multiarch_tree \
-// RUN:   -resource-dir=%S/Inputs/resource_dir --stdlib=platform 
--rtlib=platform 2>&1 | FileCheck %s --check-prefix=DEBIAN_AARCH64
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin 
-resource-dir=%S/Inputs/resource_dir \
+// RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s 
--check-prefix=DEBIAN_AARCH64
 // DEBIAN_AARCH64:  "-resource-dir" "[[RESOURCE:[^"]+]]"
 // DEBIAN_AARCH64:  "-internal-isystem"
 // DEBIAN_AARCH64-SAME: {{^}} 
"[[SYSROOT:[^"]+]]/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include/c++/10"


Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -2,7 +2,8 @@
 
 /// Test native x86-64 in the tree.
 // RUN: %clang -### %s --target=x86_64-linux-gnu --sysroot=%S/Inputs/debian_multiarch_tree \
-// RUN:   -resource-dir=%S/Inputs/resource_dir --stdlib=platform -

[PATCH] D98746: [clang][amdgpu] Use implicit code object default

2021-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Posted D101077  which is a refactor. Expect 
to shortly post a replacement for this which implements @yaxunl's suggestion 
above, i.e. pass the argument to llc whenever the user specified one to clang


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98746

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


[PATCH] D100981: Delete le32/le64 targets

2021-04-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

maskray: your undelete didn't add back BuiltinsLe64.def so builds are broken atm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100981

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


[PATCH] D100981: Delete le32/le64 targets

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D100981#2709450 , @thakis wrote:

> maskray: your undelete didn't add back BuiltinsLe64.def so builds are broken 
> atm

Fixed by vitalybuka


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100981

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


[PATCH] D101023: [Driver] Specify -ccc-install-dir for linux-cross test

2021-04-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

With a nit




Comment at: clang/test/Driver/linux-cross.cpp:16
+/// We set explicit -ccc-install-dir ensure that Clang does not pick up extra
+/// library directories which may be present in some build configuration.
 // DEBIAN_X86_64:  "-L

Rather than `in some build configuration.`, just mention the configuration 
explicitly.

No need to worry the information gets stale, people can dig up the history if 
the configuration changes.

With `some build configuration`, future people cannot know and may defensively 
add `-ccc-install-dir` everywhere, which is not what we want for these driver 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101023

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


  1   2   3   >