[PATCH] D90457: [clang][driver] Set LTO mode based on input files

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

Is the motivation just to avoid -flto or -flto=lto at link time? I am afraid 
that the advantage probably is not large enough to justify the potentially 
costly object file parsing in the driver. Before this, as I understand it, 
object files are opaque to the driver. The driver just passes all file names to 
the linker. With this change, every object file will be opened and 
`llvm::getBitcodeFileContents` will be called on every object file.




Comment at: clang/lib/Driver/Driver.cpp:1205
 
+  setLTOModeFromInputFiles();
+

On line 1133, there is a similar setLTOMode. If we are going to add the logic, 
probably consider unifying the logic. However, I am concerned with the cost, 
see my main comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90457

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


[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-11 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added inline comments.



Comment at: clang/lib/AST/Stmt.cpp:801
+// since we don't support masm style prefix in backend.
+if (Instruction.startswith("vex "))
+  MSAsmString += '{' + Instruction.substr(0, 3).str() + '}' +

From X86AsmParser, the vex/evex prefix must be the begin of the instructions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

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


[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-11 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 updated this revision to Diff 304730.
LiuChen3 added a comment.

Rebase.
Adding the '{}' to prefix when generate IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

Files:
  clang/lib/AST/Stmt.cpp
  clang/test/CodeGen/X86/ms-inline-asm-prefix.c
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3064,7 +3064,32 @@
   }
   continue;
 }
-
+// Parse MASM style pseudo prefixes.
+if (isParsingMSInlineAsm()) {
+  bool IsPrefix = false;
+  if (Name == "vex") {
+ForcedVEXEncoding = VEXEncoding_VEX;
+IsPrefix = true;
+  } else if (Name == "vex2") {
+ForcedVEXEncoding = VEXEncoding_VEX2;
+IsPrefix = true;
+  } else if (Name == "vex3") {
+ForcedVEXEncoding = VEXEncoding_VEX3;
+IsPrefix = true;
+  } else if (Name == "evex") {
+ForcedVEXEncoding = VEXEncoding_EVEX;
+IsPrefix = true;
+  }
+  if (IsPrefix) {
+NameLoc = Parser.getTok().getLoc();
+if (getLexer().isNot(AsmToken::Identifier))
+  return Error(Parser.getTok().getLoc(), "Expected identifier");
+// FIXME: The mnemonic won't match correctly if its not in lower case.
+Name = Parser.getTok().getString();
+Parser.Lex();
+continue;
+  }
+}
 break;
   }
 
@@ -4370,10 +4395,16 @@
 
   MCInst Inst;
 
-  // If VEX3 encoding is forced, we need to pass the USE_VEX3 flag to the
-  // encoder.
-  if (ForcedVEXEncoding == VEXEncoding_VEX3)
+  // If VEX/EVEX encoding is forced, we need to pass the USE_* flag to the
+  // encoder and printer.
+  if (ForcedVEXEncoding == VEXEncoding_VEX)
+Prefixes |= X86::IP_USE_VEX;
+  else if (ForcedVEXEncoding == VEXEncoding_VEX2)
+Prefixes |= X86::IP_USE_VEX2;
+  else if (ForcedVEXEncoding == VEXEncoding_VEX3)
 Prefixes |= X86::IP_USE_VEX3;
+  else if (ForcedVEXEncoding == VEXEncoding_EVEX)
+Prefixes |= X86::IP_USE_EVEX;
 
   // Set encoded flags for {disp8} and {disp32}.
   if (ForcedDispEncoding == DispEncoding_Disp8)
Index: clang/test/CodeGen/X86/ms-inline-asm-prefix.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/ms-inline-asm-prefix.c
@@ -0,0 +1,20 @@
+// REQUIRES: x86-registered-target
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-windows-msvc -target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl -fasm-blocks -mllvm -x86-asm-syntax=intel -S -o -  | FileCheck %s -check-prefix=INTEL
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-windows-msvc -target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl -fasm-blocks -mllvm -x86-asm-syntax=att -S -o -  | FileCheck %s -check-prefix=ATT
+
+void check_inline_prefix(void) {
+  __asm {
+// INTEL: {vex} vcvtps2pd   xmm0, xmm1
+// INTEL: {vex2}vcvtps2pd   xmm0, xmm1
+// INTEL: {vex3}vcvtps2pd   xmm0, xmm1
+// INTEL: {evex}vcvtps2pd   xmm0, xmm1
+// ATT:   {vex}   vcvtps2pd   %xmm1, %xmm0
+// ATT:   {vex2}  vcvtps2pd   %xmm1, %xmm0
+// ATT:   {vex3}  vcvtps2pd   %xmm1, %xmm0
+// ATT:   {evex}  vcvtps2pd   %xmm1, %xmm0
+vex vcvtps2pd xmm0, xmm1
+vex2 vcvtps2pd xmm0, xmm1
+vex3 vcvtps2pd xmm0, xmm1
+evex vcvtps2pd xmm0, xmm1
+  }
+}
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -791,7 +791,27 @@
 /// Assemble final IR asm string (MS-style).
 std::string MSAsmStmt::generateAsmString(const ASTContext ) const {
   // FIXME: This needs to be translated into the IR string representation.
-  return std::string(AsmStr);
+  SmallVector Pieces;
+  AsmStr.split(Pieces, "\n\t");
+  std::string MSAsmString;
+  for (size_t i = 0, e = Pieces.size(); i < e; ++i) {
+StringRef Instruction = Pieces[i];
+// For vex/vex2/vex3/evex masm style prefix, convert it to att style
+// since we don't support masm style prefix in backend.
+if (Instruction.startswith("vex "))
+  MSAsmString += '{' + Instruction.substr(0, 3).str() + '}' +
+ Instruction.substr(3).str();
+else if (Instruction.startswith("vex2 ") ||
+ Instruction.startswith("vex3 ") || Instruction.startswith("evex "))
+  MSAsmString += '{' + Instruction.substr(0, 4).str() + '}' +
+ Instruction.substr(4).str();
+else
+  MSAsmString += Instruction.str();
+// If this is not the last instruction, adding back the '\n\t'.
+if (i < e - 1)
+  MSAsmString += "\n\t";
+  }
+  return MSAsmString;
 }
 
 Expr *MSAsmStmt::getOutputExpr(unsigned i) {

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

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304729.
kbobyrev added a comment.

Use early return in FieldDecl canonicalization.


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
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -588,6 +588,147 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  // Fields in classes & partial and full specialiations.
+  R"cpp(
+class Foo {
+public:
+  Foo(int Variable) : [[Variabl^e]](Variable) {}
+
+  int [[Va^riable]] = 42;
+
+private:
+  void foo() { ++[[Vari^able]]; }
+};
+
+void bar() {
+  Foo f(9000);
+  f.[[Variable^]] = -1;
+}
+  )cpp",
+  R"cpp(
+template
+struct Foo {
+  T [[Vari^able]] = 42;
+};
+
+void foo() {
+  Foo f;
+  f.[[Varia^ble]] = 9000;
+}
+  )cpp",
+  R"cpp(
+template
+struct Foo {
+  T Variable[42];
+  U Another;
+
+  void bar() {}
+};
+
+template
+struct Foo {
+  T [[Var^iable]];
+  void bar() { ++[[Var^iable]]; }
+};
+
+void foo() {
+  Foo f;
+  f.[[Var^iable]] = 9000;
+}
+  )cpp",
+  R"cpp(
+template
+struct Foo {
+  T Variable[42];
+  U Another;
+
+  void bar() {}
+};
+
+template
+struct Foo {
+  T Variable;
+  void bar() { ++Variable; }
+};
+
+template<>
+struct Foo {
+  unsigned [[Var^iable]];
+  void bar() { ++[[Var^iable]]; }
+};
+
+void foo() {
+  Foo f;
+  f.[[Var^iable]] = 9000;
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,12 +18,12 @@
 #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"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include 
 
@@ -76,6 +76,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST ,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -92,8 +94,7 @@
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 +223,89 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const NamedDecl *canonicalRenameDecl(const ClassTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const NamedDecl 

[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-11 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis marked an inline comment as done.
zinovy.nis added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:1092
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{isSet}}
+}

aaron.ballman wrote:
> There's not a whole lot of context for FileCheck to determine if it's been 
> correctly applied or not (same below) -- for instance, won't this pass even 
> if no changes are applied because FileCheck is still going to find `isSet` in 
> the file?
Thanks. Fixed.


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

https://reviews.llvm.org/D91037

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


[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-11 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 304719.
zinovy.nis added a comment.

Fixed fix-it section.


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

https://reviews.llvm.org/D91037

Files:
  clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -1073,6 +1073,34 @@
   }
 }
 
+// ExprWithCleanups doesn't crash
+int positive_expr_with_cleanups() {
+  class RetT {
+  public:
+RetT(const int _code) : code_(_code) {}
+bool Ok() const { return code_ == 0; }
+static RetT Test(bool &_isSet) { return 0; }
+
+  private:
+int code_;
+  };
+
+  bool isSet = false;
+  if (RetT::Test(isSet).Ok() && isSet) {
+if (RetT::Test(isSet).Ok() && isSet) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: if (RetT::Test(isSet).Ok() ) {
+}
+  }
+  if (isSet) {
+if ((RetT::Test(isSet).Ok() && isSet)) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: if ((RetT::Test(isSet).Ok() )) {
+}
+  }
+  return 0;
+}
+
 //===--- Special Negatives 
===//
 
 // Aliasing
Index: clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
@@ -82,7 +82,9 @@
 
   // For standalone condition variables and for "or" binary operations we 
simply
   // remove the inner `if`.
-  const auto *BinOpCond = dyn_cast(InnerIf->getCond());
+  const auto *BinOpCond =
+  dyn_cast(InnerIf->getCond()->IgnoreParenImpCasts());
+
   if (isa(InnerIf->getCond()->IgnoreParenImpCasts()) ||
   (BinOpCond && BinOpCond->getOpcode() == BO_LOr)) {
 SourceLocation IfBegin = InnerIf->getBeginLoc();
@@ -129,7 +131,8 @@
 // For "and" binary operations we remove the "and" operation with the
 // condition variable from the inner if.
   } else {
-const auto *CondOp = cast(InnerIf->getCond());
+const auto *CondOp =
+cast(InnerIf->getCond()->IgnoreParenImpCasts());
 const auto *LeftDRE =
 dyn_cast(CondOp->getLHS()->IgnoreParenImpCasts());
 if (LeftDRE && LeftDRE->getDecl() == CondVar) {


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -1073,6 +1073,34 @@
   }
 }
 
+// ExprWithCleanups doesn't crash
+int positive_expr_with_cleanups() {
+  class RetT {
+  public:
+RetT(const int _code) : code_(_code) {}
+bool Ok() const { return code_ == 0; }
+static RetT Test(bool &_isSet) { return 0; }
+
+  private:
+int code_;
+  };
+
+  bool isSet = false;
+  if (RetT::Test(isSet).Ok() && isSet) {
+if (RetT::Test(isSet).Ok() && isSet) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' [bugprone-redundant-branch-condition]
+  // CHECK-FIXES: if (RetT::Test(isSet).Ok() ) {
+}
+  }
+  if (isSet) {
+if ((RetT::Test(isSet).Ok() && isSet)) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' [bugprone-redundant-branch-condition]
+  // CHECK-FIXES: if ((RetT::Test(isSet).Ok() )) {
+}
+  }
+  return 0;
+}
+
 //===--- Special Negatives ===//
 
 // Aliasing
Index: clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
@@ -82,7 +82,9 @@
 
   // For standalone condition variables and for "or" binary operations we simply
   // remove the inner `if`.
-  const auto *BinOpCond = dyn_cast(InnerIf->getCond());
+  const auto *BinOpCond =
+  dyn_cast(InnerIf->getCond()->IgnoreParenImpCasts());
+
   if (isa(InnerIf->getCond()->IgnoreParenImpCasts()) ||
   (BinOpCond && BinOpCond->getOpcode() == BO_LOr)) {
 SourceLocation IfBegin = InnerIf->getBeginLoc();
@@ -129,7 +131,8 @@
 // For "and" binary operations we remove the "and" operation with the
 // 

[PATCH] D91243: [NFC][Coroutines] Remove unused `IsImplicit` argument in maybeTailCall

2020-11-11 Thread Chuanqi Xu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd89c4dbdd3a: [NFC][coroutines] remove unused argument  in 
SemaCoroutine (authored by ChuanqiXu).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91243

Files:
  clang/lib/Sema/SemaCoroutine.cpp


Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -375,7 +375,7 @@
 // returning await_suspend that results in a guaranteed tail call to the target
 // coroutine.
 static Expr *maybeTailCall(Sema , QualType RetType, Expr *E,
-   SourceLocation Loc, bool IsImplicit) {
+   SourceLocation Loc) {
   if (RetType->isReferenceType())
 return nullptr;
   Type const *T = RetType.getTypePtr();
@@ -421,8 +421,7 @@
 /// ExprWithCleanups to clean up the awaiter associated with the co_await
 /// expression.
 static ReadySuspendResumeResult buildCoawaitCalls(Sema , VarDecl 
*CoroPromise,
-  SourceLocation Loc, Expr *E,
-  bool IsImplicit) {
+  SourceLocation Loc, Expr *E) 
{
   OpaqueValueExpr *Operand = new (S.Context)
   OpaqueValueExpr(Loc, E->getType(), VK_LValue, E->getObjectKind(), E);
 
@@ -482,7 +481,7 @@
 
 // Experimental support for coroutine_handle returning await_suspend.
 if (Expr *TailCallSuspend =
-maybeTailCall(S, RetType, AwaitSuspend, Loc, IsImplicit))
+maybeTailCall(S, RetType, AwaitSuspend, Loc))
   // Note that we don't wrap the expression with ExprWithCleanups here
   // because that might interfere with tailcall contract (e.g. inserting
   // clean up instructions in-between tailcall and return). Instead
@@ -907,7 +906,7 @@
 
   // Build the await_ready, await_suspend, await_resume calls.
   ReadySuspendResumeResult RSS = buildCoawaitCalls(
-  *this, Coroutine->CoroutinePromise, CallLoc, E, IsImplicit);
+  *this, Coroutine->CoroutinePromise, CallLoc, E);
   if (RSS.IsInvalid)
 return ExprError();
 
@@ -962,7 +961,7 @@
 
   // Build the await_ready, await_suspend, await_resume calls.
   ReadySuspendResumeResult RSS = buildCoawaitCalls(
-  *this, Coroutine->CoroutinePromise, Loc, E, /*IsImplicit*/ false);
+  *this, Coroutine->CoroutinePromise, Loc, E);
   if (RSS.IsInvalid)
 return ExprError();
 


Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -375,7 +375,7 @@
 // returning await_suspend that results in a guaranteed tail call to the target
 // coroutine.
 static Expr *maybeTailCall(Sema , QualType RetType, Expr *E,
-   SourceLocation Loc, bool IsImplicit) {
+   SourceLocation Loc) {
   if (RetType->isReferenceType())
 return nullptr;
   Type const *T = RetType.getTypePtr();
@@ -421,8 +421,7 @@
 /// ExprWithCleanups to clean up the awaiter associated with the co_await
 /// expression.
 static ReadySuspendResumeResult buildCoawaitCalls(Sema , VarDecl *CoroPromise,
-  SourceLocation Loc, Expr *E,
-  bool IsImplicit) {
+  SourceLocation Loc, Expr *E) {
   OpaqueValueExpr *Operand = new (S.Context)
   OpaqueValueExpr(Loc, E->getType(), VK_LValue, E->getObjectKind(), E);
 
@@ -482,7 +481,7 @@
 
 // Experimental support for coroutine_handle returning await_suspend.
 if (Expr *TailCallSuspend =
-maybeTailCall(S, RetType, AwaitSuspend, Loc, IsImplicit))
+maybeTailCall(S, RetType, AwaitSuspend, Loc))
   // Note that we don't wrap the expression with ExprWithCleanups here
   // because that might interfere with tailcall contract (e.g. inserting
   // clean up instructions in-between tailcall and return). Instead
@@ -907,7 +906,7 @@
 
   // Build the await_ready, await_suspend, await_resume calls.
   ReadySuspendResumeResult RSS = buildCoawaitCalls(
-  *this, Coroutine->CoroutinePromise, CallLoc, E, IsImplicit);
+  *this, Coroutine->CoroutinePromise, CallLoc, E);
   if (RSS.IsInvalid)
 return ExprError();
 
@@ -962,7 +961,7 @@
 
   // Build the await_ready, await_suspend, await_resume calls.
   ReadySuspendResumeResult RSS = buildCoawaitCalls(
-  *this, Coroutine->CoroutinePromise, Loc, E, /*IsImplicit*/ false);
+  *this, Coroutine->CoroutinePromise, Loc, E);
   if (RSS.IsInvalid)
 return ExprError();
 
___
cfe-commits mailing list

[clang] cd89c4d - [NFC][coroutines] remove unused argument in SemaCoroutine

2020-11-11 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2020-11-12T13:22:20+08:00
New Revision: cd89c4dbdd3a32749f85cb3ac666b1e9e43e9c0e

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

LOG: [NFC][coroutines] remove unused argument  in SemaCoroutine

Test plan: check-llvm, check-clang

Reviewers: lxfind, junparser

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

Added: 


Modified: 
clang/lib/Sema/SemaCoroutine.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index ce4e55873734..76820616fb9d 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -375,7 +375,7 @@ static ExprResult buildMemberCall(Sema , Expr *Base, 
SourceLocation Loc,
 // returning await_suspend that results in a guaranteed tail call to the target
 // coroutine.
 static Expr *maybeTailCall(Sema , QualType RetType, Expr *E,
-   SourceLocation Loc, bool IsImplicit) {
+   SourceLocation Loc) {
   if (RetType->isReferenceType())
 return nullptr;
   Type const *T = RetType.getTypePtr();
@@ -421,8 +421,7 @@ static Expr *maybeTailCall(Sema , QualType RetType, Expr 
*E,
 /// ExprWithCleanups to clean up the awaiter associated with the co_await
 /// expression.
 static ReadySuspendResumeResult buildCoawaitCalls(Sema , VarDecl 
*CoroPromise,
-  SourceLocation Loc, Expr *E,
-  bool IsImplicit) {
+  SourceLocation Loc, Expr *E) 
{
   OpaqueValueExpr *Operand = new (S.Context)
   OpaqueValueExpr(Loc, E->getType(), VK_LValue, E->getObjectKind(), E);
 
@@ -482,7 +481,7 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema , 
VarDecl *CoroPromise,
 
 // Experimental support for coroutine_handle returning await_suspend.
 if (Expr *TailCallSuspend =
-maybeTailCall(S, RetType, AwaitSuspend, Loc, IsImplicit))
+maybeTailCall(S, RetType, AwaitSuspend, Loc))
   // Note that we don't wrap the expression with ExprWithCleanups here
   // because that might interfere with tailcall contract (e.g. inserting
   // clean up instructions in-between tailcall and return). Instead
@@ -907,7 +906,7 @@ ExprResult Sema::BuildResolvedCoawaitExpr(SourceLocation 
Loc, Expr *E,
 
   // Build the await_ready, await_suspend, await_resume calls.
   ReadySuspendResumeResult RSS = buildCoawaitCalls(
-  *this, Coroutine->CoroutinePromise, CallLoc, E, IsImplicit);
+  *this, Coroutine->CoroutinePromise, CallLoc, E);
   if (RSS.IsInvalid)
 return ExprError();
 
@@ -962,7 +961,7 @@ ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr 
*E) {
 
   // Build the await_ready, await_suspend, await_resume calls.
   ReadySuspendResumeResult RSS = buildCoawaitCalls(
-  *this, Coroutine->CoroutinePromise, Loc, E, /*IsImplicit*/ false);
+  *this, Coroutine->CoroutinePromise, Loc, E);
   if (RSS.IsInvalid)
 return ExprError();
 



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


[PATCH] D90275: [clang][IR] Add support for leaf attribute

2020-11-11 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1435
+  let Spellings = [GCC<"leaf">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];

aaron.ballman wrote:
> gulfem wrote:
> > aaron.ballman wrote:
> > > gulfem wrote:
> > > > aaron.ballman wrote:
> > > > > gulfem wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > gulfem wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > gulfem wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > Should this attribute also be supported on things like 
> > > > > > > > > > > ObjC method decls or other function-like interfaces?
> > > > > > > > > > Do I need to do anything else to support this attribute in 
> > > > > > > > > > Objective-C as well?
> > > > > > > > > > I think we should support it in all the C languages family.
> > > > > > > > > >I think we should support it in all the C languages family.
> > > > > > > > > 
> > > > > > > > > That's already happening automatically -- there's a C and C++ 
> > > > > > > > > spelling available for it and the attribute doesn't specify 
> > > > > > > > > that it requires a particular language mode or target.
> > > > > > > > > 
> > > > > > > > > > Do I need to do anything else to support this attribute in 
> > > > > > > > > > Objective-C as well?
> > > > > > > > > You can add multiple subjects to the list here, so you can 
> > > > > > > > > have this apply to `Function, ObjCMethod` for both of those. 
> > > > > > > > > Another one to consider is whether this attribute can be 
> > > > > > > > > written on a block declaration (like a lambda, but with 
> > > > > > > > > different syntax). Beyond that, it's mostly just 
> > > > > > > > > documentation, devising the test cases to ensure the ObjC 
> > > > > > > > > functionality behaves as expected, possibly some codegen 
> > > > > > > > > changes, etc.
> > > > > > > > AFAIK, users can specify function attributes in lambda 
> > > > > > > > expressions.
> > > > > > > > Lambda functions can only be accessed/called by the functions 
> > > > > > > > in the same translation unit, right?
> > > > > > > > Leaf attribute does not have any effect on the functions that 
> > > > > > > > are defined in the same translation unit.
> > > > > > > > For this reason, I'm thinking that leaf attribute would not 
> > > > > > > > have any effect if they are used in lambda expressions.
> > > > > > > > Do you agree with me?
> > > > > > > > AFAIK, users can specify function attributes in lambda 
> > > > > > > > expressions.
> > > > > > > 
> > > > > > > I always forget that you can do that for declaration attributes 
> > > > > > > using GNU-style syntax...
> > > > > > > 
> > > > > > > > Lambda functions can only be accessed/called by the functions 
> > > > > > > > in the same translation unit, right?
> > > > > > > 
> > > > > > > Not necessarily, you could pass one across TU boundaries like a 
> > > > > > > function pointer, for instance. e.g.,
> > > > > > > ```
> > > > > > > // TU1.cpp
> > > > > > > void foo() {
> > > > > > >   auto l = []() { ... };
> > > > > > >   bar(l);
> > > > > > > }
> > > > > > > 
> > > > > > > // TU2.cpp
> > > > > > > void bar(auto func) {
> > > > > > >   func();
> > > > > > > }
> > > > > > > ```
> > > > > > > Not necessarily, you could pass one across TU boundaries like a 
> > > > > > > function pointer, for instance. e.g.,
> > > > > > As I mentioned before, leaf attribute is specifically intended for 
> > > > > > library functions and I think all the existing usage of leaf 
> > > > > > attribute is in the library function declarations. For this reason, 
> > > > > > I think we do not need to support them for lambdas. Is that 
> > > > > > reasonable?
> > > > > > 
> > > > > > For this reason, I think we do not need to support them for 
> > > > > > lambdas. Is that reasonable?
> > > > > 
> > > > > Is this considered a library function?
> > > > > 
> > > > > ```
> > > > > struct S {
> > > > >   void f(); // Is this a library function?
> > > > >   void operator()(); // How about this?
> > > > > };
> > > > > ```
> > > > > If the answer is "no", then I think we only need to support 
> > > > > `FunctionDecl` and nothing else (not even `ObjCMethodDecl`, which is 
> > > > > like a member function for ObjC). If the answer is "yes", then it's 
> > > > > not clear to me whether lambdas should or should not be supported 
> > > > > given that the attribute on the lambda expression is attached to the 
> > > > > function call operator for the lambda declaration.
> > > > > If the answer is "no", then I think we only need to support 
> > > > > `FunctionDecl` and nothing else (not even `ObjCMethodDecl`, which is 
> > > > > like a member function for ObjC). If the answer is "yes", then it's 
> > > > > not clear to me whether lambdas should or should not be supported 
> > > > > given that the attribute on the lambda expression is attached to the 
> > > > > function call operator for the 

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

2020-11-11 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 304703.
LuoYuanke added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm/CodeGen/LiveIntervalUnion.h
  llvm/include/llvm/CodeGen/LiveRegMatrix.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/CodeGen/TileShapeInfo.h
  llvm/include/llvm/CodeGen/VirtRegMap.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/CodeGen/InlineSpiller.cpp
  llvm/lib/CodeGen/LiveIntervalUnion.cpp
  llvm/lib/CodeGen/LiveRegMatrix.cpp
  llvm/lib/CodeGen/VirtRegMap.cpp
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86PreTileConfig.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/lib/Target/X86/X86TileConfig.cpp
  llvm/test/CodeGen/X86/AMX/amx-across-func.ll
  llvm/test/CodeGen/X86/AMX/amx-config.ll
  llvm/test/CodeGen/X86/AMX/amx-spill.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/ipra-reg-usage.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll
  llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir
  llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir

Index: llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir
===
--- llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir
+++ llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir
@@ -108,7 +108,7 @@
   ; CHECK:   ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
   ; CHECK:   MOV64mr [[STACK0:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $rbx :: (store 8 into [[STACK0]])
   ; CHECK:   MOV64mr [[STACK1:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $r14 :: (store 8 into [[STACK1]])
-  ; CHECK:   STATEPOINT 0, 0, 0, @foo, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, [[STACK0]], 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on [[STACK0]]), (load store 8 on [[STACK1]])
+  ; CHECK:   STATEPOINT 0, 0, 0, @foo, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, [[STACK0]], 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on [[STACK1]]), (load store 8 on [[STACK0]])
   ; CHECK-DAG:   $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK0]])
   ; CHECK-DAG:   $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK1]])
   ; CHECK:   ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
@@ -121,7 +121,7 @@
   ; CHECK:   ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
   ; CHECK-DAG:   MOV64mr [[STACK0]], 1, $noreg, 0, $noreg, killed $rbx :: (store 8 into [[STACK0]])
   ; CHECK-DAG:   MOV64mr [[STACK1]], 1, $noreg, 0, $noreg, killed $r14 :: (store 8 into [[STACK1]])
-  ; CHECK:   STATEPOINT 0, 0, 0, @bar, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, %stack.0, 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on [[STACK0]]), (load store 8 on [[STACK1]])
+  ; CHECK:   STATEPOINT 0, 0, 0, @bar, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, %stack.0, 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on [[STACK1]]), (load store 8 on [[STACK0]])
   ; CHECK-DAG:   $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK0]])
   ; CHECK-DAG:   $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK1]])
   ; CHECK:   ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
Index: llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir
===
--- llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir
+++ llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir
@@ -91,7 +91,7 @@
   ; CHECK-DAG:   MOV64mr %stack.1, 1, $noreg, 0, $noreg, $rdi :: (store 8 into %stack.1)
   ; CHECK:   EH_LABEL 
   ; CHECK:   ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
-  ; CHECK:   STATEPOINT 0, 0, 1, @some_call, $rdi, 

[PATCH] D91317: Support: Add RedirectingFileSystem::create from simple list of redirections

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: JDevlieghere, jansvoboda11.
Herald added subscribers: llvm-commits, ributzka, hiraditya.
Herald added a project: LLVM.
dexonsmith requested review of this revision.

Add an overload of `RedirectingFileSystem::create` that builds a
redirecting filesystem off of a simple vector of string pairs. This is
intended to be used to support `clang::arcmt::FileRemapper` and
`clang::PreprocessorOptions::RemappedFiles`.


https://reviews.llvm.org/D91317

Files:
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -2287,3 +2287,89 @@
   EXPECT_FALSE(FS->exists(_b.path("b")));
   EXPECT_FALSE(FS->exists(_c.path("c")));
 }
