[PATCH] D91297: Frontend: Take VFS and MainFileBuffer by reference in PrecompiledPreamble::CanReuse, NFC

2020-11-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/include/clang/Frontend/PrecompiledPreamble.h:108
   bool CanReuse(const CompilerInvocation &Invocation,
-const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds 
Bounds,
-llvm::vfs::FileSystem *VFS) const;
+const llvm::MemoryBufferRef &MainFileBuffer,
+PreambleBounds Bounds, llvm::vfs::FileSystem &VFS) const;

why not accept a value directly here? (i.e. drop const and ref)


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

https://reviews.llvm.org/D91297

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


[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 306334.
kbobyrev marked 8 inline comments as done.
kbobyrev added a comment.

Resolve review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,7 +18,6 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
@@ -76,6 +75,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -91,9 +92,7 @@
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
-// Get to CXXRecordDecl from constructor or destructor.
-D = tooling::getCanonicalSymbolDeclaration(D);
-Result.insert(D);
+Result.insert(canonicalRenameDecl(D));
   }
   return Result;
 }
@@ -222,23 +221,59 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+// Canonical declarations help simplify the process of renaming. Examples:
+// - Template's canonical decl is the templated declaration (i.e.
+//   ClassTemplateDecl is canonicalized to its child CXXRecordDecl,
+//   FunctionTemplateDecl - to child FunctionDecl)
+// - Given a constructor/destructor, canonical declaration is the parent
+//   CXXRecordDecl because we want to rename both type name and its ctor/dtor.
+// - All specializations are canonicalized to the primary template. For example:
+//
+//template 
+//bool Foo = true; (1)
+//
+//template 
+//bool Foo = true; (2)
+//
+//template <>
+//bool Foo = true; (3)
+//
+// Here, both partial (2) and full (3) specializations are canonicalized to (1)
+// which ensures all three of them are renamed.
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
+  if (const auto *Constructor = dyn_cast(D))
+return canonicalRenameDecl(Constructor->getParent());
+  if (const auto *Destructor = dyn_cast(D))
+return canonicalRenameDecl(Destructor->getParent());
+  if (const auto *VarTemplate = dyn_cast(D))
+D = VarTemplate->getSpecializedTemplate()->getTemplatedDecl();
+  if (const auto *Template = dyn_cast(D))
+if (const NamedDecl *TemplatedDecl = Template->getTemplatedDecl())
+  return canonicalRenameDecl(Template->getTemplatedDecl());
+  if (const auto *ClassTemplateSpecialization =
+  dyn_cast(D))
+D = ClassTemplateSpecialization->getSpecializedTemplate()
+->getTemplatedDecl();
+  if (const auto *Method = dyn_cast(D)) {
+if (const FunctionDecl *InstantiatedMethod =
+Method->getInstantiatedFromMemberFunction())
+  Method = cast(InstantiatedMethod);
+while (Method->isVirtual() && Method->size_overridden_methods())
+  Method = *Method->overridden_methods().begin();
+D = Method;
+  }
+  if (const auto *Function = dyn_cast(D))
+if (const FunctionTemplateDecl *Template = Function->getPrimaryTemplate())
+  return canonicalRenameDecl(Template);
+  return dyn_cast(D->getCanonicalDecl());
+}
+
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
   trace::Span Tracer("FindOccurrencesWithinFile");