+
+TEST(VFSFromRemappedFilesTest, Basic) {
+  IntrusiveRefCntPtr BaseFS =
+  new vfs::InMemoryFileSystem;
+  BaseFS->addFile("//root/b", 0, MemoryBuffer::getMemBuffer("contents of b"));
+  BaseFS->addFile("//root/c", 0, MemoryBuffer::getMemBuffer("contents of c"));
+
+  std::vector> RemappedFiles = {
+  {"//root/a/a", "//root/b"},
+  {"//root/a/b/c", "//root/c"},
+  };
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  RemappedFiles, /*UseExternalNames=*/false, *BaseFS);
+
+  auto StatA = RemappedFS->status("//root/a/a");
+  auto StatB = RemappedFS->status("//root/a/b/c");
+  ASSERT_TRUE(StatA);
+  ASSERT_TRUE(StatB);
+  EXPECT_EQ("//root/a/a", StatA->getName());
+  EXPECT_EQ("//root/a/b/c", StatB->getName());
+
+  auto BufferA = RemappedFS->getBufferForFile("//root/a/a");
+  auto BufferB = RemappedFS->getBufferForFile("//root/a/b/c");
+  ASSERT_TRUE(BufferA);
+  ASSERT_TRUE(BufferB);
+  EXPECT_EQ("contents of b", (*BufferA)->getBuffer());
+  EXPECT_EQ("contents of c", (*BufferB)->getBuffer());
+}
+
+TEST(VFSFromRemappedFilesTest, UseExternalNames) {
+  IntrusiveRefCntPtr BaseFS =
+  new vfs::InMemoryFileSystem;
+  BaseFS->addFile("//root/b", 0, MemoryBuffer::getMemBuffer("contents of b"));
+  BaseFS->addFile("//root/c", 0, MemoryBuffer::getMemBuffer("contents of c"));
+
+  std::vector> RemappedFiles = {
+  {"//root/a/a", "//root/b"},
+  {"//root/a/b/c", "//root/c"},
+  };
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  RemappedFiles, /*UseExternalNames=*/true, *BaseFS);
+
+  auto StatA = RemappedFS->status("//root/a/a");
+  auto StatB = RemappedFS->status("//root/a/b/c");
+  ASSERT_TRUE(StatA);
+  ASSERT_TRUE(StatB);
+  EXPECT_EQ("//root/b", StatA->getName());
+  EXPECT_EQ("//root/c", StatB->getName());
+
+  auto BufferA = RemappedFS->getBufferForFile("//root/a/a");
+  auto BufferB = RemappedFS->getBufferForFile("//root/a/b/c");
+  ASSERT_TRUE(BufferA);
+  ASSERT_TRUE(BufferB);
+  EXPECT_EQ("contents of b", (*BufferA)->getBuffer());
+  EXPECT_EQ("contents of c", (*BufferB)->getBuffer());
+}
+
+TEST(VFSFromRemappedFilesTest, LastMappingWins) {
+  IntrusiveRefCntPtr BaseFS =
+  new vfs::InMemoryFileSystem;
+  BaseFS->addFile("//root/b", 0, MemoryBuffer::getMemBuffer("contents of b"));
+  BaseFS->addFile("//root/c", 0, MemoryBuffer::getMemBuffer("contents of c"));
+
+  std::vector> RemappedFiles = {
+  {"//root/a", "//root/b"},
+  {"//root/a", "//root/c"},
+  };
+  auto RemappedFSKeepName = vfs::RedirectingFileSystem::create(
+  RemappedFiles, /*UseExternalNames=*/false, *BaseFS);
+  auto RemappedFSExternalName = vfs::RedirectingFileSystem::create(
+  RemappedFiles, /*UseExternalNames=*/true, *BaseFS);
+
+  auto StatKeepA = RemappedFSKeepName->status("//root/a");
+  auto StatExternalA = RemappedFSExternalName->status("//root/a");
+  ASSERT_TRUE(StatKeepA);
+  ASSERT_TRUE(StatExternalA);
+  EXPECT_EQ("//root/a", StatKeepA->getName());
+  EXPECT_EQ("//root/c", StatExternalA->getName());
+
+  auto BufferKeepA = RemappedFSKeepName->getBufferForFile("//root/a");
+  auto BufferExternalA = RemappedFSExternalName->getBufferForFile("//root/a");
+  ASSERT_TRUE(BufferKeepA);
+  ASSERT_TRUE(BufferExternalA);
+  EXPECT_EQ("contents of c", (*BufferKeepA)->getBuffer());
+  EXPECT_EQ("contents of c", (*BufferExternalA)->getBuffer());
+}
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1272,7 +1272,8 @@
 return true;
   }
 
-  RedirectingFileSystem::Entry *
+public:
+  static RedirectingFileSystem::Entry *
   lookupOrCreateEntry(RedirectingFileSystem *FS, StringRef Name,
   RedirectingFileSystem::Entry *ParentEntry = nullptr) {
 if (!ParentEntry) { // Look for a existent root
@@ -1314,6 +1315,7 @@
 return DE->getLastContent();
   }
 
+private:
   void uniqueOverlayTree(RedirectingFileSystem 

[clang] 2d4035e - Fix structural comparison of template template arguments to compare the

2020-11-11 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-11-11T19:15:21-08:00
New Revision: 2d4035e493e3933e8819ee090a66fd6db3cbd8ef

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

LOG: Fix structural comparison of template template arguments to compare the
right union member.

Should fix the armv8 buildbot.

Added: 


Modified: 
clang/lib/AST/TemplateBase.cpp

Removed: 




diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index 22af2545779d..dd898b2f808b 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -288,11 +288,14 @@ bool TemplateArgument::structurallyEquals(const 
TemplateArgument ) const {
   case Null:
   case Type:
   case Expression:
-  case Template:
-  case TemplateExpansion:
   case NullPtr:
 return TypeOrValue.V == Other.TypeOrValue.V;
 
+  case Template:
+  case TemplateExpansion:
+return TemplateArg.Name == Other.TemplateArg.Name &&
+   TemplateArg.NumExpansions == Other.TemplateArg.NumExpansions;
+
   case Declaration:
 return getAsDecl() == Other.getAsDecl();
 



___
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 prototype.

2020-11-11 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: llvm/lib/Target/X86/X86TileConfig.cpp:101
+  unsigned SubIdx = (BitSize == 8) ? X86::sub_8bit : X86::sub_16bit;
+  unsigned Opc = (BitSize == 8) ? X86::MOV8mr : X86::MOV16mr;
+  MachineInstr *NewMI =

LuoYuanke wrote:
> LuoYuanke wrote:
> > akashk4 wrote:
> > > I do not understand why wasn't PSTTILECFG used to store config to memory. 
> > >  I guess it will be difficult to do that because we do not know the scope 
> > > of a transaction since the TILE_RELEASE is not supported.
> > PSTTILECFG is use to store the config from tile config register to memory. 
> > Here to need to load the config from memory to tile config register, so 
> > that each tile data register is configured.
> > 
> > The LDTIELCFG has been inserted in the X86PreTileConfig pass. Since at 
> > X86PreTileConfig pass we don't know the config of the tile physical 
> > registers, the shape data in stack slot is zero. At the pass which is after 
> > RA, we know the shape of tile registers, so we just fill in the shape in 
> > the stack slot.
> > 
> > Do you mean to tile release at the end of each function which use AMX? 
> > Since we config tile registers at the beginning of each function that use 
> > AMX, it doesn't break AMX operation without tile release. But it may reduce 
> > the overhead of thread switch with tile release, if AMX operation in only 
> > used for a while in a thread. 
> I add tilerelease in function's epilog if the function define AMX registers. 
@akashk4, ping


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] D90887: ARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

ping


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

https://reviews.llvm.org/D90887

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


[clang] 2abc336 - [PowerPC] [Clang] Define macros to identify quad-fp semantics

2020-11-11 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2020-11-12T10:26:13+08:00
New Revision: 2abc33683b2b702c00c366d56c6285fda6d1e436

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

LOG: [PowerPC] [Clang] Define macros to identify quad-fp semantics

We have option -mabi=ieeelongdouble to set current long double to
IEEEquad semantics. Like what GCC does, we need to define
__LONG_DOUBLE_IEEE128__ macro in this case, and __LONG_DOUBLE_IBM128__
if using PPCDoubleDouble.

Reviewed By: steven.zhang

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

Added: 


Modified: 
clang/lib/Basic/Targets/PPC.cpp
clang/test/CodeGen/ppc64-long-double.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 13db564d360d..bafaed7c4caf 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -122,6 +122,10 @@ void PPCTargetInfo::getTargetDefines(const LangOptions 
,
   if (LongDoubleWidth == 128) {
 Builder.defineMacro("__LONG_DOUBLE_128__");
 Builder.defineMacro("__LONGDOUBLE128");
+if (Opts.PPCIEEELongDouble)
+  Builder.defineMacro("__LONG_DOUBLE_IEEE128__");
+else
+  Builder.defineMacro("__LONG_DOUBLE_IBM128__");
   }
 
   // Define this for elfv2 (64-bit only) or 64-bit darwin.

diff  --git a/clang/test/CodeGen/ppc64-long-double.cpp 
b/clang/test/CodeGen/ppc64-long-double.cpp
index a35965f2bf68..4f4929204dfa 100644
--- a/clang/test/CodeGen/ppc64-long-double.cpp
+++ b/clang/test/CodeGen/ppc64-long-double.cpp
@@ -16,6 +16,20 @@
 // RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - 
-mlong-double-128 %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
 
+// Check IBM-quad and IEEE-quad macros are defined.
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mabi=ibmlongdouble | FileCheck -check-prefix=CHECK-DEF-IBM128 %s
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mabi=ieeelongdouble | FileCheck -check-prefix=CHECK-DEF-IEEE128 %s
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mlong-double-64 | FileCheck -check-prefix=CHECK-DEF-F64 %s
+
+// CHECK-DEF-IBM128: #define __LONG_DOUBLE_128__
+// CHECK-DEF-IBM128: #define __LONG_DOUBLE_IBM128__
+// CHECK-DEF-IEEE128: #define __LONG_DOUBLE_128__
+// CHECK-DEF-IEEE128: #define __LONG_DOUBLE_IEEE128__
+// CHECK-DEF-F64-NOT: #define __LONG_DOUBLE_128__
+
 long double x = 0;
 int size = sizeof(x);
 



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


[PATCH] D90497: Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName, NFC

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

ping


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

https://reviews.llvm.org/D90497

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


[PATCH] D90208: [PowerPC] [Clang] Define macros to identify quad-fp semantics

2020-11-11 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2abc33683b2b: [PowerPC] [Clang] Define macros to identify 
quad-fp semantics (authored by qiucf).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90208

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/ppc64-long-double.cpp


Index: clang/test/CodeGen/ppc64-long-double.cpp
===
--- clang/test/CodeGen/ppc64-long-double.cpp
+++ clang/test/CodeGen/ppc64-long-double.cpp
@@ -16,6 +16,20 @@
 // RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - 
-mlong-double-128 %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
 
+// Check IBM-quad and IEEE-quad macros are defined.
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mabi=ibmlongdouble | FileCheck -check-prefix=CHECK-DEF-IBM128 %s
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mabi=ieeelongdouble | FileCheck -check-prefix=CHECK-DEF-IEEE128 %s
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mlong-double-64 | FileCheck -check-prefix=CHECK-DEF-F64 %s
+
+// CHECK-DEF-IBM128: #define __LONG_DOUBLE_128__
+// CHECK-DEF-IBM128: #define __LONG_DOUBLE_IBM128__
+// CHECK-DEF-IEEE128: #define __LONG_DOUBLE_128__
+// CHECK-DEF-IEEE128: #define __LONG_DOUBLE_IEEE128__
+// CHECK-DEF-F64-NOT: #define __LONG_DOUBLE_128__
+
 long double x = 0;
 int size = sizeof(x);
 
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -122,6 +122,10 @@
   if (LongDoubleWidth == 128) {
 Builder.defineMacro("__LONG_DOUBLE_128__");
 Builder.defineMacro("__LONGDOUBLE128");
+if (Opts.PPCIEEELongDouble)
+  Builder.defineMacro("__LONG_DOUBLE_IEEE128__");
+else
+  Builder.defineMacro("__LONG_DOUBLE_IBM128__");
   }
 
   // Define this for elfv2 (64-bit only) or 64-bit darwin.


Index: clang/test/CodeGen/ppc64-long-double.cpp
===
--- clang/test/CodeGen/ppc64-long-double.cpp
+++ clang/test/CodeGen/ppc64-long-double.cpp
@@ -16,6 +16,20 @@
 // RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
 
+// Check IBM-quad and IEEE-quad macros are defined.
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mabi=ibmlongdouble | FileCheck -check-prefix=CHECK-DEF-IBM128 %s
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mabi=ieeelongdouble | FileCheck -check-prefix=CHECK-DEF-IEEE128 %s
+// RUN: %clang -E -dM -ffreestanding -target powerpc64le-linux-gnu %s \
+// RUN:   -mlong-double-64 | FileCheck -check-prefix=CHECK-DEF-F64 %s
+
+// CHECK-DEF-IBM128: #define __LONG_DOUBLE_128__
+// CHECK-DEF-IBM128: #define __LONG_DOUBLE_IBM128__
+// CHECK-DEF-IEEE128: #define __LONG_DOUBLE_128__
+// CHECK-DEF-IEEE128: #define __LONG_DOUBLE_IEEE128__
+// CHECK-DEF-F64-NOT: #define __LONG_DOUBLE_128__
+
 long double x = 0;
 int size = sizeof(x);
 
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -122,6 +122,10 @@
   if (LongDoubleWidth == 128) {
 Builder.defineMacro("__LONG_DOUBLE_128__");
 Builder.defineMacro("__LONGDOUBLE128");
+if (Opts.PPCIEEELongDouble)
+  Builder.defineMacro("__LONG_DOUBLE_IEEE128__");
+else
+  Builder.defineMacro("__LONG_DOUBLE_IBM128__");
   }
 
   // Define this for elfv2 (64-bit only) or 64-bit darwin.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90733: Frontend: Sink named pipe logic from CompilerInstance down to FileManager

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

ping


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

https://reviews.llvm.org/D90733

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


[PATCH] D90485: Lex: Update Module::findHeader to return FileEntryRef, NFC

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

ping


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

https://reviews.llvm.org/D90485

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


[PATCH] D90484: FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

ping


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

https://reviews.llvm.org/D90484

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


[PATCH] D90053: Serialization: Change InputFile to use FileEntryRef and add getVirtualFileRef, NFC

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

ping


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

https://reviews.llvm.org/D90053

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


[PATCH] D91315: [RISCV] Handle zfh in the arch string.

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

Zfh in the arch string.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91315

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -78,3 +78,9 @@
 // CHECK-DOUBLE: __riscv_float_abi_double 1
 // CHECK-DOUBLE-NOT: __riscv_float_abi_soft
 // CHECK-DOUBLE-NOT: __riscv_float_abi_single
+
+// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions -march=rv32izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions -march=rv64izfh0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
+// CHECK-ZFH-EXT: __riscv_zfh 1
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -383,3 +383,12 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p9 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
 // RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izfh -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-ZFH-NOFLAG %s
+// RV32-EXPERIMENTAL-ZFH-NOFLAG: error: invalid arch name 'rv32izfh'
+// RV32-EXPERIMENTAL-ZFH-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izfh0p1 
-menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZFH %s
+// RV32-EXPERIMENTAL-ZFH: "-target-feature" "+experimental-zfh"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -64,6 +64,8 @@
 return RISCVExtensionVersion{"0", "92"};
   if (Ext == "v")
 return RISCVExtensionVersion{"0", "9"};
+  if (Ext == "zfh")
+return RISCVExtensionVersion{"0", "1"};
   return None;
 }
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -31,11 +31,12 @@
   bool HasD;
   bool HasC;
   bool HasB;
+  bool HasZfh;
 
 public:
   RISCVTargetInfo(const llvm::Triple , const TargetOptions &)
-  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false), HasB(false) {
+  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false), HasD(false),
+HasC(false), HasB(false), HasZfh(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = ::APFloat::IEEEquad();
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -129,6 +129,9 @@
 
   if (HasB)
 Builder.defineMacro("__riscv_bitmanip");
+
+  if (HasZfh)
+Builder.defineMacro("__riscv_zfh");
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -144,6 +147,7 @@
   .Case("d", HasD)
   .Case("c", HasC)
   .Case("experimental-b", HasB)
+  .Case("experimental-zfh", HasZfh)
   .Default(false);
 }
 
@@ -163,6 +167,8 @@
   HasC = true;
 else if (Feature == "+experimental-b")
   HasB = true;
+else if (Feature == "+experimental-zfh")
+  HasZfh = true;
   }
 
   return true;


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -78,3 +78,9 @@
 // CHECK-DOUBLE: __riscv_float_abi_double 1
 // CHECK-DOUBLE-NOT: __riscv_float_abi_soft
 // CHECK-DOUBLE-NOT: __riscv_float_abi_single
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izfh0p1 -x c -E -dM %s \
+// RUN: -o 

[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-11 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

In D90042#2368219 , @aaron.ballman 
wrote:

> In D90042#2360042 , @flx wrote:
>
>> In D90042#2357078 , @aaron.ballman 
>> wrote:
>>
>>> In D90042#2356265 , @flx wrote:
>>>
 In D90042#2356180 , 
 @aaron.ballman wrote:

> In D90042#2350035 , @flx wrote:
>
>> I should note that I was only able to reproduce the false positive with 
>> the actual implementation std::function and not our fake version here.
>
> Any reason not to lift enough of the actual definition to be able to 
> reproduce the issue in your test cases? Does the change in definitions 
> break other tests?

 I poured over the actual definition and couldn't find any difference wrt 
 the call operator that would explain it. I would also think that:

   template 
   void foo(T&& t) {
 std::forward(t).modify();
   }

 would be a simpler case that should trigger replacement, but it doesn't. 
 Do you have any idea what I could be missing?
>>>
>>> Perhaps silly question, but are you instantiating `foo()`?
>>
>> I think I added a full implementation of foo now, reverted the change, but 
>> am still not getting the negative case to fail. Can you spot an issue with 
>> the code?
>
> I can't, but to be honest, I'm not certain I understand how that false 
> positive could happen in the first place. That's why I was hoping to see the 
> original case -- one thing you could try is with the original code, pass `-E` 
> to preprocess to a file, and then try reducing the test case from that output 
> (either by hand or by using a tool like creduce), or did you already give 
> that a shot?

Thanks for the suggestion, I had never hear of creduce! After a bit of trial an 
error I seem to have found a more minimal example:

  namespace std {   
   
  template  class function;   
   
  template  class function {
   
  public:   
   
void operator()(b...);  
   
  };
   
  } // namespace std
   
  struct c {
   
c();
   
c(const c &);   
   
  };
   
  std::function f;   
   
  void d() {
   
c Orig; 
   
c Copy = Orig;  
   
f(Copy);
   
  }  

To be frank I can't spot a meaningful difference to the std::function copy we 
already have.

Here's also the test script I used for posterity:

  #!/bin/bash   
   

   
  trap 'exit 1' ERR 
   
  out=$(tempfile)   
   
  clang-tidy  --checks=-*,performance-unnecessary-copy-initialization 
--extra-arg=-std=c++17 full.cc > $out 
  grep "warning: local copy.*Copy" $out 
  

[PATCH] D86217: rename sram-ecc as sramecc in clang

2020-11-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.
Herald added a subscriber: dexonsmith.

ping


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

https://reviews.llvm.org/D86217

___
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-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added reviewers: aaron.ballman, EricWF.
Herald added a subscriber: jdoerfert.
Herald added projects: clang, libc++.
Herald added a reviewer: libc++.
rsmith requested review of this revision.

This attribute permits a typedef to be associated with a class template
specialization as a preferred way of naming that class template
specialization. This permits us to specify that (for example) the
preferred way to express 'std::basic_string' is as 'std::string'.

The attribute is applied to the various class templates in libc++ that have
corresponding well-known typedef names.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91311

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaTemplate/attributes.cpp
  libcxx/include/__config
  libcxx/include/iosfwd
  libcxx/include/string
  libcxx/include/string_view

Index: libcxx/include/string_view
===
--- libcxx/include/string_view
+++ libcxx/include/string_view
@@ -192,7 +192,26 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template >
-class _LIBCPP_TEMPLATE_VIS basic_string_view {
+class _LIBCPP_TEMPLATE_VIS basic_string_view;
+
+typedef basic_string_view string_view;
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef basic_string_view  u8string_view;
+#endif
+typedef basic_string_view u16string_view;
+typedef basic_string_view u32string_view;
+typedef basic_string_view  wstring_view;
+
+template
+class
+_LIBCPP_PREFERRED_NAME(string_view)
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+_LIBCPP_PREFERRED_NAME(u8string_view)
+#endif
+_LIBCPP_PREFERRED_NAME(u16string_view)
+_LIBCPP_PREFERRED_NAME(u32string_view)
+_LIBCPP_PREFERRED_NAME(wstring_view)
+basic_string_view {
 public:
 // types
 typedef _Traitstraits_type;
@@ -776,14 +795,6 @@
 operator<<(basic_ostream<_CharT, _Traits>& __os,
basic_string_view<_CharT, _Traits> __str);
 
-typedef basic_string_view string_view;
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
-typedef basic_string_view  u8string_view;
-#endif
-typedef basic_string_view u16string_view;
-typedef basic_string_view u32string_view;
-typedef basic_string_view  wstring_view;
-
 // [string.view.hash]
 template
 struct _LIBCPP_TEMPLATE_VIS hash > >
Index: libcxx/include/string
===
--- libcxx/include/string
+++ libcxx/include/string
@@ -665,8 +665,26 @@
 
 #endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+typedef basic_string u8string;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+typedef basic_string u16string;
+typedef basic_string u32string;
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
 template
-class _LIBCPP_TEMPLATE_VIS basic_string
+class
+_LIBCPP_TEMPLATE_VIS
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+_LIBCPP_PREFERRED_NAME(u8string)
+#endif
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+_LIBCPP_PREFERRED_NAME(u16string)
+_LIBCPP_PREFERRED_NAME(u32string)
+#endif
+basic_string
 : private __basic_string_common
 {
 public:
@@ -4301,15 +4319,6 @@
 __lhs.swap(__rhs);
 }
 
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
-typedef basic_string u8string;
-#endif
-
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-typedef basic_string u16string;
-typedef basic_string u32string;
-#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
-
 _LIBCPP_FUNC_VIS intstoi  (const string& __str, size_t* __idx = 0, int __base = 10);
 _LIBCPP_FUNC_VIS long   stol  (const string& __str, size_t* __idx = 0, int __base = 10);
 _LIBCPP_FUNC_VIS unsigned long  stoul (const string& __str, size_t* __idx = 0, int __base = 10);
Index: libcxx/include/iosfwd
===
--- libcxx/include/iosfwd
+++ libcxx/include/iosfwd
@@ -185,6 +185,38 @@
 typedef basic_ofstream  wofstream;
 typedef basic_fstream   wfstream;
 
+#ifdef _LIBCPP_PREFERRED_NAME
+template 
+class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_PREFERRED_NAME(wios) basic_ios;
+
+template 
+class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_PREFERRED_NAME(wstreambuf) basic_streambuf;
+template 
+class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_PREFERRED_NAME(wistream) basic_istream;
+template 
+class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_PREFERRED_NAME(wostream) basic_ostream;
+template 
+class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_PREFERRED_NAME(wiostream) basic_iostream;
+
+template 
+class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_PREFERRED_NAME(wstringbuf) basic_stringbuf;
+template 
+class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_PREFERRED_NAME(wistringstream) basic_istringstream;
+template 
+class _LIBCPP_PREFERRED_NAME(ostringstream) 

[PATCH] D91279: [PowerPC] DForm instructions should be preferred when using zero register

2020-11-11 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

Using dform with offset 0 can save one register r0/X0, this is benefit for 
register allocation? But adding it in `PPCPreEmitPeephole` pass which is after 
register allocation will make the benefit gone.
Maybe we need to do it before register allocation? For example at the place 
where the x-form with zero register is generated.

I checked one example `loadConstant` in  
`test/CodeGen/PowerPC/f128-passByValue.ll`.
We generate `LXVX $zero8, ` in ISEL because we meet the worst case and we don't 
have d-form choice for the instruction selection. so we have to use x-form and 
in x-form selection, we have to use zero/zero8 as the base and use load address 
as the index. See `PPCTargetLowering::SelectAddressRegRegOnly`.

I guess most cases are with same reason for generating x-form + zero register, 
we meet the worst case in ISEL, so we have to use x-form + zero register form, 
with this form, we can always select a powerpc load/store instruction.

For me, a better solution should be change the worst case handling in ISEL, it 
is before RA and it is also transparent for types like STXVX/LXVX/ and also 
LDX/STDX, LFDX/STFDX...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91279

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


[PATCH] D91310: [AMDGPU] Add -mcode-object-version=n

2020-11-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: kzhuravl.
Herald added subscribers: dang, kerbowa, t-tye, tpr, dstuttard, nhaehnle, 
jvesely.
yaxunl requested review of this revision.
Herald added a subscriber: wdng.

Add option -mcode-object-version=n to control code object version for
AMDGPU.


https://reviews.llvm.org/D91310

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/amdgpu-features-as.s
  clang/test/Driver/amdgpu-features.c
  clang/test/Driver/hip-autolink.hip
  clang/test/Driver/hip-code-object-version.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-device-only.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-opt.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip

Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -32,7 +32,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -43,7 +43,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -62,7 +62,7 @@
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -72,7 +72,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -26,7 +26,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
 
 // generate image for device side path on gfx803
-// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -35,7 +35,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
@@ -50,7 +50,7 @@
 // CHECK: [[LLD: ".*lld"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
-// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -59,7 +59,7 @@
 // CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 

[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

This make sense to me, thank you


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

https://reviews.llvm.org/D91204

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


[PATCH] D91277: [Syntax] Tablegen literal expressions.

2020-11-11 Thread Sam McCall 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 rG1630e50874a9: [Syntax] Tablegen literal expressions. 
(authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91277

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Nodes.td
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -196,10 +196,6 @@
   return Children;
 }
 
-syntax::Leaf *syntax::LiteralExpression::getLiteralToken() {
-  return cast_or_null(findChild(syntax::NodeRole::LiteralToken));
-}
-
 syntax::Expression *syntax::BinaryOperatorExpression::getLhs() {
   return cast_or_null(
   findChild(syntax::NodeRole::LeftHandSide));
Index: clang/include/clang/Tooling/Syntax/Nodes.td
===
--- clang/include/clang/Tooling/Syntax/Nodes.td
+++ clang/include/clang/Tooling/Syntax/Nodes.td
@@ -54,18 +54,112 @@
 Role<"CloseParen", Token<"r_paren">>,
   ];
 }
-def LiteralExpression : External {}
-def IntegerLiteralExpression : External {}
-def CharacterLiteralExpression : External {}
-def FloatingLiteralExpression : External {}
-def StringLiteralExpression : External {}
-def BoolLiteralExpression : External {}
-def CxxNullPtrExpression : External {}
-def UserDefinedLiteralExpression : External {}
-def IntegerUserDefinedLiteralExpression : External {}
-def FloatUserDefinedLiteralExpression : External {}
-def CharUserDefinedLiteralExpression : External {}
-def StringUserDefinedLiteralExpression : External {}
+def LiteralExpression : Alternatives {
+  let documentation = [{
+Expression for literals. C++ [lex.literal]
+  }];
+}
+def IntegerLiteralExpression : Sequence {
+  let documentation = [{
+Expression for integer literals. C++ [lex.icon]
+  }];
+  let children = [
+Role<"LiteralToken", Token<"numeric_constant">>,
+  ];
+}
+defvar AnyCharacterLiteral = AnyToken<[
+  "char_constant", "wide_char_constant", "utf8_char_constant",
+  "utf16_char_constant", "utf32_char_constant"
+]>;
+def CharacterLiteralExpression : Sequence {
+  let documentation = [{
+Expression for character literals. C++ [lex.ccon]
+  }];
+  let children = [
+Role<"LiteralToken", AnyCharacterLiteral>,
+  ];
+}
+def FloatingLiteralExpression : Sequence {
+  let documentation = [{
+Expression for floating-point literals. C++ [lex.fcon]
+  }];
+  let children = [
+Role<"LiteralToken", Token<"numeric_constant">>,
+  ];
+}
+defvar AnyStringLiteral = AnyToken<[
+  "string_literal", "wide_string_literal", "utf8_string_literal",
+  "utf16_string_literal", "utf32_string_literal"
+]>;
+def StringLiteralExpression : Sequence {
+  let documentation = [{
+Expression for string-literals. C++ [lex.string]
+  }];
+  // FIXME: string literals may consist of multiple tokens.
+  // These are merged in phase 6, but tokens are captured after phase 4.
+  // The child here should be a list of literal tokens instead.
+  let children = [
+Role<"LiteralToken", AnyStringLiteral>,
+  ];
+}
+def BoolLiteralExpression : Sequence {
+  let documentation = [{
+Expression for boolean literals. C++ [lex.bool]
+  }];
+  let children = [
+Role<"LiteralToken", AnyToken<["kw_false","kw_true"]>>,
+  ];
+}
+def CxxNullPtrExpression : Sequence {
+  let documentation = [{
+Expression for the `nullptr` literal. C++ [lex.nullptr]
+  }];
+  let children = [
+Role<"LiteralToken", Keyword<"nullptr">>,
+  ];
+}
+def UserDefinedLiteralExpression : Alternatives {
+  let documentation = [{
+Expression for user-defined literal. C++ [lex.ext]
+user-defined-literal:
+  user-defined-integer-literal
+  user-defined-floating-point-literal
+  user-defined-string-literal
+  user-defined-character-literal
+  }];
+}
+def IntegerUserDefinedLiteralExpression : Sequence {
+  let documentation = [{
+Expression for user-defined-integer-literal. C++ [lex.ext]
+  }];
+  let children = [
+Role<"LiteralToken", Keyword<"numeric_constant">>,
+  ];
+}
+def FloatUserDefinedLiteralExpression : Sequence {
+  let documentation = [{
+Expression for user-defined-floating-point-literal. C++ [lex.ext]
+  }];
+  let children = [
+Role<"LiteralToken", Keyword<"numeric_constant">>,
+  ];
+}
+def CharUserDefinedLiteralExpression : Sequence {
+  let documentation = [{
+Expression for user-defined-character-literal. C++ [lex.ext]
+  }];
+  let children = [
+Role<"LiteralToken", AnyCharacterLiteral>,
+  ];
+}
+def StringUserDefinedLiteralExpression : Sequence {
+  let documentation = [{
+Expression for user-defined-string-literal. C++ [lex.ext]
+  }];
+  let children = [
+Role<"LiteralToken", 

[clang] 1630e50 - [Syntax] Tablegen literal expressions.

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

Author: Sam McCall
Date: 2020-11-12T01:26:02+01:00
New Revision: 1630e50874a9ab6dae778bbdbb30d7dff6ade164

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

LOG: [Syntax] Tablegen literal expressions.

Non-mechanical changes:
 - Added FIXME to StringLiteral to cover multi-token string literals.
 - LiteralExpression::getLiteralToken() is gone. (It was never called)
   This is because we don't codegen methods in Alternatives
   It's conceptually suspect if we consider multi-token string literals, though.

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/include/clang/Tooling/Syntax/Nodes.td
clang/lib/Tooling/Syntax/Nodes.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index 6f3436691cc8..edb6d4d4381d 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -156,113 +156,6 @@ class CallArguments final : public List {
   std::vector> getArgumentsAndCommas();
 };
 
-/// Expression for literals. C++ [lex.literal]
-class LiteralExpression : public Expression {
-public:
-  LiteralExpression(NodeKind K) : Expression(K) {}
-  static bool classof(const Node *N);
-  Leaf *getLiteralToken();
-};
-
-/// Expression for integer literals. C++ [lex.icon]
-class IntegerLiteralExpression final : public LiteralExpression {
-public:
-  IntegerLiteralExpression()
-  : LiteralExpression(NodeKind::IntegerLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for character literals. C++ [lex.ccon]
-class CharacterLiteralExpression final : public LiteralExpression {
-public:
-  CharacterLiteralExpression()
-  : LiteralExpression(NodeKind::CharacterLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for floating-point literals. C++ [lex.fcon]
-class FloatingLiteralExpression final : public LiteralExpression {
-public:
-  FloatingLiteralExpression()
-  : LiteralExpression(NodeKind::FloatingLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for string-literals. C++ [lex.string]
-class StringLiteralExpression final : public LiteralExpression {
-public:
-  StringLiteralExpression()
-  : LiteralExpression(NodeKind::StringLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for boolean literals. C++ [lex.bool]
-class BoolLiteralExpression final : public LiteralExpression {
-public:
-  BoolLiteralExpression()
-  : LiteralExpression(NodeKind::BoolLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for the `nullptr` literal. C++ [lex.nullptr]
-class CxxNullPtrExpression final : public LiteralExpression {
-public:
-  CxxNullPtrExpression() : LiteralExpression(NodeKind::CxxNullPtrExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for user-defined literal. C++ [lex.ext]
-/// user-defined-literal:
-///   user-defined-integer-literal
-///   user-defined-floating-point-literal
-///   user-defined-string-literal
-///   user-defined-character-literal
-class UserDefinedLiteralExpression : public LiteralExpression {
-public:
-  UserDefinedLiteralExpression(NodeKind K) : LiteralExpression(K) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for user-defined-integer-literal. C++ [lex.ext]
-class IntegerUserDefinedLiteralExpression final
-: public UserDefinedLiteralExpression {
-public:
-  IntegerUserDefinedLiteralExpression()
-  : UserDefinedLiteralExpression(
-NodeKind::IntegerUserDefinedLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for user-defined-floating-point-literal. C++ [lex.ext]
-class FloatUserDefinedLiteralExpression final
-: public UserDefinedLiteralExpression {
-public:
-  FloatUserDefinedLiteralExpression()
-  : UserDefinedLiteralExpression(
-NodeKind::FloatUserDefinedLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for user-defined-character-literal. C++ [lex.ext]
-class CharUserDefinedLiteralExpression final
-: public UserDefinedLiteralExpression {
-public:
-  CharUserDefinedLiteralExpression()
-  : UserDefinedLiteralExpression(
-NodeKind::CharUserDefinedLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
-/// Expression for user-defined-string-literal. C++ [lex.ext]
-class StringUserDefinedLiteralExpression final
-: public UserDefinedLiteralExpression {
-public:
-  StringUserDefinedLiteralExpression()
-  : UserDefinedLiteralExpression(
-NodeKind::StringUserDefinedLiteralExpression) {}
-  static bool classof(const Node *N);
-};
-
 /// 

[PATCH] D91029: [clangd] Implement clang-tidy options from config

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

Thanks for working on this!

I think the scope of this patch is probably bigger than we need, at least 
initially:

- it adds a new TidyProvider system with a lot of flexibility. But our config 
needs are quite static. The only flexibility we need initially is being able to 
swap out reading .clang-tidy for a different strategy, and the ability to 
replace the whole thing with a fixed config (for `-checks`)
- the clangd::Config based check configuration probably does need depend on 
some refactoring of how ClangTidyOptions are created, but it doesn't need to 
land in the same patch
- it adds caching around the file IO, which may be nice to have but is 
complicated and unrelated and shouldn't be mixed with the refactoring

Do you want to take a shot at scoping this down? Is it useful if I sketch what 
I mean for the refactoring part?




Comment at: clang-tools-extra/clangd/ClangdServer.h:367
 
-  // When set, provides clang-tidy options for a specific file.
-  ClangTidyOptionsBuilder GetClangTidyOptions;
+  // OptionsPrivder for clang-tidy.
+  ClangdTidyProvider *ClangTidyProvider = nullptr;

new comment doesn't really say anything, revert to the old one?



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:250
   if (Preamble && Preamble->StatCache)
-VFS = Preamble->StatCache->getConsumingFS(std::move(VFS));
+VFS = Preamble->StatCache->getConsumingFS(VFS.get());
 

why this change?



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:310
 CTContext->setCurrentFile(Filename);
+dlog("ClangTidy configuration for file {0}: {1}", Filename,
+ tidy::configurationAsText(CTContext->getOptions()));

nit: move a few lines above to after the options-initialization if-stmt?



Comment at: clang-tools-extra/clangd/TidyProvider.h:20
+/// The base class of all clang-tidy config providers for clangd. The option
+/// getters take a pointer to a Filesystem that should be used for any file IO.
+class ClangdTidyProvider {

Any reason to pass in a VFS to get a ClangTidyOptionsProvider here, rather than 
having the subclass take a ThreadsafeFS in its constructor if it needs one?

This interface seems a bit strange, because not all implementations of 
ClangTidyProvider would necessarily get their config from a VFS.

(Moreover, it seems like ClangTidyProvider could just be a 
ClangTidyOptionsProvider with a threadsafety guarantee, if it weren't for the 
fact that ClangTidyContext wants to take ownership of the optionsprovider, 
which doesn't make a lot of sense - maybe we should fix that instead?)



Comment at: clang-tools-extra/clangd/TidyProvider.h:21
+/// getters take a pointer to a Filesystem that should be used for any file IO.
+class ClangdTidyProvider {
+public:

we don't usually use a "Clangd" prefix in the clangd namespace. 
(Clangd[LSP]Server being notable and very old exceptions)



Comment at: clang-tools-extra/clangd/TidyProvider.h:40
+/// A Provider that will mimic the behaviour of tidy::FileOptionsProvider but
+/// it caches options retrieved in a thread safe manner. To be completely 
thread
+/// safe it must be passed a thread safe filesystem when reading files.

how is the cache invalidated? (AFAICT currently it never is)



Comment at: clang-tools-extra/clangd/TidyProvider.h:41
+/// it caches options retrieved in a thread safe manner. To be completely 
thread
+/// safe it must be passed a thread safe filesystem when reading files.
+class FileTidyProvider : public ClangdTidyProvider {

We don't have a way to guarantee this, the vfs::FileSystems provided by 
ThreadsafeFS are arbitrary (ThreadsafeFS is an extension point) and don't have 
to be threadsafe.

If you need a filesystem that's threadsafe, that's what ThreadsafeFS is for.



Comment at: clang-tools-extra/clangd/TidyProvider.h:74
+  // time, while preventing any thread updating the cache.
+  std::shared_timed_mutex CacheGuard;
+  llvm::StringMap CachedOptions;

reader-writer locks are a nice model but very commonly perform equal or worse 
to plain mutexes in practice.
I think we should have evidence this is an improvement before using it.



Comment at: clang-tools-extra/clangd/TidyProvider.h:85
+/// removing checks known to cause issues in clang-tidy.
+class CheckAdjustingTidyProvider : public FileTidyProvider {
+public:

Using a deep inheritance hierarchy here parallel to the hierarchy of 
ClangTidyOptionsProvider is IMO too much complexity for the problem being 
solved. Most of these classes want to be functions.



Comment at: clang-tools-extra/clangd/TidyProvider.h:85
+/// removing checks known to cause issues in clang-tidy.
+class CheckAdjustingTidyProvider : public FileTidyProvider {
+public:

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

2020-11-11 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv marked 10 inline comments as done.
ilinpv added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:15653
+//   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0493r1.pdf
+// (2) low level libgcc and compiler-rt support implemented by:
+//   min/max outline atomics helpers

jyknight wrote:
> So, hold on -- AArch64 has umin/umax/smin/smax instructions, but libgcc and 
> compiler-rt don't have helpers for those? That seems to be a remarkably 
> unfortunate state of affairs.
> 
> Can you fix that, by implementing those functions in the compiler-rt patch, 
> and submitting the same to libgcc?
Yes, agree, initially I was going to add min/max helpers to both compiler-rt 
and libgcc. But the point is that gcc is not generating LSE min/max at all. So 
these helpers would be untested and become rotten. There is no reason for gcc 
community to support unused code. Hopefully after  maximum/minimum 
proposal approval I can easily add the helpers to libcc and compiler-rt and 
enable [U]Min/[U]Max RWM atomics expansion in LLVM.


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] D91279: [PowerPC] DForm instructions should be preferred when using zero register

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

Please also address the clang-format comment.




Comment at: llvm/lib/Target/PowerPC/PPCPreEmitPeephole.cpp:417
+
+  // should prefer D-form if LXVX / STXVX uses a ZERO or ZERO8
+  if (MI.getOpcode() == PPC::LXVX || MI.getOpcode() == PPC::STXVX) {

Please capitalize and end with a period for the comments. 
Is it possible to elaborate a bit more on the comments? In terms of why we were 
prefer the D-Forms, and why we should not apply the transformation if its a 
frame index. 



Comment at: llvm/test/CodeGen/PowerPC/VSX-XForm-Scalars.ll:2
 ; RUN: llc < %s -mcpu=pwr8 -mtriple=powerpc64le-unknown-unknown \
-; RUN:   -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names -verify-machineinstrs \
+; RUN:   -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names -verify-machineinstrs \ 
 ; RUN:   | FileCheck %s --check-prefix=CHECK-P8

I think this is an unrelated change. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91279

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


[PATCH] D91303: Simplify implementation of container-size-empty

2020-11-11 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: alexfh.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
steveire requested review of this revision.

Use IgnoreUnlessSpelledInSource to make the matcher code smaller and
more visibly-related to the code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91303

Files:
  clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h


Index: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h
+++ clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h
@@ -33,6 +33,9 @@
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace readability
Index: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -16,6 +16,11 @@
 using namespace clang::ast_matchers;
 
 namespace clang {
+namespace ast_matchers {
+AST_MATCHER(CXXConstructExpr, isDefaultConstruction) {
+  return Node.getConstructor()->isDefaultConstructor();
+}
+} // namespace ast_matchers
 namespace tidy {
 namespace readability {
 
@@ -48,27 +53,15 @@
   const auto ValidContainer = qualType(
   anyOf(ValidContainerNonTemplateType, ValidContainerTemplateType));
 
-  const auto WrongUse = traverse(
-  ast_type_traits::TK_AsIs,
-  anyOf(
-  hasParent(binaryOperator(isComparisonOperator(),
-   hasEitherOperand(ignoringImpCasts(
-   anyOf(integerLiteral(equals(1)),
- integerLiteral(equals(0))
-.bind("SizeBinaryOp")),
-  hasParent(implicitCastExpr(
-  hasImplicitDestinationType(booleanType()),
-  anyOf(hasParent(
-unaryOperator(hasOperatorName("!")).bind("NegOnSize")),
-anything(,
-  hasParent(explicitCastExpr(hasDestinationType(booleanType(,
-  hasParent(ifStmt()), hasParent(whileStmt()),
-  hasParent(binaryOperator(hasAnyOperatorName("&&", "||"))),
-  hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize";
+  const auto WrongUse = anyOf(
+  hasParent(ifStmt()), hasParent(whileStmt()),
+  hasParent(binaryOperator(isComparisonOperator()).bind("SizeBinaryOp")),
+  hasParent(binaryOperator(hasAnyOperatorName("&&", "||"))),
+  hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize")),
+  hasParent(explicitCastExpr(hasDestinationType(booleanType();
 
   Finder->addMatcher(
-  cxxMemberCallExpr(unless(isInTemplateInstantiation()),
-on(expr(anyOf(hasType(ValidContainer),
+  cxxMemberCallExpr(on(expr(anyOf(hasType(ValidContainer),
   hasType(pointsTo(ValidContainer)),
   hasType(references(ValidContainer
.bind("MemberCallObject")),
@@ -92,19 +85,10 @@
   .bind("SizeCallExpr"),
   this);
 
-  // Empty constructor matcher.
-  const auto DefaultConstructor = cxxConstructExpr(
-  hasDeclaration(cxxConstructorDecl(isDefaultConstructor(;
   // Comparison to empty string or empty constructor.
   const auto WrongComparend = anyOf(
-  ignoringImpCasts(stringLiteral(hasSize(0))),
-  ignoringImpCasts(cxxBindTemporaryExpr(has(DefaultConstructor))),
-  ignoringImplicit(DefaultConstructor),
-  cxxConstructExpr(hasDeclaration(cxxConstructorDecl(isCopyConstructor())),
-   has(expr(ignoringImpCasts(DefaultConstructor,
-  cxxConstructExpr(hasDeclaration(cxxConstructorDecl(isMoveConstructor())),
-   has(expr(ignoringImpCasts(DefaultConstructor,
-  cxxUnresolvedConstructExpr(argummentCountIs(0)));
+  stringLiteral(hasSize(0)), cxxConstructExpr(isDefaultConstruction()),
+  cxxUnresolvedConstructExpr(argumentCountIs(0)));
   // Match the object being compared.
   const auto STLArg =
   anyOf(unaryOperator(
@@ -114,7 +98,6 @@
 expr(hasType(ValidContainer)).bind("STLObject"));
   Finder->addMatcher(
   cxxOperatorCallExpr(
-  unless(isInTemplateInstantiation()),
   hasAnyOverloadedOperatorName("==", "!="),
   anyOf(allOf(hasArgument(0, WrongComparend), hasArgument(1, STLArg)),
 allOf(hasArgument(0, STLArg), 

[PATCH] D91302: Handle template instantiations better in clang-tidy check

2020-11-11 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: alexfh.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
steveire requested review of this revision.

readability-container-size-empty currently modifies source code based on
AST nodes in template instantiations, which means that it makes
transformations based on substituted types.  This can lead to
transforming code to be broken.

Change the matcher implementation to ignore template instantiations
explicitly, and add a matcher to explicitly handle template declatations
instead of instantiations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91302

Files:
  clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
@@ -442,3 +442,83 @@
   f();
   f();
 }
+
+template 
+void neverInstantiatedTemplate() {
+  std::vector v;
+  if (v.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}if (!v.empty()){{$}}
+
+  if (v == std::vector())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object [readability-container-size-empty]
+  // CHECK-FIXES: {{^  }}if (v.empty()){{$}}
+  // CHECK-FIXES-NEXT: ;
+  if (v.size() == 0)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}if (v.empty()){{$}}
+  if (static_cast(v.size()))
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:25: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}if (static_cast(!v.empty())){{$}}
+  if (v.size() && false)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}if (!v.empty() && false){{$}}
+  if (!v.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}if (v.empty()){{$}}
+
+  TemplatedContainer templated_container;
+  if (templated_container.size())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-MESSAGES: :44:8: note: method 'TemplatedContainer'::empty() defined here
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  if (templated_container != TemplatedContainer())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-MESSAGES: :44:8: note: method 'TemplatedContainer'::empty() defined here
+  // CHECK-FIXES: {{^  }}if (!templated_container.empty()){{$}}
+  // CHECK-FIXES-NEXT: ;
+}
+
+template 
+void instantiatedTemplateWithSizeCall() {
+  TypeRequiresSize t;
+  // The instantiation of the template with std::vector should not
+  // result in changing the template, because we don't know that
+  // TypeRequiresSize generally has `.empty()`
+  if (t.size())
+;
+
+  if (t == TypeRequiresSize{})
+;
+
+  if (t != TypeRequiresSize{})
+;
+}
+
+class TypeWithSize {
+public:
+  TypeWithSize();
+  bool operator==(const TypeWithSize ) const;
+  bool operator!=(const TypeWithSize ) const;
+
+  unsigned size() const { return 0; }
+  // Does not have `.empty()`
+};
+
+void instantiator() {
+  instantiatedTemplateWithSizeCall();
+  instantiatedTemplateWithSizeCall>();
+}
Index: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -26,18 +26,27 @@
 : ClangTidyCheck(Name, Context) {}
 
 void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
-  const auto ValidContainer = qualType(hasUnqualifiedDesugaredType(
-  recordType(hasDeclaration(cxxRecordDecl(isSameOrDerivedFrom(
-  

[clang] b6ccff3 - [NewPM] Provide method to run all pipeline callbacks, used for -O0

2020-11-11 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-11-11T15:10:27-08:00
New Revision: b6ccff3d5f3b8e26439c7471f433cb16eaf66863

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

LOG: [NewPM] Provide method to run all pipeline callbacks, used for -O0

Some targets may add required passes via
TargetMachine::registerPassBuilderCallbacks(). We need to run those even
under -O0. As an example, BPFTargetMachine adds
BPFAbstractMemberAccessPass, a required pass.

This also allows us to clean up BackendUtil.cpp (and out-of-tree Rust
usage of the NPM) by allowing us to share added passes like coroutines
and sanitizers between -O0 and other optimization levels.

Since callbacks may end up not adding passes, we need to check if the
pass managers are empty before adding them, so PassManager now has an
isEmpty() function. For example, polly adds callbacks but doesn't always
add passes in those callbacks, so this is necessary to keep
-debug-pass-manager tests' output from changing depending on if polly is
enabled or not.

Tests are a continuation of those added in
https://reviews.llvm.org/D89083.

Reviewed By: asbirlea, Meinersbur

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

Added: 
clang/test/CodeGen/bpf-O0.c
llvm/test/Other/new-pm-O0-ep-callbacks.ll

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/test/CodeGen/BPF/optnone-2.ll
llvm/test/Feature/optnone-opt.ll
llvm/test/Other/new-pass-manager.ll

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index a5ca113b9e77..87abce4bbeec 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1020,6 +1020,9 @@ static PassBuilder::OptimizationLevel mapToLevel(const 
CodeGenOptions ) {
   default:
 llvm_unreachable("Invalid optimization level!");
 
+  case 0:
+return PassBuilder::OptimizationLevel::O0;
+
   case 1:
 return PassBuilder::OptimizationLevel::O1;
 
@@ -1249,6 +1252,10 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   ModulePassManager MPM(CodeGenOpts.DebugPassManager);
 
   if (!CodeGenOpts.DisableLLVMPasses) {
+// Map our optimization levels into one of the distinct levels used to
+// configure the pipeline.
+PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
+
 bool IsThinLTO = CodeGenOpts.PrepareForThinLTO;
 bool IsLTO = CodeGenOpts.PrepareForLTO;
 
@@ -1297,10 +1304,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 MPM.addPass(NameAnonGlobalPass());
   }
 } else {
-  // Map our optimization levels into one of the distinct levels used to
-  // configure the pipeline.
-  PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
-
   // If we reached here with a non-empty index file name, then the index
   // file was empty and we are not performing ThinLTO backend compilation
   // (used in testing in a distributed build environment). Drop any the 
type
@@ -1438,6 +1441,8 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  PB.runRegisteredEPCallbacks(MPM, Level, CodeGenOpts.DebugPassManager);
+
   // FIXME: the backends do not handle matrix intrinsics currently. Make
   // sure they are also lowered in O0. A lightweight version of the pass
   // should run in the backend pipeline on demand.

diff  --git a/clang/test/CodeGen/bpf-O0.c b/clang/test/CodeGen/bpf-O0.c
new file mode 100644
index ..a8957aa9b9b5
--- /dev/null
+++ b/clang/test/CodeGen/bpf-O0.c
@@ -0,0 +1,7 @@
+// RUN: %clang -O0 %s -target bpf -g -c -o /dev/null 
-fexperimental-new-pass-manager
+// REQUIRES: bpf-registered-target
+
+struct ss {
+  int a;
+};
+int foo() { return __builtin_btf_type_id(0, 0) + 
__builtin_preserve_type_info(*(struct ss *)0, 0); }

diff  --git a/llvm/include/llvm/IR/PassManager.h 
b/llvm/include/llvm/IR/PassManager.h
index 44f8900f2ebf..54e859b851de 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -570,6 +570,9 @@ class PassManager : public PassInfoMixin<
   Passes.emplace_back(std::move(P));
   }
 
+  /// Returns if the pass manager contains any passes.
+  bool isEmpty() { return Passes.empty(); }
+
   static bool isRequired() { return true; }
 
 protected:

diff  --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index 31c4782eaba3..98af21b6276d 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -594,15 +594,20 @@ class PassBuilder {
   /// Register a callback for a default optimizer pipeline extension 

[PATCH] D89158: [NewPM] Provide method to run all pipeline callbacks, used for -O0

2020-11-11 Thread Arthur Eubanks 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 rGb6ccff3d5f3b: [NewPM] Provide method to run all pipeline 
callbacks, used for -O0 (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89158

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/bpf-O0.c
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/CodeGen/BPF/optnone-2.ll
  llvm/test/Feature/optnone-opt.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-ep-callbacks.ll

Index: llvm/test/Other/new-pm-O0-ep-callbacks.ll
===
--- /dev/null
+++ llvm/test/Other/new-pm-O0-ep-callbacks.ll
@@ -0,0 +1,24 @@
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-late-loop-optimizations=no-op-loop -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-loop-optimizer-end=no-op-loop -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-scalar-optimizer-late=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-cgscc-optimizer-late=no-op-cgscc -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-vectorizer-start=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-pipeline-start=no-op-module -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-optimizer-last=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+
+; CHECK: Running pass: NoOp
+
+declare void @bar() local_unnamed_addr
+
+define void @foo(i32 %n) local_unnamed_addr {
+entry:
+  br label %loop
+loop:
+  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
+  %iv.next = add i32 %iv, 1
+  tail call void @bar()
+  %cmp = icmp eq i32 %iv, %n
+  br i1 %cmp, label %exit, label %loop
+exit:
+  ret void
+}
Index: llvm/test/Other/new-pass-manager.ll
===
--- llvm/test/Other/new-pass-manager.ll
+++ llvm/test/Other/new-pass-manager.ll
@@ -358,8 +358,12 @@
 
 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
 ; RUN: -passes='default' %s 2>&1 \
-; RUN: | FileCheck %s --check-prefix=CHECK-O0
+; RUN: | FileCheck %s --check-prefix=CHECK-O0 --check-prefix=%llvmcheckext
 ; CHECK-O0: Starting llvm::Module pass manager run
+; CHECK-EXT-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
+; CHECK-EXT-NEXT: Starting llvm::Function pass manager run.
+; CHECK-EXT-NEXT: Running pass: {{.*}}Bye
+; CHECK-EXT-NEXT: Finished llvm::Function pass manager run.
 ; CHECK-O0-NEXT: Finished llvm::Module pass manager run
 
 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
Index: llvm/test/Feature/optnone-opt.ll
===
--- llvm/test/Feature/optnone-opt.ll
+++ llvm/test/Feature/optnone-opt.ll
@@ -4,7 +4,7 @@
 ; RUN: opt -O3 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1 --check-prefix=O2O3
 ; RUN: opt -dce -gvn-hoist -loweratomic -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=MORE
 ; RUN: opt -indvars -licm -loop-deletion -loop-extract -loop-idiom -loop-instsimplify -loop-reduce -loop-reroll -loop-rotate -loop-unroll -loop-unswitch -enable-new-pm=0 -S -debug %s 2>&1 | FileCheck %s --check-prefix=LOOP
-; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=NPM-O0
+; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=%llvmcheckext-NPM-O0
 ; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=NPM-O1
 ; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3
 ; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3
@@ -40,9 +40,10 @@
 
 attributes #0 = { optnone noinline }
 
-; Nothing that runs at -O0 gets skipped.
+; Nothing that runs at -O0 gets skipped (except when the Bye extension is present).
 ; O0-NOT: Skipping pass
-; NPM-O0-NOT: Skipping pass
+; CHECK-EXT-NPM-O0: Skipping pass {{.*}}Bye
+; CHECK-NOEXT-NPM-O0-NOT: Skipping pass
 
 ; IR passes run at -O1 and higher.
 ; O1-DAG: Skipping pass 'Aggressive Dead Code Elimination'
Index: llvm/test/CodeGen/BPF/optnone-2.ll
===
--- llvm/test/CodeGen/BPF/optnone-2.ll
+++ llvm/test/CodeGen/BPF/optnone-2.ll
@@ -1,5 

[clang] e7f3e21 - Suppress printing template arguments that match default template

2020-11-11 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-11-11T15:05:51-08:00
New Revision: e7f3e2103cdb567dda4fd52f81bf4bc07179f5a8

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

LOG: Suppress printing template arguments that match default template
arguments of types by default.

This somewhat improves the worst-case printing of types like
std::string, std::vector, etc., where many irrelevant default arguments
can be included in the type as printed if we've lost the type sugar.

Added: 
clang/test/Misc/diag-template.cpp

Modified: 
clang/include/clang/AST/PrettyPrinter.h
clang/include/clang/AST/Type.h
clang/lib/AST/DeclTemplate.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/test/SemaCXX/cxx14-compat.cpp
clang/test/SemaCXX/generic-selection.cpp
clang/test/SemaTemplate/class-template-id.cpp
clang/test/SemaTemplate/class-template-spec.cpp
clang/test/SemaTemplate/instantiation-default-1.cpp

Removed: 




diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index dfd5851bb30d..50e2142e2ef0 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -55,7 +55,8 @@ struct PrintingPolicy {
 SuppressInitializers(false), ConstantArraySizeAsWritten(false),
 AnonymousTagLocations(true), SuppressStrongLifetime(false),
 SuppressLifetimeQualifiers(false),
-SuppressTemplateArgsInCXXConstructors(false), Bool(LO.Bool),
+SuppressTemplateArgsInCXXConstructors(false),
+SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
 Nullptr(LO.CPlusPlus11), Restrict(LO.C99), Alignof(LO.CPlusPlus11),
 UnderscoreAlignof(LO.C11), UseVoidForZeroParams(!LO.CPlusPlus),
 SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false),
@@ -167,6 +168,10 @@ struct PrintingPolicy {
   /// constructors.
   unsigned SuppressTemplateArgsInCXXConstructors : 1;
 
+  /// When true, attempt to suppress template arguments that match the default
+  /// argument for the parameter.
+  unsigned SuppressDefaultTemplateArgs : 1;
+
   /// Whether we can use 'bool' rather than '_Bool' (even if the language
   /// doesn't actually have 'bool', because, e.g., it is defined as a macro).
   unsigned Bool : 1;

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1442bc740620..6dedd097ff89 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -61,6 +61,7 @@ class ExtQuals;
 class QualType;
 class ConceptDecl;
 class TagDecl;
+class TemplateParameterList;
 class Type;
 
 enum {
@@ -5196,15 +5197,18 @@ class alignas(8) TemplateSpecializationType
 /// enclosing the template arguments.
 void printTemplateArgumentList(raw_ostream ,
ArrayRef Args,
-   const PrintingPolicy );
+   const PrintingPolicy ,
+   const TemplateParameterList *TPL = nullptr);
 
 void printTemplateArgumentList(raw_ostream ,
ArrayRef Args,
-   const PrintingPolicy );
+   const PrintingPolicy ,
+   const TemplateParameterList *TPL = nullptr);
 
 void printTemplateArgumentList(raw_ostream ,
const TemplateArgumentListInfo ,
-   const PrintingPolicy );
+   const PrintingPolicy ,
+   const TemplateParameterList *TPL = nullptr);
 
 /// The injected class name of a C++ class template or class
 /// template partial specialization.  Used to record that a type was

diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 9918377070c3..328ceaa63df3 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -914,10 +914,14 @@ void 
ClassTemplateSpecializationDecl::getNameForDiagnostic(
   const auto *PS = dyn_cast(this);
   if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
   PS ? PS->getTemplateArgsAsWritten() : nullptr) {
-printTemplateArgumentList(OS, ArgsAsWritten->arguments(), Policy);
+printTemplateArgumentList(
+OS, ArgsAsWritten->arguments(), Policy,
+getSpecializedTemplate()->getTemplateParameters());
   } else {
 const TemplateArgumentList  = getTemplateArgs();
-printTemplateArgumentList(OS, TemplateArgs.asArray(), Policy);
+printTemplateArgumentList(
+OS, TemplateArgs.asArray(), Policy,
+getSpecializedTemplate()->getTemplateParameters());
   }
 }
 
@@ -1261,10 +1265,14 @@ void 
VarTemplateSpecializationDecl::getNameForDiagnostic(
   const auto *PS = 

[clang] 5f12f4f - Suppress printing of inline namespace names in diagnostics by default,

2020-11-11 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-11-11T15:05:51-08:00
New Revision: 5f12f4ff9078455cad9d4806da01f570553a5bf9

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

LOG: Suppress printing of inline namespace names in diagnostics by default,
except where they are necessary to disambiguate the target.

This substantially improves diagnostics from the standard library,
which are otherwise full of `::__1::` noise.

Added: 
clang/test/Misc/diag-inline-namespace.cpp

Modified: 
clang/include/clang/AST/PrettyPrinter.h
clang/lib/AST/Decl.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp

Removed: 




diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 50e2142e2ef0..e06b3b8843ce 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -52,9 +52,9 @@ struct PrintingPolicy {
   : Indentation(2), SuppressSpecifiers(false),
 SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false),
 SuppressScope(false), SuppressUnwrittenScope(false),
-SuppressInitializers(false), ConstantArraySizeAsWritten(false),
-AnonymousTagLocations(true), SuppressStrongLifetime(false),
-SuppressLifetimeQualifiers(false),
+SuppressInlineNamespace(true), SuppressInitializers(false),
+ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
+SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
 SuppressTemplateArgsInCXXConstructors(false),
 SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
 Nullptr(LO.CPlusPlus11), Restrict(LO.C99), Alignof(LO.CPlusPlus11),
@@ -118,10 +118,15 @@ struct PrintingPolicy {
   /// Suppresses printing of scope specifiers.
   unsigned SuppressScope : 1;
 
-  /// Suppress printing parts of scope specifiers that don't need
-  /// to be written, e.g., for inline or anonymous namespaces.
+  /// Suppress printing parts of scope specifiers that are never
+  /// written, e.g., for anonymous namespaces.
   unsigned SuppressUnwrittenScope : 1;
 
+  /// Suppress printing parts of scope specifiers that correspond
+  /// to inline namespaces, where the name is unambiguous with the specifier
+  /// removed.
+  unsigned SuppressInlineNamespace : 1;
+
   /// Suppress printing of variable initializers.
   ///
   /// This flag is used when printing the loop variable in a for-range

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 5055c6359d1c..88878466 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1600,21 +1600,35 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream 
,
   ContextsTy Contexts;
 
   // Collect named contexts.
-  while (Ctx) {
-if (isa(Ctx))
-  Contexts.push_back(Ctx);
-Ctx = Ctx->getParent();
+  DeclarationName NameInScope = getDeclName();
+  for (; Ctx; Ctx = Ctx->getParent()) {
+// Suppress anonymous namespace if requested.
+if (P.SuppressUnwrittenScope && isa(Ctx) &&
+cast(Ctx)->isAnonymousNamespace())
+  continue;
+
+// Suppress inline namespace if it doesn't make the result ambiguous.
+if (P.SuppressInlineNamespace && Ctx->isInlineNamespace() && NameInScope &&
+Ctx->lookup(NameInScope).size() ==
+Ctx->getParent()->lookup(NameInScope).size())
+  continue;
+
+// Skip non-named contexts such as linkage specifications and ExportDecls.
+const NamedDecl *ND = dyn_cast(Ctx);
+if (!ND)
+  continue;
+
+Contexts.push_back(Ctx);
+NameInScope = ND->getDeclName();
   }
 
-  for (const DeclContext *DC : llvm::reverse(Contexts)) {
+  for (unsigned I = Contexts.size(); I != 0; --I) {
+const DeclContext *DC = Contexts[I - 1];
 if (const auto *Spec = dyn_cast(DC)) {
   OS << Spec->getName();
   const TemplateArgumentList  = Spec->getTemplateArgs();
   printTemplateArgumentList(OS, TemplateArgs.asArray(), P);
 } else if (const auto *ND = dyn_cast(DC)) {
-  if (P.SuppressUnwrittenScope &&
-  (ND->isAnonymousNamespace() || ND->isInline()))
-continue;
   if (ND->isAnonymousNamespace()) {
 OS << (P.MSVCFormatting ? "`anonymous namespace\'"
 : "(anonymous namespace)");

diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 3368905007a4..721031932a4a 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -118,7 +118,8 @@ namespace {
 
 void printBefore(QualType T, raw_ostream );
 void printAfter(QualType T, raw_ostream );
-void AppendScope(DeclContext *DC, raw_ostream );
+void 

[clang-tools-extra] 686d8a0 - [clangd] Add index server request logging

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

Author: Sam McCall
Date: 2020-11-11T23:58:18+01:00
New Revision: 686d8a0911de7d9b13617c5aef66f6cebde05d5b

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

LOG: [clangd] Add index server request logging

- Add verbose logging of payloads
- Add public logging of request summaries
- fix non-logging of messages in request scopes (oops!)
- add test for public/non-public logging, extending pipeline_helper a bit.

We've accumulated quite a lot of duplication in the request handlers by now.
I should factor that out, but not in this patch...

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

Added: 
clang-tools-extra/clangd/test/remote-index/public-log.test

Modified: 
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index fac1bd98ad5f..20b140e00787 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -94,10 +94,14 @@ class RemoteIndexServer final : public 
v1::SymbolIndex::Service {
   }
 
 private:
+  using stopwatch = std::chrono::steady_clock;
+
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
-WithContextValue(CurrentRequest, Context);
+auto StartTime = stopwatch::now();
+WithContextValue WithRequestContext(CurrentRequest, Context);
+logRequest(*Request);
 trace::Span Tracer("LookupRequest");
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
@@ -116,21 +120,26 @@ class RemoteIndexServer final : public 
v1::SymbolIndex::Service {
   }
   LookupReply NextMessage;
   *NextMessage.mutable_stream_result() = *SerializedItem;
+  logResponse(NextMessage);
   Reply->Write(NextMessage);
   ++Sent;
 });
 LookupReply LastMessage;
 LastMessage.mutable_final_result()->set_has_more(true);
+logResponse(LastMessage);
 Reply->Write(LastMessage);
 SPAN_ATTACH(Tracer, "Sent", Sent);
 SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
+logRequestSummary("v1/Lookup", Sent, StartTime);
 return grpc::Status::OK;
   }
 
   grpc::Status FuzzyFind(grpc::ServerContext *Context,
  const FuzzyFindRequest *Request,
  grpc::ServerWriter *Reply) override {
-WithContextValue(CurrentRequest, Context);
+auto StartTime = stopwatch::now();
+WithContextValue WithRequestContext(CurrentRequest, Context);
+logRequest(*Request);
 trace::Span Tracer("FuzzyFindRequest");
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
@@ -150,20 +159,25 @@ class RemoteIndexServer final : public 
v1::SymbolIndex::Service {
   }
   FuzzyFindReply NextMessage;
   *NextMessage.mutable_stream_result() = *SerializedItem;
+  logResponse(NextMessage);
   Reply->Write(NextMessage);
   ++Sent;
 });
 FuzzyFindReply LastMessage;
 LastMessage.mutable_final_result()->set_has_more(HasMore);
+logResponse(LastMessage);
 Reply->Write(LastMessage);
 SPAN_ATTACH(Tracer, "Sent", Sent);
 SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
+logRequestSummary("v1/FuzzyFind", Sent, StartTime);
 return grpc::Status::OK;
   }
 
   grpc::Status Refs(grpc::ServerContext *Context, const RefsRequest *Request,
 grpc::ServerWriter *Reply) override {
-WithContextValue(CurrentRequest, Context);
+auto StartTime = stopwatch::now();
+WithContextValue WithRequestContext(CurrentRequest, Context);
+logRequest(*Request);
 trace::Span Tracer("RefsRequest");
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
@@ -182,21 +196,26 @@ class RemoteIndexServer final : public 
v1::SymbolIndex::Service {
   }
   RefsReply NextMessage;
   *NextMessage.mutable_stream_result() = *SerializedItem;
+  logResponse(NextMessage);
   Reply->Write(NextMessage);
   ++Sent;
 });
 RefsReply LastMessage;
 LastMessage.mutable_final_result()->set_has_more(HasMore);
+logResponse(LastMessage);
 Reply->Write(LastMessage);
 SPAN_ATTACH(Tracer, "Sent", Sent);
 SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
+logRequestSummary("v1/Refs", Sent, StartTime);
 return grpc::Status::OK;
   }
 
   grpc::Status Relations(grpc::ServerContext *Context,
  const RelationsRequest *Request,
  grpc::ServerWriter *Reply) override {
-WithContextValue(CurrentRequest, Context);
+   

[PATCH] D90654: [clangd] Add index server request logging

2020-11-11 Thread Sam McCall 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 rG686d8a0911de: [clangd] Add index server request logging 
(authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D90654?vs=302423=304664#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90654

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
  clang-tools-extra/clangd/test/remote-index/public-log.test

Index: clang-tools-extra/clangd/test/remote-index/public-log.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/remote-index/public-log.test
@@ -0,0 +1,26 @@
+# RUN: rm -rf %t
+# RUN: clangd-indexer %S/Inputs/Source.cpp > %t.idx
+# RUN: %python %S/pipeline_helper.py --input-file-name=%s --server-arg=--log=verbose --server-arg=-log-public --server-log=%t.public.log --project-root=%S --index-file=%t.idx > /dev/null
+# RUN: %python %S/pipeline_helper.py --input-file-name=%s --server-arg=--log=verbose --server-log=%t.log --project-root=%S --index-file=%t.idx > /dev/null
+# RUN: FileCheck --check-prefixes=LOG,LOG-PUBLIC %s < %t.public.log
+# RUN: FileCheck --check-prefixes=LOG,LOG-ALL %s < %t.log
+# REQUIRES: clangd-remote-index
+
+# LOG: Server listening on
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+# Verify that request and response bodies are included in the verbose logs,
+# but not when --log-public is on.
+# The request summary should be included in either case.
+{"jsonrpc":"2.0","id":1,"method":"workspace/symbol","params":{"query":"gFoo"}}
+# LOG-ALL: <<< FuzzyFindRequest
+# LOG-ALL: query: "gFoo"
+# LOG-ALL: >>> FuzzyFindReply
+# LOG-ALL: name: "getFoo"
+# LOG-PUBLIC-NOT: gFoo
+# LOG-PUBLIC-NOT: getFoo
+# LOG: request v1/FuzzyFind => OK: 1 results in {{.*}}ms
+---
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -28,6 +28,8 @@
   parser.add_argument('--input-file-name', required=True)
   parser.add_argument('--project-root', required=True)
   parser.add_argument('--index-file', required=True)
+  parser.add_argument('--server-arg', action='append', default=[])
+  parser.add_argument('--server-log', nargs='?', type=argparse.FileType('wb'), default=os.devnull)
 
   args = parser.parse_args()
 
@@ -40,7 +42,7 @@
   index_server_process = subprocess.Popen([
   'clangd-index-server', '--server-address=' + server_address,
   args.index_file, args.project_root
-  ],
+  ] + args.server_arg,
   stderr=subprocess.PIPE)
 
   # This will kill index_server_process if it hangs without printing init
@@ -53,7 +55,10 @@
   # Wait for the server to warm-up.
   found_init_message = False
   while index_server_process.poll() is None:
-if b'Server listening' in index_server_process.stderr.readline():
+line = index_server_process.stderr.readline()
+args.server_log.write(line)
+args.server_log.flush()
+if b'Server listening' in line:
   print('Server initialization complete.', file=sys.stderr)
   found_init_message = True
   break
@@ -70,12 +75,14 @@
   '--project-root=' + args.project_root, '--lit-test', '--sync'
   ],
 stdin=in_file)
-
   clangd_process.wait()
   print(
   'Clangd executed successfully, shutting down child processes.',
   file=sys.stderr)
   index_server_process.kill()
+  for line in index_server_process.stderr:
+args.server_log.write(line)
+args.server_log.flush()
 
 
 if __name__ == '__main__':
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -94,10 +94,14 @@
   }
 
 private:
+  using stopwatch = std::chrono::steady_clock;
+
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
-WithContextValue(CurrentRequest, Context);
+auto StartTime = stopwatch::now();
+WithContextValue WithRequestContext(CurrentRequest, Context);
+logRequest(*Request);
 trace::Span Tracer("LookupRequest");
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
@@ -116,21 +120,26 @@
   }
   LookupReply NextMessage;
   

[PATCH] D90654: [clangd] Add index server request logging

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 5 inline comments as done.
sammccall added a comment.

Oops, took a while to get back to this.
Planning to land this with some style unaddressed (%/S, --input-file) but 
please do LMK if they're important and I'll fix.




Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:31
+  parser.add_argument('--server-arg', action='append')
+  parser.add_argument('--server-log', nargs='?', type=argparse.FileType('wb'), 
default=os.devnull)
 

kbobyrev wrote:
> Why do we need `wb` here instead of `w`? I know that `subprocess.Popen` 
> writes binary data but since we're writing actual text to file maybe we could 
> convert to non-binary?
we're just redirecting data from one stream to another, I don't think there's 
any reason to do character decoding+encoding on the way...



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:81
 if __name__ == '__main__':
   main()

kbobyrev wrote:
> this was `pipeline_helper.py` intended for `pipeline.test`, maybe we'll use 
> it more so makes sense to rename it to just `helper.py` or somethting.
Agree - can do that as a followup.



Comment at: clang-tools-extra/clangd/test/remote-index/public-log.test:2
+# RUN: rm -rf %t
+# RUN: clangd-indexer %S/Inputs/Source.cpp > %t.idx
+# RUN: %python %S/pipeline_helper.py --input-file-name=%s 
--server-arg=--log=verbose --server-arg=-log-public --server-log=%t.public.log 
--project-root=%S --index-file=%t.idx > /dev/null

kadircet wrote:
> nit: use `%/S` to not mix forward and backslashes.
Why do we want to avoid mixing them?
(This is copied from the other test which uses %S)



Comment at: clang-tools-extra/clangd/test/remote-index/public-log.test:3
+# RUN: clangd-indexer %S/Inputs/Source.cpp > %t.idx
+# RUN: %python %S/pipeline_helper.py --input-file-name=%s 
--server-arg=--log=verbose --server-arg=-log-public --server-log=%t.public.log 
--project-root=%S --index-file=%t.idx > /dev/null
+# RUN: %python %S/pipeline_helper.py --input-file-name=%s 
--server-arg=--log=verbose --server-log=%t.log --project-root=%S 
--index-file=%t.idx > /dev/null

kadircet wrote:
> not sure if it is any easier, but it might make sense to just pass anything 
> after `--` to server, rather than explicitly mentioning `--server-arg` before 
> each one. I suppose we can also rename the script to `server_request_helper` ?
> 
> This won't work if we decide to pass arbitrary client flags too though.
Yeah, there aren't a lot of these so i'd like it to be super-explicit for now. 
Happy to change this if we end up with lots of tests passing various server 
args (and few client args)



Comment at: clang-tools-extra/clangd/test/remote-index/public-log.test:5
+# RUN: %python %S/pipeline_helper.py --input-file-name=%s 
--server-arg=--log=verbose --server-log=%t.log --project-root=%S 
--index-file=%t.idx > /dev/null
+# RUN: FileCheck --check-prefixes=LOG,LOG-PUBLIC %s < %t.public.log
+# RUN: FileCheck --check-prefixes=LOG,LOG-ALL %s < %t.log

ArcsinX wrote:
> Maybe we can use `--input-file` option of FileCheck instead of `<` (the same 
> for the next line)
Why would this be preferred? (`<` is roughly 5x more common in llvm/test and 
clang/test - neither is used significantly in clang-tools-extra)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90654

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


[PATCH] D91200: [PowerPC] Prevent the use of MMA with P9 and earlier

2020-11-11 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil updated this revision to Diff 304662.
bsaleil added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91200

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Driver/ppc-mma-support-check.c
  clang/test/Preprocessor/init-ppc64.c


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -648,7 +648,7 @@
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
 //
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power9 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s
 // PPC-MMA:#define __MMA__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +float128 -target-cpu power9 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-FLOAT128 %s
Index: clang/test/Driver/ppc-mma-support-check.c
===
--- /dev/null
+++ clang/test/Driver/ppc-mma-support-check.c
@@ -0,0 +1,22 @@
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=power10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr9 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr8 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr7 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+
+#ifdef __MMA__
+static_assert(false, "MMA enabled");
+#endif
+
+// HASMMA: MMA enabled
+// HASMMA-NOT: option '-mmma' cannot be specified with
+// NOMMA: option '-mmma' cannot be specified with
+
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -343,6 +343,13 @@
 return false;
   }
 
+  if (!(ArchDefs & ArchDefinePwr10) &&
+  llvm::find(FeaturesVec, "+mma") != FeaturesVec.end()) {
+// We have MMA on PPC but not power 10 and above.
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mmma" << CPU;
+return false;
+  }
+
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -648,7 +648,7 @@
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
 //
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +mma -target-cpu power9 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-MMA %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-MMA %s
 // PPC-MMA:#define __MMA__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +float128 -target-cpu power9 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-FLOAT128 %s
Index: clang/test/Driver/ppc-mma-support-check.c
===
--- /dev/null
+++ clang/test/Driver/ppc-mma-support-check.c
@@ -0,0 +1,22 @@
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=power10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr9 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr8 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr7 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+
+#ifdef __MMA__

[PATCH] D89158: [NewPM] Provide method to run all pipeline callbacks, used for -O0

2020-11-11 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur accepted this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

In D89158#2389520 , @aeubanks wrote:

> Thanks, I wasn't aware of this. Looks like other `opt -passes='default'` 
> tests also look at if it present or not.

I'd prefer a solution that is agnostic to which pass plugins are compiled 
statically; however, this is also how Bye pass tests itself whether it us added 
to the pass pipeline too.

> The following already fail with `-DLLVM_BYE_LINK_INTO_TOOLS=ON`
>
>   LLVM :: Other/opt-O0-pipeline.ll
>   LLVM :: Other/opt-O2-pipeline.ll
>   LLVM :: Other/opt-O3-pipeline-enable-matrix.ll
>   LLVM :: Other/opt-O3-pipeline.ll
>   LLVM :: Other/opt-Os-pipeline.ll
>
> these are all legacy PM related.

Probably a consequence of not being enabled by default. Tests do not get 
updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89158

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


[PATCH] D89158: [NewPM] Provide method to run all pipeline callbacks, used for -O0

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

forgot to amend commit with test updates


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89158

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/bpf-O0.c
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/CodeGen/BPF/optnone-2.ll
  llvm/test/Feature/optnone-opt.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-ep-callbacks.ll

Index: llvm/test/Other/new-pm-O0-ep-callbacks.ll
===
--- /dev/null
+++ llvm/test/Other/new-pm-O0-ep-callbacks.ll
@@ -0,0 +1,24 @@
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-late-loop-optimizations=no-op-loop -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-loop-optimizer-end=no-op-loop -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-scalar-optimizer-late=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-cgscc-optimizer-late=no-op-cgscc -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-vectorizer-start=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-pipeline-start=no-op-module -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-optimizer-last=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+
+; CHECK: Running pass: NoOp
+
+declare void @bar() local_unnamed_addr
+
+define void @foo(i32 %n) local_unnamed_addr {
+entry:
+  br label %loop
+loop:
+  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
+  %iv.next = add i32 %iv, 1
+  tail call void @bar()
+  %cmp = icmp eq i32 %iv, %n
+  br i1 %cmp, label %exit, label %loop
+exit:
+  ret void
+}
Index: llvm/test/Other/new-pass-manager.ll
===
--- llvm/test/Other/new-pass-manager.ll
+++ llvm/test/Other/new-pass-manager.ll
@@ -358,8 +358,12 @@
 
 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
 ; RUN: -passes='default' %s 2>&1 \
-; RUN: | FileCheck %s --check-prefix=CHECK-O0
+; RUN: | FileCheck %s --check-prefix=CHECK-O0 --check-prefix=%llvmcheckext
 ; CHECK-O0: Starting llvm::Module pass manager run
+; CHECK-EXT-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
+; CHECK-EXT-NEXT: Starting llvm::Function pass manager run.
+; CHECK-EXT-NEXT: Running pass: {{.*}}Bye
+; CHECK-EXT-NEXT: Finished llvm::Function pass manager run.
 ; CHECK-O0-NEXT: Finished llvm::Module pass manager run
 
 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
Index: llvm/test/Feature/optnone-opt.ll
===
--- llvm/test/Feature/optnone-opt.ll
+++ llvm/test/Feature/optnone-opt.ll
@@ -4,7 +4,7 @@
 ; RUN: opt -O3 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1 --check-prefix=O2O3
 ; RUN: opt -dce -gvn-hoist -loweratomic -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=MORE
 ; RUN: opt -indvars -licm -loop-deletion -loop-extract -loop-idiom -loop-instsimplify -loop-reduce -loop-reroll -loop-rotate -loop-unroll -loop-unswitch -enable-new-pm=0 -S -debug %s 2>&1 | FileCheck %s --check-prefix=LOOP
-; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=NPM-O0
+; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=%llvmcheckext-NPM-O0
 ; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=NPM-O1
 ; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3
 ; RUN: opt -enable-npm-optnone -passes='default' -S -debug-pass-manager %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3
@@ -40,9 +40,10 @@
 
 attributes #0 = { optnone noinline }
 
-; Nothing that runs at -O0 gets skipped.
+; Nothing that runs at -O0 gets skipped (except when the Bye extension is present).
 ; O0-NOT: Skipping pass
-; NPM-O0-NOT: Skipping pass
+; CHECK-EXT-NPM-O0: Skipping pass {{.*}}Bye
+; CHECK-NOEXT-NPM-O0-NOT: Skipping pass
 
 ; IR passes run at -O1 and higher.
 ; O1-DAG: Skipping pass 'Aggressive Dead Code Elimination'
Index: llvm/test/CodeGen/BPF/optnone-2.ll
===
--- llvm/test/CodeGen/BPF/optnone-2.ll
+++ llvm/test/CodeGen/BPF/optnone-2.ll
@@ -1,5 +1,5 @@
 ; RUN: opt < %s -passes='default' | llc -march=bpfel -filetype=asm -o /dev/null -
-; TODO: add -O0 once that's supported
+; RUN: opt 

[PATCH] D90890: Frontend: Change ComputePreambleBounds to take MemoryBufferRef, NFC

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c55c3b66dea: Frontend: Change ComputePreambleBounds to take 
MemoryBufferRef, NFC (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90890

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang/include/clang/Frontend/PrecompiledPreamble.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp

Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -303,9 +303,9 @@
 } // namespace
 
 PreambleBounds clang::ComputePreambleBounds(const LangOptions ,
-const llvm::MemoryBuffer *Buffer,
+const llvm::MemoryBufferRef ,
 unsigned MaxLines) {
-  return Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines);
+  return Lexer::ComputePreamble(Buffer.getBuffer(), LangOpts, MaxLines);
 }
 
 llvm::ErrorOr PrecompiledPreamble::Build(
@@ -621,7 +621,7 @@
 void PrecompiledPreamble::OverridePreamble(
 CompilerInvocation , IntrusiveRefCntPtr ,
 llvm::MemoryBuffer *MainFileBuffer) const {
-  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), MainFileBuffer, 0);
+  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), *MainFileBuffer, 0);
   configurePreamble(Bounds, CI, VFS, MainFileBuffer);
 }
 
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1317,9 +1317,8 @@
   if (!MainFileBuffer)
 return nullptr;
 
-  PreambleBounds Bounds =
-  ComputePreambleBounds(*PreambleInvocationIn.getLangOpts(),
-MainFileBuffer.get(), MaxLines);
+  PreambleBounds Bounds = ComputePreambleBounds(
+  *PreambleInvocationIn.getLangOpts(), *MainFileBuffer, MaxLines);
   if (!Bounds.Size)
 return nullptr;
 
Index: clang/include/clang/Frontend/PrecompiledPreamble.h
===
--- clang/include/clang/Frontend/PrecompiledPreamble.h
+++ clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -41,7 +41,7 @@
 
 /// Runs lexer to compute suggested preamble bounds.
 PreambleBounds ComputePreambleBounds(const LangOptions ,
- const llvm::MemoryBuffer *Buffer,
+ const llvm::MemoryBufferRef ,
  unsigned MaxLines);
 
 class PreambleCallbacks;
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -249,8 +249,7 @@
   // This means we're scanning (though not preprocessing) the preamble section
   // twice. However, it's important to precisely follow the preamble bounds used
   // elsewhere.
-  auto Bounds =
-  ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
+  auto Bounds = ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
   auto PreambleContents =
   llvm::MemoryBuffer::getMemBufferCopy(Contents.substr(0, Bounds.Size));
   auto Clang = prepareCompilerInstance(
@@ -322,8 +321,7 @@
   // without those.
   auto ContentsBuffer =
   llvm::MemoryBuffer::getMemBuffer(Inputs.Contents, FileName);
-  auto Bounds =
-  ComputePreambleBounds(*CI.getLangOpts(), ContentsBuffer.get(), 0);
+  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), *ContentsBuffer, 0);
 
   trace::Span Tracer("BuildPreamble");
   SPAN_ATTACH(Tracer, "File", FileName);
@@ -376,8 +374,7 @@
   const CompilerInvocation ) {
   auto ContentsBuffer =
   llvm::MemoryBuffer::getMemBuffer(Inputs.Contents, FileName);
-  auto Bounds =
-  ComputePreambleBounds(*CI.getLangOpts(), ContentsBuffer.get(), 0);
+  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), *ContentsBuffer, 0);
   auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
   return compileCommandsAreEqual(Inputs.CompileCommand,
  Preamble.CompileCommand) &&
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1104,7 +1104,7 @@
   // overriding the preamble will break sema completion. Fortunately we can just
   // skip all includes in this case; these completions are really simple.
   PreambleBounds PreambleRegion =
-  ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
+  

[clang] 4c55c3b - Frontend: Change ComputePreambleBounds to take MemoryBufferRef, NFC

2020-11-11 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-11-11T17:19:51-05:00
New Revision: 4c55c3b66dea3a1d6058392e1e96e166d318a2ff

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

LOG: Frontend: Change ComputePreambleBounds to take MemoryBufferRef, NFC

Avoid requiring an actual MemoryBuffer in ComputePreambleBounds, when
a MemoryBufferRef will do just fine.

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Preamble.cpp
clang/include/clang/Frontend/PrecompiledPreamble.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/PrecompiledPreamble.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 24678a3cc1bc..1d85439f53af 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1104,7 +1104,7 @@ bool 
semaCodeComplete(std::unique_ptr Consumer,
   // overriding the preamble will break sema completion. Fortunately we can 
just
   // skip all includes in this case; these completions are really simple.
   PreambleBounds PreambleRegion =
-  ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
+  ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
   bool CompletingInPreamble = PreambleRegion.Size > Input.Offset;
   if (Input.Patch)
 Input.Patch->apply(*CI);

diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index 8e1ad7242eb0..f4f82be81cde 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -249,8 +249,7 @@ scanPreamble(llvm::StringRef Contents, const 
tooling::CompileCommand ) {
   // This means we're scanning (though not preprocessing) the preamble section
   // twice. However, it's important to precisely follow the preamble bounds 
used
   // elsewhere.
-  auto Bounds =
-  ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
+  auto Bounds = ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
   auto PreambleContents =
   llvm::MemoryBuffer::getMemBufferCopy(Contents.substr(0, Bounds.Size));
   auto Clang = prepareCompilerInstance(
@@ -322,8 +321,7 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
   // without those.
   auto ContentsBuffer =
   llvm::MemoryBuffer::getMemBuffer(Inputs.Contents, FileName);
-  auto Bounds =
-  ComputePreambleBounds(*CI.getLangOpts(), ContentsBuffer.get(), 0);
+  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), *ContentsBuffer, 0);
 
   trace::Span Tracer("BuildPreamble");
   SPAN_ATTACH(Tracer, "File", FileName);
@@ -376,8 +374,7 @@ bool isPreambleCompatible(const PreambleData ,
   const CompilerInvocation ) {
   auto ContentsBuffer =
   llvm::MemoryBuffer::getMemBuffer(Inputs.Contents, FileName);
-  auto Bounds =
-  ComputePreambleBounds(*CI.getLangOpts(), ContentsBuffer.get(), 0);
+  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), *ContentsBuffer, 0);
   auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
   return compileCommandsAreEqual(Inputs.CompileCommand,
  Preamble.CompileCommand) &&

diff  --git a/clang/include/clang/Frontend/PrecompiledPreamble.h 
b/clang/include/clang/Frontend/PrecompiledPreamble.h
index 99faf60f1a44..cea39bfec95d 100644
--- a/clang/include/clang/Frontend/PrecompiledPreamble.h
+++ b/clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -41,7 +41,7 @@ class PCHContainerOperations;
 
 /// Runs lexer to compute suggested preamble bounds.
 PreambleBounds ComputePreambleBounds(const LangOptions ,
- const llvm::MemoryBuffer *Buffer,
+ const llvm::MemoryBufferRef ,
  unsigned MaxLines);
 
 class PreambleCallbacks;

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 0728fee49d78..e1aa3682a2b7 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1317,9 +1317,8 @@ ASTUnit::getMainBufferWithPrecompiledPreamble(
   if (!MainFileBuffer)
 return nullptr;
 
-  PreambleBounds Bounds =
-  ComputePreambleBounds(*PreambleInvocationIn.getLangOpts(),
-MainFileBuffer.get(), MaxLines);
+  PreambleBounds Bounds = ComputePreambleBounds(
+  *PreambleInvocationIn.getLangOpts(), *MainFileBuffer, MaxLines);
   if (!Bounds.Size)
 return nullptr;
 

diff  --git a/clang/lib/Frontend/PrecompiledPreamble.cpp 
b/clang/lib/Frontend/PrecompiledPreamble.cpp
index 87cd9169c78c..0f4259900ec2 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ 

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

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

(going to wait for a while for the other patch to get through the buildbots, in 
case rlimit causes trouble)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91299

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


[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added 1 blocking reviewer(s): arphaman.
dexonsmith added a comment.

This LGTM, but I'd like @arphaman to look as well in case he originally tried 
`getPhysicalFileSystem` and it caused a problem. I've switched him to a 
blocking reviewer.


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

https://reviews.llvm.org/D91204

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


[clang-tools-extra] 3c09103 - [clangd] Sanity-check array sizes read from disk before allocating them.

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

Author: Sam McCall
Date: 2020-11-11T23:16:53+01:00
New Revision: 3c09103291686630564c1ff3f78c0f8dc69d069f

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

LOG: [clangd] Sanity-check array sizes read from disk before allocating them.

Previously a corrupted index shard could cause us to resize arrays to an
arbitrary int32. This tends to be a huge number, and can render the
system unresponsive.

Instead, cap this at the amount of data that might reasonably be read
(e.g. the #bytes in the file). If the specified length is more than that,
assume the data is corrupt.

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

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 dcea8e902fe4..a817758d7a54 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -16,6 +16,7 @@
 #include "support/Trace.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
@@ -104,6 +105,20 @@ class Reader {
 llvm::StringRef Raw = consume(SymbolID::RawSize); // short if truncated.
 return LLVM_UNLIKELY(err()) ? SymbolID() : SymbolID::fromRaw(Raw);
   }
+
+  // Read a varint (as consumeVar) and resize the container accordingly.
+  // If the size is invalid, return false and mark an error.
+  // (The caller should abort in this case).
+  template  LLVM_NODISCARD bool consumeSize(T ) {
+auto Size = consumeVar();
+// Conservatively assume each element is at least one byte.
+if (Size > (End - Begin)) {
+  Err = true;
+  return false;
+}
+Container.resize(Size);
+return true;
+  }
 };
 
 void write32(uint32_t I, llvm::raw_ostream ) {
@@ -257,7 +272,8 @@ IncludeGraphNode readIncludeGraphNode(Reader ,
   IGN.URI = Data.consumeString(Strings);
   llvm::StringRef Digest = Data.consume(IGN.Digest.size());
   std::copy(Digest.bytes_begin(), Digest.bytes_end(), IGN.Digest.begin());
-  IGN.DirectIncludes.resize(Data.consumeVar());
+  if (!Data.consumeSize(IGN.DirectIncludes))
+return IGN;
   for (llvm::StringRef  : IGN.DirectIncludes)
 Include = Data.consumeString(Strings);
   return IGN;
@@ -323,7 +339,8 @@ Symbol readSymbol(Reader , 
llvm::ArrayRef Strings) {
   Sym.Documentation = Data.consumeString(Strings);
   Sym.ReturnType = Data.consumeString(Strings);
   Sym.Type = Data.consumeString(Strings);
-  Sym.IncludeHeaders.resize(Data.consumeVar());
+  if (!Data.consumeSize(Sym.IncludeHeaders))
+return Sym;
   for (auto  : Sym.IncludeHeaders) {
 I.IncludeHeader = Data.consumeString(Strings);
 I.References = Data.consumeVar();
@@ -353,7 +370,8 @@ std::pair>
 readRefs(Reader , llvm::ArrayRef Strings) {
   std::pair> Result;
   Result.first = Data.consumeID();
-  Result.second.resize(Data.consumeVar());
+  if (!Data.consumeSize(Result.second))
+return Result;
   for (auto  : Result.second) {
 Ref.Kind = static_cast(Data.consume8());
 Ref.Location = readLocation(Data, Strings);
@@ -400,7 +418,8 @@ InternedCompileCommand
 readCompileCommand(Reader CmdReader, llvm::ArrayRef Strings) {
   InternedCompileCommand Cmd;
   Cmd.Directory = CmdReader.consumeString(Strings);
-  Cmd.CommandLine.resize(CmdReader.consumeVar());
+  if (!CmdReader.consumeSize(Cmd.CommandLine))
+return Cmd;
   for (llvm::StringRef  : Cmd.CommandLine)
 C = CmdReader.consumeString(Strings);
   return Cmd;

diff  --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 1d2c1db1ee98..94db6c9127a8 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -7,15 +7,21 @@
 
//===--===//
 
 #include "Headers.h"
+#include "RIFF.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "support/Logger.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#ifdef LLVM_ON_UNIX
+#include 
+#endif
 
-using ::testing::_;
-using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -297,6 +303,86 @@ TEST(SerializationTest, CmdlTest) {
 

[PATCH] D91258: [clangd] Sanity-check array sizes read from disk before allocating them.

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c0910329168: [clangd] Sanity-check array sizes read from 
disk before allocating them. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91258

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
@@ -7,15 +7,21 @@
 //===--===//
 
 #include "Headers.h"
+#include "RIFF.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "support/Logger.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#ifdef LLVM_ON_UNIX
+#include 
+#endif
 
-using ::testing::_;
-using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -297,6 +303,86 @@
 EXPECT_NE(SerializedCmd.Output, Cmd.Output);
   }
 }
+
+#if LLVM_ON_UNIX // rlimit is part of POSIX
+class ScopedMemoryLimit {
+  struct rlimit OriginalLimit;
+  bool Succeeded = false;
+
+public:
+  ScopedMemoryLimit(rlim_t Bytes) {
+if (!getrlimit(RLIMIT_AS, )) {
+  struct rlimit NewLimit = OriginalLimit;
+  NewLimit.rlim_cur = Bytes;
+  Succeeded = !setrlimit(RLIMIT_AS, );
+}
+if (!Succeeded)
+  log("Failed to set rlimit");
+  }
+
+  ~ScopedMemoryLimit() {
+if (Succeeded)
+  setrlimit(RLIMIT_AS, );
+  }
+};
+#else
+class ScopedMemoryLimit {
+public:
+  ScopedMemoryLimit(unsigned Bytes) { log("rlimit unsupported"); }
+};
+#endif
+
+// 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) {
+  // This test is tricky because we need to construct a subtly invalid file.
+  // 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 and find the `srcs` chunk we're going to corrupt.
+  auto Parsed = riff::readFile(Serialized);
+  ASSERT_FALSE(!Parsed) << Parsed.takeError();
+  auto Srcs = llvm::find_if(Parsed->Chunks, [](riff::Chunk C) {
+return C.ID == riff::fourCC("srcs");
+  });
+  ASSERT_NE(Srcs, Parsed->Chunks.end());
+
+  // Srcs consists of a sequence of IncludeGraphNodes. In our case, just one.
+  // The node has:
+  //  - 1 byte: flags (1)
+  //  - varint(stringID): URI
+  //  - 8 byte: file digest
+  //  - varint: DirectIncludes.length
+  //  - repeated varint(stringID): DirectIncludes
+  // We want to set DirectIncludes.length to a huge number.
+  // The offset isn't trivial to find, so we use the file digest.
+  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
+  unsigned Pos = Srcs->Data.find_first_of(FileDigest);
+  ASSERT_NE(Pos, StringRef::npos) << "Couldn't locate file digest";
+  Pos += FileDigest.size();
+
+  // Varints are little-endian base-128 numbers, where the top-bit of each byte
+  // indicates whether there are more. 8fff7f -> 0x.
+  std::string CorruptSrcs =
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+   "some_random_garbage")
+  .str();
+  Srcs->Data = CorruptSrcs;
+
+  // 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_EQ(llvm::toString(CorruptParsed.takeError()),
+"malformed or truncated include uri");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -16,6 +16,7 @@
 #include "support/Trace.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
@@ -104,6 +105,20 @@
 llvm::StringRef Raw = consume(SymbolID::RawSize); // short if truncated.
 return LLVM_UNLIKELY(err()) ? SymbolID() : SymbolID::fromRaw(Raw);
   }
+
+  // 

[PATCH] D91300: WIP: Frontend: Use an InMemoryFileSystem for the RemappedFiles parameter in ASTUnit

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a subscriber: kadircet.
dexonsmith added inline comments.



Comment at: clang/lib/Frontend/PrecompiledPreamble.cpp:571-579
+if (OverriddenFilesFS) {
+  std::unique_ptr Buffer;
+  if (moveOnNoError(OverriddenFilesFS->getBufferForFile(F.first()),
+Buffer)) {
+if (PreambleFileHash::createForMemoryBuffer(*Buffer) != F.second)
+  return false;
+continue;

@kadircet, I'm curious if clang-tools-extra/clangd/Preamble.cpp's call to 
`ASTUnit::CanReuse` would benefit from this logic as well. I would guess clangd 
doesn't even try to reuse preambles when unsaved files have changed (since you 
might see the same crashes or wrong results I saw before adding this), but 
after this patch lands you might be able to do that safely.


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

https://reviews.llvm.org/D91300

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


[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-11 Thread Sylvain Audi via Phabricator via cfe-commits
saudi updated this revision to Diff 304648.
saudi added a comment.

Simplified the `RealFS` initialization, as suggested


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

https://reviews.llvm.org/D91204

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/Inputs/relative_directory.json
  clang/test/ClangScanDeps/relative_directory.cpp


Index: clang/test/ClangScanDeps/relative_directory.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/relative_directory.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %s %t.dir/Inputs/relative_directory_input1.cpp
+// RUN: cp %s %t.dir/Inputs/relative_directory_input2.cpp
+// RUN: touch %t.dir/Inputs/header.h
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/relative_directory.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck 
--check-prefixes=CHECK1,CHECK2 %s
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK2 %s
+
+#include 
+
+// CHECK1: relative_directory_input1.o:
+// CHECK1-NEXT: relative_directory_input1.cpp
+// CHECK1-NEXT: header.h
+
+// CHECK2: relative_directory_input2.o:
+// CHECK2-NEXT: relative_directory_input2.cpp
+// CHECK2-NEXT: header.h
Index: clang/test/ClangScanDeps/Inputs/relative_directory.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/relative_directory.json
@@ -0,0 +1,12 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -E Inputs/relative_directory_input1.cpp -IInputs",
+  "file": "DIR/Inputs/relative_directory_input1.cpp"
+},
+{
+  "directory": "DIR/Inputs",
+  "command": "clang -E relative_directory_input2.cpp -I.",
+  "file": "DIR/Inputs/relative_directory_input2.cpp"
+}
+]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -44,28 +44,6 @@
   DependencyConsumer 
 };
 
-/// A proxy file system that doesn't call `chdir` when changing the working
-/// directory of a clang tool.
-class ProxyFileSystemWithoutChdir : public llvm::vfs::ProxyFileSystem {
-public:
-  ProxyFileSystemWithoutChdir(
-  llvm::IntrusiveRefCntPtr FS)
-  : ProxyFileSystem(std::move(FS)) {}
-
-  llvm::ErrorOr getCurrentWorkingDirectory() const override {
-assert(!CWD.empty() && "empty CWD");
-return CWD;
-  }
-
-  std::error_code setCurrentWorkingDirectory(const Twine ) override {
-CWD = Path.str();
-return {};
-  }
-
-private:
-  std::string CWD;
-};
-
 /// A clang tool that runs the preprocessor in a mode that's optimized for
 /// dependency scanning for the given compiler invocation.
 class DependencyScanningAction : public tooling::ToolAction {
@@ -176,7 +154,7 @@
 : Format(Service.getFormat()) {
   DiagOpts = new DiagnosticOptions();
   PCHContainerOps = std::make_shared();
-  RealFS = new ProxyFileSystemWithoutChdir(llvm::vfs::getRealFileSystem());
+  RealFS = llvm::vfs::createPhysicalFileSystem().release();
   if (Service.canSkipExcludedPPRanges())
 PPSkipMappings =
 std::make_unique();


Index: clang/test/ClangScanDeps/relative_directory.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/relative_directory.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %s %t.dir/Inputs/relative_directory_input1.cpp
+// RUN: cp %s %t.dir/Inputs/relative_directory_input2.cpp
+// RUN: touch %t.dir/Inputs/header.h
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/relative_directory.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck --check-prefixes=CHECK1,CHECK2 %s
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefix=CHECK2 %s
+
+#include 
+
+// CHECK1: relative_directory_input1.o:
+// CHECK1-NEXT: relative_directory_input1.cpp
+// CHECK1-NEXT: header.h
+
+// CHECK2: relative_directory_input2.o:
+// CHECK2-NEXT: relative_directory_input2.cpp
+// CHECK2-NEXT: header.h
Index: clang/test/ClangScanDeps/Inputs/relative_directory.json
===
--- /dev/null
+++ 

[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/test/ClangScanDeps/relative_directory.cpp:12-13
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK1 %s

saudi wrote:
> dexonsmith wrote:
> > Can you use `CHECK-DAG` for this?
> > https://www.llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive
> If I understand correctly from the doc, it would lose the order (CHECK1, 
> CHECK1-NEXT).
> We need 2 blocks of 3 lines to be present, but only the blocks can be in any 
> order.
> 
> I did this mimicking what is done in other tests like regular_cdb.cpp.
> 
> If I understand correctly from the doc, it would lose the order (CHECK1, 
> CHECK1-NEXT).
We need 2 blocks of 3 lines to be present, but only the blocks can be in any 
order.

That's correct, but I think it's safe to assume in this test that the general 
format of the output is correct. Best would be to add a `CHECK-DAG-NEXT:` 
feature to FileCheck but that seems above and beyond for fixing this bug.

> I did this mimicking what is done in other tests like regular_cdb.cpp.

Sure, it's probably fine either way, and it might be better to match the other 
tests.


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

https://reviews.llvm.org/D91204

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


[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp:158-160
+  llvm::IntrusiveRefCntPtr PhysicalFileSystem(
+  llvm::vfs::createPhysicalFileSystem().release());
+  RealFS = new llvm::vfs::ProxyFileSystem(PhysicalFileSystem);

saudi wrote:
> dexonsmith wrote:
> > I think this can just be:
> > ```
> > RealFS = llvm::vfs::createPhysicalFileSystem();
> > ```
> > The `ProxyFileSystem` wrapper is a convenience for building other file 
> > systems; it doesn't do anything on its own IIRC.
> Note that createPhysicalFileSystem() returns a `std::unique_ptr` whereas 
> `getRealFileSystem()` return type is `llvm::IntrusiveRfCntPtr`.
> 
> Trying to change the type of RealFS requires more changes, as 
> `DependencyScanningWorkerFilesystem` is itself a `ProxyFileSystem` and thus 
> requires a `llvm::IntrusiveRfCntPtr` object.
> 
> Should DependencyScanningWorkerFilesystem not be a ProxyFileSystem? @arphaman 
> WDYT?
> However, in this case it might fall out of the scope of this patch, I'd 
> suggest we keep it as a separate patch.
> 
> I updated my patch for an intermediate fix, which also passes the tests:
> ```
> RealFS = 
> llvm::IntrusiveRefCntPtr(llvm::vfs::createPhysicalFileSystem().release());
> ```
> 
Ah, didn't realize it returned `unique_ptr`. `RealFS` should be 
`IntrusiveRefCntPtr`, but you can be less verbose like this:
```
RealFS = llvm::vfs::createPhysicalFileSystem().release();
```



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

https://reviews.llvm.org/D91204

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


[PATCH] D89980: [hip] Remove the coercion on aggregate kernel arguments.

2020-11-11 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

PING for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89980

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


[PATCH] D91300: WIP: Frontend: Use an InMemoryFileSystem for the RemappedFiles parameter in ASTUnit

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, JDevlieghere, jansvoboda11, akyrtzi.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Re-implement the `RemappedFiles` parameter to various `ASTUnit` entry points by 
storing buffers in an `InMemoryFileSystem`. This parameter is commonly used by 
indexing tools to pass in source files that haven't been saved to disk (yet). 
This is the same strategy `ClangTool` switched to in 2015.

The previous implementation added them to 
`PreprocessorOptions::RemappedFileBuffers`, which eventually triggers calls to 
`FileManager::getVirtualFile` and `SourceManager::overrideFileContents`. That's 
one of the blockers for sinking the content cache from `SourceManager` down to 
`FileManager`. The new strategy is also a bit cleaner (the old one predates 
`llvm::vfs::FileSystem`).

Follow-ups will handle the other two uses of `RemappedFileBuffers` in 
`ASTUnit`. One is for the preamble's serialized AST. The other is for 
overriding the main file buffer, which is a bit tricky since we need the 
`ASTWriter` to save the preamble-only version.

WIP: I'm not totally happy with this patch yet, but tests are finally passing 
so I'm posting this for early review. In the meantime I'll continue peeling off 
what I can for prep patches (or there may be changes I can just delete). Among 
other things, I want to add a test (in a prep patch) for the handling of a file 
showing up twice in the same `RemappedFiles` vector, since it was pretty tough 
to discover I needed special logic for that.


https://reviews.llvm.org/D91300

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Frontend/PrecompiledPreamble.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Frontend/PCHPreambleTest.cpp

Index: clang/unittests/Frontend/PCHPreambleTest.cpp
===
--- clang/unittests/Frontend/PCHPreambleTest.cpp
+++ clang/unittests/Frontend/PCHPreambleTest.cpp
@@ -85,11 +85,6 @@
 
 CI->getTargetOpts().Triple = "i386-unknown-linux-gnu";
 
-CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles();
-
-PreprocessorOptions  = CI->getPreprocessorOpts();
-PPOpts.RemappedFilesKeepOriginalName = true;
-
 IntrusiveRefCntPtr
   Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, new DiagnosticConsumer));
 
@@ -97,7 +92,8 @@
 
 std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation(
 CI, PCHContainerOpts, Diags, FileMgr,
-/*PrecompilePreambleAfterNParses=*/1);
+/*PrecompilePreambleAfterNParses=*/1, /*UserFilesAreVolatile=*/false,
+GetRemappedFiles());
 return AST;
   }
 
@@ -111,9 +107,8 @@
   }
 
 private:
-  std::vector>
-  GetRemappedFiles() const {
-std::vector> Remapped;
+  std::vector GetRemappedFiles() const {
+std::vector Remapped;
 for (const auto  : RemappedFiles) {
   std::unique_ptr buf = MemoryBuffer::getMemBufferCopy(
 RemappedFile.second, RemappedFile.first());
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -247,7 +247,7 @@
 /// AllocatedCXCodeCompleteResults outlives the CXTranslationUnit, so we can
 /// not rely on the StringPool in the TU.
 struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults {
-  AllocatedCXCodeCompleteResults(IntrusiveRefCntPtr FileMgr);
+  AllocatedCXCodeCompleteResults();
   ~AllocatedCXCodeCompleteResults();
   
   /// Diagnostics produced while performing code completion.
@@ -354,8 +354,7 @@
 /// Used for debugging purposes only.
 static std::atomic CodeCompletionResultObjects;
 
-AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults(
-IntrusiveRefCntPtr FileMgr)
+AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults()
 : CXCodeCompleteResults(), DiagOpts(new DiagnosticOptions),
   Diag(new DiagnosticsEngine(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts)),
@@ -717,21 +716,19 @@
   ASTUnit::ConcurrencyCheck Check(*AST);
 
   // Perform the remapping of source files.
-  SmallVector RemappedFiles;
+  std::vector RemappedFiles;
 
-  for (auto  : unsaved_files) {
-std::unique_ptr MB =
-llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
-RemappedFiles.push_back(std::make_pair(UF.Filename, MB.release()));
-  }
+  for (auto  : unsaved_files)
+RemappedFiles.push_back(std::make_pair(
+UF.Filename,
+llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename)));
 
   if (EnableLogging) {
 // FIXME: Add logging.
   }
 
   // Parse the resulting source file to find code-completion results.
-  AllocatedCXCodeCompleteResults 

[PATCH] D91258: [clangd] Sanity-check array sizes read from disk before allocating them.

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

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91258

___
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-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:209
+// Theoretical max ratio from https://zlib.net/zlib_tech.html
+constexpr int MaxCompressionRatio = 1032;
+if (UncompressedSize / MaxCompressionRatio > R.rest().size())

we also need a static here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91299

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


[PATCH] D83025: [clang] Include type specifiers in typo correction when checking isCXXDeclarationSpecifiers.

2020-11-11 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D83025#2389486 , @hokein wrote:

> In D83025#2389140 , @aganea wrote:
>
>> We're seeing the same issue mentionned in PR45498 
>> , but with the repro below. 
>> `git bisect` points to this patch. Could anyone please possibly confirm? 
>> Simply build clang with `-DLLVM_ENABLE_ASSERTIONS=ON`.
>>
>>   // compile with: clang-cl /c a.cpp
>>   template < a > struct b;
>>   template < bool a, class > using c = b< a >;
>>   template < class > using d = void ;
>>   template < class, class, class = void >
>>   bool e template < class f, class g >
>>   bool e< f, g, d< decltype(h(g())) > > template < class f, class g >
>>   void i(f, g ) {
>> e< f, g >
>>   }
>>   template < class _BidIt2, c< e< _BidIt, _BidIt2 >, int > = 0 >
>>   void h(_BidIt2) short do_tolower__Last {
>> i(do_tolower__First, do_tolower__Last)
>>   }
>
> thanks for the testcase. I'm not sure the patch is the root cause -- from the 
> Bugzilla thread, the issue was reported in April which is prior to this patch.
>
> btw, the issue seems to be gone on the trunk, I don't reproduce them with 
> clang building from the trunk, I guess it might be fixed by some patches 
> after llvm-11.

Thanks for getting back! Just for the record, bisecting between the 
`llvmorg-12-init` git tag and rG637f19c36b3 
 leads to 
this fix: D87853 .

  commit cffb0dd54d41d8e249d2009467c4beb5b681ba26
  Author: Bruno Cardoso Lopes 
  Date:   Mon Oct 12 15:58:52 2020 -0700
  
  [SemaTemplate] Stop passing insertion position around during VarTemplate 
instantiation
  
  They can get stale at use time because of updates from other recursive
  specializations. Instead, rely on the existence of previous declarations 
to add
  the specialization.
  
  Differential Revision: https://reviews.llvm.org/D87853

I was able to cherry-pick it cleanly on release/11.x and that solves our issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83025

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


[PATCH] D91253: [Matrix] Update mangling to use paramterized vendor ext type syntax.

2020-11-11 Thread Florian Hahn via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d5daed1997d: [Matrix] Update mangling to use paramterized 
vendor ext type syntax. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91253

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/matrix-type-builtins.cpp
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/CodeGenCXX/matrix-type.cpp

Index: clang/test/CodeGenCXX/matrix-type.cpp
===
--- clang/test/CodeGenCXX/matrix-type.cpp
+++ clang/test/CodeGenCXX/matrix-type.cpp
@@ -6,7 +6,7 @@
 // CHECK: %struct.Matrix = type { i8, [12 x float], float }
 
 void load_store(dx5x5_t *a, dx5x5_t *b) {
-  // CHECK-LABEL:  define void @_Z10load_storePU11matrix_typeLm5ELm5EdS0_(
+  // CHECK-LABEL:  define void @_Z10load_storePu11matrix_typeILm5ELm5EdES0_(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [25 x double]*, align 8
   // CHECK-NEXT:%b.addr = alloca [25 x double]*, align 8
@@ -26,7 +26,7 @@
 typedef float fx3x3_t __attribute__((matrix_type(3, 3)));
 
 void parameter_passing(fx3x3_t a, fx3x3_t *b) {
-  // CHECK-LABEL: define void @_Z17parameter_passingU11matrix_typeLm3ELm3EfPS_(
+  // CHECK-LABEL: define void @_Z17parameter_passingu11matrix_typeILm3ELm3EfEPS_(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [9 x float], align 4
   // CHECK-NEXT:%b.addr = alloca [9 x float]*, align 8
@@ -42,7 +42,7 @@
 }
 
 fx3x3_t return_matrix(fx3x3_t *a) {
-  // CHECK-LABEL: define <9 x float> @_Z13return_matrixPU11matrix_typeLm3ELm3Ef(
+  // CHECK-LABEL: define <9 x float> @_Z13return_matrixPu11matrix_typeILm3ELm3EfE(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [9 x float]*, align 8
   // CHECK-NEXT:store [9 x float]* %a, [9 x float]** %a.addr, align 8
@@ -215,42 +215,42 @@
   // CHECK-NEXT:%m4 = alloca [144 x float], align 4
   // CHECK-NEXT:%v = alloca %struct.selector.3, align 1
   // CHECK-NEXT:%undef.agg.tmp4 = alloca %struct.selector.3, align 1
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi3EERU11matrix_typeXLm10EEXT0_ET_([120 x i32]* nonnull align 4 dereferenceable(480) %m0)
-  // CHECK-NEXT:call void @_Z10use_matrixIiE8selectorILi2EERU11matrix_typeLm10ELm10ET_([100 x i32]* nonnull align 4 dereferenceable(400) %m1)
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi1EERU11matrix_typeXT0_EXLm10EET_([120 x i32]* nonnull align 4 dereferenceable(480) %m2)
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12ELm12EE8selectorILi0EERU11matrix_typeXT0_EXT1_ET_([144 x i32]* nonnull align 4 dereferenceable(576) %m3)
-  // CHECK-NEXT:call void @_Z10use_matrixILm12ELm12EE8selectorILi4EERU11matrix_typeXT_EXT0_Ef([144 x float]* nonnull align 4 dereferenceable(576) %m4)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeIXLm10EEXT0_ET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m0)
+  // CHECK-NEXT:call void @_Z10use_matrixIiE8selectorILi2EERu11matrix_typeILm10ELm10ET_E([100 x i32]* nonnull align 4 dereferenceable(400) %m1)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi1EERu11matrix_typeIXT0_EXLm10EET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m2)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12ELm12EE8selectorILi0EERu11matrix_typeIXT0_EXT1_ET_E([144 x i32]* nonnull align 4 dereferenceable(576) %m3)
+  // CHECK-NEXT:call void @_Z10use_matrixILm12ELm12EE8selectorILi4EERu11matrix_typeIXT_EXT0_EfE([144 x float]* nonnull align 4 dereferenceable(576) %m4)
   // CHECK-NEXT:ret void
 
-  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiLm12EE8selectorILi3EERU11matrix_typeXLm10EEXT0_ET_([120 x i32]* nonnull align 4 dereferenceable(480) %m)
+  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeIXLm10EEXT0_ET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m)
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%m.addr = alloca [120 x i32]*, align 8
   // CHECK-NEXT:store [120 x i32]* %m, [120 x i32]** %m.addr, align 8
   // CHECK-NEXT:call void @llvm.trap()
   // CHECK-NEXT:unreachable
 
-  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiE8selectorILi2EERU11matrix_typeLm10ELm10ET_([100 x i32]* nonnull align 4 dereferenceable(400) %m)
+  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiE8selectorILi2EERu11matrix_typeILm10ELm10ET_E([100 x i32]* nonnull align 4 dereferenceable(400) %m)
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%m.addr = alloca [100 x i32]*, align 8
   // CHECK-NEXT:store [100 x i32]* %m, [100 x i32]** %m.addr, align 8
   // CHECK-NEXT:call void @llvm.trap()
   // CHECK-NEXT:unreachable
 
-  // CHECK-LABEL: define linkonce_odr void 

[clang] 1d5daed - [Matrix] Update mangling to use paramterized vendor ext type syntax.

2020-11-11 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-11-11T21:39:22Z
New Revision: 1d5daed1997d2fc1fbb6fd19156518bde93d1034

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

LOG: [Matrix] Update mangling to use paramterized vendor ext type syntax.

The Itanium CXX ABI grammer has been extended to support parameterized
vendor extended types [1].

This patch updates Clang's mangling for matrix types to use the new
extension.

[1] 
https://github.com/itanium-cxx-abi/cxx-abi/commit/b359d28971bdb961dd9b61bd0ef8c884452b4740

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/AST/ItaniumMangle.cpp
clang/test/CodeGenCXX/matrix-type-builtins.cpp
clang/test/CodeGenCXX/matrix-type-operators.cpp
clang/test/CodeGenCXX/matrix-type.cpp

Removed: 




diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 1cf178fdd988..2b6fda4d9dcc 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3493,10 +3493,13 @@ void CXXNameMangler::mangleType(const 
DependentSizedExtVectorType *T) {
 }
 
 void CXXNameMangler::mangleType(const ConstantMatrixType *T) {
-  // Mangle matrix types using a vendor extended type qualifier:
-  // Umatrix_type
+  // Mangle matrix types as a vendor extended type:
+  // umatrix_typeIE
+
   StringRef VendorQualifier = "matrix_type";
-  Out << "U" << VendorQualifier.size() << VendorQualifier;
+  Out << "u" << VendorQualifier.size() << VendorQualifier;
+
+  Out << "I";
   auto  = getASTContext();
   unsigned BitWidth = ASTCtx.getTypeSize(ASTCtx.getSizeType());
   llvm::APSInt Rows(BitWidth);
@@ -3506,15 +3509,20 @@ void CXXNameMangler::mangleType(const 
ConstantMatrixType *T) {
   Columns = T->getNumColumns();
   mangleIntegerLiteral(ASTCtx.getSizeType(), Columns);
   mangleType(T->getElementType());
+  Out << "E";
 }
 
 void CXXNameMangler::mangleType(const DependentSizedMatrixType *T) {
-  // Umatrix_type
+  // Mangle matrix types as a vendor extended type:
+  // umatrix_typeIE
   StringRef VendorQualifier = "matrix_type";
-  Out << "U" << VendorQualifier.size() << VendorQualifier;
+  Out << "u" << VendorQualifier.size() << VendorQualifier;
+
+  Out << "I";
   mangleTemplateArg(T->getRowExpr());
   mangleTemplateArg(T->getColumnExpr());
   mangleType(T->getElementType());
+  Out << "E";
 }
 
 void CXXNameMangler::mangleType(const DependentAddressSpaceType *T) {

diff  --git a/clang/test/CodeGenCXX/matrix-type-builtins.cpp 
b/clang/test/CodeGenCXX/matrix-type-builtins.cpp
index fcd21d873716..ca353bc1f2b3 100644
--- a/clang/test/CodeGenCXX/matrix-type-builtins.cpp
+++ b/clang/test/CodeGenCXX/matrix-type-builtins.cpp
@@ -67,7 +67,7 @@ void test_transpose_rvalue() {
 }
 
 void test_transpose_const(const matrix_t ) {
-  // CHECK-LABEL:  define void 
@_Z20test_transpose_constRKU11matrix_typeLm3ELm3Ef(
+  // CHECK-LABEL:  define void 
@_Z20test_transpose_constRKu11matrix_typeILm3ELm3EfE(
   // CHECK: [[MATRIX:%.*]] = load <9 x float>, <9 x float>* {{.*}}, 
align 4
   // CHECK-NEXT:[[M_T:%.*]] = call <9 x float> 
@llvm.matrix.transpose.v9f32(<9 x float> [[MATRIX]], i32 3, i32 3)
   // CHECK-NEXT:[[M_T_ADDR:%.*]] = bitcast [9 x float]* %m_t to <9 x 
float>*
@@ -90,9 +90,9 @@ matrix_t column_major_load_with_stride(T *Ptr) {
 void test_column_major_load_with_stride_template_double(double *Ptr) {
   // CHECK-LABEL: define void 
@_Z50test_column_major_load_with_stride_template_doublePd(double* %Ptr)
   // CHECK: [[PTR:%.*]] = load double*, double** %Ptr.addr, align 8
-  // CHECK-NEXT:call <40 x double> 
@_Z29column_major_load_with_strideIdLj10ELj4ELj15EEU11matrix_typeXT0_EXT1_ET_PS0_(double*
 [[PTR]])
+  // CHECK-NEXT:call <40 x double> 
@_Z29column_major_load_with_strideIdLj10ELj4ELj15EEu11matrix_typeIXT0_EXT1_ET_EPS0_(double*
 [[PTR]])
 
-  // CHECK-LABEL:  define linkonce_odr <40 x double> 
@_Z29column_major_load_with_strideIdLj10ELj4ELj15EEU11matrix_typeXT0_EXT1_ET_PS0_(double*
 %Ptr)
+  // CHECK-LABEL:  define linkonce_odr <40 x double> 
@_Z29column_major_load_with_strideIdLj10ELj4ELj15EEu11matrix_typeIXT0_EXT1_ET_EPS0_(double*
 %Ptr)
   // CHECK: [[PTR:%.*]] = load double*, double** %Ptr.addr, align 8
   // CHECK-NEXT:call <40 x double> 
@llvm.matrix.column.major.load.v40f64(double* align 8 [[PTR]], i64 15, i1 
false, i32 10, i32 4)
 
@@ -102,9 +102,9 @@ void 
test_column_major_load_with_stride_template_double(double *Ptr) {
 void test_column_major_load_with_stride_template_int(int *Ptr) {
   // CHECK-LABEL: define void 
@_Z47test_column_major_load_with_stride_template_intPi(i32* %Ptr) #5 {
   // CHECK: [[PTR:%.*]] = load i32*, i32** %Ptr.addr, align 8
-  // CHECK-NEXT:call <6 x i32> 

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

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

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
@@ -7,12 +7,18 @@
 //===--===//
 
 #include "Headers.h"
+#include "RIFF.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "support/Logger.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#ifdef LLVM_ON_UNIX
+#include 
+#endif
 
 using ::testing::_;
 using ::testing::AllOf;
@@ -297,6 +303,75 @@
 EXPECT_NE(SerializedCmd.Output, Cmd.Output);
   }
 }
+
+#if LLVM_ON_UNIX // rlimit is part of POSIX
+class ScopedMemoryLimit {
+  struct rlimit OriginalLimit;
+  bool Succeeded = false;
+
+public:
+  ScopedMemoryLimit(rlim_t Bytes) {
+if (!getrlimit(RLIMIT_AS, )) {
+  struct rlimit NewLimit = OriginalLimit;
+  NewLimit.rlim_cur = Bytes;
+  Succeeded = !setrlimit(RLIMIT_AS, );
+}
+if (!Succeeded)
+  log("Failed to set rlimit");
+  }
+
+  ~ScopedMemoryLimit() {
+if (Succeeded)
+  setrlimit(RLIMIT_AS, );
+  }
+};
+#else
+class ScopedMemoryLimit {
+public:
+  ScopedMemoryLimit(unsigned Bytes) { log("rlimit unsupported"); }
+};
+#endif
+
+// 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, 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"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -202,6 +202,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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89158: [NewPM] Provide method to run all pipeline callbacks, used for -O0

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

AFAICT all issues were addressed.
@Meinersbur: are there any concerns left with this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89158

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


[PATCH] D91298: Frontend: Always create a new FileManager in ASTUnit::CodeComplete

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: JDevlieghere, arphaman, jansvoboda11, akyrtzi.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

The filesystem underneath it may have changed. This matches other
`ASTUnit` entry points like `Reparse`, and unblocks implementing
remapped files in a VFS layer underneath the `FileManager` in a future
patch.


https://reviews.llvm.org/D91298

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp


Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -359,8 +359,6 @@
 : CXCodeCompleteResults(), DiagOpts(new DiagnosticOptions),
   Diag(new DiagnosticsEngine(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts)),
-  FileMgr(std::move(FileMgr)),
-  SourceMgr(new SourceManager(*Diag, *this->FileMgr)),
   CodeCompletionAllocator(
   std::make_shared()),
   Contexts(CXCompletionContext_Unknown),
@@ -755,14 +753,15 @@
   LibclangInvocationReporter InvocationReporter(
   *CXXIdx, LibclangInvocationReporter::OperationKind::CompletionOperation,
   TU->ParsingOptions, CArgs, CompletionInvocation, unsaved_files);
-  AST->CodeComplete(complete_filename, complete_line, complete_column,
-RemappedFiles, (options & CXCodeComplete_IncludeMacros),
-(options & CXCodeComplete_IncludeCodePatterns),
-IncludeBriefComments, Capture,
-CXXIdx->getPCHContainerOperations(), *Results->Diag,
-Results->LangOpts, *Results->SourceMgr, *Results->FileMgr,
-Results->Diagnostics, Results->TemporaryBuffers);
-
+  AST->CodeComplete(
+  complete_filename, complete_line, complete_column, RemappedFiles,
+  (options & CXCodeComplete_IncludeMacros),
+  (options & CXCodeComplete_IncludeCodePatterns), IncludeBriefComments,
+  Capture, CXXIdx->getPCHContainerOperations(), *Results->Diag,
+  Results->LangOpts, Results->Diagnostics, Results->TemporaryBuffers);
+
+  Results->FileMgr = >getFileManager();
+  Results->SourceMgr = >getSourceManager();
   Results->DiagnosticsWrappers.resize(Results->Diagnostics.size());
 
   // Keep a reference to the allocator used for cached global completions, so
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -2132,8 +2132,8 @@
 bool IncludeCodePatterns, bool IncludeBriefComments,
 CodeCompleteConsumer ,
 std::shared_ptr PCHContainerOps,
-DiagnosticsEngine , LangOptions , SourceManager ,
-FileManager , SmallVectorImpl ,
+DiagnosticsEngine , LangOptions ,
+SmallVectorImpl ,
 SmallVectorImpl ) {
   if (!Invocation)
 return;
@@ -2211,9 +2211,12 @@
  Language::LLVM_IR &&
  "IR inputs not support here!");
 
-  // Use the source and file managers that we were given.
-  Clang->setFileManager();
-  Clang->setSourceManager();
+  // Initialize file and source managers up front so that the caller can access
+  // them after.
+  Clang->createFileManager(FS);
+  FileMgr = >getFileManager();
+  Clang->createSourceManager(*FileMgr);
+  SourceMgr = >getSourceManager();
 
   // Remap files.
   PreprocessorOpts.clearRemappedFiles();
Index: clang/include/clang/Frontend/ASTUnit.h
===
--- clang/include/clang/Frontend/ASTUnit.h
+++ clang/include/clang/Frontend/ASTUnit.h
@@ -876,7 +876,6 @@
 CodeCompleteConsumer ,
 std::shared_ptr PCHContainerOps,
 DiagnosticsEngine , LangOptions ,
-SourceManager , FileManager ,
 SmallVectorImpl ,
 SmallVectorImpl );
 


Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -359,8 +359,6 @@
 : CXCodeCompleteResults(), DiagOpts(new DiagnosticOptions),
   Diag(new DiagnosticsEngine(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts)),
-  FileMgr(std::move(FileMgr)),
-  SourceMgr(new SourceManager(*Diag, *this->FileMgr)),
   CodeCompletionAllocator(
   std::make_shared()),
   Contexts(CXCompletionContext_Unknown),
@@ -755,14 +753,15 @@
   LibclangInvocationReporter InvocationReporter(
   *CXXIdx, LibclangInvocationReporter::OperationKind::CompletionOperation,
   TU->ParsingOptions, CArgs, CompletionInvocation, unsaved_files);
-  AST->CodeComplete(complete_filename, complete_line, complete_column,
-

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

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: JDevlieghere, arphaman, jansvoboda11.
Herald added subscribers: usaxena95, ributzka, kadircet.
dexonsmith requested review of this revision.

Clarify that `PrecompiledPreamble::CanReuse` requires non-null arguments
for `VFS` and `MainFileBuffer`, taking them by reference instead of by
pointer.


https://reviews.llvm.org/D91297

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang/include/clang/Frontend/PrecompiledPreamble.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp

Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -501,12 +501,12 @@
 }
 
 bool PrecompiledPreamble::CanReuse(const CompilerInvocation ,
-   const llvm::MemoryBuffer *MainFileBuffer,
+   const llvm::MemoryBufferRef ,
PreambleBounds Bounds,
-   llvm::vfs::FileSystem *VFS) const {
+   llvm::vfs::FileSystem ) const {
 
   assert(
-  Bounds.Size <= MainFileBuffer->getBufferSize() &&
+  Bounds.Size <= MainFileBuffer.getBufferSize() &&
   "Buffer is too large. Bounds were calculated from a different buffer?");
 
   auto PreambleInvocation = std::make_shared(Invocation);
@@ -520,7 +520,7 @@
   if (PreambleBytes.size() != Bounds.Size ||
   PreambleEndsAtStartOfLine != Bounds.PreambleEndsAtStartOfLine ||
   !std::equal(PreambleBytes.begin(), PreambleBytes.end(),
-  MainFileBuffer->getBuffer().begin()))
+  MainFileBuffer.getBuffer().begin()))
 return false;
   // The preamble has not changed. We may be able to re-use the precompiled
   // preamble.
@@ -532,14 +532,14 @@
   llvm::StringSet<> OverriddenAbsPaths; // Either by buffers or files.
   for (const auto  : PreprocessorOpts.RemappedFiles) {
 llvm::vfs::Status Status;
-if (!moveOnNoError(VFS->status(R.second), Status)) {
+if (!moveOnNoError(VFS.status(R.second), Status)) {
   // If we can't stat the file we're remapping to, assume that something
   // horrible happened.
   return false;
 }
 // If a mapped file was previously missing, then it has changed.
 llvm::SmallString<128> MappedPath(R.first);
-if (!VFS->makeAbsolute(MappedPath))
+if (!VFS.makeAbsolute(MappedPath))
   OverriddenAbsPaths.insert(MappedPath);
 
 OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile(
@@ -552,13 +552,13 @@
 const PrecompiledPreamble::PreambleFileHash PreambleHash =
 PreambleFileHash::createForMemoryBuffer(RB.second->getMemBufferRef());
 llvm::vfs::Status Status;
-if (moveOnNoError(VFS->status(RB.first), Status))
+if (moveOnNoError(VFS.status(RB.first), Status))
   OverriddenFiles[Status.getUniqueID()] = PreambleHash;
 else
   OverridenFileBuffers[RB.first] = PreambleHash;
 
 llvm::SmallString<128> MappedPath(RB.first);
-if (!VFS->makeAbsolute(MappedPath))
+if (!VFS.makeAbsolute(MappedPath))
   OverriddenAbsPaths.insert(MappedPath);
   }
 
@@ -574,7 +574,7 @@
 }
 
 llvm::vfs::Status Status;
-if (!moveOnNoError(VFS->status(F.first()), Status)) {
+if (!moveOnNoError(VFS.status(F.first()), Status)) {
   // If the file's buffer is not remapped and we can't stat it,
   // assume that something horrible happened.
   return false;
@@ -603,7 +603,7 @@
   return false;
 // If a file previously recorded as missing exists as a regular file, then
 // consider the preamble out-of-date.
-if (auto Status = VFS->status(F.getKey())) {
+if (auto Status = VFS.status(F.getKey())) {
   if (Status->isRegularFile())
 return false;
 }
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1316,8 +1316,8 @@
 return nullptr;
 
   if (Preamble) {
-if (Preamble->CanReuse(PreambleInvocationIn, MainFileBuffer.get(), Bounds,
-   VFS.get())) {
+if (Preamble->CanReuse(PreambleInvocationIn, *MainFileBuffer, Bounds,
+   *VFS)) {
   // Okay! We can re-use the precompiled preamble.
 
   // Set the state of the diagnostic object to mimic its state
Index: clang/include/clang/Frontend/PrecompiledPreamble.h
===
--- clang/include/clang/Frontend/PrecompiledPreamble.h
+++ clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -105,8 +105,8 @@
   /// Check whether PrecompiledPreamble can be reused for the new contents(\p
   /// MainFileBuffer) of the main file.
   bool CanReuse(const CompilerInvocation ,
-const llvm::MemoryBuffer 

[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-11 Thread Sylvain Audi via Phabricator via cfe-commits
saudi marked 2 inline comments as not done.
saudi added inline comments.



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp:158-160
+  llvm::IntrusiveRefCntPtr PhysicalFileSystem(
+  llvm::vfs::createPhysicalFileSystem().release());
+  RealFS = new llvm::vfs::ProxyFileSystem(PhysicalFileSystem);

dexonsmith wrote:
> I think this can just be:
> ```
> RealFS = llvm::vfs::createPhysicalFileSystem();
> ```
> The `ProxyFileSystem` wrapper is a convenience for building other file 
> systems; it doesn't do anything on its own IIRC.
Note that createPhysicalFileSystem() returns a `std::unique_ptr` whereas 
`getRealFileSystem()` return type is `llvm::IntrusiveRfCntPtr`.

Trying to change the type of RealFS requires more changes, as 
`DependencyScanningWorkerFilesystem` is itself a `ProxyFileSystem` and thus 
requires a `llvm::IntrusiveRfCntPtr` object.

Should DependencyScanningWorkerFilesystem not be a ProxyFileSystem? @arphaman 
WDYT?
However, in this case it might fall out of the scope of this patch, I'd suggest 
we keep it as a separate patch.

I updated my patch for an intermediate fix, which also passes the tests:
```
RealFS = 
llvm::IntrusiveRefCntPtr(llvm::vfs::createPhysicalFileSystem().release());
```




Comment at: clang/test/ClangScanDeps/relative_directory.cpp:12-13
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK1 %s

dexonsmith wrote:
> Can you use `CHECK-DAG` for this?
> https://www.llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive
If I understand correctly from the doc, it would lose the order (CHECK1, 
CHECK1-NEXT).
We need 2 blocks of 3 lines to be present, but only the blocks can be in any 
order.

I did this mimicking what is done in other tests like regular_cdb.cpp.



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

https://reviews.llvm.org/D91204

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


[PATCH] D91296: Frontend: Clarify logic for using the preamble in ASTUnit::CodeComplete, almost NFC

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, JDevlieghere, jansvoboda11.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Clarify the logic for using the preamble (and overriding the main file
buffer) in `ASTUnit::CodeComplete` by factoring out a couple of lambdas
(`getUniqueID` and `hasSameUniqueID`).  While refactoring the logic,
hoist the check for `Line > 1` and locally check if the filenames are
equal (both to avoid unnecessary `stat` calls) and skip copying out the
filenames to `std::string`.

Besides fewer calls to `stat`, there's no functionality change here.


https://reviews.llvm.org/D91296

Files:
  clang/lib/Frontend/ASTUnit.cpp


Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -2229,28 +2229,30 @@
 = new AugmentedCodeCompleteConsumer(*this, Consumer, CodeCompleteOpts);
   Clang->setCodeCompletionConsumer(AugmentedConsumer);
 
+  auto getUniqueID =
+  [](StringRef Filename) -> Optional {
+if (auto Status = FileMgr.getVirtualFileSystem().status(Filename))
+  return Status->getUniqueID();
+return None;
+  };
+
+  auto hasSameUniqueID = [getUniqueID](StringRef LHS, StringRef RHS) {
+if (LHS == RHS)
+  return true;
+if (auto LHSID = getUniqueID(LHS))
+  if (auto RHSID = getUniqueID(RHS))
+return *LHSID == *RHSID;
+return false;
+  };
+
   // If we have a precompiled preamble, try to use it. We only allow
   // the use of the precompiled preamble if we're if the completion
   // point is within the main file, after the end of the precompiled
   // preamble.
   std::unique_ptr OverrideMainBuffer;
-  if (Preamble) {
-std::string CompleteFilePath(File);
-
-auto  = FileMgr.getVirtualFileSystem();
-auto CompleteFileStatus = VFS.status(CompleteFilePath);
-if (CompleteFileStatus) {
-  llvm::sys::fs::UniqueID CompleteFileID = 
CompleteFileStatus->getUniqueID();
-
-  std::string MainPath(OriginalSourceFile);
-  auto MainStatus = VFS.status(MainPath);
-  if (MainStatus) {
-llvm::sys::fs::UniqueID MainID = MainStatus->getUniqueID();
-if (CompleteFileID == MainID && Line > 1)
-  OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(
-  PCHContainerOps, Inv, , false, Line - 1);
-  }
-}
+  if (Preamble && Line > 1 && hasSameUniqueID(File, OriginalSourceFile)) {
+OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(
+PCHContainerOps, Inv, (), false, Line - 
1);
   }
 
   // If the main file has been overridden due to the use of a preamble,


Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -2229,28 +2229,30 @@
 = new AugmentedCodeCompleteConsumer(*this, Consumer, CodeCompleteOpts);
   Clang->setCodeCompletionConsumer(AugmentedConsumer);
 
+  auto getUniqueID =
+  [](StringRef Filename) -> Optional {
+if (auto Status = FileMgr.getVirtualFileSystem().status(Filename))
+  return Status->getUniqueID();
+return None;
+  };
+
+  auto hasSameUniqueID = [getUniqueID](StringRef LHS, StringRef RHS) {
+if (LHS == RHS)
+  return true;
+if (auto LHSID = getUniqueID(LHS))
+  if (auto RHSID = getUniqueID(RHS))
+return *LHSID == *RHSID;
+return false;
+  };
+
   // If we have a precompiled preamble, try to use it. We only allow
   // the use of the precompiled preamble if we're if the completion
   // point is within the main file, after the end of the precompiled
   // preamble.
   std::unique_ptr OverrideMainBuffer;
-  if (Preamble) {
-std::string CompleteFilePath(File);
-
-auto  = FileMgr.getVirtualFileSystem();
-auto CompleteFileStatus = VFS.status(CompleteFilePath);
-if (CompleteFileStatus) {
-  llvm::sys::fs::UniqueID CompleteFileID = CompleteFileStatus->getUniqueID();
-
-  std::string MainPath(OriginalSourceFile);
-  auto MainStatus = VFS.status(MainPath);
-  if (MainStatus) {
-llvm::sys::fs::UniqueID MainID = MainStatus->getUniqueID();
-if (CompleteFileID == MainID && Line > 1)
-  OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(
-  PCHContainerOps, Inv, , false, Line - 1);
-  }
-}
+  if (Preamble && Line > 1 && hasSameUniqueID(File, OriginalSourceFile)) {
+OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(
+PCHContainerOps, Inv, (), false, Line - 1);
   }
 
   // If the main file has been overridden due to the use of a preamble,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91295: Frontend: Remove unused parameter from ASTUnit::LoadFromCompilerInvocationAction, NFC

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: JDevlieghere, jansvoboda11.
Herald added subscribers: ributzka, arphaman.
dexonsmith requested review of this revision.

Drop `IncludeBriefCommentsInCodeCompletion` since it is always `false`.


https://reviews.llvm.org/D91295

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/tools/libclang/Indexing.cpp


Index: clang/tools/libclang/Indexing.cpp
===
--- clang/tools/libclang/Indexing.cpp
+++ clang/tools/libclang/Indexing.cpp
@@ -617,9 +617,7 @@
   std::move(CInvok), CXXIdx->getPCHContainerOperations(), Diags,
   IndexAction.get(), UPtr, Persistent, CXXIdx->getClangResourcesPath(),
   OnlyLocalDecls, CaptureDiagnostics, PrecompilePreambleAfterNParses,
-  CacheCodeCompletionResults,
-  /*IncludeBriefCommentsInCodeCompletion=*/false,
-  /*UserFilesAreVolatile=*/true);
+  CacheCodeCompletionResults, /*UserFilesAreVolatile=*/true);
   if (DiagTrap.hasErrorOccurred() && CXXIdx->getDisplayDiagnostics())
 printDiagsToStderr(UPtr);
 
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1513,8 +1513,7 @@
 ASTUnit *Unit, bool Persistent, StringRef ResourceFilesPath,
 bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
 unsigned PrecompilePreambleAfterNParses, bool CacheCodeCompletionResults,
-bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile,
-std::unique_ptr *ErrAST) {
+bool UserFilesAreVolatile, std::unique_ptr *ErrAST) {
   assert(CI && "A CompilerInvocation is required");
 
   std::unique_ptr OwnAST;
@@ -1537,8 +1536,7 @@
 AST->PreambleRebuildCountdown = PrecompilePreambleAfterNParses;
   AST->TUKind = Action ? Action->getTranslationUnitKind() : TU_Complete;
   AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
-  AST->IncludeBriefCommentsInCodeCompletion
-= IncludeBriefCommentsInCodeCompletion;
+  AST->IncludeBriefCommentsInCodeCompletion = false;
 
   // Recover resources if we crash before exiting this method.
   llvm::CrashRecoveryContextCleanupRegistrar
Index: clang/include/clang/Frontend/ASTUnit.h
===
--- clang/include/clang/Frontend/ASTUnit.h
+++ clang/include/clang/Frontend/ASTUnit.h
@@ -757,7 +757,6 @@
   CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
   unsigned PrecompilePreambleAfterNParses = 0,
   bool CacheCodeCompletionResults = false,
-  bool IncludeBriefCommentsInCodeCompletion = false,
   bool UserFilesAreVolatile = false,
   std::unique_ptr *ErrAST = nullptr);
 


Index: clang/tools/libclang/Indexing.cpp
===
--- clang/tools/libclang/Indexing.cpp
+++ clang/tools/libclang/Indexing.cpp
@@ -617,9 +617,7 @@
   std::move(CInvok), CXXIdx->getPCHContainerOperations(), Diags,
   IndexAction.get(), UPtr, Persistent, CXXIdx->getClangResourcesPath(),
   OnlyLocalDecls, CaptureDiagnostics, PrecompilePreambleAfterNParses,
-  CacheCodeCompletionResults,
-  /*IncludeBriefCommentsInCodeCompletion=*/false,
-  /*UserFilesAreVolatile=*/true);
+  CacheCodeCompletionResults, /*UserFilesAreVolatile=*/true);
   if (DiagTrap.hasErrorOccurred() && CXXIdx->getDisplayDiagnostics())
 printDiagsToStderr(UPtr);
 
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1513,8 +1513,7 @@
 ASTUnit *Unit, bool Persistent, StringRef ResourceFilesPath,
 bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
 unsigned PrecompilePreambleAfterNParses, bool CacheCodeCompletionResults,
-bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile,
-std::unique_ptr *ErrAST) {
+bool UserFilesAreVolatile, std::unique_ptr *ErrAST) {
   assert(CI && "A CompilerInvocation is required");
 
   std::unique_ptr OwnAST;
@@ -1537,8 +1536,7 @@
 AST->PreambleRebuildCountdown = PrecompilePreambleAfterNParses;
   AST->TUKind = Action ? Action->getTranslationUnitKind() : TU_Complete;
   AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
-  AST->IncludeBriefCommentsInCodeCompletion
-= IncludeBriefCommentsInCodeCompletion;
+  AST->IncludeBriefCommentsInCodeCompletion = false;
 
   // Recover resources if we crash before exiting this method.
   llvm::CrashRecoveryContextCleanupRegistrar
Index: clang/include/clang/Frontend/ASTUnit.h
===
--- clang/include/clang/Frontend/ASTUnit.h
+++ clang/include/clang/Frontend/ASTUnit.h
@@ -757,7 +757,6 @@
   CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
   unsigned 

[PATCH] D91251: [VE] Support vector register in inline asm

2020-11-11 Thread Kazushi Marukawa 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 rG6e0ae20f3b98: [VE] Support vector register in inline asm 
(authored by kaz7).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91251

Files:
  clang/lib/Basic/Targets/VE.h
  clang/test/CodeGen/VE/ve-inline-asm.c


Index: clang/test/CodeGen/VE/ve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/VE/ve-inline-asm.c
@@ -0,0 +1,23 @@
+// REQUIRES: ve-registered-target
+// RUN: %clang_cc1 -triple ve-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+void r(long v) {
+  long b;
+  asm("lea %0, 256(%1)"
+  : "=r"(b)
+  : "r"(v));
+  // CHECK: %1 = call i64 asm "lea $0, 256($1)", "=r,r"(i64 %0)
+}
+
+void v(char *ptr, char *ptr2) {
+  typedef double __vr __attribute__((__vector_size__(2048)));
+  __vr a;
+  asm("vld %0, 8, %1"
+  : "=v"(a)
+  : "r"(ptr));
+  asm("vst %0, 8, %1"
+  :
+  : "v"(a), "r"(ptr2));
+  // CHECK: %1 = call <256 x double> asm "vld $0, 8, $1", "=v,r"(i8* %0)
+  // CHECK: call void asm sideeffect "vst $0, 8, $1", "v,r"(<256 x double> %2, 
i8* %3)
+}
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -160,6 +160,13 @@
 
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
+switch (*Name) {
+default:
+  return false;
+case 'v':
+  Info.setAllowsRegister();
+  return true;
+}
 return false;
   }
 


Index: clang/test/CodeGen/VE/ve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/VE/ve-inline-asm.c
@@ -0,0 +1,23 @@
+// REQUIRES: ve-registered-target
+// RUN: %clang_cc1 -triple ve-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+void r(long v) {
+  long b;
+  asm("lea %0, 256(%1)"
+  : "=r"(b)
+  : "r"(v));
+  // CHECK: %1 = call i64 asm "lea $0, 256($1)", "=r,r"(i64 %0)
+}
+
+void v(char *ptr, char *ptr2) {
+  typedef double __vr __attribute__((__vector_size__(2048)));
+  __vr a;
+  asm("vld %0, 8, %1"
+  : "=v"(a)
+  : "r"(ptr));
+  asm("vst %0, 8, %1"
+  :
+  : "v"(a), "r"(ptr2));
+  // CHECK: %1 = call <256 x double> asm "vld $0, 8, $1", "=v,r"(i8* %0)
+  // CHECK: call void asm sideeffect "vst $0, 8, $1", "v,r"(<256 x double> %2, i8* %3)
+}
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -160,6 +160,13 @@
 
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
+switch (*Name) {
+default:
+  return false;
+case 'v':
+  Info.setAllowsRegister();
+  return true;
+}
 return false;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6e0ae20 - [VE] Support vector register in inline asm

2020-11-11 Thread Kazushi Marukawa via cfe-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-11-12T06:18:35+09:00
New Revision: 6e0ae20f3b98b7bb5a44ced22c3da42a8fe5dbc8

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

LOG: [VE] Support vector register in inline asm

Support a vector register constraint in inline asm of clang.
Add a regression test also.

Reviewed By: simoll

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

Added: 
clang/test/CodeGen/VE/ve-inline-asm.c

Modified: 
clang/lib/Basic/Targets/VE.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/VE.h b/clang/lib/Basic/Targets/VE.h
index f863a0af0acb6..b8143747a38dd 100644
--- a/clang/lib/Basic/Targets/VE.h
+++ b/clang/lib/Basic/Targets/VE.h
@@ -160,6 +160,13 @@ class LLVM_LIBRARY_VISIBILITY VETargetInfo : public 
TargetInfo {
 
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
+switch (*Name) {
+default:
+  return false;
+case 'v':
+  Info.setAllowsRegister();
+  return true;
+}
 return false;
   }
 

diff  --git a/clang/test/CodeGen/VE/ve-inline-asm.c 
b/clang/test/CodeGen/VE/ve-inline-asm.c
new file mode 100644
index 0..b3ee14407c9b5
--- /dev/null
+++ b/clang/test/CodeGen/VE/ve-inline-asm.c
@@ -0,0 +1,23 @@
+// REQUIRES: ve-registered-target
+// RUN: %clang_cc1 -triple ve-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+void r(long v) {
+  long b;
+  asm("lea %0, 256(%1)"
+  : "=r"(b)
+  : "r"(v));
+  // CHECK: %1 = call i64 asm "lea $0, 256($1)", "=r,r"(i64 %0)
+}
+
+void v(char *ptr, char *ptr2) {
+  typedef double __vr __attribute__((__vector_size__(2048)));
+  __vr a;
+  asm("vld %0, 8, %1"
+  : "=v"(a)
+  : "r"(ptr));
+  asm("vst %0, 8, %1"
+  :
+  : "v"(a), "r"(ptr2));
+  // CHECK: %1 = call <256 x double> asm "vld $0, 8, $1", "=v,r"(i8* %0)
+  // CHECK: call void asm sideeffect "vst $0, 8, $1", "v,r"(<256 x double> %2, 
i8* %3)
+}



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


[PATCH] D90957: Frontend: Skip namespace around createVFSFromCompilerInvocation definition, NFC

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e9af3d47847: Frontend: Skip namespace around 
createVFSFromCompilerInvocation definition, NFC (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90957

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4024,16 +4024,15 @@
 #undef OPTION_WITH_MARSHALLING_FLAG
 }
 
-namespace clang {
-
 IntrusiveRefCntPtr
-createVFSFromCompilerInvocation(const CompilerInvocation ,
-DiagnosticsEngine ) {
+clang::createVFSFromCompilerInvocation(const CompilerInvocation ,
+   DiagnosticsEngine ) {
   return createVFSFromCompilerInvocation(CI, Diags,
  llvm::vfs::getRealFileSystem());
 }
 
-IntrusiveRefCntPtr createVFSFromCompilerInvocation(
+IntrusiveRefCntPtr
+clang::createVFSFromCompilerInvocation(
 const CompilerInvocation , DiagnosticsEngine ,
 IntrusiveRefCntPtr BaseFS) {
   if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
@@ -4061,5 +4060,3 @@
   }
   return Result;
 }
-
-} // namespace clang


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4024,16 +4024,15 @@
 #undef OPTION_WITH_MARSHALLING_FLAG
 }
 
-namespace clang {
-
 IntrusiveRefCntPtr
-createVFSFromCompilerInvocation(const CompilerInvocation ,
-DiagnosticsEngine ) {
+clang::createVFSFromCompilerInvocation(const CompilerInvocation ,
+   DiagnosticsEngine ) {
   return createVFSFromCompilerInvocation(CI, Diags,
  llvm::vfs::getRealFileSystem());
 }
 
-IntrusiveRefCntPtr createVFSFromCompilerInvocation(
+IntrusiveRefCntPtr
+clang::createVFSFromCompilerInvocation(
 const CompilerInvocation , DiagnosticsEngine ,
 IntrusiveRefCntPtr BaseFS) {
   if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
@@ -4061,5 +4060,3 @@
   }
   return Result;
 }
-
-} // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4e9af3d - Frontend: Skip namespace around createVFSFromCompilerInvocation definition, NFC

2020-11-11 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-11-11T16:15:06-05:00
New Revision: 4e9af3d47847c68b0ffa8a062ae029702b06214d

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

LOG: Frontend: Skip namespace around createVFSFromCompilerInvocation 
definition, NFC

Qualify definitions with `clang::` rather than opening/closing a namespace.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d3516f5bf1a4..b2ce88f6cf6b 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4024,16 +4024,15 @@ void CompilerInvocation::generateCC1CommandLine(
 #undef OPTION_WITH_MARSHALLING_FLAG
 }
 
-namespace clang {
-
 IntrusiveRefCntPtr
-createVFSFromCompilerInvocation(const CompilerInvocation ,
-DiagnosticsEngine ) {
+clang::createVFSFromCompilerInvocation(const CompilerInvocation ,
+   DiagnosticsEngine ) {
   return createVFSFromCompilerInvocation(CI, Diags,
  llvm::vfs::getRealFileSystem());
 }
 
-IntrusiveRefCntPtr createVFSFromCompilerInvocation(
+IntrusiveRefCntPtr
+clang::createVFSFromCompilerInvocation(
 const CompilerInvocation , DiagnosticsEngine ,
 IntrusiveRefCntPtr BaseFS) {
   if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
@@ -4061,5 +4060,3 @@ IntrusiveRefCntPtr 
createVFSFromCompilerInvocation(
   }
   return Result;
 }
-
-} // namespace clang



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


[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-11 Thread Sylvain Audi via Phabricator via cfe-commits
saudi updated this revision to Diff 304629.
saudi added a comment.

Removed use of ProxyFileSystem


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

https://reviews.llvm.org/D91204

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/Inputs/relative_directory.json
  clang/test/ClangScanDeps/relative_directory.cpp


Index: clang/test/ClangScanDeps/relative_directory.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/relative_directory.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %s %t.dir/Inputs/relative_directory_input1.cpp
+// RUN: cp %s %t.dir/Inputs/relative_directory_input2.cpp
+// RUN: touch %t.dir/Inputs/header.h
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/relative_directory.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck 
--check-prefixes=CHECK1,CHECK2 %s
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK2 %s
+
+#include 
+
+// CHECK1: relative_directory_input1.o:
+// CHECK1-NEXT: relative_directory_input1.cpp
+// CHECK1-NEXT: header.h
+
+// CHECK2: relative_directory_input2.o:
+// CHECK2-NEXT: relative_directory_input2.cpp
+// CHECK2-NEXT: header.h
Index: clang/test/ClangScanDeps/Inputs/relative_directory.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/relative_directory.json
@@ -0,0 +1,12 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -E Inputs/relative_directory_input1.cpp -IInputs",
+  "file": "DIR/Inputs/relative_directory_input1.cpp"
+},
+{
+  "directory": "DIR/Inputs",
+  "command": "clang -E relative_directory_input2.cpp -I.",
+  "file": "DIR/Inputs/relative_directory_input2.cpp"
+}
+]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -44,28 +44,6 @@
   DependencyConsumer 
 };
 
-/// A proxy file system that doesn't call `chdir` when changing the working
-/// directory of a clang tool.
-class ProxyFileSystemWithoutChdir : public llvm::vfs::ProxyFileSystem {
-public:
-  ProxyFileSystemWithoutChdir(
-  llvm::IntrusiveRefCntPtr FS)
-  : ProxyFileSystem(std::move(FS)) {}
-
-  llvm::ErrorOr getCurrentWorkingDirectory() const override {
-assert(!CWD.empty() && "empty CWD");
-return CWD;
-  }
-
-  std::error_code setCurrentWorkingDirectory(const Twine ) override {
-CWD = Path.str();
-return {};
-  }
-
-private:
-  std::string CWD;
-};
-
 /// A clang tool that runs the preprocessor in a mode that's optimized for
 /// dependency scanning for the given compiler invocation.
 class DependencyScanningAction : public tooling::ToolAction {
@@ -176,7 +154,8 @@
 : Format(Service.getFormat()) {
   DiagOpts = new DiagnosticOptions();
   PCHContainerOps = std::make_shared();
-  RealFS = new ProxyFileSystemWithoutChdir(llvm::vfs::getRealFileSystem());
+  RealFS = llvm::IntrusiveRefCntPtr(
+  llvm::vfs::createPhysicalFileSystem().release());
   if (Service.canSkipExcludedPPRanges())
 PPSkipMappings =
 std::make_unique();


Index: clang/test/ClangScanDeps/relative_directory.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/relative_directory.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %s %t.dir/Inputs/relative_directory_input1.cpp
+// RUN: cp %s %t.dir/Inputs/relative_directory_input2.cpp
+// RUN: touch %t.dir/Inputs/header.h
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/relative_directory.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck --check-prefixes=CHECK1,CHECK2 %s
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefix=CHECK2 %s
+
+#include 
+
+// CHECK1: relative_directory_input1.o:
+// CHECK1-NEXT: relative_directory_input1.cpp
+// CHECK1-NEXT: header.h
+
+// CHECK2: relative_directory_input2.o:
+// CHECK2-NEXT: relative_directory_input2.cpp
+// CHECK2-NEXT: header.h
Index: clang/test/ClangScanDeps/Inputs/relative_directory.json
===
--- /dev/null
+++ 

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

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

I have more review to do on this but have to run for a while and wanted to get 
you this feedback sooner rather than later.




Comment at: clang/docs/ClangPlugins.rst:119
+
+Attribute plugin to mark a virtual method as `call_super`, subclasses must 
call it
+in the overridden method.

Sorry, I was unclear, it should be *double* backticks around syntax elements 
like `call_super`, not single backticks.



Comment at: clang/docs/ClangPlugins.rst:122-123
+
+This example shows the possibility that attribute plugins combine with 
PluginASTAction
+in Clang can do same things which Java Annotations do.
+

Slight tweaking for grammar:

`This example shows that attribute plugins combined with PluginASTAction in 
Clang can do some of the same things which Java Annotations do.`

(with double backticks around `PluginASTAction`)



Comment at: clang/docs/ClangPlugins.rst:125
+
+Not like other attribute plugin examples, this one do not attached any 
attribute nodes
+to a declaration node, instead, saving the declaration addresses directly, 
which may

Slight tweaking for grammar:

```
Unlike the other attribute plugin examples, this one does not attach an 
attribute AST node to the declaration AST node. Instead, it keeps a separate 
list of attributed declarations, which may be faster than using 
Decl::getAttr() in some cases. The disadvantage of this approach is that the 
attribute is not part of the AST, which means that dumping the AST will lose 
the attribute information, pretty printing the AST won't write the attribute 
back out to source, and AST matchers will not be able to match against the 
attribute on the declaration.
```
(with double backticks around `Decl::getAttr()`)



Comment at: clang/docs/ClangPlugins.rst:117
+Defining CallSuperAttr
+===
+

aaron.ballman wrote:
> The number of underlines here looks off -- can you verify it's correct?
This still appears to be incorrect and will cause build errors for the 
documentation.



Comment at: clang/docs/ClangPlugins.rst:119
+
+Attribute plugin to mark a virtual method as call_super, sub-classes must call 
it in overridden the method.
+

psionic12 wrote:
> psionic12 wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > Should add backticks around `call_super` since it's syntax. Also, 
> > > > `sub-classes` should be `subclasses`.
> > > > 
> > > > "call it in overridden the method" -> "call it in the overridden method"
> > > There should be more explanation here about what concepts the example 
> > > demonstrates. For example, one interesting bit to me is that it shows how 
> > > you can add a custom attribute that's useful even if it does not generate 
> > > an AST node for the attribute.
> > "how you can add a custom attribute that's useful even if it does not 
> > generate an AST node for the attribute", do you mean I should add an 
> > Annotation Attribute object even I don't use it? So that when someone dumps 
> > the AST, the `call_super` attribute will show?
> > 
> > Or do you mean to explain the inner implementation of how could the 
> > RecursiveASTVisitor knows the declaration is marked as `call_super`, even 
> > if I didn't add any extra attribute nodes to this declaration node?
> I got you point, please ignore the comment above.
> 
> Since this is an example, I should mention more about this example itself 
> rather than how to use this plugin, right?
> Since this is an example, I should mention more about this example itself 
> rather than how to use this plugin, right?

Exactly!



Comment at: clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp:63
+DiagnosticsEngine::Warning,
+"%0 is marked as call_super but override method %1 does not call it");
+NotePreviousCallSuperDeclaration = Diags.getCustomDiagID(

psionic12 wrote:
> aaron.ballman wrote:
> > Should put single quotes around `call_super` as it's a syntactic element.
> > 
> > I'm not certain that %0 and %1 are necessary because the overridden methods 
> > will have the same names. I think you can drop the %1 and rely on the note 
> > to point out where the overridden method lives.
> > 
> About the '%0' and '%1' problem, same as the comment about "fullName()" 
> function, since the overridden methods have the same name, I want use 
> "class_name::method_name" to distinguish between these methods to make users 
> clear.
> 
> It would very nice if you could help to come up with a decent warning message 
> which is better than this, I tried some but none of them give a 
> compiler-warning-style feeling... 
> It would very nice if you could help to come up with a decent warning message 
> which is better than this, I tried some but none of them give a 
> compiler-warning-style feeling...

How about:

`virtual function %q0 is 

[PATCH] D91147: AArch64: classify Triple::aarch64_32 as AArch64

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:1066
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
-  getTriple().isAArch64() || getTriple().isRISCV())
+  (getTriple().isAArch64() && getTriple().isArch64Bit()) ||
+  getTriple().isRISCV())

Is there a short-form we'd want for this?

Here are two ideas:
```
// getTriple().isAArch64_64() and getTriple().isAArch64_32()
bool Triple::isAArch64_64() { return isAArch64() && isArch64Bit(); }
bool Triple::isAArch64_32() { return isAArch64() && isArch32Bit(); }

// getTriple().isAArch64(64) and getTriple().isAArch64(32)
bool Triple::isAArch64(int Bits) {
  assert(Bits == 32 || Bits == 64);
  if (!isAArch64())
return false;
  return isArch64Bit() ? Bits == 64 : Bits == 32;
}
```
Or do you think it's better as-is?



Comment at: llvm/include/llvm/ADT/Triple.h:715
 
   /// Tests whether the target is AArch64 (little and big endian).
   bool isAArch64() const {

Should the comment be changed?


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

https://reviews.llvm.org/D91147

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


[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

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



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:1092
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{isSet}}
+}

There's not a whole lot of context for FileCheck to determine if it's been 
correctly applied or not (same below) -- for instance, won't this pass even if 
no changes are applied because FileCheck is still going to find `isSet` in the 
file?


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

https://reviews.llvm.org/D91037

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


[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D91204#2387050 , @saudi wrote:

> Updated the patch.
>
> Followed suggestion from @dexonsmith. Indeed it simplifies the code.
> Also, improved the test, to also test with -j 2

A couple of more comments. @arphaman , can you confirm this is a good direction?




Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp:158-160
+  llvm::IntrusiveRefCntPtr PhysicalFileSystem(
+  llvm::vfs::createPhysicalFileSystem().release());
+  RealFS = new llvm::vfs::ProxyFileSystem(PhysicalFileSystem);

I think this can just be:
```
RealFS = llvm::vfs::createPhysicalFileSystem();
```
The `ProxyFileSystem` wrapper is a convenience for building other file systems; 
it doesn't do anything on its own IIRC.



Comment at: clang/test/ClangScanDeps/relative_directory.cpp:12-13
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK1 %s

Can you use `CHECK-DAG` for this?
https://www.llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive



Comment at: clang/test/ClangScanDeps/relative_directory.cpp:19-25
+// CHECK1: relative_directory_input1.o:
+// CHECK1-NEXT: relative_directory_input1.cpp
+// CHECK1-NEXT: header.h
+
+// CHECK2: relative_directory_input2.o:
+// CHECK2-NEXT: relative_directory_input2.cpp
+// CHECK2-NEXT: header.h

I.e., maybe this can be:
```
// CHECK-DAG: relative_directory_input1.o:
// CHECK-DAG:   relative_directory_input1.cpp
// CHECK-DAG:   header.h

// CHECK-DAG: relative_directory_input2.o:
// CHECK-DAG:   relative_directory_input2.cpp
// CHECK-DAG:   header.h
```



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

https://reviews.llvm.org/D91204

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


[PATCH] D82860: Port ObjCMTAction to new option parsing system

2020-11-11 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Reverted in f917356f9ce0 
 ; I 
suspect a `static constexpr` in a class missing a definition out of class 
(required pre-c++17).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82860

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


[clang] f917356 - Revert "[clang][cli] Port ObjCMTAction to new option parsing system"

2020-11-11 Thread Mehdi Amini via cfe-commits

Author: Mehdi Amini
Date: 2020-11-11T20:01:03Z
New Revision: f917356f9ce026f9be9972b8c75cd3ba00e43497

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

LOG: Revert "[clang][cli] Port ObjCMTAction to new option parsing system"

This reverts commit 09248a5d25bb1c9f357247fa3da8fbe4470e9c67.

Some builds are broken. I suspect a `static constexpr` in a class missing a
definition out of class (required pre-c++17).

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/unittests/Option/Opts.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 05a218ca09f0..6df4a0222484 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -340,53 +340,36 @@ def ccc_objcmt_migrate : Separate<["-"], 
"ccc-objcmt-migrate">,
   InternalDriverOpt,
   HelpText<"Apply modifications and produces temporary files to migrate to "
"modern ObjC syntax">;
-
 def objcmt_migrate_literals : Flag<["-"], "objcmt-migrate-literals">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC literals">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Literals">;
+  HelpText<"Enable migration to modern ObjC literals">;
 def objcmt_migrate_subscripting : Flag<["-"], "objcmt-migrate-subscripting">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC subscripting">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Subscripting">;
+  HelpText<"Enable migration to modern ObjC subscripting">;
 def objcmt_migrate_property : Flag<["-"], "objcmt-migrate-property">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC property">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Property">;
+  HelpText<"Enable migration to modern ObjC property">;
 def objcmt_migrate_all : Flag<["-"], "objcmt-migrate-all">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_MigrateDecls">;
+  HelpText<"Enable migration to modern ObjC">;
 def objcmt_migrate_readonly_property : Flag<["-"], 
"objcmt-migrate-readonly-property">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC readonly property">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_ReadonlyProperty">;
+  HelpText<"Enable migration to modern ObjC readonly property">;
 def objcmt_migrate_readwrite_property : Flag<["-"], 
"objcmt-migrate-readwrite-property">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC readwrite property">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_ReadwriteProperty">;
+  HelpText<"Enable migration to modern ObjC readwrite property">;
 def objcmt_migrate_property_dot_syntax : Flag<["-"], 
"objcmt-migrate-property-dot-syntax">, Flags<[CC1Option]>,
-  HelpText<"Enable migration of setter/getter messages to property-dot 
syntax">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_PropertyDotSyntax">;
+  HelpText<"Enable migration of setter/getter messages to property-dot 
syntax">;
 def objcmt_migrate_annotation : Flag<["-"], "objcmt-migrate-annotation">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to property and method annotations">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Annotation">;
+  HelpText<"Enable migration to property and method annotations">;
 def objcmt_migrate_instancetype : Flag<["-"], "objcmt-migrate-instancetype">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to infer instancetype for method result type">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Instancetype">;
+  HelpText<"Enable migration to infer instancetype for method result type">;
 def objcmt_migrate_nsmacros : Flag<["-"], "objcmt-migrate-ns-macros">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_NsMacros">;
+  HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">;
 def objcmt_migrate_protocol_conformance : Flag<["-"], 
"objcmt-migrate-protocol-conformance">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to add protocol conformance on classes">,
-  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_ProtocolConformance">;
+  HelpText<"Enable 

[PATCH] D89158: [NewPM] Provide method to run all pipeline callbacks, used for -O0

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

In D89158#2388991 , @Meinersbur wrote:

> Could you try configuring LLVM with `-DLLVM_BYE_LINK_INTO_TOOLS=ON`? I assume 
> the test will break because it unconditionally adds a FunctionPass.

Thanks, I wasn't aware of this. Looks like other `opt -passes='default'` 
tests also look at if it present or not.

The following already fail with `-DLLVM_BYE_LINK_INTO_TOOLS=ON`

  LLVM :: Other/opt-O0-pipeline.ll
  LLVM :: Other/opt-O2-pipeline.ll
  LLVM :: Other/opt-O3-pipeline-enable-matrix.ll
  LLVM :: Other/opt-O3-pipeline.ll
  LLVM :: Other/opt-Os-pipeline.ll

these are all legacy PM related.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89158

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


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

2020-11-11 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 304616.
Xiangling_L added a comment.

Add testcases to both CodeGen and CodeGenCXX folder;


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

[PATCH] D89158: [NewPM] Provide method to run all pipeline callbacks, used for -O0

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

fix tests when Bye plugin is present


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89158

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/bpf-O0.c
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/CodeGen/BPF/optnone-2.ll
  llvm/test/Other/new-pm-O0-ep-callbacks.ll

Index: llvm/test/Other/new-pm-O0-ep-callbacks.ll
===
--- /dev/null
+++ llvm/test/Other/new-pm-O0-ep-callbacks.ll
@@ -0,0 +1,24 @@
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-late-loop-optimizations=no-op-loop -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-loop-optimizer-end=no-op-loop -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-scalar-optimizer-late=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-cgscc-optimizer-late=no-op-cgscc -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-vectorizer-start=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-pipeline-start=no-op-module -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-optimizer-last=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+
+; CHECK: Running pass: NoOp
+
+declare void @bar() local_unnamed_addr
+
+define void @foo(i32 %n) local_unnamed_addr {
+entry:
+  br label %loop
+loop:
+  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
+  %iv.next = add i32 %iv, 1
+  tail call void @bar()
+  %cmp = icmp eq i32 %iv, %n
+  br i1 %cmp, label %exit, label %loop
+exit:
+  ret void
+}
Index: llvm/test/CodeGen/BPF/optnone-2.ll
===
--- llvm/test/CodeGen/BPF/optnone-2.ll
+++ llvm/test/CodeGen/BPF/optnone-2.ll
@@ -1,5 +1,5 @@
 ; RUN: opt < %s -passes='default' | llc -march=bpfel -filetype=asm -o /dev/null -
-; TODO: add -O0 once that's supported
+; RUN: opt < %s -passes='default' | llc -march=bpfel -filetype=asm -o /dev/null -
 
 ; IR generated by
 ; $ cat /tmp/a.c
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1661,6 +1661,56 @@
   return MPM;
 }
 
+void PassBuilder::runRegisteredEPCallbacks(ModulePassManager ,
+   OptimizationLevel Level,
+   bool DebugLogging) {
+  assert(Level == OptimizationLevel::O0 &&
+ "runRegisteredEPCallbacks should only be used with O0");
+  for (auto  : PipelineStartEPCallbacks)
+C(MPM, Level);
+  if (!LateLoopOptimizationsEPCallbacks.empty()) {
+LoopPassManager LPM(DebugLogging);
+for (auto  : LateLoopOptimizationsEPCallbacks)
+  C(LPM, Level);
+if (!LPM.isEmpty()) {
+  MPM.addPass(createModuleToFunctionPassAdaptor(
+  createFunctionToLoopPassAdaptor(std::move(LPM;
+}
+  }
+  if (!LoopOptimizerEndEPCallbacks.empty()) {
+LoopPassManager LPM(DebugLogging);
+for (auto  : LoopOptimizerEndEPCallbacks)
+  C(LPM, Level);
+if (!LPM.isEmpty()) {
+  MPM.addPass(createModuleToFunctionPassAdaptor(
+  createFunctionToLoopPassAdaptor(std::move(LPM;
+}
+  }
+  if (!ScalarOptimizerLateEPCallbacks.empty()) {
+FunctionPassManager FPM(DebugLogging);
+for (auto  : ScalarOptimizerLateEPCallbacks)
+  C(FPM, Level);
+if (!FPM.isEmpty())
+  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+  }
+  if (!CGSCCOptimizerLateEPCallbacks.empty()) {
+CGSCCPassManager CGPM(DebugLogging);
+for (auto  : CGSCCOptimizerLateEPCallbacks)
+  C(CGPM, Level);
+if (!CGPM.isEmpty())
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+  }
+  if (!VectorizerStartEPCallbacks.empty()) {
+FunctionPassManager FPM(DebugLogging);
+for (auto  : VectorizerStartEPCallbacks)
+  C(FPM, Level);
+if (!FPM.isEmpty())
+  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+  }
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);
+}
+
 AAManager PassBuilder::buildDefaultAAPipeline() {
   AAManager AA;
 
@@ -2243,6 +2293,8 @@
 MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
   }
 
+  runRegisteredEPCallbacks(MPM, L, DebugLogging);
+
   // Do nothing else at all!
   return Error::success();
 }
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- 

[clang-tools-extra] 956c899 - [clangd] Fix serialization error check.

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

Author: Sam McCall
Date: 2020-11-11T20:46:04+01:00
New Revision: 956c899296dc19593c66b06af87e60564dff18e0

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

LOG: [clangd] Fix serialization error check.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index 40bca7b7d4d5..dcea8e902fe4 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -499,10 +499,10 @@ llvm::Expected readRIFF(llvm::StringRef 
Data) {
   }
   if (Chunks.count("cmdl")) {
 Reader CmdReader(Chunks.lookup("cmdl"));
-if (CmdReader.err())
-  return error("malformed or truncated commandline section");
 InternedCompileCommand Cmd =
 readCompileCommand(CmdReader, Strings->Strings);
+if (CmdReader.err())
+  return error("malformed or truncated commandline section");
 Result.Cmd.emplace();
 Result.Cmd->Directory = std::string(Cmd.Directory);
 Result.Cmd->CommandLine.reserve(Cmd.CommandLine.size());



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


[PATCH] D91253: [Matrix] Update mangling to use paramterized vendor ext type syntax.

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

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91253

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


[PATCH] D83025: [clang] Include type specifiers in typo correction when checking isCXXDeclarationSpecifiers.

2020-11-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D83025#2389140 , @aganea wrote:

> We're seeing the same issue mentionned in PR45498 
> , but with the repro below. `git 
> bisect` points to this patch. Could anyone please possibly confirm? Simply 
> build clang with `-DLLVM_ENABLE_ASSERTIONS=ON`.
>
>   // compile with: clang-cl /c a.cpp
>   template < a > struct b;
>   template < bool a, class > using c = b< a >;
>   template < class > using d = void ;
>   template < class, class, class = void >
>   bool e template < class f, class g >
>   bool e< f, g, d< decltype(h(g())) > > template < class f, class g >
>   void i(f, g ) {
> e< f, g >
>   }
>   template < class _BidIt2, c< e< _BidIt, _BidIt2 >, int > = 0 >
>   void h(_BidIt2) short do_tolower__Last {
> i(do_tolower__First, do_tolower__Last)
>   }

thanks for the testcase. I'm not sure the patch is the root cause -- from the 
Bugzilla thread, the issue was reported in April which is prior to this patch.

btw, the issue seems to be gone on the trunk, I don't reproduce them with clang 
building from the trunk, I guess it might be fixed by some patches after 
llvm-11.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83025

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


[PATCH] D91253: [Matrix] Update mangling to use paramterized vendor ext type syntax.

2020-11-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked an inline comment as done.
fhahn added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:3523
   mangleType(T->getElementType());
+  Out << "I";
 }

rjmccall wrote:
> Your `I`s and `E`s are backwards.
Argh, used different orders for comment & code :( Should be fixed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91253

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


[PATCH] D91253: [Matrix] Update mangling to use paramterized vendor ext type syntax.

2020-11-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 304605.
fhahn added a comment.

Update comment and fix I and E order


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91253

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/matrix-type-builtins.cpp
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/CodeGenCXX/matrix-type.cpp

Index: clang/test/CodeGenCXX/matrix-type.cpp
===
--- clang/test/CodeGenCXX/matrix-type.cpp
+++ clang/test/CodeGenCXX/matrix-type.cpp
@@ -6,7 +6,7 @@
 // CHECK: %struct.Matrix = type { i8, [12 x float], float }
 
 void load_store(dx5x5_t *a, dx5x5_t *b) {
-  // CHECK-LABEL:  define void @_Z10load_storePU11matrix_typeLm5ELm5EdS0_(
+  // CHECK-LABEL:  define void @_Z10load_storePu11matrix_typeILm5ELm5EdES0_(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [25 x double]*, align 8
   // CHECK-NEXT:%b.addr = alloca [25 x double]*, align 8
@@ -26,7 +26,7 @@
 typedef float fx3x3_t __attribute__((matrix_type(3, 3)));
 
 void parameter_passing(fx3x3_t a, fx3x3_t *b) {
-  // CHECK-LABEL: define void @_Z17parameter_passingU11matrix_typeLm3ELm3EfPS_(
+  // CHECK-LABEL: define void @_Z17parameter_passingu11matrix_typeILm3ELm3EfEPS_(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [9 x float], align 4
   // CHECK-NEXT:%b.addr = alloca [9 x float]*, align 8
@@ -42,7 +42,7 @@
 }
 
 fx3x3_t return_matrix(fx3x3_t *a) {
-  // CHECK-LABEL: define <9 x float> @_Z13return_matrixPU11matrix_typeLm3ELm3Ef(
+  // CHECK-LABEL: define <9 x float> @_Z13return_matrixPu11matrix_typeILm3ELm3EfE(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [9 x float]*, align 8
   // CHECK-NEXT:store [9 x float]* %a, [9 x float]** %a.addr, align 8
@@ -215,42 +215,42 @@
   // CHECK-NEXT:%m4 = alloca [144 x float], align 4
   // CHECK-NEXT:%v = alloca %struct.selector.3, align 1
   // CHECK-NEXT:%undef.agg.tmp4 = alloca %struct.selector.3, align 1
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi3EERU11matrix_typeXLm10EEXT0_ET_([120 x i32]* nonnull align 4 dereferenceable(480) %m0)
-  // CHECK-NEXT:call void @_Z10use_matrixIiE8selectorILi2EERU11matrix_typeLm10ELm10ET_([100 x i32]* nonnull align 4 dereferenceable(400) %m1)
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi1EERU11matrix_typeXT0_EXLm10EET_([120 x i32]* nonnull align 4 dereferenceable(480) %m2)
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12ELm12EE8selectorILi0EERU11matrix_typeXT0_EXT1_ET_([144 x i32]* nonnull align 4 dereferenceable(576) %m3)
-  // CHECK-NEXT:call void @_Z10use_matrixILm12ELm12EE8selectorILi4EERU11matrix_typeXT_EXT0_Ef([144 x float]* nonnull align 4 dereferenceable(576) %m4)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeIXLm10EEXT0_ET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m0)
+  // CHECK-NEXT:call void @_Z10use_matrixIiE8selectorILi2EERu11matrix_typeILm10ELm10ET_E([100 x i32]* nonnull align 4 dereferenceable(400) %m1)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi1EERu11matrix_typeIXT0_EXLm10EET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m2)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12ELm12EE8selectorILi0EERu11matrix_typeIXT0_EXT1_ET_E([144 x i32]* nonnull align 4 dereferenceable(576) %m3)
+  // CHECK-NEXT:call void @_Z10use_matrixILm12ELm12EE8selectorILi4EERu11matrix_typeIXT_EXT0_EfE([144 x float]* nonnull align 4 dereferenceable(576) %m4)
   // CHECK-NEXT:ret void
 
-  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiLm12EE8selectorILi3EERU11matrix_typeXLm10EEXT0_ET_([120 x i32]* nonnull align 4 dereferenceable(480) %m)
+  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeIXLm10EEXT0_ET_E([120 x i32]* nonnull align 4 dereferenceable(480) %m)
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%m.addr = alloca [120 x i32]*, align 8
   // CHECK-NEXT:store [120 x i32]* %m, [120 x i32]** %m.addr, align 8
   // CHECK-NEXT:call void @llvm.trap()
   // CHECK-NEXT:unreachable
 
-  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiE8selectorILi2EERU11matrix_typeLm10ELm10ET_([100 x i32]* nonnull align 4 dereferenceable(400) %m)
+  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiE8selectorILi2EERu11matrix_typeILm10ELm10ET_E([100 x i32]* nonnull align 4 dereferenceable(400) %m)
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%m.addr = alloca [100 x i32]*, align 8
   // CHECK-NEXT:store [100 x i32]* %m, [100 x i32]** %m.addr, align 8
   // CHECK-NEXT:call void @llvm.trap()
   // CHECK-NEXT:unreachable
 
-  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiLm12EE8selectorILi1EERU11matrix_typeXT0_EXLm10EET_([120 x i32]* nonnull align 4 dereferenceable(480) %m)
+  // CHECK-LABEL: define 

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

2020-11-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 304604.
yaxunl edited the summary of this revision.
yaxunl added a comment.

rename faststd to fast-honor-pragmas


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

https://reviews.llvm.org/D90174

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGenCUDA/fp-contract.cu
  clang/test/Driver/autocomplete.c

Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -66,6 +66,7 @@
 // FNOSANICOVERALL-NEXT: trace-pc-guard
 // RUN: %clang --autocomplete=-ffp-contract= | FileCheck %s -check-prefix=FFPALL
 // FFPALL: fast
+// FFPALL-NEXT: fast-honor-pragmas 
 // FFPALL-NEXT: off
 // FFPALL-NEXT: on
 // RUN: %clang --autocomplete=-flto= | FileCheck %s -check-prefix=FLTOALL
Index: clang/test/CodeGenCUDA/fp-contract.cu
===
--- clang/test/CodeGenCUDA/fp-contract.cu
+++ clang/test/CodeGenCUDA/fp-contract.cu
@@ -1,32 +1,298 @@
-// REQUIRES: x86-registered-target
-// REQUIRES: nvptx-registered-target
+// REQUIRES: x86-registered-target, nvptx-registered-target, amdgpu-registered-target
 
-// By default we should fuse multiply/add into fma instruction.
+// By default CUDA uses -ffp-contract=fast, HIP uses -ffp-contract=fast-honor-pragmas.
+// we should fuse multiply/add into fma instruction.
+// In IR, fmul/fadd instructions with contract flag are emitted.
+// In backend
+//nvptx -  assumes fast fp fuse option, which fuses
+// mult/add insts disregarding contract flag and
+// llvm.fmuladd intrinsics.
+//amdgcn - assumes standard fp fuse option, which only
+// fuses mult/add insts with contract flag and
+// llvm.fmuladd intrinsics.
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefixes=COMMON,NV-ON %s
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -S \
+// RUN:   -target-cpu gfx906 -disable-llvm-passes -o - -x hip %s \
+// RUN:   | FileCheck -check-prefixes=COMMON,AMD-ON %s
 // RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
-// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix ENABLED %s
+// RUN:   -O3 -o - %s \
+// RUN:   | FileCheck -check-prefixes=COMMON,NV-OPT-FAST %s
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -S \
+// RUN:   -O3 -target-cpu gfx906 -o - -x hip %s \
+// RUN:   | FileCheck -check-prefixes=COMMON,AMD-OPT-FASTSTD %s
+
+// Check separate compile/backend steps corresponding to -save-temps.
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -O3 -disable-llvm-passes -target-cpu gfx906 -o %t.ll -x hip %s
+// RUN: cat %t.ll  | FileCheck -check-prefixes=COMMON,AMD-OPT-FAST-IR %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -S \
+// RUN:   -O3 -target-cpu gfx906 -o - -x ir %t.ll \
+// RUN:   | FileCheck -check-prefixes=COMMON,AMD-OPT-FASTSTD %s
 
 // Explicit -ffp-contract=fast
+// In IR, fmul/fadd instructions with contract flag are emitted.
+// In backend
+//nvptx/amdgcn - assumes fast fp fuse option, which fuses
+//   mult/add insts disregarding contract flag and
+//   llvm.fmuladd intrinsics.
+
 // RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
 // RUN:   -ffp-contract=fast -disable-llvm-passes -o - %s \
-// RUN:   | FileCheck -check-prefix ENABLED %s
+// RUN:   | FileCheck -check-prefixes=COMMON,NV-ON %s
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -S \
+// RUN:   -target-cpu gfx906 -disable-llvm-passes -o - -x hip %s \
+// RUN:   -ffp-contract=fast \
+// RUN:   | FileCheck -check-prefixes=COMMON,AMD-ON %s
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -O3 -o - %s \
+// RUN:   -ffp-contract=fast \
+// RUN:   | FileCheck -check-prefixes=COMMON,NV-OPT-FAST %s
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -S \
+// RUN:   -O3 -target-cpu gfx906 -o - -x hip %s \
+// RUN:   -ffp-contract=fast \
+// RUN:   | FileCheck -check-prefixes=COMMON,AMD-OPT-FAST %s
+
+// Check separate compile/backend steps corresponding to -save-temps.
+// When input is IR, -ffp-contract has no effect. Backend uses default
+// default FP fuse option.
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -ffp-contract=fast \
+// RUN:   -O3 -disable-llvm-passes -target-cpu gfx906 -o %t.ll -x hip %s
+// RUN: cat %t.ll  | FileCheck -check-prefixes=COMMON,AMD-OPT-FAST-IR %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -S \
+// RUN:   -O3 -target-cpu gfx906 -o - -x ir %t.ll 

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

2020-11-11 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added a comment.

In D90892#2386908 , @aaron.ballman 
wrote:

> I think this generally seems reasonable, but I'm far from an AIX expert so 
> you should wait a few days in case other reviewers have feedback.

Thanks for reviews. And @sfertile has kindly offered a further review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90892

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


[PATCH] D91258: [clangd] Sanity-check array sizes read from disk before allocating them.

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 304578.
sammccall marked 2 inline comments as done.
sammccall added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91258

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
@@ -7,15 +7,21 @@
 //===--===//
 
 #include "Headers.h"
+#include "RIFF.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "support/Logger.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#ifdef LLVM_ON_UNIX
+#include 
+#endif
 
-using ::testing::_;
-using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -297,6 +303,86 @@
 EXPECT_NE(SerializedCmd.Output, Cmd.Output);
   }
 }
+
+#if LLVM_ON_UNIX // rlimit is part of POSIX
+class ScopedMemoryLimit {
+  struct rlimit OriginalLimit;
+  bool Succeeded = false;
+
+public:
+  ScopedMemoryLimit(rlim_t Bytes) {
+if (!getrlimit(RLIMIT_AS, )) {
+  struct rlimit NewLimit = OriginalLimit;
+  NewLimit.rlim_cur = Bytes;
+  Succeeded = !setrlimit(RLIMIT_AS, );
+}
+if (!Succeeded)
+  log("Failed to set rlimit");
+  }
+
+  ~ScopedMemoryLimit() {
+if (Succeeded)
+  setrlimit(RLIMIT_AS, );
+  }
+};
+#else
+class ScopedMemoryLimit {
+public:
+  ScopedMemoryLimit(unsigned Bytes) { log("rlimit unsupported"); }
+};
+#endif
+
+// 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) {
+  // This test is tricky because we need to construct a subtly invalid file.
+  // 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 and find the `srcs` chunk we're going to corrupt.
+  auto Parsed = riff::readFile(Serialized);
+  ASSERT_FALSE(!Parsed) << Parsed.takeError();
+  auto Srcs = llvm::find_if(Parsed->Chunks, [](riff::Chunk C) {
+return C.ID == riff::fourCC("srcs");
+  });
+  ASSERT_NE(Srcs, Parsed->Chunks.end());
+
+  // Srcs consists of a sequence of IncludeGraphNodes. In our case, just one.
+  // The node has:
+  //  - 1 byte: flags (1)
+  //  - varint(stringID): URI
+  //  - 8 byte: file digest
+  //  - varint: DirectIncludes.length
+  //  - repeated varint(stringID): DirectIncludes
+  // We want to set DirectIncludes.length to a huge number.
+  // The offset isn't trivial to find, so we use the file digest.
+  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
+  unsigned Pos = Srcs->Data.find_first_of(FileDigest);
+  ASSERT_NE(Pos, StringRef::npos) << "Couldn't locate file digest";
+  Pos += FileDigest.size();
+
+  // Varints are little-endian base-128 numbers, where the top-bit of each byte
+  // indicates whether there are more. 8fff7f -> 0x.
+  std::string CorruptSrcs =
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+   "some_random_garbage")
+  .str();
+  Srcs->Data = CorruptSrcs;
+
+  // 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_EQ(llvm::toString(CorruptParsed.takeError()),
+"malformed or truncated include uri");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -16,6 +16,7 @@
 #include "support/Trace.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
@@ -104,6 +105,20 @@
 llvm::StringRef Raw = consume(SymbolID::RawSize); // short if truncated.
 return LLVM_UNLIKELY(err()) ? SymbolID() : SymbolID::fromRaw(Raw);
   }
+
+  // Read a varint (as consumeVar) and resize the container accordingly.

[PATCH] D82860: Port ObjCMTAction to new option parsing system

2020-11-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D82860#2388916 , @jpienaar wrote:

> This seems to breaking clang-5 builds:
>
> utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptParserEmitter.cpp.o: In function 
> `llvm::EmitOptParser(llvm::RecordKeeper&, llvm::raw_ostream&)':
> /var/lib/buildkite-agent/builds/buildkite-69fdf6c495-wt2bd-1/mlir/mlir-core/llvm/utils/TableGen/OptParserEmitter.cpp:(.text._ZN4llvm13EmitOptParserERNS_12RecordKeeperERNS_11raw_ostreamE+0x148a):
>  undefined reference to `MarshallingInfo::MacroName'
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
>
> (https://buildkite.com/mlir/mlir-core/builds/9273#ae602c1f-8c21-4ac6-90bb-99c9a3ae473e)

Jan is in Europe and may not see this until tomorrow; if you need this fixed 
sooner you might want to revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82860

___
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-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Probably should be pluralized for consistency, `fast-honor-pragmas`, but yeah, 
that's fine with me.


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] D91103: [tooling] Add support for fixits that indicate code will need reformatting

2020-11-11 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 304574.
njames93 marked an inline comment as done.
njames93 added a comment.

Address nit by replacing optional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91103

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Tooling/Core/Replacement.h
  clang/lib/Frontend/DiagnosticRenderer.cpp
  clang/lib/Frontend/Rewrite/FixItRewriter.cpp
  clang/lib/Tooling/Core/Replacement.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1167,9 +1167,10 @@
   // This is cobbed from clang::Rewrite::FixItRewriter.
   if (fixit.CodeToInsert.empty()) {
 if (fixit.InsertFromRange.isValid()) {
-  commit.insertFromRange(fixit.RemoveRange.getBegin(),
- fixit.InsertFromRange, /*afterToken=*/false,
- fixit.BeforePreviousInsertions);
+  if (!fixit.isReformatFixit())
+commit.insertFromRange(fixit.RemoveRange.getBegin(),
+   fixit.InsertFromRange, /*afterToken=*/false,
+   fixit.BeforePreviousInsertions);
   return;
 }
 commit.remove(fixit.RemoveRange);
Index: clang/lib/Tooling/Core/Replacement.cpp
===
--- clang/lib/Tooling/Core/Replacement.cpp
+++ clang/lib/Tooling/Core/Replacement.cpp
@@ -22,6 +22,7 @@
 #include "clang/Rewrite/Core/RewriteBuffer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -42,32 +43,57 @@
 
 static const char * const InvalidLocation = "";
 
-Replacement::Replacement() : FilePath(InvalidLocation) {}
+FileRange::FileRange() : FilePath(InvalidLocation), RangeInFile(0, 0) {}
+
+FileRange::FileRange(StringRef FilePath, Range RangeInFile)
+: FilePath(FilePath), RangeInFile(RangeInFile) {}
+FileRange::FileRange(StringRef FilePath, unsigned Offset, unsigned Length)
+: FileRange(FilePath, Range(Offset, Length)) {}
+
+FileRange::FileRange(const SourceManager , SourceLocation Start,
+ unsigned Length) {
+  setFromSourceLocation(Sources, Start, Length);
+}
+
+FileRange::FileRange(const SourceManager , const CharSourceRange ,
+ const LangOptions ) {
+  setFromSourceRange(Sources, Range, LangOpts);
+}
+
+bool FileRange::isValid() const { return FilePath != InvalidLocation; }
+
+void FileRange::setFromSourceLocation(const SourceManager ,
+  SourceLocation Start, unsigned Length) {
+  const std::pair DecomposedLocation =
+  Sources.getDecomposedLoc(Start);
+  const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
+  this->FilePath = std::string(Entry ? Entry->getName() : InvalidLocation);
+  this->RangeInFile = {DecomposedLocation.second, Length};
+}
+
+Replacement::Replacement() : ReplacementRange() {}
+
+Replacement::Replacement(FileRange FileRange, StringRef ReplacementText)
+: ReplacementRange(FileRange), ReplacementText(ReplacementText) {}
 
 Replacement::Replacement(StringRef FilePath, unsigned Offset, unsigned Length,
  StringRef ReplacementText)
-: FilePath(std::string(FilePath)), ReplacementRange(Offset, Length),
-  ReplacementText(std::string(ReplacementText)) {}
+: Replacement(FileRange(FilePath, Offset, Length), ReplacementText) {}
 
 Replacement::Replacement(const SourceManager , SourceLocation Start,
- unsigned Length, StringRef ReplacementText) {
-  setFromSourceLocation(Sources, Start, Length, ReplacementText);
-}
+ unsigned Length, StringRef ReplacementText)
+: Replacement(FileRange(Sources, Start, Length), ReplacementText) {}
 
 Replacement::Replacement(const SourceManager ,
  const CharSourceRange ,
- StringRef ReplacementText,
- const LangOptions ) {
-  setFromSourceRange(Sources, Range, ReplacementText, LangOpts);
-}
+ StringRef ReplacementText, const LangOptions )
+: Replacement(FileRange(Sources, Range, LangOpts), ReplacementText) {}
 
-bool Replacement::isApplicable() const {
-  return FilePath != InvalidLocation;
-}
+bool Replacement::isApplicable() const { return 

[PATCH] D90956: [clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.

2020-11-11 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

The tests look good to me FWIW.  The Sema side is already covered by 
`Sema/attr-arm-sve-vector-bits.c` and the patch seems to test for the important 
ABI bits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90956

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

In D90174#2389269 , @tra wrote:

> In D90174#2387518 , @scanon wrote:
>
>> Strictly speaking, fp-contract=fast probably should have been a separate 
>> flag entirely (since there's no _expression_ being contracted in fast). 
>> Unfortunately, that ship has sailed, and it does constrain our ability to 
>> choose an accurate name somewhat.
>>
>> What if we just spell it out? fast-respect-pragma? fast-when-unspecified? I 
>> don't think that we really need to try to be as brief as possible with this 
>> one.
>
> This sounds reasonable. We already have `-fhonor-nans` and 
> `-fhonor-infinities`. Should we make it `fast-honor-pragma` for consistency?

+1 with fast-honor-pragma


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] D91281: [CUDA][HIP] Diagnose reference of host variable

2020-11-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM.


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

https://reviews.llvm.org/D91281

___
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-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D90174#2387518 , @scanon wrote:

> Strictly speaking, fp-contract=fast probably should have been a separate flag 
> entirely (since there's no _expression_ being contracted in fast). 
> Unfortunately, that ship has sailed, and it does constrain our ability to 
> choose an accurate name somewhat.
>
> What if we just spell it out? fast-respect-pragma? fast-when-unspecified? I 
> don't think that we really need to try to be as brief as possible with this 
> one.

This sounds reasonable. We already have `-fhonor-nans` and 
`-fhonor-infinities`. Should we make it `fast-honor-pragma` for consistency?


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] D91258: [clangd] Sanity-check array sizes read from disk before allocating them.

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:121
+  template 
+  LLVM_NODISCARD bool consumeSize(T , unsigned MinSize = 1) {
+auto Size = consumeVar();

kadircet wrote:
> regarding minsizes, i suppose the idea was to pass `ElementSizeInBytes` for 
> containers ? I am OK with the overshooting if you don't want to make this 
> more detailed, but can we drop the param?
Yeah fair enough - I thought having the param made the logic easier to follow 
but actually passing it made the code too fragile.

Just inlined badSize() and hardcoded MinSize=1, we can always extract it again 
later.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:529
 Reader CmdReader(Chunks.lookup("cmdl"));
 if (CmdReader.err())
   return error("malformed or truncated commandline section");

kadircet wrote:
> unrelated to this patch, but it feels like we are checking for the error at 
> the wrong place ?
agree. Will fix in a different commit



Comment at: clang-tools-extra/clangd/unittests/SerializationTests.cpp:320
+if (!Succeeded)
+  elog("Failed to set rlimit");
+  }

kadircet wrote:
> should we rather `ADD_FAILURE` ?
No, because rlimit can legitimately fail (e.g. we're already using more ram 
than the limit we tried to set).

If rlimit fails then we may not be able to perform the test meaningfully, so we 
could skip it in that case (i.e. decide to *pass* immediately).



Comment at: clang-tools-extra/clangd/unittests/SerializationTests.cpp:345
+  std::string Serialized = llvm::to_string(Out);
+  llvm::consumeError(readIndexFile(Serialized).takeError());
+

kadircet wrote:
> why not `ASSERT_TRUE(readIndexFile(..))` ? (or `llvm::cantFail`)
Whoops, this was leftover experimentation code.



Comment at: clang-tools-extra/clangd/unittests/SerializationTests.cpp:364
+  // The offset isn't trivial to find, so we use the file digest.
+  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
+  unsigned Pos = Srcs->Data.find_first_of(FileDigest);

kadircet wrote:
> can we use `In.Sources.begin()->Digest` instead?
Hmm, we could, but it has the wrong data type (uint8_t vs char) so we need a 
reinterpret_cast... not sure it's clearer.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91258

___
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-11 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added a comment.

@joechrisellis thanks for the patch Joe, I've added a few comments. I also 
noticed this only covers C++, do we want to test C as well?




Comment at: clang/lib/Sema/SemaCast.cpp:-2227
+// Allow bitcasting if either the source or destination is a scalable
+// vector.
+if (SrcType->isSizelessBuiltinType() || DestType->isSizelessBuiltinType()) 
{
+  Kind = CK_BitCast;
+  return TC_Success;
+}

This is a bit ambiguous, it'll allow bitcasting between things like a fixed 
predicate and any sizeless type which I don't think makes sense. I think it'll 
also allow bitcasting between any scalable and GNU vectors regardless of vector 
length, e.g.:

```
typedef int32_t int32x4_t __attribute__((vector_size(16)));

void foo() {
svint32_t s32;
int32x4_t g32;
g32 = (int32x4_t)s32;
s32 = (svint32_t)g32;
}
```

the above should only work when `-msve-vector-bits=128` but will currently be 
allowed for any N.



Comment at: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp:1
+// 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
+

C++ sema tests should be under `clang/test/SemaCXX/`



Comment at: clang/test/Sema/aarch64-sve-explicit-casts.cpp:1-36
+// 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
+
+#include 
+
+// SVE types cannot be C-style casted to one another.
+// "To avoid any ambiguity [between the two operations], the ACLE does not 
allow C-style casting from one
+// vector type to another." ~ACLE Section 3.4 (Vector Types)

`clang/test/SemaCXX/sizeless-1.cpp` already contains a test checking C-style 
casts between distinct sizeless types aren't supported, I'm not sure if adding 
this is necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

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


  1   2   3   >