-  // If the cursor is at the underlying CXXRecordDecl of the
-  // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
-  // get the primary template manually.
-  // getUSRsForDeclaration will find other related symbols, e.g. virtual and its
-  // overriddens, primary template and all explicit specializations.
-  // FIXME: Get rid of the remaining tooling APIs.
-  const auto *RenameDecl =
-  ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
-  std::vector RenameUSRs =
-  tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
-  llvm::DenseSet TargetIDs;
-  for (auto &USR : RenameUSRs)
-TargetIDs.insert(SymbolID(USR));
+  assert(canonicalRenameDecl(&ND) == &ND &&
+ "ND should be already canonicalized.");
 
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getLocalTopLevelDecls()) {
@@ -246,11 +281,11 @@
   if (Ref.Targets.empty())
 return;
   for (const auto *Target : Ref.Targets) {
-auto ID = getSymbolID(Target);
-if (!ID || TargetIDs.find(ID) == TargetIDs.end())
+if (canonicalRenameDecl(Target) == &ND)

[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90750

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


[clang-tools-extra] 47518d6 - [clang-tidy] Improving bugprone-sizeof-expr check.

2020-11-19 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-11-19T10:26:33+01:00
New Revision: 47518d6a0aed7ec3607aeacfa511dedda2cd67cb

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

LOG: [clang-tidy] Improving bugprone-sizeof-expr check.

Do not warn for "pointer to aggregate" in a `sizeof(A) / sizeof(A[0])`
expression if `A` is an array of pointers. This is the usual way of
calculating the array length even if the array is of pointers.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
index 39526dab79ae..5790e8f84cee 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -77,6 +77,10 @@ void 
SizeofExpressionCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME:
+  // Some of the checks should not match in template code to avoid false
+  // positives if sizeof is applied on template argument.
+
   const auto IntegerExpr = ignoringParenImpCasts(integerLiteral());
   const auto ConstantExpr = expr(ignoringParenImpCasts(
   anyOf(integerLiteral(), unaryOperator(hasUnaryOperand(IntegerExpr)),
@@ -132,6 +136,7 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder 
*Finder) {
  this);
 
   // Detect sizeof(ptr) where ptr points to an aggregate (i.e. sizeof(&S)).
+  // Do not find it if RHS of a 'sizeof(arr) / sizeof(arr[0])' expression.
   const auto ArrayExpr = expr(ignoringParenImpCasts(
   expr(hasType(qualType(hasCanonicalType(arrayType()));
   const auto ArrayCastExpr = expr(anyOf(
@@ -151,13 +156,31 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder 
*Finder) {
   hasType(qualType(hasCanonicalType(PointerToStructType))),
   unless(cxxThisExpr();
 
-  Finder->addMatcher(
-  expr(anyOf(sizeOfExpr(has(expr(ignoringParenImpCasts(
-   anyOf(ArrayCastExpr, PointerToArrayExpr, StructAddrOfExpr,
- PointerToStructExpr),
-sizeOfExpr(has(PointerToStructType
-  .bind("sizeof-pointer-to-aggregate"),
-  this);
+  const auto ArrayOfPointersExpr = expr(ignoringParenImpCasts(expr(hasType(
+  qualType(hasCanonicalType(arrayType(hasElementType(pointerType()))
+.bind("type-of-array-of-pointers")));
+  const auto ArrayOfSamePointersExpr =
+  expr(ignoringParenImpCasts(expr(hasType(qualType(hasCanonicalType(
+  arrayType(equalsBoundNode("type-of-array-of-pointers";
+  const auto ZeroLiteral =
+  expr(ignoringParenImpCasts(integerLiteral(equals(0;
+  const auto ArrayOfSamePointersZeroSubscriptExpr =
+  expr(ignoringParenImpCasts(arraySubscriptExpr(
+  hasBase(ArrayOfSamePointersExpr), hasIndex(ZeroLiteral;
+  const auto ArrayLengthExprDenom =
+  expr(hasParent(expr(ignoringParenImpCasts(
+   binaryOperator(hasOperatorName("/"),
+  hasLHS(expr(ignoringParenImpCasts(expr(
+  sizeOfExpr(has(ArrayOfPointersExpr)),
+   sizeOfExpr(has(ArrayOfSamePointersZeroSubscriptExpr)));
+
+  
Finder->addMatcher(expr(anyOf(sizeOfExpr(has(expr(ignoringParenImpCasts(anyOf(
+ArrayCastExpr, PointerToArrayExpr,
+StructAddrOfExpr, PointerToStructExpr),
+sizeOfExpr(has(PointerToStructType))),
+  unless(ArrayLengthExprDenom))
+ .bind("sizeof-pointer-to-aggregate"),
+ this);
 
   // Detect expression like: sizeof(epxr) <= k for a suspicious constant 'k'.
   if (WarnOnSizeOfCompareToConstant) {
@@ -178,6 +201,12 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder 
*Finder) {
  this);
 
   // Detect sizeof(...) /sizeof(...));
+  // FIXME:
+  // Re-evaluate what cases to handle by the checker.
+  // Probably any sizeof(A)/sizeof(B) should be error if
+  // 'A' is not an array (type) and 'B' the (type of the) first element of it.
+  // Except if 'A' and 'B' are non-pointers, then use the existing size 
division
+  // rule.
   const auto ElemType =
   arrayType(hasElementType(recordType().bind("elem-type")));
   const auto ElemPtrType = pointerType(pointee(type().bind("elem-ptr-type")));

diff  --git 
a/

[PATCH] D91543: [clang-tidy] Improving bugprone-sizeof-expr check.

2020-11-19 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47518d6a0aed: [clang-tidy] Improving bugprone-sizeof-expr 
check. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91543

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -187,6 +187,7 @@
 
 int Test5() {
   typedef int Array10[10];
+  typedef C ArrayC[10];
 
   struct MyStruct {
 Array10 arr;
@@ -203,6 +204,8 @@
   PMyStruct PS;
   PMyStruct2 PS2;
   Array10 A10;
+  C *PtrArray[10];
+  C *PC;
 
   int sum = 0;
   sum += sizeof(&S.arr);
@@ -239,6 +242,17 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
   sum += sizeof(&A10);
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
+  sum += sizeof(PtrArray) / sizeof(PtrArray[1]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
+  sum += sizeof(A10) / sizeof(PtrArray[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
+  sum += sizeof(PC) / sizeof(PtrArray[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
+  // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-3]]:23: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
+  sum += sizeof(ArrayC) / sizeof(PtrArray[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-2]]:27: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
 
   return sum;
 }
@@ -276,6 +290,10 @@
   int A[] = {1, 2, 3, 4};
   static const char str[] = "hello";
   static const char* ptr[] { "aaa", "bbb", "ccc" };
+  typedef C *CA10[10];
+  C *PtrArray[10];
+  CA10 PtrArray1;
+
   int sum = 0;
   if (sizeof(A) < 10)
 sum += sizeof(A);
@@ -293,5 +311,10 @@
   sum += sizeof(str) / sizeof(str[0]);
   sum += sizeof(ptr) / sizeof(ptr[0]);
   sum += sizeof(ptr) / sizeof(*(ptr));
+  sum += sizeof(PtrArray) / sizeof(PtrArray[0]);
+  // Canonical type of PtrArray1 is same as PtrArray.
+  sum = sizeof(PtrArray) / sizeof(PtrArray1[0]);
+  // There is no warning for 'sizeof(T*)/sizeof(Q)' case.
+  sum += sizeof(PtrArray) / sizeof(A[0]);
   return sum;
 }
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -77,6 +77,10 @@
 }
 
 void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME:
+  // Some of the checks should not match in template code to avoid false
+  // positives if sizeof is applied on template argument.
+
   const auto IntegerExpr = ignoringParenImpCasts(integerLiteral());
   const auto ConstantExpr = expr(ignoringParenImpCasts(
   anyOf(integerLiteral(), unaryOperator(hasUnaryOperand(IntegerExpr)),
@@ -132,6 +136,7 @@
  this);
 
   // Detect sizeof(ptr) where ptr points to an aggregate (i.e. sizeof(&S)).
+  // Do not find it if RHS of a 'sizeof(arr) / sizeof(arr[0])' expression.
   const auto ArrayExpr = expr(ignoringParenImpCasts(
   expr(hasType(qualType(hasCanonicalType(arrayType()));
   const auto ArrayCastExpr = expr(anyOf(
@@ -151,13 +156,31 @@
   hasType(qualType(hasCanonicalType(PointerToStructType))),
   unless(cxxThisExpr();
 
-  Finder->addMatcher(
-  expr(anyOf(sizeOfExpr(has(expr(ignoringParenImpCasts(
-   anyOf(ArrayCastExpr, PointerToArrayExpr, StructAddrOfExpr,
- PointerToStructExpr),
-sizeOfExpr(has(PointerToStructType
-  .bind("sizeof-pointer-to-aggregate"),
-  this);
+  const auto ArrayOfPointersExpr = expr(ignoringParenImpCasts(expr(hasType(
+  qualType(hasCanonicalType(arrayType(hasElementType(pointerType()))
+.bind("type-of-array-of-pointers")));
+  const auto ArrayOfSamePointersExpr =
+  expr(ignoringParenImpCasts(expr(hasType(qualType(hasCanonicalType(
+  arrayType(equalsBoundNode("type-of-array-of-pointers";
+  const auto ZeroLiteral =
+  expr(ignoringParenImpCasts(integerLiteral(equals(0)

[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-11-19 Thread Rafal Kupiec via Phabricator via cfe-commits
belliash added a comment.

With your latest patch update clang segfaults for me even when '-feh-asynch' is 
not passed.


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

https://reviews.llvm.org/D80344

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


[PATCH] D91519: [AST][Mach0] Fix unused-variable warnings

2020-11-19 Thread David Stenberg 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 rG2d1f471e45af: [Mach0] Fix unused-variable warnings (authored 
by ehjogab, committed by dstenb).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D91519?vs=305984&id=306339#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91519

Files:
  lld/MachO/SymbolTable.cpp


Index: lld/MachO/SymbolTable.cpp
===
--- lld/MachO/SymbolTable.cpp
+++ lld/MachO/SymbolTable.cpp
@@ -134,7 +134,7 @@
 // FIXME: Make every symbol (including absolute symbols) contain a
 // reference to their originating file, then add that file name to this
 // error message.
-if (auto *defined = dyn_cast(s))
+if (isa(s))
   error("found defined symbol with illegal name " + DSOHandle::name);
   }
   replaceSymbol(s, header);


Index: lld/MachO/SymbolTable.cpp
===
--- lld/MachO/SymbolTable.cpp
+++ lld/MachO/SymbolTable.cpp
@@ -134,7 +134,7 @@
 // FIXME: Make every symbol (including absolute symbols) contain a
 // reference to their originating file, then add that file name to this
 // error message.
-if (auto *defined = dyn_cast(s))
+if (isa(s))
   error("found defined symbol with illegal name " + DSOHandle::name);
   }
   replaceSymbol(s, header);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91776: [ARM][AAarch64] Initial command-line support for v8.7-A

2020-11-19 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.
pratlucas requested review of this revision.

This introduces command-line support for the 'armv8.7-a' architecture name
(and an alias without the '-', as usual), and for the 'ls64' extension name.

Based on patches written by Simon Tatham.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91776

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/aarch64-ls64.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Index: llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -5384,6 +5384,7 @@
 case AArch64::ArchKind::ARMV8_4A:
 case AArch64::ArchKind::ARMV8_5A:
 case AArch64::ArchKind::ARMV8_6A:
+case AArch64::ArchKind::ARMV8_7A:
 case AArch64::ArchKind::ARMV8R:
   RequestedExtensions.push_back("sm4");
   RequestedExtensions.push_back("sha3");
@@ -5405,6 +5406,7 @@
 case AArch64::ArchKind::ARMV8_4A:
 case AArch64::ArchKind::ARMV8_5A:
 case AArch64::ArchKind::ARMV8_6A:
+case AArch64::ArchKind::ARMV8_7A:
   RequestedExtensions.push_back("nosm4");
   RequestedExtensions.push_back("nosha3");
   RequestedExtensions.push_back("nosha2");
Index: llvm/lib/Support/ARMTargetParser.cpp
===
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -154,6 +154,7 @@
   .Case("v8.4a", "v8.4-a")
   .Case("v8.5a", "v8.5-a")
   .Case("v8.6a", "v8.6-a")
+  .Case("v8.7a", "v8.7-a")
   .Case("v8r", "v8-r")
   .Case("v8m.base", "v8-m.base")
   .Case("v8m.main", "v8-m.main")
Index: llvm/lib/Support/AArch64TargetParser.cpp
===
--- llvm/lib/Support/AArch64TargetParser.cpp
+++ llvm/lib/Support/AArch64TargetParser.cpp
@@ -118,6 +118,8 @@
 Features.push_back("+v8.5a");
   if (AK == AArch64::ArchKind::ARMV8_6A)
 Features.push_back("+v8.6a");
+  if (AK == AArch64::ArchKind::ARMV8_7A)
+Features.push_back("+v8.7a");
   if(AK == AArch64::ArchKind::ARMV8R)
 Features.push_back("+v8r");
 
Index: llvm/include/llvm/Support/AArch64TargetParser.h
===
--- llvm/include/llvm/Support/AArch64TargetParser.h
+++ llvm/include/llvm/Support/AArch64TargetParser.h
@@ -62,6 +62,7 @@
   AEK_I8MM =1 << 30,
   AEK_F32MM =   1ULL << 31,
   AEK_F64MM =   1ULL << 32,
+  AEK_LS64 =1ULL << 33,
 };
 
 enum class ArchKind {
Index: llvm/include/llvm/Support/AArch64TargetParser.def
===
--- llvm/include/llvm/Support/AArch64TargetParser.def
+++ llvm/include/llvm/Support/AArch64TargetParser.def
@@ -51,6 +51,13 @@
   AArch64::AEK_RDM  | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
   AArch64::AEK_SM4  | AArch64::AEK_SHA3 | AArch64::AEK_BF16|
   AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM))
+AARCH64_ARCH("armv8.7-a", ARMV8_7A, "8.7-A", "v8.7a",
+ ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,
+ (AArch64::AEK_CRC | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+  AArch64::AEK_SM4 | AArch64::AEK_SHA3 | AArch64::AEK_BF16 |
+  AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM))
 AARCH64_ARCH("armv8-r", ARMV8R, "8-R", "v8r",
  ARMBuildAttrs::CPUArch::v8_R, FK_CRYPTO_NEON_FP_ARMV8,
  (AArch64::AEK_CRC | AArch64::AEK_RDM  | AArch64::AEK_SSBS|
@@ -99,6 +106,7 @@
 AARCH64_ARCH_EXT_NAME("f32mm",AArch64::AEK_F32MM,   "+f32mm", "-f32mm")
 AARCH64_ARCH_EXT_NAME("f64mm",AArch64::AEK_F64MM,   "+f64mm", "-f64mm")
 AARCH64_ARCH_EXT_NAME("tme",  AArch64::AEK_TME, "+tme",   "-tme")
+AARCH64_ARCH_EXT_NAME("ls64", AArch64::AEK_LS64,"+ls64",  "-ls64")
 #undef AARCH64_ARCH_EXT_NAME
 
 #ifndef AARCH64_CPU_NAME
Index: clang/test/Driver/aarch64-ls64.c
===
--- /dev/null
+++ clang/test/Driver/aarch64-ls64.c
@@ -0,0 +1,12 @@
+// Test that target feature ls64 is implemented and available correctly
+// RUN: %clang -### -target aarch64-none-none-eabi -

[PATCH] D91777: [clangd] No crash on "-verify" mode.

2020-11-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: adamcz.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

If there is a "-verify" flag in the compile command, clangd will crash
(hit the assertion) inside the `~VerifyDiagnosticConsumer` (Looks like our
compiler invocation doesn't setup correctly?).

This patch disables the verify mode as it is rarely useful in clangd.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91777

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -491,6 +491,15 @@
   ElementsAre(Diag(Test.range(), "use of undeclared identifier 'b'")));
 }
 
+TEST(DiagnosticsTest, IgnoreVerify) {
+  auto TU = TestTU::withCode(R"cpp(
+int a; // expected-error {{}}
+  )cpp");
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-verify");
+  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
 // Recursive main-file include is diagnosed, and doesn't crash.
 TEST(DiagnosticsTest, RecursivePreamble) {
   auto TU = TestTU::withCode(R"cpp(
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -60,6 +60,10 @@
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+  // our compiler invocation set-up doesn't seem to work with it (leading
+  // assertions in VerifyDiagnosticConsumer).
+  CI->getDiagnosticOpts().VerifyDiagnostics = false;
 
   // Disable any dependency outputting, we don't want to generate files or 
write
   // to stdout/stderr.


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -491,6 +491,15 @@
   ElementsAre(Diag(Test.range(), "use of undeclared identifier 'b'")));
 }
 
+TEST(DiagnosticsTest, IgnoreVerify) {
+  auto TU = TestTU::withCode(R"cpp(
+int a; // expected-error {{}}
+  )cpp");
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-verify");
+  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
 // Recursive main-file include is diagnosed, and doesn't crash.
 TEST(DiagnosticsTest, RecursivePreamble) {
   auto TU = TestTU::withCode(R"cpp(
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -60,6 +60,10 @@
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+  // our compiler invocation set-up doesn't seem to work with it (leading
+  // assertions in VerifyDiagnosticConsumer).
+  CI->getDiagnosticOpts().VerifyDiagnostics = false;
 
   // Disable any dependency outputting, we don't want to generate files or write
   // to stdout/stderr.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91696: [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

2020-11-19 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 306351.
joechrisellis marked an inline comment as done.
joechrisellis added a comment.

Address @c-rhodes's comments regarding lax conversion when 
__ARM_FEATURE_SVE_BITS != N for GNU vectors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91696

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Sema/aarch64-sve-lax-vector-conversions.c
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp

Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -7,32 +7,61 @@
 #include 
 
 #define N __ARM_FEATURE_SVE_BITS
-#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
 
-typedef svfloat32_t fixed_float32_t FIXED_ATTR;
-typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
+typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
+typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
+typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
 
-void allowed_with_integer_lax_conversions() {
-  fixed_int32_t fi32;
+void sve_allowed_with_integer_lax_conversions() {
+  sve_fixed_int32_t fi32;
   svint64_t si64;
 
   // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
   // -flax-vector-conversions={integer,all}.
   fi32 = si64;
-  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
   si64 = fi32;
   // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
 }
 
-void allowed_with_all_lax_conversions() {
-  fixed_float32_t ff32;
+void sve_allowed_with_all_lax_conversions() {
+  sve_fixed_float32_t ff32;
   svfloat64_t sf64;
 
   // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
   // -flax-vector-conversions=all.
   ff32 = sf64;
-  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
-  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  sf64 = ff32;
+  // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_integer_lax_conversions() {
+  gnu_fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // -flax-vector-conversions={integer,all}.
+  fi32 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  si64 = fi32;
+  // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_all_lax_conversions() {
+  gnu_fixed_float32_t ff32;
+  svfloat64_t sf64;
+
+  // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+  // -flax-vector-conversions=all.
+  ff32 = sf64;
+  // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
   sf64 = ff32;
   // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
   // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -272,9 +272,6 @@
 // Test the implicit conversion only applies to valid types
 fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
 
-svint64_t to_svint64_t__from_gnu_int32_t(gnu_int32_t x) { return x; } // expected-error-re {{returning 'gnu_int32_t' (vector of

[PATCH] D91696: [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

2020-11-19 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis added inline comments.



Comment at: clang/test/Sema/attr-arm-sve-vector-bits.c:278-283
-// Test implicit conversion between SVE and GNU vector is invalid when
-// __ARM_FEATURE_SVE_BITS != N
-#if defined(__ARM_FEATURE_SVE_BITS) && __ARM_FEATURE_SVE_BITS == 512
-typedef int32_t int4 __attribute__((vector_size(16)));
-svint32_t badcast(int4 x) { return x; } // expected-error {{returning 'int4' 
(vector of 4 'int32_t' values) from a function with incompatible result type 
'svint32_t' (aka '__SVInt32_t')}}
-#endif

c-rhodes wrote:
> I don't think this can be removed. The ACLE states "Whenever 
> __ARM_FEATURE_SVE_BITS==N, GNUT implicitly converts to VLAT and VLAT 
> implicitly converts to GNUT.".
> 
> AFAIK lax vector conversions only apply to vectors of the same width, with 
> GNU vectors for example the following is invalid regardless of lax vector 
> conversions:
> 
> ```typedef int8_t int8x16_t __attribute__((vector_size(16)));
> typedef int8_t int8x64_t __attribute__((vector_size(64)));
> 
> int8x16_t foo(int8x64_t x) { return x; }```
Great spot, didn't see that in the spec. I've re-added the test and added an 
extra condition to check if `__ARM_FEATURE_SVE_BITS == N` before allowing the 
lax conversion for GNU vectors. Not sure if this is the best way to do it, 
though. :) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91696

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


[PATCH] D91605: [sanitizers] Implement GetTls on Solaris

2020-11-19 Thread Rainer Orth via Phabricator via cfe-commits
ro added inline comments.



Comment at: clang/lib/Driver/ToolChains/Solaris.cpp:150
+  const SanitizerArgs &SA = getToolChain().getSanitizerArgs();
+  if (LINKER_SUPPORTS_Z_RELAX_TRANSTLS &&
+  getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&

MaskRay wrote:
> MaskRay wrote:
> > Can the configure-time variable `LINKER_SUPPORTS_Z_RELAX_TRANSTLS` be 
> > replaced by a version check on the triple suffix?
> > 
> > You can see some tests where `x86_64-unknown-freebsd11` or 
> > `x86_64-unknown-freebsd12` is used. The idea is that the driver 
> > continuously bumps the default version.
> .. and the code base should not be littered with -D macros from 
> configure-time variables here and there.
> Can the configure-time variable `LINKER_SUPPORTS_Z_RELAX_TRANSTLS` be 
> replaced by a version check on the triple suffix?
> 
> You can see some tests where `x86_64-unknown-freebsd11` or 
> `x86_64-unknown-freebsd12` is used. The idea is that the driver continuously 
> bumps the default version.

This cannot work: both Solaris 11 and Illumos share the same configure triple, 
`x86_64-pc-solaris2.11`.

Please keep in mind that Solaris 11 was released almost exactly 9 years ago, is 
in its 5th micro version since, each of which getting monthly updates (at least 
for a while).  Even if it were possible to extract the micro version and update 
number from the triple, hardcoding which introduced which feature is 
effectively impossible.  Some `ld` and `libc` features are also backported to 
an update of the previous micro version; hardcoding all this knowledge is 
simply a nightmare.

TBH, I feel put back to the bad old times 20+ years ago when software tried to 
hardcode all knowledge about the environment, and usually failed even at the 
time of writing.  This only got better once feature-based approaches got 
traction.



Comment at: clang/lib/Driver/ToolChains/Solaris.cpp:150
+  const SanitizerArgs &SA = getToolChain().getSanitizerArgs();
+  if (LINKER_SUPPORTS_Z_RELAX_TRANSTLS &&
+  getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&

ro wrote:
> MaskRay wrote:
> > MaskRay wrote:
> > > Can the configure-time variable `LINKER_SUPPORTS_Z_RELAX_TRANSTLS` be 
> > > replaced by a version check on the triple suffix?
> > > 
> > > You can see some tests where `x86_64-unknown-freebsd11` or 
> > > `x86_64-unknown-freebsd12` is used. The idea is that the driver 
> > > continuously bumps the default version.
> > .. and the code base should not be littered with -D macros from 
> > configure-time variables here and there.
> > Can the configure-time variable `LINKER_SUPPORTS_Z_RELAX_TRANSTLS` be 
> > replaced by a version check on the triple suffix?
> > 
> > You can see some tests where `x86_64-unknown-freebsd11` or 
> > `x86_64-unknown-freebsd12` is used. The idea is that the driver 
> > continuously bumps the default version.
> 
> This cannot work: both Solaris 11 and Illumos share the same configure 
> triple, `x86_64-pc-solaris2.11`.
> 
> Please keep in mind that Solaris 11 was released almost exactly 9 years ago, 
> is in its 5th micro version since, each of which getting monthly updates (at 
> least for a while).  Even if it were possible to extract the micro version 
> and update number from the triple, hardcoding which introduced which feature 
> is effectively impossible.  Some `ld` and `libc` features are also backported 
> to an update of the previous micro version; hardcoding all this knowledge is 
> simply a nightmare.
> 
> TBH, I feel put back to the bad old times 20+ years ago when software tried 
> to hardcode all knowledge about the environment, and usually failed even at 
> the time of writing.  This only got better once feature-based approaches got 
> traction.
> .. and the code base should not be littered with -D macros from 
> configure-time variables here and there.

What's so bad about that?  Why is `LINKER_SUPPORTS_Z_RELAX_TRANSTLS` detected 
at build time better than a runtime check for Solaris/x86 11.3 or higher, but 
not 11.3 update < x and not Illumos?

With the configure-based approach, I know at least which features are tested by 
the code, rather than finding months or even years later that some check is 
hardcoded in some obscure part of the code that I missed?  And for new targets, 
many things just fall into place automatically.  Consider `compiler-rt`'s maze 
in `sanitizer_platform_interceptors.h`. With features introduced in micro 
versions and updates, one cannot even express that some feature got introduced 
in one of those.



Comment at: clang/tools/driver/CMakeLists.txt:123
+
+check_linker_flag("-Wl,-z,relax=transtls" LINKER_SUPPORTS_Z_RELAX_TRANSTLS)

MaskRay wrote:
> GNU ld reports a warning instead of an error when an unknown `-z` is seen. 
> The warning remains a warning even with `--fatal-warnings`.
> GNU ld reports a warning instead of a

[PATCH] D91507: [clang-format] Add option for case sensitive regexes for sorted includes

2020-11-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Can you rerun

clang/docs/tools/dump_style.py


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91507

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


[PATCH] D91507: [clang-format] Add option for case sensitive regexes for sorted includes

2020-11-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

make sure you build the other clang-extra tools (I'm not sure who else uses the 
lib/Tooling)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91507

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


[PATCH] D91428: Add support for multiple program address spaces

2020-11-19 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

The RFC has now been sent to the mailing list: 
http://lists.llvm.org/pipermail/llvm-dev/2020-November/146723.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

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


[PATCH] D91776: [ARM][AAarch64] Initial command-line support for v8.7-A

2020-11-19 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard accepted this revision.
ostannard added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91776

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


[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-19 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 306358.
joechrisellis added a comment.

Avoid doing `FirstType->getAs()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
  clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp

Index: clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define CAST(from, to) \
+void from##_to_##to(from a, to b) { \
+b = (to) a; \
+}
+
+#define TESTCASE(ty1, ty2) \
+CAST(ty1, ty2) \
+CAST(ty2, ty1)
+
+TESTCASE(fixed_float32_t, svfloat32_t)
+TESTCASE(fixed_float32_t, svfloat64_t)
+TESTCASE(fixed_float32_t, svint32_t)
+TESTCASE(fixed_float32_t, svint64_t)
+
+TESTCASE(fixed_float64_t, svfloat32_t)
+TESTCASE(fixed_float64_t, svfloat64_t)
+TESTCASE(fixed_float64_t, svint32_t)
+TESTCASE(fixed_float64_t, svint64_t)
+
+TESTCASE(fixed_int32_t, svfloat32_t)
+TESTCASE(fixed_int32_t, svfloat64_t)
+TESTCASE(fixed_int32_t, svint32_t)
+TESTCASE(fixed_int32_t, svint64_t)
+
+TESTCASE(fixed_int64_t, svfloat32_t)
+TESTCASE(fixed_int64_t, svfloat64_t)
+TESTCASE(fixed_int64_t, svint32_t)
+TESTCASE(fixed_int64_t, svint64_t)
Index: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define CAST(from, to) \
+void from##_to_##to(from a, to b) { \
+b = (to) a; \
+}
+
+#define TESTCASE(ty1, ty2) \
+CAST(ty1, ty2) \
+CAST(ty2, ty1)
+
+TESTCASE(fixed_float32_t, svfloat32_t)
+TESTCASE(fixed_float32_t, svfloat64_t)
+TESTCASE(fixed_float32_t, svint32_t)
+TESTCASE(fixed_float32_t, svint64_t)
+
+TESTCASE(fixed_float64_t, s

[clang] 1e2da38 - [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-19 Thread Joe Ellis via cfe-commits

Author: Joe Ellis
Date: 2020-11-19T11:18:35Z
New Revision: 1e2da3839cc3543629ecb847fd3aa34edb64b42a

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

LOG: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

This patch allows C-style casting between fixed-size and scalable
vectors. This kind of cast was previously blocked by the compiler, but
it should be allowed.

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

Added: 
clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index fb95b8cbd193..20c7e8c2ed1b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11501,6 +11501,8 @@ class Sema final {
   QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS,
SourceLocation Loc, bool IsCompAssign);
 
+  bool isValidSveBitcast(QualType srcType, QualType destType);
+
   bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
   bool isLaxVectorConversion(QualType srcType, QualType destType);
 

diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 0bd240585bd7..671820afd485 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2219,6 +2219,12 @@ static TryCastResult TryReinterpretCast(Sema &Self, 
ExprResult &SrcExpr,
   bool destIsVector = DestType->isVectorType();
   bool srcIsVector = SrcType->isVectorType();
   if (srcIsVector || destIsVector) {
+// Allow bitcasting between SVE VLATs and VLSTs, and vice-versa.
+if (Self.isValidSveBitcast(SrcType, DestType)) {
+  Kind = CK_BitCast;
+  return TC_Success;
+}
+
 // The non-vector type, if any, must have integral type.  This is
 // the same rule that C vector casts use; note, however, that enum
 // types are not integral in C++.
@@ -2752,6 +2758,13 @@ void CastOperation::CheckCStyleCast() {
 return;
   }
 
+  // Allow bitcasting between compatible SVE vector types.
+  if ((SrcType->isVectorType() || DestType->isVectorType()) &&
+  Self.isValidSveBitcast(SrcType, DestType)) {
+Kind = CK_BitCast;
+return;
+  }
+
   if (!DestType->isScalarType() && !DestType->isVectorType()) {
 const RecordType *DestRecordTy = DestType->getAs();
 

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e1a87ede3bdd..7a8124fadfd7 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7197,6 +7197,28 @@ static bool breakDownVectorType(QualType type, uint64_t 
&len,
   return true;
 }
 
+/// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from the
+/// first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE VLST)
+/// allowed?
+///
+/// This will also return false if the two given types do not make sense from
+/// the perspective of SVE bitcasts.
+bool Sema::isValidSveBitcast(QualType srcTy, QualType destTy) {
+  assert(srcTy->isVectorType() || destTy->isVectorType());
+
+  auto ValidScalableConversion = [](QualType FirstType, QualType SecondType) {
+if (!FirstType->isSizelessBuiltinType())
+  return false;
+
+const auto *VecTy = SecondType->getAs();
+return VecTy &&
+   VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector;
+  };
+
+  return ValidScalableConversion(srcTy, destTy) ||
+ ValidScalableConversion(destTy, srcTy);
+}
+
 /// Are the two types lax-compatible vector types?  That is, given
 /// that one of them is a vector, do they have equal storage sizes,
 /// where the storage size is the number of elements times the element

diff  --git a/clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c 
b/clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
new file mode 100644
index ..a93110db7cce
--- /dev/null
+++ b/clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=128 -flax-vector-conversions=none 
-fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=256 -flax-vector-conversions=none 
-fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=512 -flax-vector-conversions=none 
-fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu 

[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-19 Thread Joe Ellis 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 rG1e2da3839cc3: [AArch64][SVE] Allow C-style casts between 
fixed-size and scalable vectors (authored by joechrisellis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
  clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp

Index: clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define CAST(from, to) \
+void from##_to_##to(from a, to b) { \
+b = (to) a; \
+}
+
+#define TESTCASE(ty1, ty2) \
+CAST(ty1, ty2) \
+CAST(ty2, ty1)
+
+TESTCASE(fixed_float32_t, svfloat32_t)
+TESTCASE(fixed_float32_t, svfloat64_t)
+TESTCASE(fixed_float32_t, svint32_t)
+TESTCASE(fixed_float32_t, svint64_t)
+
+TESTCASE(fixed_float64_t, svfloat32_t)
+TESTCASE(fixed_float64_t, svfloat64_t)
+TESTCASE(fixed_float64_t, svint32_t)
+TESTCASE(fixed_float64_t, svint64_t)
+
+TESTCASE(fixed_int32_t, svfloat32_t)
+TESTCASE(fixed_int32_t, svfloat64_t)
+TESTCASE(fixed_int32_t, svint32_t)
+TESTCASE(fixed_int32_t, svint64_t)
+
+TESTCASE(fixed_int64_t, svfloat32_t)
+TESTCASE(fixed_int64_t, svfloat64_t)
+TESTCASE(fixed_int64_t, svint32_t)
+TESTCASE(fixed_int64_t, svint64_t)
Index: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define CAST(from, to) \
+void from##_to_##to(from a, to b) { \
+b = (to) a; \
+}
+
+#define TESTCASE(ty1, ty2) \
+CAST(ty1, ty2) \
+CAST(ty2, ty1)
+
+TESTCASE(fixed_float32_t, svfloat32_

[PATCH] D72184: [BPF] support atomic instructions

2020-11-19 Thread Brendan Jackman via Phabricator via cfe-commits
jackmanb added a comment.

Can we please keep barriers out of scope? I think there's a lot of design to be 
done there and I'd rather just get the core atomics working first.

BTW I got

  [ 31%] Building LanaiGenDAGISel.inc...
   
  Included from 
/usr/local/google/home/jackmanb/src/llvm-project/llvm/lib/Target/BPF/BPF.td:13: 
   
  
/usr/local/google/home/jackmanb/src/llvm-project/llvm/lib/Target/BPF/BPFInstrInfo.td:677:1:
 error: Pattern doesn't match mayStore = 1
  def : Pat<(atomic_fence (timm), (timm)), (SYNC)>; 
   
  ^ 
   
  error: pattern conflicts  
   

But removing line 677 fixes it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72184

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


[PATCH] D17993: [CodeGen] Apply 'nonnull' and 'dereferenceable(N)' to 'this' pointer arguments.

2020-11-19 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2169
+if (!CodeGenOpts.NullPointerIsValid &&
+getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
+  Attrs.addAttribute(llvm::Attribute::NonNull);

rjmccall wrote:
> arichardson wrote:
> > rjmccall wrote:
> > > rsmith wrote:
> > > > jdoerfert wrote:
> > > > > rjmccall wrote:
> > > > > > rsmith wrote:
> > > > > > > jdoerfert wrote:
> > > > > > > > arichardson wrote:
> > > > > > > > > Isn't the `this` pointer also nonnull in other address spaces?
> > > > > > > > > 
> > > > > > > > > In our CHERI fork we use AS200 for the this pointer and would 
> > > > > > > > > quite like to have the nonnull attribute.
> > > > > > > > > I can obviously change this line locally when I next merge 
> > > > > > > > > from upstream, but I would like to avoid diffs and it seems 
> > > > > > > > > to me like this restriction is unnecessary.
> > > > > > > > I also think `NullPointerIsValid` is sufficient. 
> > > > > > > It's my understanding that:
> > > > > > > * The LLVM `null` value in any address space is the all-zero-bits 
> > > > > > > value.
> > > > > > > * In address space zero, the `null` value does not correspond to 
> > > > > > > addressable memory, but this is not assumed to hold in other 
> > > > > > > address spaces.
> > > > > > > * An address-space-zero `null` value that is addressspacecast to 
> > > > > > > a different address space might not be the `null` in the target 
> > > > > > > address space.
> > > > > > > * The `nonnull` attribute implies that the pointer value is not 
> > > > > > > the `null` value.
> > > > > > > * A null pointer in the frontend in a non-zero address space 
> > > > > > > corresponds to the value produced by an addressspacecast of an 
> > > > > > > address-space-zero `null` value to the target address space.
> > > > > > > 
> > > > > > > That being the case, there is simply no connection between the C 
> > > > > > > and C++ notion of a null pointer and a `null` LLVM pointer value 
> > > > > > > in a non-zero address space in general, so it is not correct to 
> > > > > > > use the `nonnull` attribute in a non-zero address space in 
> > > > > > > general. Only if we know that a C++ null pointer is actually 
> > > > > > > represented by the LLVM `null` value in the corresponding address 
> > > > > > > space can we use the `nonnull` attribute to expose that fact to 
> > > > > > > LLVM. And we do not know that in general.
> > > > > > I think all of this is correct except that the frontend does know 
> > > > > > what the bit-pattern of the null pointer is in any particular 
> > > > > > language-level address space, and it knows what the language-level 
> > > > > > address space of `this` is.  So we should be able to ask whether 
> > > > > > the null value in the `this` address space is the all-zero value 
> > > > > > and use that to decide whether to apply `nonnull`.
> > > > > Hm, I think the problem is that we don't couple `NullPointerIsValid` 
> > > > > with the address space. As I said before. In LLVM-IR, if we don't 
> > > > > have the `null-pointer-is-valid` property, then "memory access" 
> > > > > implies `dereferenceable` implies `nonnull`. Now, we usually assume 
> > > > > non-0 address spaces to have the above property, but that should be 
> > > > > decoupled. The query if "null is valid" should take the function and 
> > > > > the AS, as it does conceptually in LLVM-core, and then decide if 
> > > > > `null-pointer-is-valid` or not. If we had that, @arichardson could 
> > > > > define that AS200 does not have valid null pointers. If you do that 
> > > > > right now the IR passes will at least deduce `nonnull` based on 
> > > > > `derferenceable`.
> > > > > I think all of this is correct except that the frontend does know 
> > > > > what the bit-pattern of the null pointer is in any particular 
> > > > > language-level address space
> > > > 
> > > > Interesting. How do we get at that? Do we ask the middle-end to 
> > > > constant-fold `addrspacecast i8* null to i8* addrspace(N)` and see if 
> > > > we get a `null` back, or is there a better way?
> > > > 
> > > > In any case, this patch follows the same pattern we use for return 
> > > > values of reference type, parameters of reference type, and decayed 
> > > > array function parameters with static array bounds, all of which apply 
> > > > `nonnull` only in address space 0. If we want to use a different 
> > > > pattern, to consider whether LLVM's `nonnull` means "not a null 
> > > > pointer" rather than assuming that holds only in address space 0, we 
> > > > should make a holistic change for that throughout CGCall.cpp, rather 
> > > > than touching only the handling of the `this` pointer.
> > > > 
> > > > It'd also be interesting to consider what we want 
> > > > `__attribute__((nonnull))` to mean in address spaces where the null 
> > > > pointer isn't the zero pointer: should it mean non-zero at th

[PATCH] D87981: [X86] AMX programming model.

2020-11-19 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

You should at least get @craig.topper's feedback, given this is a significant 
change in the x86 backend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

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


[PATCH] D87981: [X86] AMX programming model.

2020-11-19 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added a comment.

In D87981#2405187 , @rengolin wrote:

> You should at least get @craig.topper's feedback, given this is a significant 
> change in the x86 backend.

We had internal review with Craig on the design before. Craig

In D87981#2405187 , @rengolin wrote:

> You should at least get @craig.topper's feedback, given this is a significant 
> change in the x86 backend.

We have internal review with Craig and Andy on the design before. Craig may be 
very busy for now.
@craig.topper 
Would you take the time to review my patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

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


[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-19 Thread Andrea Di Biagio via Phabricator via cfe-commits
andreadb added a comment.

LGTM for llvm-mca.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91410

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


[clang-tools-extra] 1407833 - [clangd] Disable SerializationTest.NoCrashOnBadArraySize with ASAN

2020-11-19 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-11-19T13:24:55+01:00
New Revision: 140783347afb6e1848c81617d7fa3e556087cadd

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

LOG: [clangd] Disable SerializationTest.NoCrashOnBadArraySize with ASAN

Address Sanitizer crashes on large allocations:

```c++
// Try to crash rather than hang on large allocation.
ScopedMemoryLimit MemLimit(1000 * 1024 * 1024); // 1GB
```

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SerializationTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index ca7d3ba7e3e1..68d1d1a0df8b 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -332,6 +332,7 @@ class ScopedMemoryLimit {
 };
 #endif
 
+#ifndef LLVM_ADDRESS_SANITIZER_BUILD
 // Test that our deserialization detects invalid array sizes without 
allocating.
 // If this detection fails, the test should allocate a huge array and crash.
 TEST(SerializationTest, NoCrashOnBadArraySize) {
@@ -382,6 +383,7 @@ TEST(SerializationTest, NoCrashOnBadArraySize) {
   EXPECT_EQ(llvm::toString(CorruptParsed.takeError()),
 "malformed or truncated include uri");
 }
+#endif
 
 } // namespace
 } // namespace clangd



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


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-19 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D91311#2404098 , @rsmith wrote:

> In D91311#2403805 , @ldionne wrote:
>
>> We can stick with this design, but I'd like to understand why `#if 
>> _LIBCPP_HAS_NO_PREFERRED_NAME` is necessary in ``, and also the CI 
>> is failing on MacOS.
>
> You mean the HWAddressSanitizer test failure? That appears to be a flake. 
> Looking through recent failures I found more that look the same: 
> https://reviews.llvm.org/B79364 https://reviews.llvm.org/B79363 
> https://reviews.llvm.org/B79358

I was talking about his issue in the libc++ CI. See 
https://buildkite.com/llvm-project/libcxx-ci/builds/422#8e9a6d80-32ff-429e-a3de-e7ecc111c2fb
 (gotta look at the raw log).

  
/tmp/buildkite-agent/builds/libcxx-mbp-local-1/llvm-project/libcxx-ci/libcxx/include/iosfwd:190:34:
 error: redefinition of 'ios' as different kind of symbol
  
  class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_PREFERRED_NAME(wios) basic_ios;
  
   ^




Comment at: libcxx/include/iosfwd:188
 
+#ifdef _LIBCPP_PREFERRED_NAME
+template 

rsmith wrote:
> ldionne wrote:
> > rsmith wrote:
> > > aaron.ballman wrote:
> > > > We always define `_LIBCPP_PREFERRED_NAME` so is this actually needed?
> > > Thanks, I was trying to avoid the redundant redeclarations when the 
> > > attribute is unavailable, but clearly this doesn't do that! Fixed.
> > Is that really needed? What's the issue with having redundant declarations?
> It's not necessary. I'm happy to remove it and redeclare the templates 
> unconditionally if you prefer.
Yes, I'd prefer that, and removing `_LIBCPP_HAS_PREFERRED_NAME`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[PATCH] D91784: [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

2020-11-19 Thread Kristof Provost via Phabricator via cfe-commits
kprovost created this revision.
kprovost added reviewers: kito-cheng, khchen, s.egerton, emaste.
Herald added subscribers: cfe-commits, frasercrmck, NickHung, evandro, 
luismarques, apazos, sameer.abuasal, pzheng, lenary, Jim, benna, psnobl, 
jocewei, PkmX, jfb, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: clang.
kprovost requested review of this revision.
Herald added a subscriber: MaskRay.

The RISCV target did not set the GCC atomic compare and swap defines,
unlike other targets.
This broke builds for things like glib on RISCV.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91784

Files:
  clang/lib/Basic/Targets/RISCV.cpp


Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -115,8 +115,14 @@
 Builder.defineMacro("__riscv_muldiv");
   }
 
-  if (HasA)
+  if (HasA) {
 Builder.defineMacro("__riscv_atomic");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+if (Is64Bit)
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+  }
 
   if (HasF || HasD) {
 Builder.defineMacro("__riscv_flen", HasD ? "64" : "32");


Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -115,8 +115,14 @@
 Builder.defineMacro("__riscv_muldiv");
   }
 
-  if (HasA)
+  if (HasA) {
 Builder.defineMacro("__riscv_atomic");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+if (Is64Bit)
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+  }
 
   if (HasF || HasD) {
 Builder.defineMacro("__riscv_flen", HasD ? "64" : "32");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91784: [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

2020-11-19 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 accepted this revision.
jrtc27 added reviewers: asb, lenary, luismarques.
jrtc27 added a comment.
This revision is now accepted and ready to land.

This seems correct. GCC doesn't define the 1 and 2 variants but it implements 
those with libcalls rather than inline like LLVM so that's to be expected, just 
something to be aware of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91784

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


[PATCH] D91784: [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines

2020-11-19 Thread Kristof Provost via Phabricator via cfe-commits
kprovost added a comment.

Thanks for the review.

I don't have commit access to the LLVM repo, so I'd appreciate it if someone 
who does can commit this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91784

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


[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-19 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 306373.
MarkMurrayARM added a comment.

Address more review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/AArch64/armv8.5a-ssbs.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -280,6 +280,12 @@
 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
 ARM::AEK_RAS | ARM::AEK_DOTPROD,
 "8.2-A"));
+  EXPECT_TRUE(testARMCPU("neoverse-n2", "armv8.5-a", "crypto-neon-fp-armv8",
+ ARM::AEK_CRC | ARM::AEK_HWDIVTHUMB | ARM::AEK_HWDIVARM |
+ ARM::AEK_MP | ARM::AEK_SEC | ARM::AEK_VIRT |
+ ARM::AEK_DSP | ARM::AEK_BF16 | ARM::AEK_DOTPROD |
+ ARM::AEK_RAS | ARM::AEK_I8MM | ARM::AEK_SB,
+"8.5-A"));
   EXPECT_TRUE(testARMCPU("neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
  ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
  ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
@@ -328,7 +334,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 90;
+static constexpr unsigned NumARMCPUArchs = 91;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -996,6 +1002,15 @@
   AArch64::AEK_PROFILE | AArch64::AEK_RAS | AArch64::AEK_RCPC |
   AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_SSBS,
  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+ "neoverse-n2", "armv8.5-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_FP16 | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_SVE | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_RDM | AArch64::AEK_MTE |
+  AArch64::AEK_SSBS | AArch64::AEK_SB | AArch64::AEK_SVE2 |
+  AArch64::AEK_SVE2BITPERM | AArch64::AEK_BF16 | AArch64::AEK_I8MM,
+ "8.5-A"));
   EXPECT_TRUE(testAArch64CPU(
   "thunderx2t99", "armv8.1-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
@@ -1048,7 +1063,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 44;
+static constexpr unsigned NumAArch64CPUArchs = 45;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -9,6 +9,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple thumb -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
+// RUN: llvm-mc -triple thumb -mcpu=neoverse-n2 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 
 // RUN: not llvm-mc -triple thumb -mattr=-dotprod -show-encoding < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ERROR < %t %s
Index: llvm/test/MC/ARM/armv8.2a-dotprod-a32.s

[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-19 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:909
+  FeatureMTE,
+  FeatureSVE2,
+  FeatureTRBE]>;

SVE2 Bitperm is missing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

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


[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2020-11-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:51
+  // check specific version of feature)
+  void supportFeatureForPreOCL30(StringRef Feat, bool On = true) {
+assert(CLVer < 300 && "Can'be called for OpenCL C higher 3.0");

azabaznov wrote:
> Anastasia wrote:
> > azabaznov wrote:
> > > Anastasia wrote:
> > > > I find the name of this function very confusing but I can't think of 
> > > > any better one. Also the flow is becoming harder to understand to be 
> > > > honest. This function is not as straight forward as `support` because 
> > > > it might not actually do what is expected from it. I wonder if the name 
> > > > with something like `adjust` would be more appropriate. At the same 
> > > > time `adjustFeatures` is the only place where we need to check for the 
> > > > version. Perhaps you can just do the language version check straight in 
> > > > `adjustFeatures`?
> > > > 
> > > > Overall, let's just get clear about the flow of setting the features 
> > > > and extensions. If in `adjustFeatures` we set default features 
> > > > supported in a certain language version then targets can set the other 
> > > > features. Now let's examine what should happen with the features and 
> > > > extensions on the following use cases:
> > > > - Do we always set the equivalent extension when the feature is being 
> > > > set by the target?
> > > > - Do we always set the equivalent feature when the extension is being 
> > > > set by the target?
> > > > - What happens when equivalent features and extensions are set but to 
> > > > different values?
> > > > - What if targets set core feature/extension to unsupported?
> > > > - How does `-cl-ext` modify core features/extensions and equivalent 
> > > > features+extensions?
> > > > 
> > > > I am a bit worried about the fact that we have different items for the 
> > > > same optional functionality in `OpenCLOptions` as it might be a 
> > > > nightmare to keep them consistent. We can however also choose a path of 
> > > > not keeping them consistent in the common code and rely on targets to 
> > > > set them up correctly.
> > > > 
> > > > Initially, when we discussed adding feature macros to earlier standards 
> > > > I was thinking of simplifying the design. For example instead of 
> > > > checking for extension macros and feature macros in the header when 
> > > > declaring certain functions we could only check for one of those. The 
> > > > question whether we can really achieve the simplifications and at what 
> > > > cost.
> > > Ok.
> > > 
> > > Now I think that defining features for pre-OpenCL C 3.0 if they have 
> > > equivalent extension indeed brings up some complexities. The check for 
> > > the support of features in header will still look like follows:
> > > 
> > > ```
> > > #if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
> > > ...
> > > #endif
> > > ```
> > > 
> > > so there is no need to add a feature macro for pre-OpenCL C 3.0 if there 
> > > is a same extension to check. Are you agree with that?
> > > 
> > > However, I still see a reason for defining  equivalent extension for 
> > > OpenCL C 3.0 if feature is supported (backward compatibility with earlier 
> > > OpenCL C kernels).
> > > 
> > > > Overall, let's just get clear about the flow of setting the features 
> > > > and extensions
> > > IMO the main thing which we need to try to follow here is that features 
> > > are stronger concept than extensions in OpenCL C 3.0. The reason for this 
> > > is that API won't report extension support if the feature is not 
> > > supported ([[ 
> > > https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#_3d_image_writes
> > >  | 3d image writes example]]. To be clear, if users need to support 
> > > functionality in OpenCL C 3.0 they should use features, for earlier 
> > > versions they should use extensions.
> > > 
> > > Answering your questions:
> > > 
> > > > Do we always set the equivalent extension when the feature is being set 
> > > > by the target?
> > > I think we should do it for OpenCL C 3.0 only to maintain backward 
> > > compatibility with OpenCL C 1.2 applications.
> > > 
> > > > Do we always set the equivalent feature when the extension is being set 
> > > > by the target
> > > I think we shouldn't set equivalent feature for pre-OpenCL C 3.0 since 
> > > there is no need in that. This brings up some complexities, and we can 
> > > check an extension presence.
> > > 
> > > > What happens when equivalent features and extensions are set but to 
> > > > different values
> > > We need to avoid that case for OpenCL C 3.0 since implementation could 
> > > not report extension support if equivalent feature is not supported.
> > > 
> > > > How does -cl-ext modify core features/extensions and equivalent 
> > > > features+extensions
> > > '-сl-ext' should not affect feature support in pre-OpenCL 3.0. In OpenCL 
> > > C 3.0 it's more likely to use featur

[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Config.h:88
 
+inline bool operator<(const Config::ExternalIndexSpec &LHS,
+  const Config::ExternalIndexSpec &RHS) {

Maybe we could use DenseMap instead? Defining an order on specs seems 
semantically iffy.

(Maybe one day we'll get to use a better hashtable and DenseMapInfo won't be so 
gross)



Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:137
+  if (!Gen) {
+Gen = [](const Config::ExternalIndexSpec &External,
+ AsyncTaskRunner &Tasks) {

nit: I think this would be clearer as a named function instead of a lambda



Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:100
+  });
+  addIndex(std::move(NewIndex));
+  return PlaceHolder;

kadircet wrote:
> sammccall wrote:
> > from memoize:
> > 
> > > Concurrent calls for the same key may run the
> > > computation multiple times, but each call will return the same result.
> > 
> > so this side-effect may run multiple times too, resulting in multiple index 
> > copies getting leaked. This seems like it may be bad in the case of file 
> > indexes.
> > 
> > Why can't the memoize map own the indexes?
> > This would still result in loading the index multiple times and throwing 
> > things away, hmm. Not sure how best to resolve this.
> > so this side-effect may run multiple times too, resulting in multiple index 
> > copies getting leaked. This seems like it may be bad in the case of file 
> > indexes.
> 
> The only way i can see this happening is by synchronizing calls to `getIndex`.
> 
> > Why can't the memoize map own the indexes?
> 
> Main problem is, it returns a copy to the stored elements, rather than a 
> reference to them. Which might be necessary in general to guarantee 
> thread-safety. Since we can't copy unique_ptrs, I had to store them elsewhere 
> and only keep pointers to it within the memoize map.
> 
> 
> So both things considered, maybe we should just give up on memoize and have 
> our own thread-safe cache here?
Yeah given that we know the compute function is going to be fast, we can just 
run it under the lock. So let's just use a big fat mutex.



Comment at: clang-tools-extra/clangd/index/ProjectAware.h:21
+/// A functor to create an index for an external index specification.
+using IndexGenerator = std::function(
+const Config::ExternalIndexSpec &, AsyncTaskRunner &)>;

nit: "factory" is more common than "generator" for this purpose, probably



Comment at: clang-tools-extra/clangd/index/ProjectAware.h:25
+/// Returns an index that answers queries using external indices. 
IndexGenerator
+/// can be used to customize how to generate an index from an external source.
+std::unique_ptr createProjectAwareIndex(IndexGenerator = nullptr);

Mention the default?

The default implementation loads the index asynchronously on the 
AsyncTaskRunner.
The index will appear empty until loaded.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90750

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


[PATCH] D91485: [clang-tidy] ElseAfterReturn check wont suggest fixes if preprocessor branches are involved

2020-11-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-pp-no-crash.cpp:1
+// RUN: clang-tidy %s -checks=-*,readability-else-after-return -- -std=c++11
+

You can drop the `-- -std=c++11` from this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91485

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


[PATCH] D91047: Add a call super attribute plugin example

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

LGTM, thank you for the new plugin example! Do you need me to commit on your 
behalf? If so, are you okay with `Yafei Liu ` for 
attribution?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91047

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


[PATCH] D91789: [clang-tidy] find/fix unneeded trailing semicolons in macros

2020-11-19 Thread Tom Rix via Phabricator via cfe-commits
trixirt created this revision.
trixirt added reviewers: nickdesaulniers, alexfh, hokein, aaron.ballman.
trixirt added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.
Herald added a project: clang.
trixirt requested review of this revision.

Cleaning up -Wextra-semi-stmt in the linux kernel shows a high
incidence of macros with trailing semicolons

#define M(a) a++; <-- clang-tidy fixes problem here
 int f() {

  int v = 0;
  M(v); <-- clang reports problem here
  return v;

}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91789

Files:
  clang-tools-extra/clang-tidy/linuxkernel/CMakeLists.txt
  clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
  clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp
  clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.h
  clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c

Index: clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s linuxkernel-macro-trailing-semi %t
+
+#define M(a) a++;
+// CHECK-MESSAGES: warning: unneeded semicolon
+// CHECK-MESSAGES: note: FIX-IT applied suggested code changes
+
+int f() {
+  int v = 0;
+  M(v);
+  return v;
+}
+
+// A corner case
+// An empty macro could conditionally contain another path so
+// do not warn or fix.
+#ifdef UNSET_CONDITION
+#define E() ;
+#else
+#define E()
+#endif
+#define N(a) a++;
+
+int g() {
+  int v = 0;
+  N(v) E();
+  return v;
+}
Index: clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.h
@@ -0,0 +1,40 @@
+//===--- MacroTrailingSemiCheck.h - clang-tidy --*- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LINUXKERNEL_MACROTRAILINGSEMICHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LINUXKERNEL_MACROTRAILINGSEMICHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "clang/Lex/MacroInfo.h"
+#include 
+
+namespace clang {
+namespace tidy {
+namespace linuxkernel {
+
+class MacroTrailingSemiCheck : public ClangTidyCheck {
+public:
+  MacroTrailingSemiCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override final;
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void checkMacro(SourceManager &sourceMgr, const Token &MacroNameTok,
+  const MacroInfo *MI);
+
+private:
+  std::vector SuspectMacros;
+};
+
+} // namespace linuxkernel
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LINUXKERNEL_MACROTRAILINGSEMI_CHECK_H
Index: clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp
@@ -0,0 +1,139 @@
+//===--- MacroTrailingSemiCheck.cpp - clang-tidy---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MacroTrailingSemiCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace linuxkernel {
+
+class MacroTrailingSemiCheckPPCallbacks : public PPCallbacks {
+public:
+  MacroTrailingSemiCheckPPCallbacks(Preprocessor *PP,
+MacroTrailingSemiCheck *Check)
+  : PP(PP), Check(Check) {}
+
+  void MacroDefined(const Token &MacroNameTok,
+const MacroDirective *MD) override {
+auto *MI = MD->getMacroInfo();
+
+if (MI->isBuiltinMacro() || MI->isObjectLike())
+  return;
+Check->checkMacro(PP->getSourceManager(), MacroNameTok, MI);
+  }
+
+private:
+  Preprocessor *PP;
+  MacroTrailingSemiCheck *Check;
+};
+
+void MacroTrailingSemiCheck::registerMatchers(Matc

[PATCH] D89684: [AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.

2020-11-19 Thread Digger via Phabricator via cfe-commits
DiggerLin accepted this revision.
DiggerLin added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89684

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


[PATCH] D83691: Port Comment option flags to new parsing system

2020-11-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Thanks. Committing this without the NFC change.




Comment at: clang/include/clang/Driver/Options.td:407
+
+def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>,
+  MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;

dexonsmith wrote:
> Nit: is moving this option and adding a comment a necessary part of the 
> patch, or is it just a cleanup that could be done before in an NFC commit? If 
> it's possible, I would suggest moving it in a separate commit.
That's a fair point, moving the option is not necessary. I will revert the move 
in this patch and consider creating the `// Comment options.` section once all 
comment options get ported to the marshaling system.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83691

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


[clang] 17497ec - [AIX][FE] Support constructor/destructor attribute

2020-11-19 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2020-11-19T09:24:01-05:00
New Revision: 17497ec514f7a87e0ac39a803534b3a324a19324

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

LOG: [AIX][FE] Support constructor/destructor attribute

Support attribute((constructor)) and attribute((destructor)) on AIX

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

Added: 
clang/test/CodeGen/aix-constructor-attribute.c
clang/test/CodeGen/aix-destructor-attribute.c
clang/test/CodeGenCXX/aix-constructor-attribute.cpp
clang/test/CodeGenCXX/aix-destructor-attribute.cpp

Modified: 
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 
clang/test/CodeGen/aix-constructor-attribute.cpp
clang/test/CodeGen/aix-destructor-attribute.cpp
clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp



diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index b9ff561aa641..3dbf4cc7cb97 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -273,8 +273,10 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(const 
VarDecl &VD,
 
 void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
   // extern "C" int atexit(void (*f)(void));
-  assert(cast(dtorStub)->getFunctionType() ==
- llvm::FunctionType::get(CGM.VoidTy, false) &&
+  assert(dtorStub->getType() ==
+ llvm::PointerType::get(
+ llvm::FunctionType::get(CGM.VoidTy, false),
+ dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to atexit has a wrong type.");
 
   llvm::FunctionType *atexitTy =
@@ -290,7 +292,7 @@ void 
CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
 }
 
 llvm::Value *
-CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Function *dtorStub) {
+CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) {
   // The unatexit subroutine unregisters __dtor functions that were previously
   // registered by the atexit subroutine. If the referenced function is found,
   // it is removed from the list of functions that are called at normal program
@@ -298,8 +300,10 @@ 
CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Function *dtorStub) {
   // value is returned.
   //
   // extern "C" int unatexit(void (*f)(void));
-  assert(dtorStub->getFunctionType() ==
- llvm::FunctionType::get(CGM.VoidTy, false) &&
+  assert(dtorStub->getType() ==
+ llvm::PointerType::get(
+ llvm::FunctionType::get(CGM.VoidTy, false),
+ dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to unatexit has a wrong type.");
 
   llvm::FunctionType *unatexitTy =

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 8a1e47db33ff..40efa6dbc5ff 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4304,7 +4304,7 @@ class CodeGenFunction : public CodeGenTypeCache {
   void registerGlobalDtorWithAtExit(llvm::Constant *dtorStub);
 
   /// Call unatexit() with function dtorStub.
-  llvm::Value *unregisterGlobalDtorWithUnAtExit(llvm::Function *dtorStub);
+  llvm::Value *unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub);
 
   /// Emit code in this function to perform a guarded variable
   /// initialization.  Guarded initializations are used when it's not

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 1f81faaa2c6f..f56b7374082f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1278,11 +1278,10 @@ void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, 
int Priority,
 
 /// AddGlobalDtor - Add a function to the list that will be called
 /// when the module is unloaded.
-void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) {
-  if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) {
-if (getCXXABI().useSinitAndSterm())
-  llvm::report_fatal_error(
-  "register global dtors with atexit() is not supported yet");
+void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority,
+  bool IsDtorAttrFunc) {
+  if (CodeGenOpts.RegisterGlobalDtorsWithAtExit &&
+  (!getContext().getTargetInfo().getTriple().isOSAIX() || IsDtorAttrFunc)) 
{
 DtorsUsingAtExit[Priority].push_back(Dtor);
 return;
   }
@@ -4716,7 +4715,7 @@ void 
CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
   if (const ConstructorAttr *CA = D->getAttr())
 AddGlobalCtor(Fn, CA->getPriority()

[PATCH] D90892: [AIX][FE] Support constructor/destructor attribute

2020-11-19 Thread Xiangling Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG17497ec514f7: [AIX][FE] Support constructor/destructor 
attribute (authored by Xiangling_L).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90892

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.c
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.c
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGenCXX/aix-constructor-attribute.cpp
  clang/test/CodeGenCXX/aix-destructor-attribute.cpp
  clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp

Index: clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
===
--- clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
-// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
-// RUN:   FileCheck %s
-
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
-// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
-// RUN:   FileCheck %s
-
-struct T {
-  T();
-  ~T();
-} t;
-
-// CHECK: error in backend: register global dtors with atexit() is not supported yet
Index: clang/test/CodeGenCXX/aix-destructor-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-destructor-attribute.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit < %s | \
+// RUN:   FileCheck --check-prefix=NO-REGISTER %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit < %s | \
+// RUN:   FileCheck --check-prefix=NO-REGISTER %s
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \
+// RUN:   FileCheck --check-prefix=REGISTER %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \
+// RUN:   FileCheck --check-prefix=REGISTER %s
+
+struct test {
+  test();
+  ~test();
+} t;
+
+int bar() __attribute__((destructor(100)));
+int bar2() __attribute__((destructor(65535)));
+int bar3(int) __attribute__((destructor(65535)));
+
+int bar() {
+  return 1;
+}
+
+int bar2() {
+  return 2;
+}
+
+int bar3(int a) {
+  return a;
+}
+
+// NO-REGISTER: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }]
+// NO-REGISTER: @llvm.global_dtors = appending global [4 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 100, void ()* bitcast (i32 ()* @_Z3barv to void ()*), i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* bitcast (i32 ()* @_Z4bar2v to void ()*), i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* bitcast (i32 (i32)* @_Z4bar3i to void ()*), i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }]
+
+// REGISTER: @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }, { i32, void ()*, i8* } { i32 100, void ()* @__GLOBAL_init_100, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__GLOBAL_init_65535, i8* null }]
+// REGISTER: @llvm.global_dtors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }, { i32, void ()*, i8* } { i32 100, void ()* @__GLOBAL_cleanup_100, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__GLOBAL_cleanup_65535, i8* null }]
+
+// REGISTER: define internal void @__GLOBAL_init_100() [[ATTR:#[0-9]+]] {
+// REGISTER: entry:
+// REGISTER:   %0 = call i32 @atexit(void ()* bitcast (i32 ()* @_Z3barv to void ()*))
+// REGISTER:   ret void
+// REGISTER: }
+
+// REGISTER: define internal void @__GLOBAL_init_65535() [[ATTR:#[0-9]+]] {
+// REGISTER: entry:
+// REGISTER:   %0 = call i32 @atexit(void ()* bitcast (i32 ()* @_Z4bar2v to void ()*))
+// REGISTER:   %1 = call i32 @atexit(void ()* bitcast (i32 (i32)* @_Z4bar3i to void ()*))
+// REGISTER:   ret void
+// REGISTER: }
+
+// REGISTER: define internal void @__GLOBAL_cleanup_100() [[ATTR:#[0-9]+]] {
+// REGISTER: entry:
+// REGISTER:   %0 = call i32 @unatexit(void ()* bitcast (i32 ()* @_Z3barv to void ()*))
+// REGISTER:   %needs_destruct = icmp eq i32 %0, 0
+// REGISTER:   br i1 %needs_destruct, label %destruct.call, label %destruct.end
+
+// REGISTER: destruct.

[PATCH] D91639: Add documentation illustrating use of IgnoreUnlessSpelledInSource

2020-11-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for the documentation effort!




Comment at: clang/docs/LibASTMatchersReference.html:100
+
+Traverse Mode
+

I think this section should go above the Node Matchers section in the document 
so that Node Matchers stays directly above the table of node matchers.



Comment at: clang/docs/LibASTMatchersReference.html:104
+The default mode of operation of AST Matchers visits all nodes in the AST,
+even if they are not spelled in the source. This is AsIs mode. This mode is
+hard to use correctly and requires more development iteration because it means

Can you add `` tags around `AsIs` and `IgnoreUnlessSpelledInSource` to 
make it clear that these are sort of syntactic constructs rather than prose?



Comment at: clang/docs/LibASTMatchersReference.html:105-107
+hard to use correctly and requires more development iteration because it means
+that the user must write AST Matchers to explicitly traverse or ignore nodes
+which are not visible.

Rather than say the default mode is hard to use correctly, how about:

`This mode requires writing AST matchers that explicitly traverse or ignore 
implicit nodes, such as parentheses surrounding an expression or expressions 
with cleanups.  These implicit nodes are not always obvious from the syntax of 
the source code, and so this mode requires careful consideration and testing to 
get the desired behavior from an AST matcher.`



Comment at: clang/docs/LibASTMatchersReference.html:116
+the source using the IgnoreUnlessSpelledInSource mode. This is likely to be far
+less error-prone for users who are not already very familiar with the AST. It 
is
+also likely to be less error-prone for experienced AST users, as difficult 
cases

familiar with the AST -> familiar with where implicit nodes appear in the AST



Comment at: clang/docs/LibASTMatchersReference.html:128
+
+When using the C++ API such as in clang-tidy checks, the traverse() matcher
+is used to set the mode:

 tags around `traverse()`



Comment at: clang/docs/LibASTMatchersReference.html:153
+
+struct B
+{

Should we consistently switch this style to:
```
struct B {
```
to save on some vertical whitespace (it doesn't impact all of the rows, but 
will help in some cases)?



Comment at: clang/docs/LibASTMatchersReference.html:288
+
+Match found! Insertion produces incorrect output:
+

How about switching the exclamation points into full stops (here and elsewhere)?



Comment at: clang/docs/LibASTMatchersReference.html:303
+
+  Replacement of `begin()` with `cbegin()`:
+

Backticks won't help here -- should probably use  tags.



Comment at: clang/docs/LibASTMatchersReference.html:312-318
+void foo()
+{
+  const Container c;
+  c.begin();
+
+  for (auto i : c)
+  {

Some more potential places for vertical whitespace savings.

Actually, would it be too onerous to ask you to run all of the code snippets 
through clang-format with the LLVM style so that they're consistently formatted 
and trims some of the vertical whitespace?



Comment at: clang/docs/LibASTMatchersReference.html:356
+
+  Replacement of int member with safe_int:
+

Could use some  tags around the code constructs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91639

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


[PATCH] D83691: Port Comment option flags to new parsing system

2020-11-19 Thread Jan Svoboda 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 rGa1702a297b8b: [clang][cli] Port Comment option flags to new 
parsing system (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D83691?vs=306042&id=306397#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83691

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -930,7 +930,8 @@
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation 
comment block command">,
   MetaVarName<"">;
-def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>;
+def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>,
+  MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
 def frecord_command_line : Flag<["-"], "frecord-command-line">,
   Group;
 def fno_record_command_line : Flag<["-"], "fno-record-command-line">,


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -930,7 +930,8 @@
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation comment block command">,
   MetaVarName<"">;
-def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>;
+def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>,
+  MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
 def frecord_command_line : Flag<["-"], "frecord-command-line">,
   Group;
 def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a1702a2 - [clang][cli] Port Comment option flags to new parsing system

2020-11-19 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-11-19T15:27:13+01:00
New Revision: a1702a297b8bb1e4ed15673c6e122ac9dab4c802

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

LOG: [clang][cli] Port Comment option flags to new parsing system

Depends on D83690

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7a75eb683249..f72e9af40547 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -930,7 +930,8 @@ def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, 
Group,
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation 
comment block command">,
   MetaVarName<"">;
-def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>;
+def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>,
+  MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
 def frecord_command_line : Flag<["-"], "frecord-command-line">,
   Group;
 def fno_record_command_line : Flag<["-"], "fno-record-command-line">,



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


[PATCH] D91104: APINotes: add property models for YAML attributes

2020-11-19 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/include/clang/APINotes/Types.h:60
+  /// Whether SwiftPrivate was specified.
+  unsigned SwiftPrivateSpecified : 1;
+

I was wondering whether Swift specific properties are meaningful to all 
descendants of `CommonEntityInfo`. With other words, can we attach the swift 
private attribute to all kind of declarations? If not, perhaps then we need a 
"middle" base class injected into the class hierarchy.

And I have the same question for `CommonTypeInfo`, regarding SwiftBridge and 
other Swift sweeties.



Comment at: clang/include/clang/APINotes/Types.h:125
+class CommonTypeInfo : public CommonEntityInfo {
+  /// The Swift type to which a given type is bridged.
+  ///

This comment is probably off.



Comment at: clang/include/clang/APINotes/Types.h:529
+  /// Adds the return type info.
+  void addReturnTypeInfo(NullabilityKind kind) { addTypeInfo(0, kind); }
+

Do we document somewhere that the `0` index means the return type? Maybe adding 
a constant like `ReturnIdx` could resolve this magic number.



Comment at: clang/include/clang/APINotes/Types.h:531
+
+  /// Adds the return type info.
+  void addParamTypeInfo(unsigned index, NullabilityKind kind) {

Probably this comment is off.



Comment at: clang/lib/APINotes/APINotesTypes.cpp:20
+
+void ObjCContextInfo::dump(llvm::raw_ostream &OS) {
+  OS << HasDefaultNullability << ' ' << DefaultNullability << ' '

Perhaps it would be worth to add `dump` methods for the other `Info` classes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91104

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


[PATCH] D91009: [clang-tidy] Include std::basic_string_view in readability-redundant-string-init.

2020-11-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp:25
+struct basic_string_view {
+  using size_type = unsigned;
+

nit: `using size_type = decltype(sizeof(0));`



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp:30
+  basic_string_view(const C *, size_type);
+  basic_string_view(const C *, const A &a = A());
+  template 

This constructor doesn't exist according to the standard: 
http://eel.is/c++draft/string.view.template.general



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp:65
 
+void fview() {
+  std::string_view a = "";

Can you also add tests for `wstring_view`?

Also, perhaps one for `std::string_view foo{};` (to remove the spurious `{}`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91009

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


[PATCH] D91760: [Driver] Default Generic_GCC aarch64 to use -fasynchronous-unwind-tables

2020-11-19 Thread Peter Smith via Phabricator via cfe-commits
psmith added a comment.

Personally I'm in favour of clang and gcc behaving the same way unless there is 
a good reason not to. I've shared the review internally to see if anyone has 
any concerns. May be worth informing the clang built linux community to see if 
they will need to make any alterations as a result.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91760

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


[PATCH] D90282: [clang-tidy] Add IgnoreShortNames config to identifier naming checks

2020-11-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D90282#2395956 , @smhc wrote:

> I updated it to use XXShortSizeThreshold.
>
> But I was thinking.. perhaps a more generic approach could be 
> "xxIgnoreRegex", this would allow you to do things such as :
>
> VariableIgnoreRegex: ([a-z]{2}|index)
> ClassIgnoreRegex: (Special_CASE|CommonOther.*)
> etc.
>
> it would be more generic while also allowing for excluding short names.

I don't have a strong opinion on that approach. It would be a more flexible 
approach and that's appealing, but it also means writing regular expressions 
which is a bit unappealing because those aren't obvious to everyone and it's 
unclear what the performance characteristics would be of running those regexes 
on every identifier in the program. I'm curious if @alexfh or @njames93 (or 
others) have opinions on this.


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

https://reviews.llvm.org/D90282

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


[clang] 7a0ea12 - [clang][cli] Port analyzer flags to new option parsing system

2020-11-19 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-11-19T15:42:34+01:00
New Revision: 7a0ea120e2a1fffab71f9c8e3d5337899f7a42af

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

LOG: [clang][cli] Port analyzer flags to new option parsing system

Depends on D83691

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f72e9af40547..d4aa4aa2f953 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3664,7 +3664,8 @@ def fno_padding_on_unsigned_fixed_point : Flag<["-"], 
"fno-padding-on-unsigned-f
 
//===--===//
 
 def analysis_UnoptimizedCFG : Flag<["-"], "unoptimized-cfg">,
-  HelpText<"Generate unoptimized CFGs for all analyses">;
+  HelpText<"Generate unoptimized CFGs for all analyses">,
+  MarshallingInfoFlag<"AnalyzerOpts->UnoptimizedCFG">;
 def analysis_CFGAddImplicitDtors : Flag<["-"], "cfg-add-implicit-dtors">,
   HelpText<"Add C++ implicit destructors to CFGs for all analyses">;
 
@@ -3687,18 +3688,23 @@ def analyzer_purge : Separate<["-"], "analyzer-purge">,
 def analyzer_purge_EQ : Joined<["-"], "analyzer-purge=">, 
Alias;
 
 def analyzer_opt_analyze_headers : Flag<["-"], "analyzer-opt-analyze-headers">,
-  HelpText<"Force the static analyzer to analyze functions defined in header 
files">;
+  HelpText<"Force the static analyzer to analyze functions defined in header 
files">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzeAll">;
 def analyzer_opt_analyze_nested_blocks : Flag<["-"], 
"analyzer-opt-analyze-nested-blocks">,
-  HelpText<"Analyze the definitions of blocks in addition to functions">;
+  HelpText<"Analyze the definitions of blocks in addition to functions">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzeNestedBlocks">;
 def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">,
-  HelpText<"Emit verbose output about the analyzer's progress">;
+  HelpText<"Emit verbose output about the analyzer's progress">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzerDisplayProgress">;
 def analyze_function : Separate<["-"], "analyze-function">,
   HelpText<"Run analysis on specific function (for C++ include parameters in 
name)">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, 
Alias;
 def trim_egraph : Flag<["-"], "trim-egraph">,
-  HelpText<"Only show error-related paths in the analysis graph">;
+  HelpText<"Only show error-related paths in the analysis graph">,
+  MarshallingInfoFlag<"AnalyzerOpts->TrimGraph">;
 def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">,
-  HelpText<"Display exploded graph using GraphViz">;
+  HelpText<"Display exploded graph using GraphViz">,
+  MarshallingInfoFlag<"AnalyzerOpts->visualizeExplodedGraphWithGraphViz">;
 def analyzer_dump_egraph : Separate<["-"], "analyzer-dump-egraph">,
   HelpText<"Dump exploded graph to the specified file">;
 def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, 
Alias;
@@ -3713,12 +3719,14 @@ def analyzer_inlining_mode : Separate<["-"], 
"analyzer-inlining-mode">,
 def analyzer_inlining_mode_EQ : Joined<["-"], "analyzer-inlining-mode=">, 
Alias;
 
 def analyzer_disable_retry_exhausted : Flag<["-"], 
"analyzer-disable-retry-exhausted">,
-  HelpText<"Do not re-analyze paths leading to exhausted nodes with a 
diff erent strategy (may decrease code coverage)">;
+  HelpText<"Do not re-analyze paths leading to exhausted nodes with a 
diff erent strategy (may decrease code coverage)">,
+  MarshallingInfoFlag<"AnalyzerOpts->NoRetryExhausted">;
 
 def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">,
   HelpText<"The maximum number of times the analyzer will go through a loop">;
 def analyzer_stats : Flag<["-"], "analyzer-stats">,
-  HelpText<"Print internal analyzer statistics.">;
+  HelpText<"Print internal analyzer statistics.">,
+  MarshallingInfoFlag<"AnalyzerOpts->PrintStats">;
 
 def analyzer_checker : Separate<["-"], "analyzer-checker">,
   HelpText<"Choose analyzer checkers to enable">,
@@ -3743,41 +3751,50 @@ def analyzer_disable_checker_EQ : Joined<["-"], 
"analyzer-disable-checker=">,
   Alias;
 
 def analyzer_disable_all_checks : Flag<["-"], "analyzer-disable-all-checks">,
-  HelpText<"Disable all static analyzer checks">;
+  HelpText<"Disable all static analyzer checks">,
+  MarshallingInfoFlag<"AnalyzerOpts->DisableAllCheckers">;
 
 def analyzer_checker_help : Flag<["-"], "analyzer-checker-help">,
-  HelpText<"Display the list of analyzer checkers that are 

[PATCH] D83693: Port analyzer flags to new option parsing system

2020-11-19 Thread Jan Svoboda 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 rG7a0ea120e2a1: [clang][cli] Port analyzer flags to new option 
parsing system (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83693

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -454,44 +454,19 @@
 }
   }
 
-  Opts.ShowCheckerHelp = Args.hasArg(OPT_analyzer_checker_help);
-  Opts.ShowCheckerHelpAlpha = Args.hasArg(OPT_analyzer_checker_help_alpha);
-  Opts.ShowCheckerHelpDeveloper =
-  Args.hasArg(OPT_analyzer_checker_help_developer);
-
-  Opts.ShowCheckerOptionList = Args.hasArg(OPT_analyzer_checker_option_help);
-  Opts.ShowCheckerOptionAlphaList =
-  Args.hasArg(OPT_analyzer_checker_option_help_alpha);
-  Opts.ShowCheckerOptionDeveloperList =
-  Args.hasArg(OPT_analyzer_checker_option_help_developer);
-
-  Opts.ShowConfigOptionsList = Args.hasArg(OPT_analyzer_config_help);
-  Opts.ShowEnabledCheckerList = Args.hasArg(OPT_analyzer_list_enabled_checkers);
   Opts.ShouldEmitErrorsOnInvalidConfigValue =
   /* negated */!llvm::StringSwitch(
Args.getLastArgValue(OPT_analyzer_config_compatibility_mode))
 .Case("true", true)
 .Case("false", false)
 .Default(false);
-  Opts.DisableAllCheckers = Args.hasArg(OPT_analyzer_disable_all_checks);
 
-  Opts.visualizeExplodedGraphWithGraphViz =
-Args.hasArg(OPT_analyzer_viz_egraph_graphviz);
   Opts.DumpExplodedGraphTo =
   std::string(Args.getLastArgValue(OPT_analyzer_dump_egraph));
-  Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
-  Opts.AnalyzerWerror = Args.hasArg(OPT_analyzer_werror);
-  Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
-  Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
-  Opts.AnalyzeNestedBlocks =
-Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
   Opts.AnalyzeSpecificFunction =
   std::string(Args.getLastArgValue(OPT_analyze_function));
-  Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
-  Opts.TrimGraph = Args.hasArg(OPT_trim_egraph);
   Opts.maxBlockVisitOnPath =
   getLastArgIntValue(Args, OPT_analyzer_max_loop, 4, Diags);
-  Opts.PrintStats = Args.hasArg(OPT_analyzer_stats);
   Opts.InlineMaxStackDepth =
   getLastArgIntValue(Args, OPT_analyzer_inline_max_stack_depth,
  Opts.InlineMaxStackDepth, Diags);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3664,7 +3664,8 @@
 //===--===//
 
 def analysis_UnoptimizedCFG : Flag<["-"], "unoptimized-cfg">,
-  HelpText<"Generate unoptimized CFGs for all analyses">;
+  HelpText<"Generate unoptimized CFGs for all analyses">,
+  MarshallingInfoFlag<"AnalyzerOpts->UnoptimizedCFG">;
 def analysis_CFGAddImplicitDtors : Flag<["-"], "cfg-add-implicit-dtors">,
   HelpText<"Add C++ implicit destructors to CFGs for all analyses">;
 
@@ -3687,18 +3688,23 @@
 def analyzer_purge_EQ : Joined<["-"], "analyzer-purge=">, Alias;
 
 def analyzer_opt_analyze_headers : Flag<["-"], "analyzer-opt-analyze-headers">,
-  HelpText<"Force the static analyzer to analyze functions defined in header files">;
+  HelpText<"Force the static analyzer to analyze functions defined in header files">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzeAll">;
 def analyzer_opt_analyze_nested_blocks : Flag<["-"], "analyzer-opt-analyze-nested-blocks">,
-  HelpText<"Analyze the definitions of blocks in addition to functions">;
+  HelpText<"Analyze the definitions of blocks in addition to functions">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzeNestedBlocks">;
 def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">,
-  HelpText<"Emit verbose output about the analyzer's progress">;
+  HelpText<"Emit verbose output about the analyzer's progress">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzerDisplayProgress">;
 def analyze_function : Separate<["-"], "analyze-function">,
   HelpText<"Run analysis on specific function (for C++ include parameters in name)">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, Alias;
 def trim_egraph : Flag<["-"], "trim-egraph">,
-  HelpText<"Only show error-related paths in the analysis graph">;
+  HelpText<"Only show error-related paths in the analysis graph">,
+  MarshallingInfoFlag<"AnalyzerOpts->TrimGraph">;
 def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-v

[clang-tools-extra] 734d2f9 - [clangd] No crash on "-verify" mode.

2020-11-19 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-19T15:51:53+01:00
New Revision: 734d2f98f64940b1f545d677729d213a954c7a3f

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

LOG: [clangd] No crash on "-verify" mode.

If there is a "-verify" flag in the compile command, clangd will crash
(hit the assertion) inside the `~VerifyDiagnosticConsumer` (Looks like our
compiler invocation doesn't setup correctly?).

This patch disables the verify mode as it is rarely useful in clangd.

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

Added: 


Modified: 
clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Compiler.cpp 
b/clang-tools-extra/clangd/Compiler.cpp
index c22585fc53f9..3d5c7113f852 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -60,6 +60,10 @@ buildCompilerInvocation(const ParseInputs &Inputs, 
clang::DiagnosticConsumer &D,
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+  // our compiler invocation set-up doesn't seem to work with it (leading
+  // assertions in VerifyDiagnosticConsumer).
+  CI->getDiagnosticOpts().VerifyDiagnostics = false;
 
   // Disable any dependency outputting, we don't want to generate files or 
write
   // to stdout/stderr.

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 00303a28b92a..8f84d0ba4806 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -491,6 +491,15 @@ TEST(DiagnosticsTest, Preprocessor) {
   ElementsAre(Diag(Test.range(), "use of undeclared identifier 'b'")));
 }
 
+TEST(DiagnosticsTest, IgnoreVerify) {
+  auto TU = TestTU::withCode(R"cpp(
+int a; // expected-error {{}}
+  )cpp");
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-verify");
+  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
 // Recursive main-file include is diagnosed, and doesn't crash.
 TEST(DiagnosticsTest, RecursivePreamble) {
   auto TU = TestTU::withCode(R"cpp(



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


[PATCH] D91777: [clangd] No crash on "-verify" mode.

2020-11-19 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG734d2f98f649: [clangd] No crash on "-verify" mode. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91777

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -491,6 +491,15 @@
   ElementsAre(Diag(Test.range(), "use of undeclared identifier 'b'")));
 }
 
+TEST(DiagnosticsTest, IgnoreVerify) {
+  auto TU = TestTU::withCode(R"cpp(
+int a; // expected-error {{}}
+  )cpp");
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-verify");
+  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
 // Recursive main-file include is diagnosed, and doesn't crash.
 TEST(DiagnosticsTest, RecursivePreamble) {
   auto TU = TestTU::withCode(R"cpp(
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -60,6 +60,10 @@
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+  // our compiler invocation set-up doesn't seem to work with it (leading
+  // assertions in VerifyDiagnosticConsumer).
+  CI->getDiagnosticOpts().VerifyDiagnostics = false;
 
   // Disable any dependency outputting, we don't want to generate files or 
write
   // to stdout/stderr.


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -491,6 +491,15 @@
   ElementsAre(Diag(Test.range(), "use of undeclared identifier 'b'")));
 }
 
+TEST(DiagnosticsTest, IgnoreVerify) {
+  auto TU = TestTU::withCode(R"cpp(
+int a; // expected-error {{}}
+  )cpp");
+  TU.ExtraArgs.push_back("-Xclang");
+  TU.ExtraArgs.push_back("-verify");
+  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
 // Recursive main-file include is diagnosed, and doesn't crash.
 TEST(DiagnosticsTest, RecursivePreamble) {
   auto TU = TestTU::withCode(R"cpp(
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -60,6 +60,10 @@
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+  // our compiler invocation set-up doesn't seem to work with it (leading
+  // assertions in VerifyDiagnosticConsumer).
+  CI->getDiagnosticOpts().VerifyDiagnostics = false;
 
   // Disable any dependency outputting, we don't want to generate files or write
   // to stdout/stderr.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91789: [clang-tidy] find/fix unneeded trailing semicolons in macros

2020-11-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp:31
+const MacroDirective *MD) override {
+auto *MI = MD->getMacroInfo();
+

Please don't use auto when type is not spelled explicitly in same statement or 
iterator.



Comment at: 
clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp:99
+  if (Loc.isMacroID()) {
+auto &SM = Result.Context->getSourceManager();
+FullSourceLoc SpellingLoc = FullSourceLoc(Loc, 
SM).getSpellingLoc();

Please don't use auto when type is not spelled explicitly in same statement or 
iterator.



Comment at: 
clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp:113
+  if (TI != MI->tokens_end()) {
+auto Tok = MI->getReplacementToken(MI->getNumTokens() - 1);
+SourceLocation FixLoc = Tok.getLocation();

Please don't use auto when type is not spelled explicitly in same statement or 
iterator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91789

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


[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-19 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 306408.
MarkMurrayARM added a comment.

Address reviewer comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/AArch64/armv8.5a-ssbs.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -280,6 +280,12 @@
 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
 ARM::AEK_RAS | ARM::AEK_DOTPROD,
 "8.2-A"));
+  EXPECT_TRUE(testARMCPU("neoverse-n2", "armv8.5-a", "crypto-neon-fp-armv8",
+ ARM::AEK_CRC | ARM::AEK_HWDIVTHUMB | ARM::AEK_HWDIVARM |
+ ARM::AEK_MP | ARM::AEK_SEC | ARM::AEK_VIRT |
+ ARM::AEK_DSP | ARM::AEK_BF16 | ARM::AEK_DOTPROD |
+ ARM::AEK_RAS | ARM::AEK_I8MM | ARM::AEK_SB,
+"8.5-A"));
   EXPECT_TRUE(testARMCPU("neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
  ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
  ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
@@ -328,7 +334,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 90;
+static constexpr unsigned NumARMCPUArchs = 91;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -996,6 +1002,15 @@
   AArch64::AEK_PROFILE | AArch64::AEK_RAS | AArch64::AEK_RCPC |
   AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_SSBS,
  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+ "neoverse-n2", "armv8.5-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_FP16 | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_SVE | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_RDM | AArch64::AEK_MTE |
+  AArch64::AEK_SSBS | AArch64::AEK_SB | AArch64::AEK_SVE2 |
+  AArch64::AEK_SVE2BITPERM | AArch64::AEK_BF16 | AArch64::AEK_I8MM,
+ "8.5-A"));
   EXPECT_TRUE(testAArch64CPU(
   "thunderx2t99", "armv8.1-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
@@ -1048,7 +1063,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 44;
+static constexpr unsigned NumAArch64CPUArchs = 45;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -9,6 +9,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple thumb -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
+// RUN: llvm-mc -triple thumb -mcpu=neoverse-n2 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 
 // RUN: not llvm-mc -triple thumb -mattr=-dotprod -show-encoding < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ERROR < %t %s
Index: llvm/test/MC/ARM/armv8.2a-dotprod-a32.s

[PATCH] D91157: [AArch64] Out-of-line atomics (-moutline-atomics) implementation.

2020-11-19 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv added a comment.

Have you got any further comments?




Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:2170
+  SmallVector Ops;
+  if (TLI.getLibcallName(LC)) {
+Ops.append(Node->op_begin() + 2, Node->op_end());

t.p.northover wrote:
> jyknight wrote:
> > t.p.northover wrote:
> > > I think this is a bit of an abuse of the `LibcallName` mechanism. A 
> > > separate function in `TargetLowering` would probably be better.
> > I don't think that's odd or unusual -- we often condition libcall 
> > availability on getLibcallName != nullptr.
> > 
> > What does strike me here is the (pre-existing) code duplication between 
> > this function (DAGTypeLegalizer::ExapndAtomic) and 
> > SelectionDAGLegalize::ConvertNodeToLibcall. Not sure what's up with that...
> Fair enough. Didn't realise it was that common.
I noticed this existed duplication too, but find no proper place to put common 
functionality from DAGTypeLegalizer and  SelectionDAGLegalize.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91157

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


[PATCH] D89380: [clang-tidy] Fix for cppcoreguidelines-prefer-member-initializer to handle classes declared in macros

2020-11-19 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp:492
+
+#define MACRO1 struct InMacro1 { int i; InMacro1() { i = 0; } };
+// CHECK-MESSAGES: :[[@LINE-1]]:54: warning: 'i' should be initialized in a 
member initializer of the constructor 
[cppcoreguidelines-prefer-member-initializer]

alexfh wrote:
> baloghadamsoftware wrote:
> > alexfh wrote:
> > > Could you add tests where the field name comes from a macro argument and 
> > > from token pasting? Something along the lines of:
> > > 
> > > ```
> > > #define MACRO4(field) struct InMacro1 { int field; InMacro1() { field = 
> > > 0; } }
> > > 
> > > MACRO4(q);
> > > 
> > > #define MACRO5(X) X
> > > 
> > > MACRO5(struct InMacro1 { int field; InMacro1() { field = 0; } });
> > > 
> > > #define MACRO6(field) struct InMacro1 { int qqq ## field; InMacro1() { 
> > > qqq ## field = 0; } }
> > > 
> > > MACRO6(q);
> > > ```
> > It seems that handling of macro parameters in the `SourceManager` is 
> > totally off. The location in these cases are the macro call itself, but the 
> > spelling location is not the real location inside the macro, but in 
> > `MACRO4` it is the location of the argument still in the macro call. The 
> > case with `MACRO6` is even worse, because its spelling location is 
> > erroneous. So I could only added some fixmes. However, it does not crash, 
> > at least. That is the main intention of this particular patch.
> It's impossible to correctly handle replacements in all cases involving 
> macros (apart from expanding all macros while applying fixes ;). The usual 
> strategy is to warn always, but only suggest replacements when we can be 
> sufficiently confident in their validity. In this case we can either disable 
> fixes when any part of the code being touched is in a macro or try to detect 
> that the whole range being modified is sort of "on the same level of macro 
> hell". The `Lexer::makeFileCharRange` is supposed to help with the latter 
> (see clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp for an 
> example of using it).
Actually, this is what the patch does: it does not suggest a fix in complex 
macro cases, only in the simplest ones. And most importantly, it prevents the 
crash mentioned in the //Bugzilla// bug report.


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

https://reviews.llvm.org/D89380

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


[PATCH] D91157: [AArch64] Out-of-line atomics (-moutline-atomics) implementation.

2020-11-19 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

LG after fixing the minor nits.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6377
+} else {
+  CmdArgs.push_back("-target-feature");
+  CmdArgs.push_back("-outline-atomics");

We don't usually explicitly use negative features like this, do we? I think 
this else clause can be omitted.



Comment at: llvm/lib/CodeGen/TargetLoweringBase.cpp:492-495
+#define LCALL4(A)  
\
+  LCALLS(A, 1), LCALLS(A, 2), LCALLS(A, 4), LCALLS(A, 8), {
\
+UNKNOWN_LIBCALL, UNKNOWN_LIBCALL, UNKNOWN_LIBCALL, UNKNOWN_LIBCALL 
\
+  }

As with the .def file, get rid of LCALL4, and just use LCALL5 for everything 
here. AArch64ISelLowering won't setup libcall names for 128-bit ones, which is 
fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91157

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


[PATCH] D72184: [BPF] support atomic instructions

2020-11-19 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

Thanks. Somehow my build is successful. I kind of know what is the possible 
issue but wonder why I did not hit it.

> Can we please keep barriers out of scope? I think there's a lot of design to 
> be done there and I'd rather just get the core atomics working first.

The reason I put it here is to make *cpu=v4* roughly complete. Because if you 
adds barrier later we may need to add "cpu=v5", and I want to avoid that. But I 
agree this is a little bit overwhelming on you and let us discuss in bpf office 
hour how to proceed.

For the time being, alternatively, you can remove the following code
+let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in {
+  def SYNC : TYPE_LD_ST {
+let Inst{7-4} = BPF_BARRIER.Value;
+let BPFClass = BPF_STX;
+  }
+}
+
+def : Pat<(atomic_fence (timm), (timm)), (SYNC)>;
to workaround compilation issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72184

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


[PATCH] D87946: [OpenMP] Add Location Fields to Libomptarget Runtime for Debugging

2020-11-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

Still LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87946

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


[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-11-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.cpp:57
+const MatchFinder::MatchResult &Result) {
+  bool IsPosix = PP->isMacroDefined("_POSIX_C_SOURCE") ||
+ Result.Context->getTargetInfo().getTriple().getVendor() ==

Nothing for you to change here, but this demonstrates that 
`isLanguageVersionSupported()` isn't sufficient. We don't want to register the 
check at all for POSIX platforms in the same way we don't want to register 
checks at all based on the language standard being enforced, but we can't 
because we can't get to the `Preprocessor` or target information from there.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.cpp:68
+const SourceManager &SM, Preprocessor *pp, Preprocessor *ModuleExpanderPP) 
{
+  PP = pp;
+}

abelkocsis wrote:
> whisperity wrote:
> > Global state is always a potential problem. Are you sure this is the right 
> > way to do things? Most other tidy checks that actively use this function 
> > define their own `PPCallback` subclass and use the existing preprocessor 
> > here to ensure the preprocessor executes the callback.
> I've used the same way in another check (https://reviews.llvm.org/D69181). 
> I'm not entirely sure which is the better way to do.
Defining the `PPCallback` subclass is a better approach 
(https://github.com/llvm/llvm-project/blob/e40a742a5008c5a4cf647c0ea805486498786393/clang-tools-extra/clang-tidy/cert/SetLongJmpCheck.cpp#L49
 shows a reasonable demonstration). At the very least, this doesn't have to set 
a global variable, it could set a member variable on 
`SignalInMultithreadedProgramCheck`.

I hadn't caught that in D69181, sorry about that! 



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.h:24
+/// check considers the analyzed program multithreaded if it finds at least
+/// one function call of the following: ``thrd_create``, ``std::thread``,
+/// ``boost::thread``, ``pthread_t``.

aaron.ballman wrote:
> The comment is a bit stale as it also accepts user-defined functions. Note, I 
> think `CreateThread`, `CreateRemoteThread`, `_beginthread`, and 
> `_beginthreadex` should be added to the list as those are the common Win32 
> APIs for creating threads (where pthreads aren't available).
The comment has gone stale again. Rather than listing the functions in the 
comment, I think it's fine to change it to: `... if it finds at least one 
threading-related function.`



Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:91
 // CON
+CheckFactories.registerCheck(
+"cert-con37-c");

We try to keep these in order, so this should move down below con36-c.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229

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


[PATCH] D91789: [clang-tidy] find/fix unneeded trailing semicolons in macros

2020-11-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp:15
+
+#include 
+

Any reason for including the c standard header?



Comment at: 
clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp:102-105
+for (std::vector::iterator it =
+ SuspectMacros.begin();
+ it != SuspectMacros.end(); ++it) {
+  const MacroInfo *MI = *it;

Could this be a range for loop.



Comment at: 
clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp:106-111
+  auto TI = MI->tokens_begin();
+  for (; TI != MI->tokens_end(); TI++) {
+SourceLocation L = TI->getLocation();
+if (SpellingLoc == L)
+  break;
+  }

Could this be refactored using `llvm::find_if`



Comment at: 
clang-tools-extra/clang-tidy/linuxkernel/MacroTrailingSemiCheck.cpp:116
+SourceLocation EndLoc = Tok.getEndLoc();
+auto H = FixItHint::CreateRemoval(SourceRange(FixLoc, EndLoc));
+diag(FixLoc, "unneeded semicolon") << H;

No need for this to be a temporary



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c:4
+#define M(a) a++;
+// CHECK-MESSAGES: warning: unneeded semicolon
+// CHECK-MESSAGES: note: FIX-IT applied suggested code changes

Please specify the location where this warning is emitted, you can check other 
test files but the typical format is
`// CHECK-MESSAGES: :[[@LINE-]]:: warning: unneeded semicolon`.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c:5
+// CHECK-MESSAGES: warning: unneeded semicolon
+// CHECK-MESSAGES: note: FIX-IT applied suggested code changes
+

Don't need to check the FIX-IT note, however it is preferred if you check the 
fix-it was applied correctly.
`// CHECK-FIXES` will run FileCheck over the input file after clang-tidy has 
gone in and made changes then check for lines in the output.
I haven't read enough into where the fix is but an example would be:
`// CHECK-FIXES: #define M(a) a++{{$}}`
the `{{$}}` says regex for end of line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91789

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


[PATCH] D91799: [clang-format] State where clang-format-diff.py should be run from

2020-11-19 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
DavidSpickett requested review of this revision.

At least with git, file paths in a diff will be relative
to the repo root. So if you are in "llvm-project/lldb"
and the diff shows "clang/foo" modified you get:
No such file or directory

>From clang-format-diff.py, since clang-format was
asked to read:
llvm-project/lldb/clang/foo

Add a note to the docs to explain this.

(there is `git diff --relative` but that excludes
changes outside of the current dir)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91799

Files:
  clang/docs/ClangFormat.rst


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -248,6 +248,9 @@
 The option `-U0` will create a diff without context lines (the script would 
format
 those as well).
 
+These commands use the file paths shown in the diff output
+so they will only work from the root of the repository.
+
 Current State of Clang Format for LLVM
 ==
 


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -248,6 +248,9 @@
 The option `-U0` will create a diff without context lines (the script would format
 those as well).
 
+These commands use the file paths shown in the diff output
+so they will only work from the root of the repository.
+
 Current State of Clang Format for LLVM
 ==
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90928: [OpenCL] Check for extension string extension lookup

2020-11-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

LGTM for the fix! Do you think we could improve testing? I presume there is 
something that triggers a failure without your change...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90928

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


[PATCH] D90174: [HIP] Fix regressions due to fp contract change

2020-11-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D90174

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


[PATCH] D90174: [HIP] Fix regressions due to fp contract change

2020-11-19 Thread Steve Canon via Phabricator via cfe-commits
scanon accepted this revision.
scanon added a comment.
This revision is now accepted and ready to land.

I'm fine with this.


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

https://reviews.llvm.org/D90174

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


[PATCH] D87946: [OpenMP] Add Location Fields to Libomptarget Runtime for Debugging

2020-11-19 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda8bec47ab8c: [OpenMP] Add Location Fields to Libomptarget 
Runtime for Debugging (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D87946?vs=306210&id=306430#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87946

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
  clang/test/OpenMP/target_data_member_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_00.cpp
  clang/test/OpenMP/target_map_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_02.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_04.cpp
  clang/test/OpenMP/target_map_codegen_05.cpp
  clang/test/OpenMP/target_map_codegen_06.cpp
  clang/test/OpenMP/target_map_codegen_07.cpp
  clang/test/OpenMP/target_map_codegen_08.cpp
  clang/test/OpenMP/target_map_codegen_09.cpp
  clang/test/OpenMP/target_map_codegen_10.cpp
  clang/test/OpenMP/target_map_codegen_11.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_15.cpp
  clang/test/OpenMP/target_map_codegen_16.cpp
  clang/test/OpenMP/target_map_codegen_17.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_19.cpp
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_21.cpp
  clang/test/OpenMP/target_map_codegen_22.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_24.cpp
  clang/test/OpenMP/target_map_codegen_25.cpp
  clang/test/OpenMP/target_map_codegen_26.cpp
  clang/test/OpenMP/target_map_codegen_27.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_30.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_33.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_map_names.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp

[PATCH] D91585: [NPM] Move more O0 pass building into PassBuilder

2020-11-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/lib/Passes/PassBuilder.cpp:2365
+Matches[1] != "lto") {
+  MPM.addPass(buildO0DefaultPipeline(L, Matches[1] != "default"));
   return Error::success();

I think it would be clearer to check against "thinlto-pre-link" and 
"lto-pre-link" here (and more robust in case any other types added in the 
future).



Comment at: llvm/lib/Passes/PassBuilder.cpp:2365
+  // Don't do anything for (thin)lto backend compiles at O0.
+  if (Matches[1] != "thinlto" && Matches[1] != "lto")
+MPM.addPass(buildO0DefaultPipeline(L, Matches[1] != "default"));

aeubanks wrote:
> aeubanks wrote:
> > tejohnson wrote:
> > > This seems to change behavior. For one, previously we were only 
> > > suppressing adding the PGO Instr passes for ThinLTO. Now this will 
> > > suppress adding the coroutines passes and whatever else 
> > > runRegisteredEPCallbacks was doing. Also, it's now doing the same for 
> > > regular LTO but it didn't seem to do any special handling in that case 
> > > before. Are these changes intended?
> > The callbacks are generally for two purposes. One is to lower certain 
> > constructs, which only needs to be done once. It should already have been 
> > done in the pre-link step. The other is for optimization purposes at 
> > specific points in the pipeline. Since this is -O0, that doesn't matter.
> > 
> > So I think this makes sense.
> Actually, I just noticed that build(Thin)LTODefaultPipeline does handle O0. 
> The default and LTO pre-link ones assert when passed O0 so I assumed that was 
> the case for the LTO pipelines, but that's not the case. I'll change that.
Ok, just to confirm, it seems like this code was incorrectly adding additional 
passes before for thinlto (coroutines, runRegisteredEPCallbacks) and for 
lto (pgo, coroutines, runRegisteredEPCallbacks) - is that correct?

I would have expected some changes in the new PM pipeline tests, but it looks 
like there is a lack of testing of these two. I don't see any pipeline tests 
for lto, and only one for thinlto - and that only checks the PGO passes 
(llvm/test/Other/new-pm-pgo-O0.ll). Can you add lto to that test? Can you 
also beef it up to add some of the other passes that (I think) we were 
previously adding below here for thinlto and lto that we won't anymore?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91585

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


[PATCH] D91104: APINotes: add property models for YAML attributes

2020-11-19 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked 2 inline comments as done.
compnerd added inline comments.



Comment at: clang/include/clang/APINotes/Types.h:60
+  /// Whether SwiftPrivate was specified.
+  unsigned SwiftPrivateSpecified : 1;
+

martong wrote:
> I was wondering whether Swift specific properties are meaningful to all 
> descendants of `CommonEntityInfo`. With other words, can we attach the swift 
> private attribute to all kind of declarations? If not, perhaps then we need a 
> "middle" base class injected into the class hierarchy.
> 
> And I have the same question for `CommonTypeInfo`, regarding SwiftBridge and 
> other Swift sweeties.
The `__swift_private__` attribute applies to all declarations, so I think that 
it makes sense as is.  I suppose that we can do multiple inheritance if you 
want to separate the Swift and ObjC attributes.

The `__swift_bridge__` attribute only applies to tags, typedefs, ObjC 
interfaces and protocols.  The `__swift_name__` attribute applies to all 
declarations.

The `__ns_error_domain__` attribute is ObjC specific, though Swift does care 
about it.  It only applies to enum types though.

The vast majority of the Swift attributes do apply to a wide variety of types, 
and I think that the current structure makes sense.  It seems a bit unnecessary 
to split them out further into a structure and loose the packing, but I suppose 
that one option would be to add wrapper structs around all the language 
specific options, but that comes at the cost of higher memory usage for clang, 
which is already significant at times.



Comment at: clang/include/clang/APINotes/Types.h:125
+class CommonTypeInfo : public CommonEntityInfo {
+  /// The Swift type to which a given type is bridged.
+  ///

martong wrote:
> This comment is probably off.
I think that this comment is correct, it is describing the `SwiftBridge` field.



Comment at: clang/include/clang/APINotes/Types.h:529
+  /// Adds the return type info.
+  void addReturnTypeInfo(NullabilityKind kind) { addTypeInfo(0, kind); }
+

martong wrote:
> Do we document somewhere that the `0` index means the return type? Maybe 
> adding a constant like `ReturnIdx` could resolve this magic number.
Sure, I can add a constant for that.  I don't think that we have that 
documented, but, I think that the constant should be sufficient for that no?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91104

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


[PATCH] D91585: [NPM] Move more O0 pass building into PassBuilder

2020-11-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 306448.
aeubanks added a comment.

check 'thinlto-pre-link'/'lto-pre-link' explicitly
add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91585

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-defaults.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-pgo-O0.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
  llvm/test/Transforms/NameAnonGlobals/rename.ll

Index: llvm/test/Transforms/NameAnonGlobals/rename.ll
===
--- llvm/test/Transforms/NameAnonGlobals/rename.ll
+++ llvm/test/Transforms/NameAnonGlobals/rename.ll
@@ -1,5 +1,6 @@
 ; RUN: opt -S -name-anon-globals < %s | FileCheck %s
-; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc < %s
+; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc -enable-new-pm=0 < %s
+; RUN: opt -passes='thinlto-pre-link,require' -o %t.bc < %s
 
 
 ; foo contribute to the unique hash for the module
Index: llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
===
--- llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
+++ llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
@@ -1,6 +1,7 @@
 ; RUN: opt -S -canonicalize-aliases < %s | FileCheck %s
-; RUN: opt -prepare-for-thinlto -O0 -module-summary -o - < %s | llvm-dis -o - | FileCheck %s
 ; RUN: opt -S -passes=canonicalize-aliases < %s | FileCheck %s
+; RUN: opt -prepare-for-thinlto -O0 -module-summary -o - < %s -enable-new-pm=0 | llvm-dis -o - | FileCheck %s
+; RUN: opt -passes='thinlto-pre-link,require' -o - < %s | llvm-dis -o - | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -2,27 +2,27 @@
 ;
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S  %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S  %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O3,CHECK-O23SZ,CHECK-EP-PIPELINE-START
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Os,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Oz,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager -new-pm-debug-info-for-profiling \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S  %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S  %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ
 ;
 ; CHECK-O: Starting {{.*}}Module pass manager run.
@@ -173,6 +173,7 @@
 ; CHECK-O-NEXT: Finished {{.*}}Module pass manager run.
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo
+; CHECK-O-NEXT: Running pa

[PATCH] D91585: [NPM] Move more O0 pass building into PassBuilder

2020-11-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks marked an inline comment as done.
aeubanks added inline comments.



Comment at: llvm/lib/Passes/PassBuilder.cpp:2365
+  // Don't do anything for (thin)lto backend compiles at O0.
+  if (Matches[1] != "thinlto" && Matches[1] != "lto")
+MPM.addPass(buildO0DefaultPipeline(L, Matches[1] != "default"));

tejohnson wrote:
> aeubanks wrote:
> > aeubanks wrote:
> > > tejohnson wrote:
> > > > This seems to change behavior. For one, previously we were only 
> > > > suppressing adding the PGO Instr passes for ThinLTO. Now this will 
> > > > suppress adding the coroutines passes and whatever else 
> > > > runRegisteredEPCallbacks was doing. Also, it's now doing the same for 
> > > > regular LTO but it didn't seem to do any special handling in that case 
> > > > before. Are these changes intended?
> > > The callbacks are generally for two purposes. One is to lower certain 
> > > constructs, which only needs to be done once. It should already have been 
> > > done in the pre-link step. The other is for optimization purposes at 
> > > specific points in the pipeline. Since this is -O0, that doesn't matter.
> > > 
> > > So I think this makes sense.
> > Actually, I just noticed that build(Thin)LTODefaultPipeline does handle O0. 
> > The default and LTO pre-link ones assert when passed O0 so I assumed that 
> > was the case for the LTO pipelines, but that's not the case. I'll change 
> > that.
> Ok, just to confirm, it seems like this code was incorrectly adding 
> additional passes before for thinlto (coroutines, 
> runRegisteredEPCallbacks) and for lto (pgo, coroutines, 
> runRegisteredEPCallbacks) - is that correct?
> 
> I would have expected some changes in the new PM pipeline tests, but it looks 
> like there is a lack of testing of these two. I don't see any pipeline tests 
> for lto, and only one for thinlto - and that only checks the PGO 
> passes (llvm/test/Other/new-pm-pgo-O0.ll). Can you add lto to that test? 
> Can you also beef it up to add some of the other passes that (I think) we 
> were previously adding below here for thinlto and lto that we won't anymore?
added a new test in the vein of new-pm-defaults.ll, could you see if the 
printed passes make sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91585

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


[PATCH] D91805: [OPENMP]Use the real pointer value as base, not indexed value.

2020-11-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: arphaman, guansong, yaxunl.
Herald added a project: clang.
ABataev requested review of this revision.

After fix for PR48174 the base pointer for pointer-based
array-sections/array-subscripts will be emitted as `&ptr[idx]`, but
actually it should be just `ptr`, i.e. the address stored in the ponter
to point correctly to the beginning of the array. Currently it may lead
to a crash in the runtime.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91805

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp


Index: clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
===
--- clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
+++ clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
@@ -38,10 +38,17 @@
 // CHECK-DAG: [[MAPS1:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, 
i64 281474976710673]
 // CHECK: @main
 int main(void) {
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* 
%{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject***
+// CHECK: store %struct.MyObject** @objects, %struct.MyObject*** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, 
i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* [[SIZES0]], i32 0, i32 0), i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* [[MAPS0]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects [0:1])
+#pragma omp target enter data map(to : objects [1:1])
+// CHECK: [[OBJ:%.+]] = load %struct.MyObject*, %struct.MyObject** @objects,
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* 
%{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject**
+// CHECK: store %struct.MyObject* [[OBJ]], %struct.MyObject** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, 
i64 -1, i32 2, i8** %{{.+}}, i8** %{{.+}}, i64* %{{.+}}, i64* getelementptr 
inbounds ([2 x i64], [2 x i64]* [[MAPS1]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects[0].arr [0:1])
+#pragma omp target enter data map(to : objects[1].arr [0:1])
 
   return 0;
 }
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7903,8 +7903,11 @@
 IsCaptureFirstInfo = false;
 FirstPointerInComplexData = false;
   } else if (FirstPointerInComplexData) {
-BP = CGF.EmitOMPSharedLValue(I->getAssociatedExpression())
- .getAddress(CGF);
+QualType Ty = Components.rbegin()
+  ->getAssociatedDeclaration()
+  ->getType()
+  .getNonReferenceType();
+BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
 FirstPointerInComplexData = false;
   }
 }


Index: clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
===
--- clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
+++ clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
@@ -38,10 +38,17 @@
 // CHECK-DAG: [[MAPS1:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 281474976710673]
 // CHECK: @main
 int main(void) {
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject***
+// CHECK: store %struct.MyObject** @objects, %struct.MyObject*** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[SIZES0]], i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[MAPS0]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects [0:1])
+#pragma omp target enter data map(to : objects [1:1])
+// CHECK: [[OBJ:%.+]] = load %struct.MyObject*, %struct.MyObject** @objects,
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject**
+// CHECK: store %struct.MyObject* [[OBJ]], %struct.MyObject** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 2, i8** %{{.+}}, i8** %{{.+}}, i64* %{{.+}}, i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPS1]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects[0].arr [0:1])
+#pragma omp target ent

[PATCH] D91806: [SVE] Remove warnings from release notes example on SVE ACLE.

2020-11-19 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli created this revision.
fpetrogalli added reviewers: peterwaller-arm, efriedma, paulwalker-arm, 
joechrisellis, sdesmalen.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, lxfind, 
psnobl, hiraditya, tschuett.
Herald added projects: clang, LLVM.
fpetrogalli requested review of this revision.

The warnings were raised in the method `valueCoversEntireFragment` by
the implicit cast of `TypeSize` to `uint64_t` in the RHS of:

  uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);

The other changes in this patch have been made to update
`valueCoversEntireFragment` to uniformily use `TypeSize` instead of
`uint64_t`. No functional changes are intended for these extra
changes. Assertions have been added to prevent untested codepath.

The change is guarded by:

1. a test that compiles the SVE ACLE example `VLA_add_arrays` in the release 
note of LLVM 11 at 
https://releases.llvm.org/11.0.0/tools/clang/docs/ReleaseNotes.html,

2. a test in LLVM that stresses the code path in InstCombiner that triggers the 
warning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91806

Files:
  clang/test/CodeGen/aarch64-sve-acle-rel-note.c
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  
llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll

Index: llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
@@ -0,0 +1,42 @@
+; RUN: opt -mtriple aarch64-gnu-linux -mattr=+sve -instcombine %s -o - 2>&1 -S | FileCheck %s
+
+; If this check fails please read
+; clang/test/CodeGen/aarch64-sve-intrinsics/README for instructions
+; on how to resolve it.
+
+; CHECK-NOT: warning
+define dso_local  @debug_local_scalable( %tostore) #0 {
+  %vx = alloca , align 16
+  call void @llvm.dbg.declare(metadata * %vx, metadata !5, metadata !DIExpression()), !dbg !15
+  store  %tostore, * %vx, align 16
+  %ret = call  @f(* %vx)
+  ret  %ret
+}
+
+declare  @f(*) #0
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { "target-features"="+sve" }
+attributes #1 = { nofree nosync nounwind readnone speculatable willreturn "target-features"="+sve" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp/")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !DILocalVariable(name: "vx", scope: !6, file: !7, line: 26, type: !8)
+!6 = distinct !DISubprogram(name: "debug_local_scalable", scope: null, file: !1, line: 25, scopeLine: 25, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
+!7 = !DIFile(filename: "test.c", directory: "/tmp/")
+!8 = !DIDerivedType(tag: DW_TAG_typedef, name: "svfloat64_t", file: !9, line: 56, baseType: !10)
+!9 = !DIFile(filename: "arm_sve.h", directory: "/tmp/")
+!10 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVFloat64_t", file: !1, baseType: !11)
+!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, flags: DIFlagVector, elements: !13)
+!12 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
+!13 = !{!14}
+!14 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
+!15 = !DILocation(line: 26, column: 15, scope: !6)
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1368,16 +1368,17 @@
 /// least n bits.
 static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
   const DataLayout &DL = DII->getModule()->getDataLayout();
-  uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
-  if (auto FragmentSize = DII->getFragmentSizeInBits())
-return ValueSize >= *FragmentSize;
+  TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
+  if (Optional FragmentSize = DII->getFragmentSizeInBits())
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
   // We can't always calculate the size of the DI variable (e.g. if it is a
   // VLA). Try to use the size of the alloca that the dbg intrinsic describes
   // intead.
   if (DII->isAddressOfVariable())
 if (auto *AI = dyn_cast_or_null(DII->getVariableLocati

[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

2020-11-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D89743#2363201 , @aaron.ballman 
wrote:

> In D89743#2360258 , @sammccall wrote:
>
>> (while this is useful to you, let's keep discussing, but I'm also happy to 
>> stop and land this with your preferred API/semantics - just LMK if changes 
>> are needed)
>
> Let's hold off on landing for just a little bit. I don't think changes are 
> needed yet, but the discussion may change my opinion and we might as well 
> avoid churn. However, if you need to land part of this while we discuss other 
> parts, LMK.

Sorry I haven't had more to say on this. I would like to land at least the 
attr-in-DynTypedNode part, as this unblocks some stuff unrelated to matchers in 
clangd (someone just filed a dupe bug, which reminded me...)

Happy to cut out all of the matcher part, or land just attr() without any attr 
matchers, or all of it, or make another round of changes...

>> In D89743#2360032 , @aaron.ballman 
>> wrote:
>>
>>> 
>
> My mental model is that there is no declaration of an attribute (in the usual 
> sense, because users cannot specify their own attributes without changing the 
> compiler), and so there's not a referential model like there are with a 
> DeclRefExpr that refers back to a specific declaration. Instead, to me, an 
> attribute is a bit more like a builtin type --  you may have multiple ways to 
> spell the type (`char` vs `signed char` or `unsigned char`, `long int` vs 
> `long`, etc), but it's the same type under the hood.

Ah, this also makes sense! Again, the wrinkle is IIUC `attr::Kind` is like a 
builtin type, while `Attr` is more like VectorType - it specifies a builtin 
type, but also some other stuff.

> However, that brings up an interesting observation: you can't do 
> `hasType(hasName("long"))` and instead have to do 
> `hasType(asString("long"))`. I don't recall the background about why there is 
> `asString()` for matching string types vs `hasName()` -- you wouldn't happen 
> to remember that context, would you?

That was before my time I'm afraid.
It seems the implementation checks whether QualType::getAsString() exactly 
matches the argument. `asString("long")` matches a type specified as `long` or 
`long int`. But `asString("long int")` doesn't match anything! (Sugar types 
muddle things a bit but don't fundamentally change this).
My guess is this implementation was just a question of practicality: parsing 
the matcher argument as a type isn't feasible, but having the node producing a 
single string to compare to is easy. And it generalizes to complicated template 
types.

It's reasonable to think of these as doing different things `hasName` is 
querying a property, while `asString` is doing a specialized comparison of the 
whole thing.
I'm not *sure* that's why the different names where chosen though. And the fact 
that `hasName` allows qualifiers definitely feels a bit bolted on here.

> For instance, is the correct pattern to allow `attr(asString("aligned"))` to 
> map back to an `AlignedAttr` regardless of how the attribute was spelled in 
> source, similar to how `asString("long")` matches `long int`?

If we're following precedents (not sure we have to):

- per your mental model, `asString` would pick one fixed name for each 
attribute kind - which may not be the one used!
- ... but also `asString` should roughly be "node as string" which logically 
includes arguments and should use the right name (since the node records it)
- `hasName` should match against the `name` attribute of Attr, possibly with 
optional qualifiers
- ... but there's no precedent for rejecting synonymous names per se, and this 
may be confusing behavior

So I don't think either of these are a *great* fit, assuming we think 
"attribute named XYZ or any synonym" is the most important operation (which I 
agree with).
I can't think of a pithy name, but I also think it's OK to be a bit verbose and 
explicit here - attributes aren't the most commonly used bit of the AST.

> Maybe `attr(equivalentAttrName("..."))` or so, possibly constrasting to 
> `attr(exactAttrName("..."))`?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743

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


[PATCH] D91585: [NPM] Move more O0 pass building into PassBuilder

2020-11-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/lib/Passes/PassBuilder.cpp:2365
+Matches[1] != "lto") {
+  MPM.addPass(buildO0DefaultPipeline(L, Matches[1] != "default"));
   return Error::success();

tejohnson wrote:
> I think it would be clearer to check against "thinlto-pre-link" and 
> "lto-pre-link" here (and more robust in case any other types added in the 
> future).
Sorry, to be more explicit, I was talking about the below line, where it sets 
up the LTOPreLink parameter to buildO0DefaultPipeline. I think the above line 
is actually better the way it was (checking != "thinlto" and != "lto").


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91585

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


[PATCH] D91807: [CUDA] Unbreak CUDA compilation with -std=c++20

2020-11-19 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added subscribers: bixia, yaxunl.
Herald added a project: clang.
tra requested review of this revision.

Standard libc++ headers in stdc++ mode include  which picks up
cuda_wrappers/new before any of the CUDA macros have been defined.

We can not include CUDA headers that early, so the work-around is to define
__device__ in the wrapper header itself.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91807

Files:
  clang/lib/Headers/cuda_wrappers/new


Index: clang/lib/Headers/cuda_wrappers/new
===
--- clang/lib/Headers/cuda_wrappers/new
+++ clang/lib/Headers/cuda_wrappers/new
@@ -33,66 +33,76 @@
 #define CUDA_NOEXCEPT
 #endif
 
+#pragma push_macro("__DEVICE__")
+#if defined __device__
+#define __DEVICE__ __device__
+#else
+//  has been included too early from the standard libc++ headers and the
+// standard CUDA macros are not available yet. We have to define our own.
+#define __DEVICE__ __attribute__((device))
+#endif
+
 // Device overrides for non-placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size) {
   if (size == 0) {
 size = 1;
   }
   return ::malloc(size);
 }
-__device__ inline void *operator new(__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size,
  const std::nothrow_t &) CUDA_NOEXCEPT {
   return ::operator new(size);
 }
 
-__device__ inline void *operator new[](__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size) {
   return ::operator new(size);
 }
-__device__ inline void *operator new[](__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size,
const std::nothrow_t &) {
   return ::operator new(size);
 }
 
-__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
+__DEVICE__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
   if (ptr) {
 ::free(ptr);
   }
 }
-__device__ inline void operator delete(void *ptr,
+__DEVICE__ inline void operator delete(void *ptr,
const std::nothrow_t &) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
+__DEVICE__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__device__ inline void operator delete[](void *ptr,
+__DEVICE__ inline void operator delete[](void *ptr,
  const std::nothrow_t &) CUDA_NOEXCEPT 
{
   ::operator delete(ptr);
 }
 
 // Sized delete, C++14 only.
 #if __cplusplus >= 201402L
-__device__ inline void operator delete(void *ptr,
+__DEVICE__ inline void operator delete(void *ptr,
__SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__device__ inline void operator delete[](void *ptr,
+__DEVICE__ inline void operator delete[](void *ptr,
  __SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 #endif
 
 // Device overrides for placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
+__DEVICE__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
   return __ptr;
 }
-__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
   return __ptr;
 }
-__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
-__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
+__DEVICE__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
+__DEVICE__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
 
+#pragma pop_macro("__DEVICE__")
 #pragma pop_macro("CUDA_NOEXCEPT")
 
 #endif // include guard


Index: clang/lib/Headers/cuda_wrappers/new
===
--- clang/lib/Headers/cuda_wrappers/new
+++ clang/lib/Headers/cuda_wrappers/new
@@ -33,66 +33,76 @@
 #define CUDA_NOEXCEPT
 #endif
 
+#pragma push_macro("__DEVICE__")
+#if defined __device__
+#define __DEVICE__ __device__
+#else
+//  has been included too early from the standard libc++ headers and the
+// standard CUDA macros are not available yet. We have to define our own.
+#define __DEVICE__ __attribute__((device))
+#endif
+
 // Device overrides for non-placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size) {
   if (size == 0) {
 size = 1;
   }
   return ::malloc(size);
 }
-__device__ inline void *operator new(__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size,
   

[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-19 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.

Seems that sufficient approvals have been received.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91410

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


[PATCH] D88676: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

2020-11-19 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:235
+return TM.isPPC64()
+   ? (Subtarget.hasAltivec() ? CSR_64_AllRegs_Altivec_RegMask
+ : CSR_PPC64_RegMask)

ZarkoCA wrote:
> sfertile wrote:
> > `CSR_64_AllRegs_Altivec_RegMask` should be `CSR_PPC64_Altivec_RegMask`.  
> > FWIW I don't think this is testable without D86476. If that's the case, 
> > then it should go in that patch, not this patch. 
> Are you suggesting that I also leave the error in if I were to move this 
> change to D84676? 
Can you still run the tests that are part of this commit with that error in? My 
understanding was that it didn't interfere, but I didn't verify that. If we can 
still run the tests then yes leave the error in. If we can't then it probably 
gives us a clue about how to test the change in this patch without needing 
D84676, in which case we can keep the change and simply add the testing that 
exercises it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88676

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


[clang-tools-extra] 617e8e5 - [clang-tidy] ElseAfterReturn check wont suggest fixes if preprocessor branches are involved

2020-11-19 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-11-19T18:20:32Z
New Revision: 617e8e5ee3bb3316baae7a69d74b5ff95031d571

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

LOG: [clang-tidy] ElseAfterReturn check wont suggest fixes if preprocessor 
branches are involved

Consider this code:
```
if (Cond) {
#ifdef X_SUPPORTED
  X();
#else
  return;
#endif
} else {
  Y();
}
Z();```

In this example, if `X_SUPPORTED` is not defined, currently we'll get a warning 
from the else-after-return check. However If we apply that fix, and then the 
code is recompiled with `X_SUPPORTED` defined, we have inadvertently changed 
the behaviour of the if statement due to the else being removed. Code flow when 
`Cond` is `true` will be:
```
X();
Y();
Z();```
 where as before the fix it was:
 ```
 X();
 Z();```

 This patch adds checks that guard against `#endif` directives appearing 
between the control flow interrupter and the else and not applying the fix if 
they are detected.

Reviewed By: aaron.ballman

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-pp-no-crash.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
index 9ad6fb737ec9..79e3cded45bc 100644
--- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/FixIt.h"
 #include "llvm/ADT/SmallVector.h"
 
@@ -19,10 +20,30 @@ namespace clang {
 namespace tidy {
 namespace readability {
 
-static const char ReturnStr[] = "return";
-static const char ContinueStr[] = "continue";
-static const char BreakStr[] = "break";
-static const char ThrowStr[] = "throw";
+namespace {
+
+class PPConditionalCollector : public PPCallbacks {
+public:
+  PPConditionalCollector(
+  ElseAfterReturnCheck::ConditionalBranchMap &Collections,
+  const SourceManager &SM)
+  : Collections(Collections), SM(SM) {}
+  void Endif(SourceLocation Loc, SourceLocation IfLoc) override {
+if (!SM.isWrittenInSameFile(Loc, IfLoc))
+  return;
+SmallVectorImpl &Collection = Collections[SM.getFileID(Loc)];
+assert(Collection.empty() || Collection.back().getEnd() < Loc);
+Collection.emplace_back(IfLoc, Loc);
+  }
+
+private:
+  ElseAfterReturnCheck::ConditionalBranchMap &Collections;
+  const SourceManager &SM;
+};
+
+} // namespace
+
+static const char InterruptingStr[] = "interrupting";
 static const char WarningMessage[] = "do not use 'else' after '%0'";
 static const char WarnOnUnfixableStr[] = "WarnOnUnfixable";
 static const char WarnOnConditionVariablesStr[] = "WarnOnConditionVariables";
@@ -140,11 +161,18 @@ void 
ElseAfterReturnCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, WarnOnConditionVariablesStr, WarnOnConditionVariables);
 }
 
+void ElseAfterReturnCheck::registerPPCallbacks(const SourceManager &SM,
+   Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) 
{
+  PP->addPPCallbacks(
+  std::make_unique(this->PPConditionals, SM));
+}
+
 void ElseAfterReturnCheck::registerMatchers(MatchFinder *Finder) {
-  const auto InterruptsControlFlow =
-  stmt(anyOf(returnStmt().bind(ReturnStr), 
continueStmt().bind(ContinueStr),
- breakStmt().bind(BreakStr),
- expr(ignoringImplicit(cxxThrowExpr().bind(ThrowStr);
+  const auto InterruptsControlFlow = stmt(anyOf(
+  returnStmt().bind(InterruptingStr), continueStmt().bind(InterruptingStr),
+  breakStmt().bind(InterruptingStr),
+  expr(ignoringImplicit(cxxThrowExpr().bind(InterruptingStr);
   Finder->addMatcher(
   compoundStmt(
   forEach(ifStmt(unless(isConstexpr()),
@@ -157,21 +185,72 @@ void ElseAfterReturnCheck::registerMatchers(MatchFinder 
*Finder) {
   this);
 }
 
+static bool hasPreprocessorBranchEndBetweenLocations(
+const ElseAfterReturnCheck::ConditionalBranchMap &ConditionalBranchMap,
+const SourceManager &SM, SourceLocation StartLoc, SourceLocation EndLoc) {
+
+  SourceLocation ExpandedStartLoc = SM.getExpansionLoc(StartLoc);
+  SourceLocation ExpandedEndLoc = SM.getExpansionLoc(EndLoc);
+  if (!SM.isWrittenInSameFi

[PATCH] D91485: [clang-tidy] ElseAfterReturn check wont suggest fixes if preprocessor branches are involved

2020-11-19 Thread Nathan James via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG617e8e5ee3bb: [clang-tidy] ElseAfterReturn check wont 
suggest fixes if preprocessor branches… (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D91485?vs=306143&id=306463#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91485

Files:
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-pp-no-crash.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return.cpp
@@ -226,3 +226,89 @@
   }
   return;
 }
+
+void testPPConditionals() {
+
+  // These cases the return isn't inside the conditional so diagnose as normal.
+  if (true) {
+return;
+#if 1
+#endif
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+return;
+  }
+  if (true) {
+#if 1
+#endif
+return;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+return;
+  }
+
+  // No return here in the AST, no special handling needed.
+  if (true) {
+#if 0
+return;
+#endif
+  } else {
+return;
+  }
+
+  // Return here is inside a preprocessor conditional block, ignore this case.
+  if (true) {
+#if 1
+return;
+#endif
+  } else {
+return;
+  }
+
+  // These cases, same as above but with an #else block.
+  if (true) {
+#if 1
+return;
+#else
+#endif
+  } else {
+return;
+  }
+  if (true) {
+#if 0
+#else
+return;
+#endif
+  } else {
+return;
+  }
+
+// Ensure it can handle macros.
+#define RETURN return
+  if (true) {
+#if 1
+RETURN;
+#endif
+  } else {
+return;
+  }
+#define ELSE else
+  if (true) {
+#if 1
+return;
+#endif
+  }
+  ELSE {
+return;
+  }
+
+  // Whole statement is in a conditional block so diagnose as normal.
+#if 1
+  if (true) {
+return;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use 'else' after 'return'
+return;
+  }
+#endif
+}
Index: clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-pp-no-crash.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-pp-no-crash.cpp
@@ -0,0 +1,22 @@
+// RUN: clang-tidy %s -checks=-*,readability-else-after-return
+
+// We aren't concerned about the output here, just want to ensure clang-tidy doesn't crash.
+void foo() {
+#if 1
+  if (true) {
+return;
+#else
+  {
+#endif
+  } else {
+return;
+  }
+
+  if (true) {
+#if 1
+return;
+  } else {
+#endif
+return;
+  }
+}
Index: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
+++ clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_ELSEAFTERRETURNCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "llvm/ADT/DenseMap.h"
 
 namespace clang {
 namespace tidy {
@@ -23,12 +24,18 @@
   ElseAfterReturnCheck(StringRef Name, ClangTidyContext *Context);
 
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
+  using ConditionalBranchMap =
+  llvm::DenseMap>;
+
 private:
   const bool WarnOnUnfixable;
   const bool WarnOnConditionVariables;
+  ConditionalBranchMap PPConditionals;
 };
 
 } // namespace readability
Index: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/FixIt.h"
 #include "llvm/ADT/SmallVector.h"
 
@@ -19,10 +20,30 @@
 namespace tidy {
 namespace readability {
 
-static const char ReturnStr[] = "return";
-static const char ContinueStr[] = 

[PATCH] D91807: [CUDA] Unbreak CUDA compilation with -std=c++20

2020-11-19 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

How fun.  :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91807

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


[PATCH] D91157: [AArch64] Out-of-line atomics (-moutline-atomics) implementation.

2020-11-19 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6377
+} else {
+  CmdArgs.push_back("-target-feature");
+  CmdArgs.push_back("-outline-atomics");

jyknight wrote:
> We don't usually explicitly use negative features like this, do we? I think 
> this else clause can be omitted.
We do, -soft-float for example in Clang.cpp:2397

```
if (Value.startswith("-mhard-float")) {
  CmdArgs.push_back("-target-feature");
  CmdArgs.push_back("-soft-float");
  continue;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91157

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2020-11-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D91656: [clang-tidy] add concurrency module

2020-11-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

LG, I have no further comments, though see what other say about this first.


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

https://reviews.llvm.org/D91656

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


[PATCH] D91789: [clang-tidy] find/fix unneeded trailing semicolons in macros

2020-11-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp:25
 "linuxkernel-must-check-errs");
 CheckFactories.registerCheck("linuxkernel-switch-semi");
   }

This check hasn't landed, can you please make sure your patches are against a 
commit on trunk, otherwise it can't be applied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91789

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


[PATCH] D91585: [NPM] Move more O0 pass building into PassBuilder

2020-11-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 306473.
aeubanks added a comment.

change strings to check for


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91585

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-defaults.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-pgo-O0.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
  llvm/test/Transforms/NameAnonGlobals/rename.ll

Index: llvm/test/Transforms/NameAnonGlobals/rename.ll
===
--- llvm/test/Transforms/NameAnonGlobals/rename.ll
+++ llvm/test/Transforms/NameAnonGlobals/rename.ll
@@ -1,5 +1,6 @@
 ; RUN: opt -S -name-anon-globals < %s | FileCheck %s
-; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc < %s
+; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc -enable-new-pm=0 < %s
+; RUN: opt -passes='thinlto-pre-link,require' -o %t.bc < %s
 
 
 ; foo contribute to the unique hash for the module
Index: llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
===
--- llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
+++ llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll
@@ -1,6 +1,7 @@
 ; RUN: opt -S -canonicalize-aliases < %s | FileCheck %s
-; RUN: opt -prepare-for-thinlto -O0 -module-summary -o - < %s | llvm-dis -o - | FileCheck %s
 ; RUN: opt -S -passes=canonicalize-aliases < %s | FileCheck %s
+; RUN: opt -prepare-for-thinlto -O0 -module-summary -o - < %s -enable-new-pm=0 | llvm-dis -o - | FileCheck %s
+; RUN: opt -passes='thinlto-pre-link,require' -o - < %s | llvm-dis -o - | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -2,27 +2,27 @@
 ;
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S  %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S  %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O3,CHECK-O23SZ,CHECK-EP-PIPELINE-START
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Os,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Oz,CHECK-O23SZ
 ; RUN: opt -disable-verify -debug-pass-manager -new-pm-debug-info-for-profiling \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
-; RUN: -passes='thinlto-pre-link,name-anon-globals' -S  %s 2>&1 \
+; RUN: -passes='thinlto-pre-link' -S  %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ
 ;
 ; CHECK-O: Starting {{.*}}Module pass manager run.
@@ -173,6 +173,7 @@
 ; CHECK-O-NEXT: Finished {{.*}}Module pass manager run.
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo
+; CHECK-O-NEXT: Running pass: CanonicalizeAliasesPass
 ; C

[clang] 9a46505 - [CUDA] Unbreak CUDA compilation with -std=c++20

2020-11-19 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2020-11-19T10:35:47-08:00
New Revision: 9a465057a64dba8a8614424d26136f5c0452bcc3

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

LOG: [CUDA] Unbreak CUDA compilation with -std=c++20

Standard libc++ headers in stdc++ mode include  which picks up
cuda_wrappers/new before any of the CUDA macros have been defined.

We can not include CUDA headers that early, so the work-around is to define
__device__ in the wrapper header itself.

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

Added: 


Modified: 
clang/lib/Headers/cuda_wrappers/new

Removed: 




diff  --git a/clang/lib/Headers/cuda_wrappers/new 
b/clang/lib/Headers/cuda_wrappers/new
index f49811c5a57c..47690f1152fe 100644
--- a/clang/lib/Headers/cuda_wrappers/new
+++ b/clang/lib/Headers/cuda_wrappers/new
@@ -33,66 +33,76 @@
 #define CUDA_NOEXCEPT
 #endif
 
+#pragma push_macro("__DEVICE__")
+#if defined __device__
+#define __DEVICE__ __device__
+#else
+//  has been included too early from the standard libc++ headers and the
+// standard CUDA macros are not available yet. We have to define our own.
+#define __DEVICE__ __attribute__((device))
+#endif
+
 // Device overrides for non-placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size) {
   if (size == 0) {
 size = 1;
   }
   return ::malloc(size);
 }
-__device__ inline void *operator new(__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size,
  const std::nothrow_t &) CUDA_NOEXCEPT {
   return ::operator new(size);
 }
 
-__device__ inline void *operator new[](__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size) {
   return ::operator new(size);
 }
-__device__ inline void *operator new[](__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size,
const std::nothrow_t &) {
   return ::operator new(size);
 }
 
-__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
+__DEVICE__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
   if (ptr) {
 ::free(ptr);
   }
 }
-__device__ inline void operator delete(void *ptr,
+__DEVICE__ inline void operator delete(void *ptr,
const std::nothrow_t &) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
+__DEVICE__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__device__ inline void operator delete[](void *ptr,
+__DEVICE__ inline void operator delete[](void *ptr,
  const std::nothrow_t &) CUDA_NOEXCEPT 
{
   ::operator delete(ptr);
 }
 
 // Sized delete, C++14 only.
 #if __cplusplus >= 201402L
-__device__ inline void operator delete(void *ptr,
+__DEVICE__ inline void operator delete(void *ptr,
__SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__device__ inline void operator delete[](void *ptr,
+__DEVICE__ inline void operator delete[](void *ptr,
  __SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 #endif
 
 // Device overrides for placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
+__DEVICE__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
   return __ptr;
 }
-__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
   return __ptr;
 }
-__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
-__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
+__DEVICE__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
+__DEVICE__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
 
+#pragma pop_macro("__DEVICE__")
 #pragma pop_macro("CUDA_NOEXCEPT")
 
 #endif // include guard



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


[PATCH] D91807: [CUDA] Unbreak CUDA compilation with -std=c++20

2020-11-19 Thread Artem Belevich 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 rG9a465057a64d: [CUDA] Unbreak CUDA compilation with 
-std=c++20 (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91807

Files:
  clang/lib/Headers/cuda_wrappers/new


Index: clang/lib/Headers/cuda_wrappers/new
===
--- clang/lib/Headers/cuda_wrappers/new
+++ clang/lib/Headers/cuda_wrappers/new
@@ -33,66 +33,76 @@
 #define CUDA_NOEXCEPT
 #endif
 
+#pragma push_macro("__DEVICE__")
+#if defined __device__
+#define __DEVICE__ __device__
+#else
+//  has been included too early from the standard libc++ headers and the
+// standard CUDA macros are not available yet. We have to define our own.
+#define __DEVICE__ __attribute__((device))
+#endif
+
 // Device overrides for non-placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size) {
   if (size == 0) {
 size = 1;
   }
   return ::malloc(size);
 }
-__device__ inline void *operator new(__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size,
  const std::nothrow_t &) CUDA_NOEXCEPT {
   return ::operator new(size);
 }
 
-__device__ inline void *operator new[](__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size) {
   return ::operator new(size);
 }
-__device__ inline void *operator new[](__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__ size,
const std::nothrow_t &) {
   return ::operator new(size);
 }
 
-__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
+__DEVICE__ inline void operator delete(void* ptr) CUDA_NOEXCEPT {
   if (ptr) {
 ::free(ptr);
   }
 }
-__device__ inline void operator delete(void *ptr,
+__DEVICE__ inline void operator delete(void *ptr,
const std::nothrow_t &) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 
-__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
+__DEVICE__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__device__ inline void operator delete[](void *ptr,
+__DEVICE__ inline void operator delete[](void *ptr,
  const std::nothrow_t &) CUDA_NOEXCEPT 
{
   ::operator delete(ptr);
 }
 
 // Sized delete, C++14 only.
 #if __cplusplus >= 201402L
-__device__ inline void operator delete(void *ptr,
+__DEVICE__ inline void operator delete(void *ptr,
__SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
-__device__ inline void operator delete[](void *ptr,
+__DEVICE__ inline void operator delete[](void *ptr,
  __SIZE_TYPE__ size) CUDA_NOEXCEPT {
   ::operator delete(ptr);
 }
 #endif
 
 // Device overrides for placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
+__DEVICE__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
   return __ptr;
 }
-__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
+__DEVICE__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
   return __ptr;
 }
-__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
-__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
+__DEVICE__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
+__DEVICE__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
 
+#pragma pop_macro("__DEVICE__")
 #pragma pop_macro("CUDA_NOEXCEPT")
 
 #endif // include guard


Index: clang/lib/Headers/cuda_wrappers/new
===
--- clang/lib/Headers/cuda_wrappers/new
+++ clang/lib/Headers/cuda_wrappers/new
@@ -33,66 +33,76 @@
 #define CUDA_NOEXCEPT
 #endif
 
+#pragma push_macro("__DEVICE__")
+#if defined __device__
+#define __DEVICE__ __device__
+#else
+//  has been included too early from the standard libc++ headers and the
+// standard CUDA macros are not available yet. We have to define our own.
+#define __DEVICE__ __attribute__((device))
+#endif
+
 // Device overrides for non-placement new and delete.
-__device__ inline void *operator new(__SIZE_TYPE__ size) {
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size) {
   if (size == 0) {
 size = 1;
   }
   return ::malloc(size);
 }
-__device__ inline void *operator new(__SIZE_TYPE__ size,
+__DEVICE__ inline void *operator new(__SIZE_TYPE__ size,
  const std::nothrow_t &) CUDA_NOEXCEPT {
   return ::operator new(size);
 }
 
-__device__ inline void *operator new[](__SIZE_TYPE__ size) {
+__DEVICE__ 

[PATCH] D91585: [NPM] Move more O0 pass building into PassBuilder

2020-11-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91585

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-11-19 Thread Ten Tzen via Phabricator via cfe-commits
tentzen updated this revision to Diff 306469.
tentzen added a comment.

Fixed the clang fault when built without '-feh-asynch'  option.
EHStack's CGF field must be initialized even without -feh-asynch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/EHScopeStack.h
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
  clang/test/CodeGen/windows-seh-EHa-CppCondiTemps.cpp
  clang/test/CodeGen/windows-seh-EHa-CppDtors01.cpp
  clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/Verifier.cpp

Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4223,6 +4223,10 @@
   Assert(
   !F->isIntrinsic() || isa(I) ||
   F->getIntrinsicID() == Intrinsic::donothing ||
+  F->getIntrinsicID() == Intrinsic::seh_try_begin ||
+  F->getIntrinsicID() == Intrinsic::seh_try_end ||
+  F->getIntrinsicID() == Intrinsic::seh_scope_begin ||
+  F->getIntrinsicID() == Intrinsic::seh_scope_end ||
   F->getIntrinsicID() == Intrinsic::coro_resume ||
   F->getIntrinsicID() == Intrinsic::coro_destroy ||
   F->getIntrinsicID() == Intrinsic::experimental_patchpoint_void ||
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -2789,6 +2789,10 @@
   llvm_unreachable("Cannot invoke this intrinsic");
 case Intrinsic::donothing:
   // Ignore invokes to @llvm.donothing: jump directly to the next BB.
+case Intrinsic::seh_try_begin:
+case Intrinsic::seh_scope_begin:
+case Intrinsic::seh_try_end:
+case Intrinsic::seh_scope_end:
   break;
 case Intrinsic::experimental_patchpoint_void:
 case Intrinsic::experimental_patchpoint_i64:
@@ -6583,6 +6587,10 @@
   lowerCallToExternalSymbol(I, FunctionName);
 return;
   case Intrinsic::donothing:
+  case Intrinsic::seh_try_begin:
+  case Intrinsic::seh_scope_begin:
+  case Intrinsic::seh_try_end:
+  case Intrinsic::seh_scope_end:
 // ignore
 return;
   case Intrinsic::experimental_stackmap:
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -456,6 +456,16 @@
  [llvm_ptr_ty, llvm_ptr_ty],
  [IntrNoMem]>;
 
+// To mark the beginning/end of a try-scope for Windows SEH -EHa
+//  calls/invokes to these intrinsics are placed to model control flows
+//caused by HW exceptions under option -EHa.
+//  calls/invokes to these intrinsics will be discarded during a codegen pass
+//   after EH tables are generated
+def int_seh_try_begin : Intrinsic<[], [], [IntrReadMem, IntrWriteMem, IntrWillReturn]>;
+def int_seh_try_end : Intrinsic<[], [], [IntrReadMem, IntrWriteMem, IntrWillReturn]>;
+def int_seh_scope_begin : Intrinsic<[], [], [IntrNoMem]>;
+def int_seh_scope_end : Intrinsic<[], [], [IntrNoMem]>;
+
 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
 // model their dependencies on allocas.
 def int_stacksave : Intrinsic<[llvm_ptr_ty]>,
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -11530,6 +11530,66 @@
 the escaped allocas are allocated, which would break attempts to use
 '``llvm.localrecover``'.
 
+'``llvm.seh.try.begin``' and '``llvm.seh.try.end``' Intrinsics
+
+
+Syntax:
+"""
+
+::
+
+  declare void @llvm.seh.try.begin()
+  declare void @llvm.seh.try.end()
+
+Overview:
+"
+
+The '``llvm.seh.try.begin``' and '``llvm.seh.try.end``' intrinsics mark
+the boundary of a _try region for Windows SEH Asynchrous Exception Handling.
+
+Semantics:
+"

[PATCH] D83812: [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting stubs

2020-11-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 306472.
leonardchan added a comment.

Rebased.

@rjmccall This might've changed a bit since you last accepted the revision. 
Will wait a couple of days before submitting if you have any more comments on 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83812

Files:
  clang/lib/CodeGen/CGVTables.cpp
  
clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inline-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/no-stub-when-dso-local.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp

Index: clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
@@ -6,8 +6,6 @@
 // CHECK: %class.B = type { %class.A }
 // CHECK: %"class.std::type_info" = type { i32 (...)**, i8* }
 
-// CHECK: $_ZN1A3fooEv.stub = comdat any
-// CHECK: $_ZN1B3fooEv.stub = comdat any
 // CHECK: $_ZTI1A.rtti_proxy = comdat any
 // CHECK: $_ZTI1B.rtti_proxy = comdat any
 
Index: clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// If the linkage of the class is internal, then the stubs and proxies should
-// also be internally linked.
-
-// RUN: %clang_cc1 %s -triple=x86_64-unknown-fuchsia -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
-
-// External linkage.
-// CHECK: @_ZTI8External.rtti_proxy = hidden unnamed_addr constant { i8*, i8* }* @_ZTI8External, comdat
-
-class External {
-public:
-  virtual void func();
-};
-
-void External::func() {}
-
-// Internal linkage.
-// CHECK: @_ZTIN12_GLOBAL__N_18InternalE.rtti_proxy = internal unnamed_addr constant { i8*, i8* }* @_ZTIN12_GLOBAL__N_18InternalE
-namespace {
-
-class Internal {
-public:
-  virtual void func();
-};
-
-void Internal::func() {}
-
-} // namespace
-
-// This gets the same treatment as an externally available vtable.
-// CHECK: @_ZTI11LinkOnceODR.rtti_proxy = hidden unnamed_addr constant { i8*, i8* }* @_ZTI11LinkOnceODR, comdat
-class LinkOnceODR {
-public:
-  virtual void func() {} // A method defined in the class definition results in this linkage for the vtable.
-};
-
-// Force an emission of a vtable for Internal by using it here.
-void manifest_internal() {
-  Internal internal;
-  (void)internal;
-  LinkOnceODR linkonceodr;
-  (void)linkonceodr;
-}
-
-// Aliases are typically emitted after the vtable definitions but before the
-// function definitions.
-// CHECK: @_ZTV8External = unnamed_addr alias { [3 x i32] }, { [3 x i32] }* @_ZTV8External.local
-// CHECK: @_ZTV11LinkOnceODR = linkonce_odr unnamed_addr alias { [3 x i32] }, { [3 x i32] }* @_ZTV11LinkOnceODR.local
-
-// CHECK: define void @_ZN8External4funcEv
-// CHECK: define internal void @_ZN12_GLOBAL__N_18Internal4funcEv.stub
-// CHECK: define hidden void @_ZN11LinkOnceODR4funcEv.stub
Index: clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
@@ -2,35 +2,23 @@
 
 // RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O1 -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
 
-// We should be emitting comdats for each of the virtual function stubs and RTTI proxies
-// CHECK: $_ZN1A3fooEv.stub = comdat any
+// We should be emitting comdats for each of the virtu

[PATCH] D90719: [DebugInfo] Modify ctor homing as workaround for unconstructed libcxx types

2020-11-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

Thanks, looks like I'll try to see if libcxx code can be changed here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90719

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


[PATCH] D90507: Adding DWARF64 clang flag: -gdwarf64

2020-11-19 Thread Alexander Yermolovich via Phabricator via cfe-commits
ayermolo updated this revision to Diff 306477.
ayermolo marked 3 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -375,3 +375,16 @@
 // RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
 // NO_DEBUG_UNUSED_TYPES: 
"-debug-info-kind={{limited|line-tables-only|standalone}}"
 // NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
+//
+// RUN: %clang -### -gdwarf-5 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | 
FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | 
FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-3 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | 
FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-2 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | 
FileCheck -check-prefix=GDWARF64_OFF %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target x86_64-linux-gnu -target 
x86_64-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target i386-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_32ARCH %s
+//
+// GDWARF64_ON:  "-gdwarf64"
+// GDWARF64_OFF:  error: invalid argument '-gdwarf64' only allowed with 
'DWARVv3 or greater'
+// GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 
bit architecture'
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1005,6 +1005,7 @@
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
   Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
   Opts.AsmVerbose = !Args.hasArg(OPT_fno_verbose_asm);
+  Opts.Dwarf64 = Args.hasArg(OPT_gdwarf64);
   Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
   Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
   Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4015,6 +4015,22 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  if (Args.hasArg(options::OPT_gdwarf64)) {
+const Arg *A = Args.getLastArg(options::OPT_gdwarf64);
+const llvm::Triple &RawTriple = TC.getTriple();
+if (DWARFVersion < 3)
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << A->getAsString(Args) << "DWARVv3 or greater";
+else if (!RawTriple.isArch64Bit())
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << A->getAsString(Args) << "64 bit architecture";
+else if (!RawTriple.isOSBinFormatELF())
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << A->getAsString(Args) << "elf output format";
+else
+  CmdArgs.push_back("-gdwarf64");
+  }
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -563,6 +563,7 @@
   Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.MCNoWarn = CodeGenOpts.NoWarn;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
+  Options.MCOptions.Dwarf64 = CodeGenOpts.Dwarf64;
   Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
   Options.MCOptions.ABIName = TargetOpts.ABI;
   for (const auto &Entry : HSOpts.UserEntries)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2142,6 +2142,8 @@
   HelpText<"Generate source-level debug information with dwarf version 4">;
 def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group,
   HelpText<"Generate source-level debug information with dwarf version 5">;
+def gdwarf64 : Flag<["-"], "gdwarf64">, Group, Flags<[CC1Option]>,
+  HelpText<"Enables DWARF64 format for ELF binaries, if debug information 
emission is enabled.">;
 
 def gcodeview : Flag<["-"], "gcodeview">,
   HelpText<"Generate CodeView debug information">,
Index: clang/include/clang/Basic/CodeGenOptions.de

[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-11-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:237
+std::string Val = HNOption.General.lookup(Opt.first);
+if (Val.empty()) {
+  HNOption.General.insert({Opt.first, Opt.second.str()});

Usual style is to elide braces for single-line `if` statements (applies 
elsewhere in the patch as well).



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:254
+  static constexpr std::pair CStrings[] = {
+  {"char*", "sz"}, {"char", "sz"}, {"wchar_t*", "wsz"}, {"wchar_t", 
"wsz"}};
+  for (const auto &CStr : CStrings) {

One thing that confused me was the plain `char` and `wchar_t` entries -- those 
are for arrays of `char` and `wchar_t`, aren't they? Can we use `char[]` to 
make that more clear? If not, can you add a comment to clarify?



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:376-380
+  static constexpr std::pair HNCStrings[] = {
+  {"CharPrinter", "char*"},
+  {"CharArray", "char"},
+  {"WideCharPrinter", "wchar_t*"},
+  {"WideCharArray", "wchar_t"}};

Similar question here as above, but less pressing because we at least have the 
word "array" nearby.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:421-422
+  std::string OptionVal = StrMap.lookup(OptionKey);
+  for (auto &C : OptionVal)
+C = toupper(C);
+





Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:431
 static IdentifierNamingCheck::FileStyle
-getFileStyleFromOptions(const ClangTidyCheck::OptionsView &Options) {
+getFileStyleFromOptions(const ClangTidyCheck::OptionsView &Options,
+IdentifierNamingCheck::HungarianNotationOption &HNOption) {

Formatting



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:591-592
+for (const auto &Type : HNOption.PrimitiveType) {
+  std::string Key = Type.getKey().str();
+  if (ModifiedTypeName == Key) {
+PrefixStr = Type.getValue();





Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:602-603
+for (const auto &Type : HNOption.UserDefinedType) {
+  std::string Key = Type.getKey().str();
+  if (ModifiedTypeName == Key) {
+PrefixStr = Type.getValue();





Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:667
+  std::string Initial;
+  for (auto const &Word : Words) {
+Initial += tolower(Word[0]);





Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:678-680
+  if (clang::Decl::Kind::EnumConstant == ND->getKind() ||
+  clang::Decl::Kind::CXXMethod == ND->getKind() ||
+  clang::Decl::Kind::Function == ND->getKind()) {

No need to check for `CXXMethodDecl` because those inherit from `FunctionDecl` 
anyway.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:694
+  // character instead of the `getEndLoc()` function.
+  char *EOL = const_cast(strchr(Begin, '\n'));
+  if (!EOL) {

I think `EOL` should probably be `const char *` and can remove remove all these 
`const_cast<>`?



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:781
+  std::string Prefix;
+  switch (ND->getKind()) {
+  case clang::Decl::Kind::Var:

I think this `switch` should be replaced with:
```
if (const auto *ECD = dyn_cast(ND)) {
  ...
} else if (const auto *CRD = dyn_cast(ND)) {
  ...
} else if (isa(ND)) {
  ...
}
```



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:786
+  case clang::Decl::Kind::Record:
+if (ND) {
+  std::string TypeName = getDeclTypeName(ND);

Can remove all of the `if (ND)` in this method -- we already early return if 
`ND == nullptr`.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:826-827
+for (const auto &Str : Map) {
+  bool Found = (Str.getValue() == CorrectName);
+  if (Found) {
+Words.assign(Words.begin() + 1, Words.end());





Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:874
+static std::string
+fixupWithCase(const StringRef &Type, const StringRef &Name, const Decl *D,
+  const IdentifierNamingCheck::NamingStyle &Style,





Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:1038
 static std::string
-fixupWithStyle(StringRef Name,
-   const IdentifierNamingCheck::NamingStyle &Style) {
-  const std::string 

[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2020-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 306478.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Switch to -fbinutils-version=none from 'future'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fbinutils-version.c
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/X86/explicit-section-mergeable.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -81,6 +81,14 @@
  cl::value_desc("N"),
  cl::desc("Repeat compilation N times for timing"));
 
+static cl::opt BinutilsVersion(
+"binutils-version", cl::Hidden,
+cl::desc(
+"Used ELF features need to be supported by GNU ld "
+"from the specified binutils version. 'none' means that "
+"features not implemented by any known release can be used. If "
+"-no-integrated-as is specified, this also affects assembly output"));
+
 static cl::opt
 NoIntegratedAssembler("no-integrated-as", cl::Hidden,
   cl::desc("Disable integrated assembler"));
@@ -427,6 +435,8 @@
   TargetOptions Options;
   auto InitializeOptions = [&](const Triple &TheTriple) {
 Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple);
+Options.BinutilsVersion =
+TargetMachine::parseBinutilsVersion(BinutilsVersion);
 Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
Index: llvm/test/CodeGen/X86/explicit-section-mergeable.ll
===
--- llvm/test/CodeGen/X86/explicit-section-mergeable.ll
+++ llvm/test/CodeGen/X86/explicit-section-mergeable.ll
@@ -282,15 +282,19 @@
 ;; --no-integrated-as avoids the use of ",unique," for compatibility with older binutils.
 
 ;; Error if an incompatible symbol is explicitly placed into a mergeable section.
-; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as 2>&1 \
+; RUN: not llc < %s -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=NO-I-AS-ERR
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_1' from module '' required a section with entry-size=0 but was placed in section '.rodata.cst16' with entry-size=16: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_default_4' from module '' required a section with entry-size=0 but was placed in section '.debug_str' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_implicit_2' from module '' required a section with entry-size=0 but was placed in section '.rodata.str1.1' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 ; NO-I-AS-ERR: error: Symbol 'explicit_implicit_4' from module '' required a section with entry-size=0 but was placed in section '.rodata.str1.1' with entry-size=1: Explicit assignment by pragma or attribute of an incompatible symbol to this section?
 
+;; For GNU as before 2.35,
 ;; Don't create mergeable sections for globals with an explicit section name.
 ; RUN: echo '@explicit = unnamed_addr constant [2 x i16] [i16 1, i16 1], section ".explicit"' > %t.no_i_as.ll
-; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as 2>&1 \
-; RUN: | FileCheck %s --check-prefix=NO-I-AS
-; NO-I-AS: .section .explicit,"a",@progbits
+; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as -binutils-version=2.34 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NO-I-AS-OLD
+; NO-I-AS-OLD: .section .explicit,"a",@progbits
+; RUN: llc < %t.no_i_as.ll -mtriple=x86_64 --no-integrated-as -binutils-version=2.35 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NO-I-AS-NEW
+; NO-I-AS-NEW: .section .explicit,"aM",@progbits,4,unique,1
Index: llvm/lib/Target/TargetMachine.cpp
===
--- llvm/lib/Target/TargetMachine.cpp
+++ llvm/lib/Target/TargetMachine.cpp
@@ -281,3 +281,12 @@
   return TargetIRAnalysis(
   [this](const Function &F) { return this->getTargetTransformInfo(F); });
 }
+
+std::pair TargetMachine::parseBinutilsVersion(StringRef Version) {
+  if (Version == "none")
+

[PATCH] D90507: Adding DWARF64 clang flag: -gdwarf64

2020-11-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4023
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << A->getAsString(Args) << "DWARVv3 or greater";
+else if (!RawTriple.isArch64Bit())





Comment at: clang/test/Driver/debug-options.c:389
+// GDWARF64_ON:  "-gdwarf64"
+// GDWARF64_OFF:  error: invalid argument '-gdwarf64' only allowed with 
'DWARVv3 or greater'
+// GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 
bit architecture'




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

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


[PATCH] D85576: [clang][Fuchsia] Add relative-vtables multilib

2020-11-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping* any more comments on this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85576

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


[PATCH] D90507: Adding DWARF64 clang flag: -gdwarf64

2020-11-19 Thread Alexander Yermolovich via Phabricator via cfe-commits
ayermolo updated this revision to Diff 306482.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90507

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -375,3 +375,16 @@
 // RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
 // NO_DEBUG_UNUSED_TYPES: 
"-debug-info-kind={{limited|line-tables-only|standalone}}"
 // NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
+//
+// RUN: %clang -### -gdwarf-5 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | 
FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | 
FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-3 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | 
FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-2 -gdwarf64 -target x86_64-linux-gnu %s 2>&1 | 
FileCheck -check-prefix=GDWARF64_OFF %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target x86_64-linux-gnu -target 
x86_64-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -gdwarf-4 -gdwarf64 -target i386-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_32ARCH %s
+//
+// GDWARF64_ON:  "-gdwarf64"
+// GDWARF64_OFF:  error: invalid argument '-gdwarf64' only allowed with 
'DWARFv3 or greater'
+// GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 
bit architecture'
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1005,6 +1005,7 @@
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
   Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
   Opts.AsmVerbose = !Args.hasArg(OPT_fno_verbose_asm);
+  Opts.Dwarf64 = Args.hasArg(OPT_gdwarf64);
   Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
   Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
   Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4015,6 +4015,22 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  if (Args.hasArg(options::OPT_gdwarf64)) {
+const Arg *A = Args.getLastArg(options::OPT_gdwarf64);
+const llvm::Triple &RawTriple = TC.getTriple();
+if (DWARFVersion < 3)
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << A->getAsString(Args) << "DWARFv3 or greater";
+else if (!RawTriple.isArch64Bit())
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << A->getAsString(Args) << "64 bit architecture";
+else if (!RawTriple.isOSBinFormatELF())
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << A->getAsString(Args) << "elf output format";
+else
+  CmdArgs.push_back("-gdwarf64");
+  }
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -563,6 +563,7 @@
   Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.MCNoWarn = CodeGenOpts.NoWarn;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
+  Options.MCOptions.Dwarf64 = CodeGenOpts.Dwarf64;
   Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
   Options.MCOptions.ABIName = TargetOpts.ABI;
   for (const auto &Entry : HSOpts.UserEntries)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2142,6 +2142,8 @@
   HelpText<"Generate source-level debug information with dwarf version 4">;
 def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group,
   HelpText<"Generate source-level debug information with dwarf version 5">;
+def gdwarf64 : Flag<["-"], "gdwarf64">, Group, Flags<[CC1Option]>,
+  HelpText<"Enables DWARF64 format for ELF binaries, if debug information 
emission is enabled.">;
 
 def gcodeview : Flag<["-"], "gcodeview">,
   HelpText<"Generate CodeView debug information">,
Index: clang/include/clang/Basic/CodeGenOptions.def
=

[PATCH] D85576: [clang][Fuchsia] Add relative-vtables multilib

2020-11-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85576

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


[clang-tools-extra] d7747da - [clangd] Also detect corrupt stri table size.

2020-11-19 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-11-19T20:11:14+01:00
New Revision: d7747dacba8e4a7784ea8ef20abbff87d5681b81

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

LOG: [clangd] Also detect corrupt stri table size.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/unittests/SerializationTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index 5d48edf81343..bba5eaa36754 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -223,6 +223,15 @@ llvm::Expected 
readStringTable(llvm::StringRef Data) {
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
   else if (llvm::zlib::isAvailable()) {
+// Don't allocate a massive buffer if UncompressedSize was corrupted
+// This is effective for sharded index, but not big monolithic ones, as
+// once compressed size reaches 4MB nothing can be ruled out.
+// Theoretical max ratio from https://zlib.net/zlib_tech.html
+constexpr int MaxCompressionRatio = 1032;
+if (UncompressedSize / MaxCompressionRatio > R.rest().size())
+  return error("Bad stri table: uncompress {0} -> {1} bytes is 
implausible",
+   R.rest().size(), UncompressedSize);
+
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);

diff  --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 68d1d1a0df8b..c4995cd0de19 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -14,6 +14,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
@@ -383,6 +384,46 @@ TEST(SerializationTest, NoCrashOnBadArraySize) {
   EXPECT_EQ(llvm::toString(CorruptParsed.takeError()),
 "malformed or truncated include uri");
 }
+
+// Check we detect invalid string table size size without allocating it first.
+// If this detection fails, the test should allocate a huge array and crash.
+TEST(SerializationTest, NoCrashOnBadStringTableSize) {
+  if (!llvm::zlib::isAvailable()) {
+log("skipping test, no zlib");
+return;
+  }
+
+  // First, create a valid serialized file.
+  auto In = readIndexFile(YAML);
+  ASSERT_FALSE(!In) << In.takeError();
+  IndexFileOut Out(*In);
+  Out.Format = IndexFileFormat::RIFF;
+  std::string Serialized = llvm::to_string(Out);
+
+  // Low-level parse it again, we're going to replace the `stri` chunk.
+  auto Parsed = riff::readFile(Serialized);
+  ASSERT_FALSE(!Parsed) << Parsed.takeError();
+  auto Stri = llvm::find_if(Parsed->Chunks, [](riff::Chunk C) {
+return C.ID == riff::fourCC("stri");
+  });
+  ASSERT_NE(Stri, Parsed->Chunks.end());
+
+  // stri consists of an 8 byte uncompressed-size, and then compressed data.
+  // We'll claim our small amount of data expands to 4GB
+  std::string CorruptStri =
+  (llvm::fromHex("") + Stri->Data.drop_front(4)).str();
+  Stri->Data = CorruptStri;
+  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
+
+  // Try to crash rather than hang on large allocation.
+  ScopedMemoryLimit MemLimit(1000 * 1024 * 1024); // 1GB
+
+  std::string CorruptFile = llvm::to_string(*Parsed);
+  auto CorruptParsed = readIndexFile(CorruptFile);
+  ASSERT_TRUE(!CorruptParsed);
+  EXPECT_THAT(llvm::toString(CorruptParsed.takeError()),
+  testing::HasSubstr("bytes is implausible"));
+}
 #endif
 
 } // namespace



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


[PATCH] D91299: [clangd] Also detect corrupt stri table size.

2020-11-19 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7747dacba8e: [clangd] Also detect corrupt stri table size. 
(authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D91299?vs=304641&id=306484#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91299

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -14,6 +14,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
@@ -383,6 +384,46 @@
   EXPECT_EQ(llvm::toString(CorruptParsed.takeError()),
 "malformed or truncated include uri");
 }
+
+// Check we detect invalid string table size size without allocating it first.
+// If this detection fails, the test should allocate a huge array and crash.
+TEST(SerializationTest, NoCrashOnBadStringTableSize) {
+  if (!llvm::zlib::isAvailable()) {
+log("skipping test, no zlib");
+return;
+  }
+
+  // First, create a valid serialized file.
+  auto In = readIndexFile(YAML);
+  ASSERT_FALSE(!In) << In.takeError();
+  IndexFileOut Out(*In);
+  Out.Format = IndexFileFormat::RIFF;
+  std::string Serialized = llvm::to_string(Out);
+
+  // Low-level parse it again, we're going to replace the `stri` chunk.
+  auto Parsed = riff::readFile(Serialized);
+  ASSERT_FALSE(!Parsed) << Parsed.takeError();
+  auto Stri = llvm::find_if(Parsed->Chunks, [](riff::Chunk C) {
+return C.ID == riff::fourCC("stri");
+  });
+  ASSERT_NE(Stri, Parsed->Chunks.end());
+
+  // stri consists of an 8 byte uncompressed-size, and then compressed data.
+  // We'll claim our small amount of data expands to 4GB
+  std::string CorruptStri =
+  (llvm::fromHex("") + Stri->Data.drop_front(4)).str();
+  Stri->Data = CorruptStri;
+  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
+
+  // Try to crash rather than hang on large allocation.
+  ScopedMemoryLimit MemLimit(1000 * 1024 * 1024); // 1GB
+
+  std::string CorruptFile = llvm::to_string(*Parsed);
+  auto CorruptParsed = readIndexFile(CorruptFile);
+  ASSERT_TRUE(!CorruptParsed);
+  EXPECT_THAT(llvm::toString(CorruptParsed.takeError()),
+  testing::HasSubstr("bytes is implausible"));
+}
 #endif
 
 } // namespace
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -223,6 +223,15 @@
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
   else if (llvm::zlib::isAvailable()) {
+// Don't allocate a massive buffer if UncompressedSize was corrupted
+// This is effective for sharded index, but not big monolithic ones, as
+// once compressed size reaches 4MB nothing can be ruled out.
+// Theoretical max ratio from https://zlib.net/zlib_tech.html
+constexpr int MaxCompressionRatio = 1032;
+if (UncompressedSize / MaxCompressionRatio > R.rest().size())
+  return error("Bad stri table: uncompress {0} -> {1} bytes is 
implausible",
+   R.rest().size(), UncompressedSize);
+
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);


Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -14,6 +14,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
@@ -383,6 +384,46 @@
   EXPECT_EQ(llvm::toString(CorruptParsed.takeError()),
 "malformed or truncated include uri");
 }
+
+// Check we detect invalid string table size size without allocating it first.
+// If this detection fails, the test should allocate a huge array and crash.
+TEST(SerializationTest, NoCrashOnBadStringTableSize) {
+  if (!llvm::zlib::isAvailable()) {
+log("skipping test, no zlib");
+return;
+  }
+
+  // First, create a valid serialized file.
+  auto In = readIndexFile(YAML);
+  ASSERT_FALSE(!In) << In.takeError();
+  IndexFileOut Out(*In);
+  Out.Form

[clang-tools-extra] ad5a195 - [clangd] Express ASAN interactions of tests more clearly. NFC

2020-11-19 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-11-19T20:14:51+01:00
New Revision: ad5a195ae510fbfaf7885549e4899c85f0593fa5

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

LOG: [clangd] Express ASAN interactions of tests more clearly. NFC

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SerializationTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index c4995cd0de19..f866635283e5 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -305,7 +305,9 @@ TEST(SerializationTest, CmdlTest) {
   }
 }
 
-#if LLVM_ON_UNIX // rlimit is part of POSIX
+// rlimit is part of POSIX.
+// ASan uses a lot of address space, so we can't apply strict limits.
+#if LLVM_ON_UNIX && !LLVM_ADDRESS_SANITIZER_BUILD
 class ScopedMemoryLimit {
   struct rlimit OriginalLimit;
   bool Succeeded = false;
@@ -333,7 +335,6 @@ class ScopedMemoryLimit {
 };
 #endif
 
-#ifndef LLVM_ADDRESS_SANITIZER_BUILD
 // Test that our deserialization detects invalid array sizes without 
allocating.
 // If this detection fails, the test should allocate a huge array and crash.
 TEST(SerializationTest, NoCrashOnBadArraySize) {
@@ -424,7 +425,6 @@ TEST(SerializationTest, NoCrashOnBadStringTableSize) {
   EXPECT_THAT(llvm::toString(CorruptParsed.takeError()),
   testing::HasSubstr("bytes is implausible"));
 }
-#endif
 
 } // namespace
 } // namespace clangd



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


  1   2   >