[PATCH] D83419: [clangd] Add error() function for creating formatv-style llvm::Errors. NFC

2020-07-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

anyway, I'm fine with this change, feel free to submit it as-is (or do any 
refinements), don't really want the naming to block this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83419



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


[PATCH] D82157: Fix crash on `user defined literals`

2020-07-09 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas marked 2 inline comments as done.
eduucaldas added inline comments.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:723
+  syntax::UserDefinedLiteralExpression *
+  buildUserDefinedLiteral(UserDefinedLiteral *S) {
+switch (S->getLiteralOperatorKind()) {

b or B? Should I use camelCase or TitleCase?




Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:735-751
+  auto TokLoc = S->getBeginLoc();
+  auto buffer = SmallVector();
+  bool invalidSpelling = false;
+  auto TokSpelling =
+  Lexer::getSpelling(TokLoc, buffer, Context.getSourceManager(),
+ Context.getLangOpts(), &invalidSpelling);
+  assert(!invalidSpelling);

I'll write a comment explaining why this crazyness. Promise not to rant about 
the lexer that doesn't distinguish between float and integer.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:738-740
+  auto TokSpelling =
+  Lexer::getSpelling(TokLoc, buffer, Context.getSourceManager(),
+ Context.getLangOpts(), &invalidSpelling);

This is exactly the function used by the parser to get the `TokSpelling`. see: 
llvm-project/clang/lib/Sema/SemaExpr.cpp:3633


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82157



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


[clang] 50f2433 - Add diagnostic option backing field for -fansi-escape-codes

2020-07-09 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2020-07-10T07:26:56+01:00
New Revision: 50f24331fd91e70de6bf6c3efe45272ddfc711fd

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

LOG: Add diagnostic option backing field for -fansi-escape-codes

Summary:
Keep track of -fansi-escape-codes in DiagnosticOptions and move the
option to the new option parsing system.

Depends on D82860

Reviewers: Bigcheese

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticOptions.def 
b/clang/include/clang/Basic/DiagnosticOptions.def
index 6d1a1af92821..a946b5c6be8e 100644
--- a/clang/include/clang/Basic/DiagnosticOptions.def
+++ b/clang/include/clang/Basic/DiagnosticOptions.def
@@ -65,6 +65,7 @@ VALUE_DIAGOPT(ShowCategories, 2, 0) /// Show categories: 0 -> 
none, 1 -> Number,
 ENUM_DIAGOPT(Format, TextDiagnosticFormat, 2, Clang) /// Format for 
diagnostics:
 
 DIAGOPT(ShowColors, 1, 0)   /// Show diagnostics with ANSI color sequences.
+DIAGOPT(UseANSIEscapeCodes, 1, 0)
 ENUM_DIAGOPT(ShowOverloads, OverloadsShown, 1,
  Ovl_All)/// Overload candidates to show.
 DIAGOPT(VerifyDiagnostics, 1, 0) /// Check that diagnostics match the expected

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 113696aeec7f..c6acd745bfd0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -849,7 +849,8 @@ def fdiagnostics_color : Flag<["-"], "fdiagnostics-color">, 
Group,
   Flags<[CoreOption, DriverOption]>;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, 
Group;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group,
-  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for 
diagnostics">;
+  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for 
diagnostics">,
+  MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes", "false">;
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation 
comment block command">,
   MetaVarName<"">;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 6f6af917e3a3..64dcfa831824 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1580,8 +1580,6 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, 
ArgList &Args,
   Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
   Opts.ShowOptionNames = !Args.hasArg(OPT_fno_diagnostics_show_option);
 
-  llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
-
   // Default behavior is to not to show note include stacks.
   Opts.ShowNoteIncludeStack = false;
   if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
@@ -3724,6 +3722,10 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
   }
 
   Success &= Res.parseSimpleArgs(Args, Diags);
+
+  llvm::sys::Process::UseANSIEscapeCodes(
+  Res.DiagnosticOpts->UseANSIEscapeCodes);
+
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);



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


[PATCH] D82874: Add diagnostic option backing field for -fansi-escape-codes

2020-07-09 Thread Daniel Grumberg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50f24331fd91: Add diagnostic option backing field for 
-fansi-escape-codes (authored by dang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82874

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


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1580,8 +1580,6 @@
   Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
   Opts.ShowOptionNames = !Args.hasArg(OPT_fno_diagnostics_show_option);
 
-  llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
-
   // Default behavior is to not to show note include stacks.
   Opts.ShowNoteIncludeStack = false;
   if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
@@ -3724,6 +3722,10 @@
   }
 
   Success &= Res.parseSimpleArgs(Args, Diags);
+
+  llvm::sys::Process::UseANSIEscapeCodes(
+  Res.DiagnosticOpts->UseANSIEscapeCodes);
+
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -849,7 +849,8 @@
   Flags<[CoreOption, DriverOption]>;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, 
Group;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group,
-  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for 
diagnostics">;
+  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for 
diagnostics">,
+  MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes", "false">;
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation 
comment block command">,
   MetaVarName<"">;
Index: clang/include/clang/Basic/DiagnosticOptions.def
===
--- clang/include/clang/Basic/DiagnosticOptions.def
+++ clang/include/clang/Basic/DiagnosticOptions.def
@@ -65,6 +65,7 @@
 ENUM_DIAGOPT(Format, TextDiagnosticFormat, 2, Clang) /// Format for 
diagnostics:
 
 DIAGOPT(ShowColors, 1, 0)   /// Show diagnostics with ANSI color sequences.
+DIAGOPT(UseANSIEscapeCodes, 1, 0)
 ENUM_DIAGOPT(ShowOverloads, OverloadsShown, 1,
  Ovl_All)/// Overload candidates to show.
 DIAGOPT(VerifyDiagnostics, 1, 0) /// Check that diagnostics match the expected


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1580,8 +1580,6 @@
   Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
   Opts.ShowOptionNames = !Args.hasArg(OPT_fno_diagnostics_show_option);
 
-  llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
-
   // Default behavior is to not to show note include stacks.
   Opts.ShowNoteIncludeStack = false;
   if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
@@ -3724,6 +3722,10 @@
   }
 
   Success &= Res.parseSimpleArgs(Args, Diags);
+
+  llvm::sys::Process::UseANSIEscapeCodes(
+  Res.DiagnosticOpts->UseANSIEscapeCodes);
+
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -849,7 +849,8 @@
   Flags<[CoreOption, DriverOption]>;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group,
-  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">;
+  Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">,
+  MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes", "false">;
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation comment block command">,
   MetaVarName<"">;
Index: clang/include/clang/Basic/DiagnosticOptions.def
===
--- clang/include/clang/Basic/Diag

[PATCH] D82157: Fix crash on `user defined literals`

2020-07-09 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1210
+  12_t;  // call: operator<'1', '2'> "" _x() | kind: integer
+  1.2_t; // call: operator<'1', '2'> "" _x() | kind: float
 }

gribozavr2 wrote:
> call -> calls? (as in, "this expression calls ...")
it is a noun here, as kind is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82157



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


[PATCH] D82157: Fix crash on `user defined literals`

2020-07-09 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 276919.
eduucaldas marked 9 inline comments as done.
eduucaldas added a comment.

Use right function to get TokSpelling, answer comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -1184,20 +1184,139 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, IntegerLiteral) {
+TEST_P(SyntaxTreeTest, UserDefinedLiteral) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
+typedef decltype(sizeof(void *)) size_t;
+
+unsigned operator "" _i(unsigned long long);
+unsigned operator "" _f(long double);
+unsigned operator "" _c(char);
+unsigned operator "" _s(const char*, size_t);
+unsigned operator "" _r(const char*);
+template 
+unsigned operator "" _t();
+
 void test() {
-  12;
-  12u;
-  12l;
-  12ul;
-  014;
-  0XC;
+  12_i;   // call: operator "" _i(12uLL)  | kind: integer
+  1.2_f;  // call: operator "" _f(1.2L)   | kind: float
+  '2'_c;  // call: operator "" _c('2')| kind: char
+  "12"_s; // call: operator "" _s("12")   | kind: string
+
+  12_r;   // call: operator "" _r("12")   | kind: integer
+  1.2_r;  // call: operator "" _i("1.2")  | kind: float
+  12_t;   // call: operator<'1', '2'> "" _x() | kind: integer
+  1.2_t;  // call: operator<'1', '2'> "" _x() | kind: float
 }
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
+|-SimpleDeclaration
+| |-typedef
+| |-decltype
+| |-(
+| |-UnknownExpression
+| | |-sizeof
+| | |-(
+| | |-void
+| | |-*
+| | `-)
+| |-)
+| |-SimpleDeclarator
+| | `-size_t
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_i
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-unsigned
+| |   | |-long
+| |   | `-long
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_f
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-long
+| |   | `-double
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_c
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | `-char
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_s
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-const
+| |   | |-char
+| |   | `-SimpleDeclarator
+| |   |   `-*
+| |   |-,
+| |   |-SimpleDeclaration
+| |   | `-size_t
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_r
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-const
+| |   | |-char
+| |   | `-SimpleDeclarator
+| |   |   `-*
+| |   `-)
+| `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-SimpleDeclaration
+| | `-char
+| |-...
+| |->
+| `-SimpleDeclaration
+|   |-unsigned
+|   |-SimpleDeclarator
+|   | |-operator
+|   | |-""
+|   | |-_t
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   `-)
+|   `-;
 `-SimpleDeclaration
   |-void
   |-SimpleDeclarator
@@ -1208,28 +1327,36 @@
   `-CompoundStatement
 |-{
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_i
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12u
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_f
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12l
+| |-CharUserDefinedLiteralExpression
+| | `-'2'_c
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12ul
+| |-StringUserDefinedLiteralExpression
+| | `-"12"_s
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-014
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_r
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-0XC
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_r
+| `-;
+|-ExpressionStatement
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_t
+| `-;
+|-ExpressionStatement
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_t
 | `-;
 `-}
 )txt"));
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -32,6 +32,14 @@
 return OS << "BoolLiteralExpression";
   case NodeKind::CxxNullPtrExpressio

[PATCH] D83511: [clangd] Config: If.PathExclude

2020-07-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:73
+  Frag.If.PathMatch.emplace_back("b.*");
+  Frag.If.PathExclude.emplace_back(".*r");
+  EXPECT_FALSE(compileAndApply());

IIUC the semantic is: we only process the file `if (PathMatch("bar", "b.*") && 
!PathExclude("bar", ".*r"))`, PathExclude is true here, so we won't process the 
file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83511



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


[PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-09 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 276916.
nridge marked 4 inline comments as done.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82739

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -548,6 +548,40 @@
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
 }
 
+TEST_F(TargetDeclTest, DependentExprs) {
+  Flags = {"-fno-delayed-template-parsing"};
+
+  // Heuristic resolution of method of dependent field
+  Code = R"cpp(
+struct A { void foo() {} };
+template 
+struct B {
+  A a;
+  void bar() {
+this->a.[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  A getA();
+};
+template 
+struct C {
+  B c;
+  void bar() { 
+this->c.getA().[[foo]]();
+  }
+};
+)cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(
@@ -705,36 +739,37 @@
 
 TEST_F(FindExplicitReferencesTest, All) {
   std::pair Cases[] =
-  {// Simple expressions.
-   {R"cpp(
+  {
+  // Simple expressions.
+  {R"cpp(
 int global;
 int func();
 void foo(int param) {
   $0^global = $1^param + $2^func();
 }
 )cpp",
-"0: targets = {global}\n"
-"1: targets = {param}\n"
-"2: targets = {func}\n"},
-   {R"cpp(
+   "0: targets = {global}\n"
+   "1: targets = {param}\n"
+   "2: targets = {func}\n"},
+  {R"cpp(
 struct X { int a; };
 void foo(X x) {
   $0^x.$1^a = 10;
 }
 )cpp",
-"0: targets = {x}\n"
-"1: targets = {X::a}\n"},
-   {R"cpp(
+   "0: targets = {x}\n"
+   "1: targets = {X::a}\n"},
+  {R"cpp(
 // error-ok: testing with broken code
 int bar();
 int foo() {
   return $0^bar() + $1^bar(42);
 }
 )cpp",
-"0: targets = {bar}\n"
-"1: targets = {bar}\n"},
-   // Namespaces and aliases.
-   {R"cpp(
+   "0: targets = {bar}\n"
+   "1: targets = {bar}\n"},
+  // Namespaces and aliases.
+  {R"cpp(
   namespace ns {}
   namespace alias = ns;
   void foo() {
@@ -742,19 +777,19 @@
 using namespace $1^alias;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {alias}\n"},
-   // Using declarations.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {alias}\n"},
+  // Using declarations.
+  {R"cpp(
   namespace ns { int global; }
   void foo() {
 using $0^ns::$1^global;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {ns::global}, qualifier = 'ns::'\n"},
-   // Simple types.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+  // Simple types.
+  {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
@@ -763,13 +798,13 @@
static_cast<$4^Struct*>(0);
  }
)cpp",
-"0: targets = {Struct}\n"
-"1: targets = {x}, decl\n"
-"2: targets = {Typedef}\n"
-"3: targets = {y}, decl\n"
-"4: targets = {Struct}\n"},
-   // Name qualifiers.
-   {R"cpp(
+   "0: targets = {Struct}\n"
+   "1: targets = {x}, decl\n"
+   "2: targets = {Typedef}\n"
+   "3: targets = {y}, decl\n"
+   "4: targets = {Struct}\n"},
+  // Name qualifiers.
+  {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
$0^a::$1^b::$2^S $3^x;
@@ -777,25 +812,25 @@
$6^S::$7^type $8^y;
  }
 )cpp",
-"0: targets = {a}\n"
-"1: targets = {a::b}, qualifier = 'a::'\n"
-"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-"3: targets = {x}, decl\n"
-"4: targets = {a}\n"
-"5: targets = {a::b}, qualifier = 'a::'\n"
-"6: targets = {a::b::S}\n"
-"7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
-"8: targets = {y}, decl\n"},
-   {R"cpp(
+   "0: targets = {a}\n"
+  

[PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-09 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:196
   switch (E->getStmtClass()) {
   case Stmt::CXXDependentScopeMemberExprClass: {
 const auto *ME = llvm::cast(E);

hokein wrote:
> I'm doubting whether we will miss some other exprs, since we are using it to 
> find the decls for the base expr of `CXXDependentScopeMemberExpr`. 
> 
> could you try the following testcase (also add it to the unittest)?
> 
> ```
> struct A {
>   void foo() {}
> };
> struct B {
>   A getA();
> };
> 
> template  struct C {
>   C c;
> 
>   void bar() { this->c.getA().foo(); }
> };
> ```
Thank you for the example! Handling this case required a bit of additional 
logic, which I've now added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82739



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


[clang-tools-extra] 98d763a - [clangd] Factor out some helper functions related to heuristic resolution in TargetFinder

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

Author: Nathan Ridge
Date: 2020-07-10T01:58:34-04:00
New Revision: 98d763ad051f5eab89fa46167516fc8a84f471d0

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

LOG: [clangd] Factor out some helper functions related to heuristic resolution 
in TargetFinder

Summary:
Two helpers are introduced:

 * Some of the logic previously in TargetFinder::Visit*() methods is
   factored out into resolveDependentExprToDecls().

 * Some of the logic in getMembersReferencedViaDependentName() is
   factored out into resolveTypeToRecordDecl().

D82739 will build on this and use these functions in new ways.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 1d09e8408c83..627f40c85436 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -58,6 +58,24 @@ nodeToString(const ast_type_traits::DynTypedNode &N) {
   return S;
 }
 
+// Helper function for getMembersReferencedViaDependentName()
+// which takes a dependent type `T` and heuristically
+// resolves it to a CXXRecordDecl in which we can try name lookup.
+CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
+  assert(T);
+  if (const auto *ICNT = T->getAs()) {
+T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
+  }
+  const auto *TST = T->getAs();
+  if (!TST)
+return nullptr;
+  const ClassTemplateDecl *TD = dyn_cast_or_null(
+  TST->getTemplateName().getAsTemplateDecl());
+  if (!TD)
+return nullptr;
+  return TD->getTemplatedDecl();
+}
+
 // Given a dependent type and a member name, heuristically resolve the
 // name to one or more declarations.
 // The current heuristic is simply to look up the name in the primary
@@ -82,25 +100,17 @@ std::vector 
getMembersReferencedViaDependentName(
 ET->getDecl()->lookup(NameFactory(ET->getDecl()->getASTContext()));
 return {Result.begin(), Result.end()};
   }
-  if (auto *ICNT = T->getAs()) {
-T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
+  if (auto *RD = resolveTypeToRecordDecl(T)) {
+if (!RD->hasDefinition())
+  return {};
+RD = RD->getDefinition();
+DeclarationName Name = NameFactory(RD->getASTContext());
+return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
+  return IsNonstaticMember ? D->isCXXInstanceMember()
+   : !D->isCXXInstanceMember();
+});
   }
-  auto *TST = T->getAs();
-  if (!TST)
-return {};
-  const ClassTemplateDecl *TD = dyn_cast_or_null(
-  TST->getTemplateName().getAsTemplateDecl());
-  if (!TD)
-return {};
-  CXXRecordDecl *RD = TD->getTemplatedDecl();
-  if (!RD->hasDefinition())
-return {};
-  RD = RD->getDefinition();
-  DeclarationName Name = NameFactory(RD->getASTContext());
-  return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
-return IsNonstaticMember ? D->isCXXInstanceMember()
- : !D->isCXXInstanceMember();
-  });
+  return {};
 }
 
 // Given the type T of a dependent expression that appears of the LHS of a 
"->",
@@ -144,6 +154,28 @@ const Type *getPointeeType(const Type *T) {
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+// Try to heuristically resolve a dependent expression `E` to one
+// or more declarations that it likely references.
+std::vector resolveDependentExprToDecls(const Expr *E) {
+  assert(E->isTypeDependent());
+  if (const auto *ME = dyn_cast(E)) {
+const Type *BaseType = ME->getBaseType().getTypePtrOrNull();
+if (ME->isArrow()) {
+  BaseType = getPointeeType(BaseType);
+}
+return getMembersReferencedViaDependentName(
+BaseType, [ME](ASTContext &) { return ME->getMember(); },
+/*IsNonstaticMember=*/true);
+  }
+  if (const auto *RE = dyn_cast(E)) {
+return getMembersReferencedViaDependentName(
+RE->getQualifier()->getAsType(),
+[RE](ASTContext &) { return RE->getDeclName(); },
+/*IsNonstaticMember=*/false);
+  }
+  return {};
+}
+
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
 if (const auto *Result = CRD->getTemplateInstantiationPattern())
@@ -341,21 +373,12 @@ struct TargetFinder {
   }
   void
   VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
-const Type *BaseType = E->getBaseType().getTypePtrOrNull();
-if (E->isArrow()) {
-  BaseType = getPointeeType(BaseType);
-}
-for (const NamedDecl *D : getMembersRe

[PATCH] D83371: [clangd] Factor out some helper functions related to heuristic resolution in TargetFinder

2020-07-09 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG98d763ad051f: [clangd] Factor out some helper functions 
related to heuristic resolution in… (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83371

Files:
  clang-tools-extra/clangd/FindTarget.cpp

Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -58,6 +58,24 @@
   return S;
 }
 
+// Helper function for getMembersReferencedViaDependentName()
+// which takes a dependent type `T` and heuristically
+// resolves it to a CXXRecordDecl in which we can try name lookup.
+CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
+  assert(T);
+  if (const auto *ICNT = T->getAs()) {
+T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
+  }
+  const auto *TST = T->getAs();
+  if (!TST)
+return nullptr;
+  const ClassTemplateDecl *TD = dyn_cast_or_null(
+  TST->getTemplateName().getAsTemplateDecl());
+  if (!TD)
+return nullptr;
+  return TD->getTemplatedDecl();
+}
+
 // Given a dependent type and a member name, heuristically resolve the
 // name to one or more declarations.
 // The current heuristic is simply to look up the name in the primary
@@ -82,25 +100,17 @@
 ET->getDecl()->lookup(NameFactory(ET->getDecl()->getASTContext()));
 return {Result.begin(), Result.end()};
   }
-  if (auto *ICNT = T->getAs()) {
-T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
+  if (auto *RD = resolveTypeToRecordDecl(T)) {
+if (!RD->hasDefinition())
+  return {};
+RD = RD->getDefinition();
+DeclarationName Name = NameFactory(RD->getASTContext());
+return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
+  return IsNonstaticMember ? D->isCXXInstanceMember()
+   : !D->isCXXInstanceMember();
+});
   }
-  auto *TST = T->getAs();
-  if (!TST)
-return {};
-  const ClassTemplateDecl *TD = dyn_cast_or_null(
-  TST->getTemplateName().getAsTemplateDecl());
-  if (!TD)
-return {};
-  CXXRecordDecl *RD = TD->getTemplatedDecl();
-  if (!RD->hasDefinition())
-return {};
-  RD = RD->getDefinition();
-  DeclarationName Name = NameFactory(RD->getASTContext());
-  return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
-return IsNonstaticMember ? D->isCXXInstanceMember()
- : !D->isCXXInstanceMember();
-  });
+  return {};
 }
 
 // Given the type T of a dependent expression that appears of the LHS of a "->",
@@ -144,6 +154,28 @@
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+// Try to heuristically resolve a dependent expression `E` to one
+// or more declarations that it likely references.
+std::vector resolveDependentExprToDecls(const Expr *E) {
+  assert(E->isTypeDependent());
+  if (const auto *ME = dyn_cast(E)) {
+const Type *BaseType = ME->getBaseType().getTypePtrOrNull();
+if (ME->isArrow()) {
+  BaseType = getPointeeType(BaseType);
+}
+return getMembersReferencedViaDependentName(
+BaseType, [ME](ASTContext &) { return ME->getMember(); },
+/*IsNonstaticMember=*/true);
+  }
+  if (const auto *RE = dyn_cast(E)) {
+return getMembersReferencedViaDependentName(
+RE->getQualifier()->getAsType(),
+[RE](ASTContext &) { return RE->getDeclName(); },
+/*IsNonstaticMember=*/false);
+  }
+  return {};
+}
+
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
 if (const auto *Result = CRD->getTemplateInstantiationPattern())
@@ -341,21 +373,12 @@
   }
   void
   VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
-const Type *BaseType = E->getBaseType().getTypePtrOrNull();
-if (E->isArrow()) {
-  BaseType = getPointeeType(BaseType);
-}
-for (const NamedDecl *D : getMembersReferencedViaDependentName(
- BaseType, [E](ASTContext &) { return E->getMember(); },
- /*IsNonstaticMember=*/true)) {
+for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
   void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E) {
-for (const NamedDecl *D : getMembersReferencedViaDependentName(
- E->getQualifier()->getAsType(),
- [E](ASTContext &) { return E->getDeclName(); },
- /*IsNonstaticMember=*/false)) {
+for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83371: [clangd] Factor out some helper functions related to heuristic resolution in TargetFinder

2020-07-09 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 276911.
nridge marked 3 inline comments as done.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83371

Files:
  clang-tools-extra/clangd/FindTarget.cpp

Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -58,6 +58,24 @@
   return S;
 }
 
+// Helper function for getMembersReferencedViaDependentName()
+// which takes a dependent type `T` and heuristically
+// resolves it to a CXXRecordDecl in which we can try name lookup.
+CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
+  assert(T);
+  if (const auto *ICNT = T->getAs()) {
+T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
+  }
+  const auto *TST = T->getAs();
+  if (!TST)
+return nullptr;
+  const ClassTemplateDecl *TD = dyn_cast_or_null(
+  TST->getTemplateName().getAsTemplateDecl());
+  if (!TD)
+return nullptr;
+  return TD->getTemplatedDecl();
+}
+
 // Given a dependent type and a member name, heuristically resolve the
 // name to one or more declarations.
 // The current heuristic is simply to look up the name in the primary
@@ -82,25 +100,17 @@
 ET->getDecl()->lookup(NameFactory(ET->getDecl()->getASTContext()));
 return {Result.begin(), Result.end()};
   }
-  if (auto *ICNT = T->getAs()) {
-T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
+  if (auto *RD = resolveTypeToRecordDecl(T)) {
+if (!RD->hasDefinition())
+  return {};
+RD = RD->getDefinition();
+DeclarationName Name = NameFactory(RD->getASTContext());
+return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
+  return IsNonstaticMember ? D->isCXXInstanceMember()
+   : !D->isCXXInstanceMember();
+});
   }
-  auto *TST = T->getAs();
-  if (!TST)
-return {};
-  const ClassTemplateDecl *TD = dyn_cast_or_null(
-  TST->getTemplateName().getAsTemplateDecl());
-  if (!TD)
-return {};
-  CXXRecordDecl *RD = TD->getTemplatedDecl();
-  if (!RD->hasDefinition())
-return {};
-  RD = RD->getDefinition();
-  DeclarationName Name = NameFactory(RD->getASTContext());
-  return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
-return IsNonstaticMember ? D->isCXXInstanceMember()
- : !D->isCXXInstanceMember();
-  });
+  return {};
 }
 
 // Given the type T of a dependent expression that appears of the LHS of a "->",
@@ -144,6 +154,28 @@
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+// Try to heuristically resolve a dependent expression `E` to one
+// or more declarations that it likely references.
+std::vector resolveDependentExprToDecls(const Expr *E) {
+  assert(E->isTypeDependent());
+  if (const auto *ME = dyn_cast(E)) {
+const Type *BaseType = ME->getBaseType().getTypePtrOrNull();
+if (ME->isArrow()) {
+  BaseType = getPointeeType(BaseType);
+}
+return getMembersReferencedViaDependentName(
+BaseType, [ME](ASTContext &) { return ME->getMember(); },
+/*IsNonstaticMember=*/true);
+  }
+  if (const auto *RE = dyn_cast(E)) {
+return getMembersReferencedViaDependentName(
+RE->getQualifier()->getAsType(),
+[RE](ASTContext &) { return RE->getDeclName(); },
+/*IsNonstaticMember=*/false);
+  }
+  return {};
+}
+
 const NamedDecl *getTemplatePattern(const NamedDecl *D) {
   if (const CXXRecordDecl *CRD = dyn_cast(D)) {
 if (const auto *Result = CRD->getTemplateInstantiationPattern())
@@ -341,21 +373,12 @@
   }
   void
   VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
-const Type *BaseType = E->getBaseType().getTypePtrOrNull();
-if (E->isArrow()) {
-  BaseType = getPointeeType(BaseType);
-}
-for (const NamedDecl *D : getMembersReferencedViaDependentName(
- BaseType, [E](ASTContext &) { return E->getMember(); },
- /*IsNonstaticMember=*/true)) {
+for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
   void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E) {
-for (const NamedDecl *D : getMembersReferencedViaDependentName(
- E->getQualifier()->getAsType(),
- [E](ASTContext &) { return E->getDeclName(); },
- /*IsNonstaticMember=*/false)) {
+for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82574: Merge TableGen files used for clang options

2020-07-09 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added a comment.

Yes I committed this a while ago, I duplicated all the functionality in 
Options.td.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82574



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-09 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1246
+
+// AIX `power` alignment does not apply the preferred alignment for
+// non-union classes if the source of the alignment (the current base in

Move the comment to above the previous `if` and make the following `if` the 
`else` of the previous `if`.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+  DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+  !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > Xiangling_L wrote:
> > > hubert.reinterpretcast wrote:
> > > > The condition is still more complex than I think it should be.
> > > > 
> > > > If we have found a "first" other-than-overlapping-empty-field, then we 
> > > > should set `HandledFirstNonOverlappingEmptyField` to `true` for 
> > > > non-union cases.
> > > > 
> > > > If `HandledFirstNonOverlappingEmptyField` being `false` is not enough 
> > > > for `FieldOffset == CharUnits::Zero()` to be true, then I think the 
> > > > correction would be to set `HandledFirstNonOverlappingEmptyField` in 
> > > > more places.
> > > > 
> > > > I would like to remove the check on `FieldOffset == CharUnits::Zero()` 
> > > > from here and instead have an assertion that 
> > > > `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == 
> > > > CharUnits::Zero()`.
> > > > 
> > > > Also, since we're managing `HandledFirstNonOverlappingEmptyField` in 
> > > > non-AIX cases, we should remove the `DefaultsToAIXPowerAlignment` 
> > > > condition for what is currently named 
> > > > `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting uses of it as 
> > > > necessary) and rename `FoundFirstNonOverlappingEmptyFieldToHandle` to 
> > > > `FoundFirstNonOverlappingEmptyField`.
> > > > Also, since we're managing HandledFirstNonOverlappingEmptyField in 
> > > > non-AIX cases, we should remove the DefaultsToAIXPowerAlignment 
> > > > condition for what is currently named 
> > > > FoundFirstNonOverlappingEmptyFieldToHandle 
> > > 
> > > I am not sure if we want to remove the `DefaultsToAIXPowerAlignment` 
> > > condition and bother with maintaining correct status of 
> > > `HandledFirstNonOverlappingEmptyField` for other targets.
> > > 
> > > We are actually claiming `HandledFirstNonOverlappingEmptyField` is an 
> > > auxiliary flag used for AIX only in its definition comments.
> > > 
> > > Besides, if we do want to manage `HandledFirstNonOverlappingEmptyField` 
> > > in non-AIX cases, I noticed that we have to set this flag to `true` 
> > > somewhere for objective-C++ cases. 
> > Okay, the other option I'm open is setting 
> > `HandledFirstNonOverlappingEmptyField` to `true` up front when not dealing 
> > with AIX `power` alignment.
> Thanks, that works too. I will address it in the next commit.
I'm not seeing the change for 
https://reviews.llvm.org/D79719?id=276143#inline-767942?



Comment at: clang/test/Layout/aix-Wpacked-expecting-diagnostics.cpp:19
+  char x alignas(4)[8];
+} ;
+

Minor nit: Remove the space before the semicolon.



Comment at: clang/test/Layout/aix-Wpacked-no-diagnostics.cpp:15
+
+int a = sizeof(QQ);

Is there a reason to drop the `FileCheck` checking for the layout?


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

https://reviews.llvm.org/D79719



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


[clang] ceb76d2 - [CMake][Fuchsia] Move runtimes to outer scope

2020-07-09 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-07-09T21:07:44-07:00
New Revision: ceb76d2fe73d39f2230bf55d47b8fd68849d47d7

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

LOG: [CMake][Fuchsia] Move runtimes to outer scope

This is needed for runtimes to be properly configured, addressing an
issue introduced in 53e38c85.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4d9b8526d0c4..259684ff2b0d 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -5,6 +5,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 if(NOT APPLE)
@@ -70,7 +71,6 @@ if(APPLE)
   set(DARWIN_iossim_ARCHS i386;x86_64 CACHE STRING "")
   set(DARWIN_osx_ARCHS x86_64 CACHE STRING "")
   set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "")
-  set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE 
STRING "")
 endif()
 
 if(WIN32)



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


[PATCH] D83509: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock

2020-07-09 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I don't remember if this will auto-close, since I forgot to add the Phabricator 
ID to the commit message. In any case it's in: 
00c9a504aeed2603bd8bc9b89d753534e929c8e8 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83509



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


[clang] 00c9a50 - CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock

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

Author: Oliver Hunt
Date: 2020-07-09T20:27:33-07:00
New Revision: 00c9a504aeed2603bd8bc9b89d753534e929c8e8

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

LOG: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock

Add a guard for re-entering an SDiagsWriter's HandleDiagnostics
method after we've started finalizing. This is a generic catch
all for unexpected fatal errors so we don't recursive crash inside
the generic llvm error handler.

We also add logic to handle the actual error case in
llvm::~raw_fd_ostream caused by failing to clear errors before
it is destroyed.



Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/lib/Frontend/SerializedDiagnosticPrinter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 83c13e0dbbe0..ceb24bce5978 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -119,6 +119,9 @@ def warn_fe_serialized_diag_merge_failure : Warning<
 def warn_fe_serialized_diag_failure : Warning<
 "unable to open file %0 for serializing diagnostics (%1)">,
 InGroup;
+def warn_fe_serialized_diag_failure_during_finalisation : Warning<
+"Received warning after diagnostic serialization teardown was underway: 
%0">,
+InGroup;
 
 def err_verify_missing_line : Error<
 "missing or invalid line number following '@' in expected %0">;

diff  --git a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp 
b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
index e3ca8fdec393..462aeda6e027 100644
--- a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -239,6 +239,9 @@ class SDiagsWriter : public DiagnosticConsumer {
   /// generated from child processes.
   bool MergeChildRecords;
 
+  /// Whether we've started finishing and tearing down this instance.
+  bool IsFinishing = false;
+
   /// State that is shared among the various clones of this diagnostic
   /// consumer.
   struct SharedState {
@@ -568,6 +571,17 @@ unsigned SDiagsWriter::getEmitDiagnosticFlag(StringRef 
FlagName) {
 
 void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const Diagnostic &Info) {
+  assert(!IsFinishing &&
+ "Received a diagnostic after we've already started teardown.");
+  if (IsFinishing) {
+SmallString<256> diagnostic;
+Info.FormatDiagnostic(diagnostic);
+getMetaDiags()->Report(
+diag::warn_fe_serialized_diag_failure_during_finalisation)
+<< diagnostic;
+return;
+  }
+
   // Enter the block for a non-note diagnostic immediately, rather than waiting
   // for beginDiagnostic, in case associated notes are emitted before we get
   // there.
@@ -761,6 +775,9 @@ void SDiagsWriter::RemoveOldDiagnostics() {
 }
 
 void SDiagsWriter::finish() {
+  assert(!IsFinishing);
+  IsFinishing = true;
+
   // The original instance is responsible for writing the file.
   if (!OriginalInstance)
 return;
@@ -786,12 +803,20 @@ void SDiagsWriter::finish() {
   if (EC) {
 getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
 << State->OutputFile << EC.message();
+OS->clear_error();
 return;
   }
 
   // Write the generated bitstream to "Out".
   OS->write((char *)&State->Buffer.front(), State->Buffer.size());
   OS->flush();
+
+  assert(!OS->has_error());
+  if (OS->has_error()) {
+getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
+<< State->OutputFile << OS->error().message();
+OS->clear_error();
+  }
 }
 
 std::error_code SDiagsMerger::visitStartOfDiagnostic() {



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


[PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen.

2020-07-09 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo created this revision.
Herald added subscribers: cfe-commits, martong.
Herald added a reviewer: shafik.
Herald added a project: clang.

This helps avoiding hacks downstream.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83529

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp

Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -271,6 +271,8 @@
 S->setConditionVariable(Record.getContext(), readDeclAs());
 
   S->setWhileLoc(readSourceLocation());
+  S->setLParenLoc(readSourceLocation());
+  S->setRParenLoc(readSourceLocation());
 }
 
 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -1347,9 +1347,10 @@
   ///
   /// By default, performs semantic analysis to build the new statement.
   /// Subclasses may override this routine to provide different behavior.
-  StmtResult RebuildWhileStmt(SourceLocation WhileLoc,
-  Sema::ConditionResult Cond, Stmt *Body) {
-return getSema().ActOnWhileStmt(WhileLoc, Cond, Body);
+  StmtResult RebuildWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc,
+  Sema::ConditionResult Cond,
+  SourceLocation RParenLoc, Stmt *Body) {
+return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
   }
 
   /// Build a new do-while statement.
@@ -7335,7 +7336,8 @@
   Body.get() == S->getBody())
 return Owned(S);
 
-  return getDerived().RebuildWhileStmt(S->getWhileLoc(), Cond, Body.get());
+  return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
+   Cond, S->getRParenLoc(), Body.get());
 }
 
 template
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1328,8 +1328,9 @@
 }
 }
 
-StmtResult Sema::ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond,
-Stmt *Body) {
+StmtResult Sema::ActOnWhileStmt(SourceLocation WhileLoc,
+SourceLocation LParenLoc, ConditionResult Cond,
+SourceLocation RParenLoc, Stmt *Body) {
   if (Cond.isInvalid())
 return StmtError();
 
@@ -1344,7 +1345,7 @@
 getCurCompoundScope().setHasEmptyLoopBodies();
 
   return WhileStmt::Create(Context, CondVal.first, CondVal.second, Body,
-   WhileLoc);
+   WhileLoc, LParenLoc, RParenLoc);
 }
 
 StmtResult
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -1156,10 +1156,14 @@
 /// should try to recover harder.  It returns false if the condition is
 /// successfully parsed.  Note that a successful parse can still have semantic
 /// errors in the condition.
+/// Additionally, if LParenLoc and RParenLoc are non-null, it will assign
+/// the location of the outer-most '(' and ')', respectively, to them.
 bool Parser::ParseParenExprOrCondition(StmtResult *InitStmt,
Sema::ConditionResult &Cond,
SourceLocation Loc,
-   Sema::ConditionKind CK) {
+   Sema::ConditionKind CK,
+   SourceLocation *LParenLoc,
+   SourceLocation *RParenLoc) {
   BalancedDelimiterTracker T(*this, tok::l_paren);
   T.consumeOpen();
 
@@ -1189,6 +1193,13 @@
   // Otherwise the condition is valid or the rparen is present.
   T.consumeClose();
 
+  if (LParenLoc != nullptr) {
+*LParenLoc = T.getOpenLocation();
+  }
+  if (RParenLoc != nullptr) {
+*RParenLoc = T.getCloseLocation();
+  }
+
   // Check for extraneous ')'s to catch things like "if (foo())) {".  We know
   // that all callers are looking for a statement after the condition, so ")"
   // isn't valid.
@@ -1582,8 +1593,10 @@
 
   // Parse the condition.
   Sema::ConditionResult Cond;
+  SourceLocation LParen;
+  SourceLocation RParen;
   if (ParseParenExprOrCondition(nullptr, Cond, WhileLoc,
-Sema::ConditionKind::Boolean))
+Sema::ConditionKind::Boolean, &LParen, &RParen))
 return StmtError();
 
   // C99 6.8.5p5 - In C99,

[PATCH] D83514: [Lexer] Fix missing coverage line after #endif

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 276899.
zequanwu added a comment.
Herald added subscribers: usaxena95, kadircet, jkorous.

Fix clangd unit test.


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

https://reviews.llvm.org/D83514

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/test/CoverageMapping/preprocessor.c

Index: clang/test/CoverageMapping/preprocessor.c
===
--- clang/test/CoverageMapping/preprocessor.c
+++ clang/test/CoverageMapping/preprocessor.c
@@ -3,7 +3,7 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0
   int x = i;
 #endif
 }
@@ -11,7 +11,7 @@
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0
+#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+4]]:29 = 0
   if(i == 0) {
 i = 1;
   }
@@ -22,44 +22,44 @@
   if(i == 0) {   // CHECK: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1
 i = 1;
   }
-#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0
+#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0
   if(i == 1) {
 i = 0;
   }
 }
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24
 #\
   if 0
 #\
   endif // also skipped
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
 #\
   elif 0
 #endif
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
 #\
   else
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
 #\
   ifdef NOT_DEFINED
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
 #\
   ifndef __FILE__
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26
 #\
   ifdef NOT_DEFINED
 #\
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -432,6 +432,7 @@
 // Skip to the next '#endif' / '#else' / '#elif'.
 CurLexer->skipOver(*SkipLength);
   }
+  SourceLocation endLoc;
   while (true) {
 CurLexer->Lex(Tok);
 
@@ -538,7 +539,7 @@
   // Restore the value of LexingRawMode so that trailing comments
   // are handled correctly, if we've reached the outermost block.
   CurPPLexer->LexingRawMode = false;
-  CheckEndOfDirective("endif");
+  endLoc = CheckEndOfDirective("endif");
   CurPPLexer->LexingRawMode = true;
   if (Callbacks)
 Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc);
@@ -565,7 +566,7 @@
   // Restore the value of LexingRawMode so that trailing comments
   // are handled correctly.
   CurPPLexer->LexingRawMode = false;
-  CheckEndOfDirective("else");
+  endLoc = CheckEndOfDirective("else");
   CurPPLexer->LexingRawMode = true;
   if (Callbacks)
 Callbacks->Else(Tok.getLocation(), CondInfo.IfLoc);
@@ -621,7 +622,9 @@
   // by the end of the preamble; we'll resume parsing after the preamble.
   if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble()))
 Callbacks->SourceRangeSkipped(
-SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()),
+SourceRange(HashTokenLoc, endLoc.isValid()
+  ? endLoc
+  : CurPPLexer->getSourceLocation()),
 Tok.getLocation());
 }
 
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -224,7 +224,7 @@
   // Create one token for each line in the skipped range, so it works
   // with line-based diffing.
   assert(R.start.line <= R.end.line);
-  for (int Line = R.start.line; Line < R.end.line; ++Line) {
+  for (int Line = R.start.line; Line <= R.end.line; ++Line) {
 // Don't bother computing the offset for the end of the line, just use
 // zero. The client will treat this highlighting kind specially, and
 // highlight the entire line 

[PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary

2020-07-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I agree that avoiding the copy is best.  However, at the very least, if that 
function isn't going to handle the aggregate case correctly, it should assert 
that it isn't in it.

Otherwise this LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82513



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


[PATCH] D83519: [NewPM] Support optnone under new pass manager

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



Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150
 for (auto &C : Callbacks->BeforePassCallbacks)
-  ShouldRun &= C(Pass.name(), llvm::Any(&IR));
+  ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR));
 return ShouldRun;

aeubanks wrote:
> ychen wrote:
> > Could we do this to not changing the callback API?
> > `ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();`
> Each pass instrumentation should decide whether or not to run the pass based 
> on whether or not the pass is required or optional. An optional pass may 
> still be run, (which should be the case for the vast majority of instances).
> 
> For example, the optnone would only care if a pass is required or not if it 
> sees that a function is marked optnone.
> Similarly, opt-bisect would only care if a pass is required if it's hit the 
> bisect limit.
Sorry, now I understand what you mean, the ands and ors confused me.

I don't want to rule out the possibility of some future pass instrumentation 
wanting to skip even a required pass. But I am open to discussion on this point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

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

Nit: re-add `const`s


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341

Files:
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/CFGDiff.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,8 +107,7 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
+  template  struct ChildrenGetter {
 using ResultTy = SmallVector;
 
 static ResultTy Get(NodePtr N, std::integral_constant) {
@@ -121,49 +120,23 @@
   return ResultTy(IChildren.begin(), IChildren.end());
 }
 
-using Tag = std::integral_constant;
+using Tag = std::integral_constant;
 
 // The function below is the core part of the batch updater. It allows the
 // Depth Based Search algorithm to perform incremental updates in lockstep
 // with updates to the CFG. We emulated lockstep CFG updates by getting its
 // next snapshots by reverse-applying future updates.
 static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was performed.
-  auto &FutureChildren = (Inverse != IsPostDom) ? BUI->FuturePredecessors
-: BUI->FutureSuccessors;
-  auto FCIt = FutureChildren.find(N);
-  if (FCIt == FutureChildren.end()) return Res;
-
-  for (auto ChildAndKind : FCIt->second) {
-const NodePtr Child = ChildAndKind.getPointer();
-const UpdateKind UK = ChildAndKind.getInt();
-

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 276890.
asbirlea added a comment.
This revision is now accepted and ready to land.

Updated to include the part of the patch that's moving the Updates to a CFGDiff 
object. Splitting off from the clean-up work merging the two branches when BUI 
is null.
This patch does not exhibit the compile-time regression which caused it to be 
reverted previously.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341

Files:
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/CFGDiff.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,8 +107,7 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
+  template  struct ChildrenGetter {
 using ResultTy = SmallVector;
 
 static ResultTy Get(NodePtr N, std::integral_constant) {
@@ -121,49 +120,23 @@
   return ResultTy(IChildren.begin(), IChildren.end());
 }
 
-using Tag = std::integral_constant;
+using Tag = std::integral_constant;
 
 // The function below is the core part of the batch updater. It allows the
 // Depth Based Search algorithm to perform incremental updates in lockstep
 // with updates to the CFG. We emulated lockstep CFG updates by getting its
 // next snapshots by reverse-applying future updates.
 static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was performed.
-  auto &FutureChildren = (Inverse != IsPostDom) ? BUI->FuturePredecessors
-   

[PATCH] D83519: [NewPM] Support optnone under new pass manager

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



Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150
 for (auto &C : Callbacks->BeforePassCallbacks)
-  ShouldRun &= C(Pass.name(), llvm::Any(&IR));
+  ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR));
 return ShouldRun;

ychen wrote:
> Could we do this to not changing the callback API?
> `ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();`
Each pass instrumentation should decide whether or not to run the pass based on 
whether or not the pass is required or optional. An optional pass may still be 
run, (which should be the case for the vast majority of instances).

For example, the optnone would only care if a pass is required or not if it 
sees that a function is marked optnone.
Similarly, opt-bisect would only care if a pass is required if it's hit the 
bisect limit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[clang] 7462793 - Move default argument instantiation to SemaTemplateInstantiateDecl.cpp.

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

Author: Richard Smith
Date: 2020-07-09T17:24:19-07:00
New Revision: 7462793be771712092de4c31fef1b04ac365ccea

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

LOG: Move default argument instantiation to SemaTemplateInstantiateDecl.cpp.

No functionality change intended.

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7535849144d0..c3bebea0cccb 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9101,6 +9101,8 @@ class Sema final {
  TemplateArgumentListInfo &Result,
  const MultiLevelTemplateArgumentList &TemplateArgs);
 
+  bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD,
+  ParmVarDecl *Param);
   void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
 FunctionDecl *Function);
   bool CheckInstantiatedFunctionTemplateConstraints(

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0a7604d9f399..24b9c6777be1 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5575,83 +5575,9 @@ bool Sema::CheckCXXDefaultArgExpr(SourceLocation 
CallLoc, FunctionDecl *FD,
 return true;
   }
 
-  if (Param->hasUninstantiatedDefaultArg()) {
-Expr *UninstExpr = Param->getUninstantiatedDefaultArg();
-
-EnterExpressionEvaluationContext EvalContext(
-*this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
-
-// Instantiate the expression.
-//
-// FIXME: Pass in a correct Pattern argument, otherwise
-// getTemplateInstantiationArgs uses the lexical context of FD, e.g.
-//
-// template
-// struct A {
-//   static int FooImpl();
-//
-//   template
-//   // bug: default argument A::FooImpl() is evaluated with 2-level
-//   // template argument list [[T], [Tp]], should be [[Tp]].
-//   friend A Foo(int a);
-// };
-//
-// template
-// A Foo(int a = A::FooImpl());
-MultiLevelTemplateArgumentList MutiLevelArgList
-  = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true);
-
-InstantiatingTemplate Inst(*this, CallLoc, Param,
-   MutiLevelArgList.getInnermost());
-if (Inst.isInvalid())
-  return true;
-if (Inst.isAlreadyInstantiating()) {
-  Diag(Param->getBeginLoc(), diag::err_recursive_default_argument) << FD;
-  Param->setInvalidDecl();
-  return true;
-}
-
-ExprResult Result;
-{
-  // C++ [dcl.fct.default]p5:
-  //   The names in the [default argument] expression are bound, and
-  //   the semantic constraints are checked, at the point where the
-  //   default argument expression appears.
-  ContextRAII SavedContext(*this, FD);
-  LocalInstantiationScope Local(*this);
-  runWithSufficientStackSpace(CallLoc, [&] {
-Result = SubstInitializer(UninstExpr, MutiLevelArgList,
-  /*DirectInit*/false);
-  });
-}
-if (Result.isInvalid())
-  return true;
-
-// Check the expression as an initializer for the parameter.
-InitializedEntity Entity
-  = InitializedEntity::InitializeParameter(Context, Param);
-InitializationKind Kind = InitializationKind::CreateCopy(
-Param->getLocation(),
-/*FIXME:EqualLoc*/ UninstExpr->getBeginLoc());
-Expr *ResultE = Result.getAs();
-
-InitializationSequence InitSeq(*this, Entity, Kind, ResultE);
-Result = InitSeq.Perform(*this, Entity, Kind, ResultE);
-if (Result.isInvalid())
-  return true;
-
-Result =
-ActOnFinishFullExpr(Result.getAs(), Param->getOuterLocStart(),
-/*DiscardedValue*/ false);
-if (Result.isInvalid())
-  return true;
-
-// Remember the instantiated default argument.
-Param->setDefaultArg(Result.getAs());
-if (ASTMutationListener *L = getASTMutationListener()) {
-  L->DefaultArgumentInstantiated(Param);
-}
-  }
+  if (Param->hasUninstantiatedDefaultArg() &&
+  InstantiateDefaultArgument(CallLoc, FD, Param))
+return true;
 
   assert(Param->hasInit() && "default argument but no initializer?");
 

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 444fb209e932..1098a9aa782c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4227,6 +4227,87 @@ static bool addInstantiatedParametersToScope(Sema &S, 
FunctionDecl *Function,
   return false;
 }
 
+bool Sema:

[clang] f721e05 - PR46648: Do not eagerly instantiate default arguments for a generic

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

Author: Richard Smith
Date: 2020-07-09T17:24:20-07:00
New Revision: f721e0582b158c60c56d2601235b6d60758f4d7a

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

LOG: PR46648: Do not eagerly instantiate default arguments for a generic
lambda when instantiating a call operator specialization.

We previously incorrectly thought that such substitution was happening
in the context of substitution into a local scope, which is a context
where we should perform eager default argument instantiation.

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/default-arguments-cxx0x.cpp
clang/test/SemaTemplate/dependent-expr.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 5e00be35d8ce..4f33ff104ffd 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -875,15 +875,19 @@ class alignas(8) Decl {
 return getParentFunctionOrMethod() == nullptr;
   }
 
-  /// Returns true if this declaration is lexically inside a function or inside
-  /// a variable initializer. It recognizes non-defining declarations as well
-  /// as members of local classes and lambdas:
+  /// Determine whether a substitution into this declaration would occur as
+  /// part of a substitution into a dependent local scope. Such a substitution
+  /// transitively substitutes into all constructs nested within this
+  /// declaration.
+  ///
+  /// This recognizes non-defining declarations as well as members of local
+  /// classes and lambdas:
   /// \code
-  /// void foo() { void bar(); }
-  /// void foo2() { class ABC { void bar(); }; }
-  /// inline int x = [](){ return 0; }();
+  /// template void foo() { void bar(); }
+  /// template void foo2() { class ABC { void bar(); }; }
+  /// template inline int x = [](){ return 0; }();
   /// \endcode
-  bool isInLocalScope() const;
+  bool isInLocalScopeForInstantiation() const;
 
   /// If this decl is defined inside a function/method/block it returns
   /// the corresponding DeclContext, otherwise it returns null.

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 3fd27757815e..da1eadd9d931 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -364,8 +364,10 @@ void Decl::setDeclContextsImpl(DeclContext *SemaDC, 
DeclContext *LexicalDC,
   }
 }
 
-bool Decl::isInLocalScope() const {
+bool Decl::isInLocalScopeForInstantiation() const {
   const DeclContext *LDC = getLexicalDeclContext();
+  if (!LDC->isDependentContext())
+return false;
   while (true) {
 if (LDC->isFunctionOrMethod())
   return true;

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 8197e7d901e9..11e03c517d01 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2426,7 +2426,7 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
 UnparsedDefaultArgInstantiations[OldParm].push_back(NewParm);
   } else if (Expr *Arg = OldParm->getDefaultArg()) {
 FunctionDecl *OwningFunc = cast(OldParm->getDeclContext());
-if (OwningFunc->isInLocalScope()) {
+if (OwningFunc->isInLocalScopeForInstantiation()) {
   // Instantiate default arguments for methods of local classes (DR1484)
   // and non-defining declarations.
   Sema::ContextRAII SavedContext(*this, OwningFunc);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 6179d90d54f7..85adc4ef2dbd 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4458,7 +4458,7 @@ 
TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
 EPI.ExceptionSpec.Type != EST_None &&
 EPI.ExceptionSpec.Type != EST_DynamicNone &&
 EPI.ExceptionSpec.Type != EST_BasicNoexcept &&
-!Tmpl->isInLocalScope()) {
+!Tmpl->isInLocalScopeForInstantiation()) {
   FunctionDecl *ExceptionSpecTemplate = Tmpl;
   if (EPI.ExceptionSpec.Type == EST_Uninstantiated)
 ExceptionSpecTemplate = EPI.ExceptionSpec.SourceTemplate;

diff  --git a/clang/test/SemaTemplate/default-arguments-cxx0x.cpp 
b/clang/test/SemaTemplate/default-arguments-cxx0x.cpp
index 02696a80bc0f..1aa456553599 100644
--- a/clang/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ b/clang/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang

[clang] a5569f0 - Push parameters into the local instantiation scope before instantiating

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

Author: Richard Smith
Date: 2020-07-09T17:24:20-07:00
New Revision: a5569f089844209dbea2e3241460173d7b6b1420

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

LOG: Push parameters into the local instantiation scope before instantiating
a default argument.

Default arguments can (after recent language changes) refer to
parameters of the same function. Make sure they're added to the local
instantiation scope before transforming a default argument so that we
can remap such references to them properly.

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/lib/AST/Decl.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/default-arguments-cxx0x.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 6c39f6aab1b9..28faa2c1fc78 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -2618,7 +2618,13 @@ class FunctionDecl : public DeclaratorDecl,
   /// Retrieve the function declaration from which this function could
   /// be instantiated, if it is an instantiation (rather than a non-template
   /// or a specialization, for example).
-  FunctionDecl *getTemplateInstantiationPattern() const;
+  ///
+  /// If \p ForDefinition is \c false, explicit specializations will be treated
+  /// as if they were implicit instantiations. This will then find the pattern
+  /// corresponding to non-definition portions of the declaration, such as
+  /// default arguments and the exception specification.
+  FunctionDecl *
+  getTemplateInstantiationPattern(bool ForDefinition = true) const;
 
   /// Retrieve the primary template that this function template
   /// specialization either specializes or was instantiated from.

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 1676f319394d..5c0a98815dd7 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3623,7 +3623,8 @@ bool FunctionDecl::isTemplateInstantiation() const {
   return clang::isTemplateInstantiation(getTemplateSpecializationKind());
 }
 
-FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
+FunctionDecl *
+FunctionDecl::getTemplateInstantiationPattern(bool ForDefinition) const {
   // If this is a generic lambda call operator specialization, its
   // instantiation pattern is always its primary template's pattern
   // even if its primary template was instantiated from another
@@ -3640,18 +3641,20 @@ FunctionDecl 
*FunctionDecl::getTemplateInstantiationPattern() const {
   }
 
   if (MemberSpecializationInfo *Info = getMemberSpecializationInfo()) {
-if (!clang::isTemplateInstantiation(Info->getTemplateSpecializationKind()))
+if (ForDefinition &&
+!clang::isTemplateInstantiation(Info->getTemplateSpecializationKind()))
   return nullptr;
 return 
getDefinitionOrSelf(cast(Info->getInstantiatedFrom()));
   }
 
-  if (!clang::isTemplateInstantiation(getTemplateSpecializationKind()))
+  if (ForDefinition &&
+  !clang::isTemplateInstantiation(getTemplateSpecializationKind()))
 return nullptr;
 
   if (FunctionTemplateDecl *Primary = getPrimaryTemplate()) {
 // If we hit a point where the user provided a specialization of this
 // template, we're done looking.
-while (!Primary->isMemberSpecialization()) {
+while (!ForDefinition || !Primary->isMemberSpecialization()) {
   auto *NewPrimary = Primary->getInstantiatedFromMemberTemplate();
   if (!NewPrimary)
 break;

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 1098a9aa782c..6179d90d54f7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4273,6 +4273,13 @@ bool Sema::InstantiateDefaultArgument(SourceLocation 
CallLoc, FunctionDecl *FD,
 //   default argument expression appears.
 ContextRAII SavedContext(*this, FD);
 LocalInstantiationScope Local(*this);
+
+FunctionDecl *Pattern = FD->getTemplateInstantiationPattern(
+/*ForDefinition*/ false);
+if (addInstantiatedParametersToScope(*this, FD, Pattern, Local,
+ TemplateArgs))
+  return true;
+
 runWithSufficientStackSpace(CallLoc, [&] {
   Result = SubstInitializer(UninstExpr, TemplateArgs,
 /*DirectInit*/false);
@@ -4338,6 +4345,10 @@ void Sema::InstantiateExceptionSpec(SourceLocation 
PointOfInstantiation,
   MultiLevelTemplateArgumentList TemplateArgs =
 getTemplateInstantiationArgs(Decl, nullptr, /*RelativeToPrimary*/true);
 
+  // FIXME: We can't use getTemplateInstantiationPattern(false) in general
+  // here, because for a non-defining friend declaration in a class template,

[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-07-09 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 276881.
amyk added a comment.

Rebased patch, and addressed review comments of having a single `CHECK`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -0,0 +1,117 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; These test cases aims to test the builtins for the Power10 VSX vector
+; instructions introduced in ISA 3.1.
+
+define void @vec_xst_trunc_sc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_sc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stxvrbx v2, r6, r5
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <16 x i8>
+  %conv = extractelement <16 x i8> %0, i32 0
+  %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
+  store i8 %conv, i8* %add.ptr, align 1
+  ret void
+}
+
+define void @vec_xst_trunc_uc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_uc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:stxvrbx v2, r6, r5
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <16 x i8>
+  %conv = extractelement <16 x i8> %0, i32 0
+  %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
+  store i8 %conv, i8* %add.ptr, align 1
+  ret void
+}
+
+define void @vec_xst_trunc_ss(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_ss:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 1
+; CHECK-NEXT:stxvrhx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <8 x i16>
+  %conv = extractelement <8 x i16> %0, i32 0
+  %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
+  store i16 %conv, i16* %add.ptr, align 2
+  ret void
+}
+
+define void @vec_xst_trunc_us(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_us:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 1
+; CHECK-NEXT:stxvrhx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <8 x i16>
+  %conv = extractelement <8 x i16> %0, i32 0
+  %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
+  store i16 %conv, i16* %add.ptr, align 2
+  ret void
+}
+
+define void @vec_xst_trunc_si(<1 x i128> %__vec, i64 %__offset, i32* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_si:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 2
+; CHECK-NEXT:stxvrwx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <4 x i32>
+  %conv = extractelement <4 x i32> %0, i32 0
+  %add.ptr = getelementptr inbounds i32, i32* %__ptr, i64 %__offset
+  store i32 %conv, i32* %add.ptr, align 4
+  ret void
+}
+
+define void @vec_xst_trunc_ui(<1 x i128> %__vec, i64 %__offset, i32* nocapture %__ptr) {
+; CHECK-LABEL: vec_xst_trunc_ui:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 2
+; CHECK-NEXT:stxvrwx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <4 x i32>
+  %conv = extractelement <4 x i32> %0, i32 0
+  %add.ptr = getelementptr inbounds i32, i32* %__ptr, i64 %__offset
+  store i32 %conv, i32* %add.ptr, align 4
+  ret void
+}
+
+define void @vec_xst_trunc_sll(<1 x i128> %__vec, i64 %__offset, i64* nocapture %__ptr)  {
+; CHECK-LABEL: vec_xst_trunc_sll:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 3
+; CHECK-NEXT:stxvrdx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <2 x i64>
+  %conv = extractelement <2 x i64> %0, i32 0
+  %add.ptr = getelementptr inbounds i64, i64* %__ptr, i64 %__offset
+  store i64 %conv, i64* %add.ptr, align 8
+  ret void
+}
+
+define void @vec_xst_trunc_ull(<1 x i128> %__vec, i64 %__offset, i64* nocapture %__ptr)  {
+; CHECK-LABEL: vec_xst_trunc_ull:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r5, 3
+; CHECK-NEXT:stxvrdx v2, r6, r3
+; CHECK-NEXT:blr
+entry:
+  %0 = bitcast <1 x i128> %__vec to <2 x i64>
+  %conv = extractelement <2 x i64> %0, i32 0
+  %add.ptr = getelementptr inbounds i64, i64* %__ptr, i64 %__offset
+  store i64 %conv, i64* %add.ptr, align 8
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCIn

[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-09 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150
 for (auto &C : Callbacks->BeforePassCallbacks)
-  ShouldRun &= C(Pass.name(), llvm::Any(&IR));
+  ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR));
 return ShouldRun;

Could we do this to not changing the callback API?
`ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-09 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 276866.
Xiangling_L marked 9 inline comments as done.
Xiangling_L added a comment.

Fixed a base class related case by adding `IsFirstNonEmpty` flag;
Split the `aix-Wpacked.cpp` testcase into two;
Addressed other comments;


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

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/RecordLayout.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-Wpacked-expecting-diagnostics.cpp
  clang/test/Layout/aix-Wpacked-no-diagnostics.cpp
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-pack-attr-on-base.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

Index: clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc64-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+struct A {
+  double d1;
+  virtual void boo() {}
+};
+
+struct B {
+  double d2;
+  A a;
+};
+
+struct C : public A {
+  double d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::A
+// CHECK-NEXT:0 |   (A vtable pointer)
+// CHECK32-NEXT:  4 |   double d1
+// CHECK32-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 |   double d1
+// CHECK64-NEXT:| [sizeof=16, dsize=16, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::B
+// CHECK-NEXT:0 |   double d2
+// CHECK-NEXT:8 |   struct test1::A a
+// CHECK-NEXT:8 | (A vtable pointer)
+// CHECK32-NEXT: 12 | double d1
+// CHECK32-NEXT:| [sizeof=24, dsize=20, align=4, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=8]
+// CHECK64-NEXT: 16 | double d1
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::C
+// CHECK-NEXT:0 |   struct test1::A (primary base)
+// CHECK-NEXT:0 | (A vtable pointer)
+// CHECK32-NEXT:  4 | double d1
+// CHECK32-NEXT: 12 |   double d3
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 | double d1
+// CHECK64-NEXT: 16 |   double d3
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+} // namespace test1
+
+namespace test2 {
+struct A {
+  long long l1;
+};
+
+struct B : public virtual A {
+  double d2;
+};
+
+#pragma pack(2)
+struct C : public virtual A {
+  double __attribute__((aligned(4))) d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::A
+// CHECK-NEXT:0 |   long long l1
+// CHECK-NEXT:  | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK-NEXT:  |  nvsize=8, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::B
+// CHECK-NEXT:0 |   (B vtable pointer)
+// CHECK32-NEXT:  4 |   double d2
+// CHECK64-NEXT:  8 |   double d2
+// CHECK-NEXT:   16 |   struct test2::A (virtual base)
+// CHECK-NEXT:   16 | long long l1
+// CHECK-NEXT:  | [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::C
+// CHECK-NEXT:0 |   (C vtable pointer)
+// CHECK32-NEXT:  4 

[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-07-09 Thread Alexey Lapshin via Phabricator via cfe-commits
avl added a comment.

Thank you, for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

2020-07-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D81583



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-07-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D82085/new/

https://reviews.llvm.org/D82085



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


[PATCH] D83055: [clang][Driver] Fix tool path priority test failures

2020-07-09 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:117
+/// Check file exists first in case $DEFAULT_TRIPLE == %target_triple
+// RUN: file -E %t/$DEFAULT_TRIPLE-gcc 2>&1 > /dev/null && \
+// RUN:   mv %t/$DEFAULT_TRIPLE-gcc  %t/prefix || true

Maybe I'm not seeing something obvious here, but I'm not aware of the `file -E` 
usage, and on Linux I got `file: invalid option -- 'E'`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83055



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


[PATCH] D79147: Switch to using -debug-info-kind=constructor as default (from =limited)

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

Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` 
`Subscribers:` `Tags:` and the text `Summary:` from the git commit with the 
following script:

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. Please keep the tag. 
(`--date=now` is my personal preference (author dates are usually not useful. 
Using committer dates can make log almost monotonic in time))

`llvm/utils/git/pre-push.py` can validate the message does not include unneeded 
tags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79147



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


[PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary

2020-07-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D82513#2142596 , @rjmccall wrote:

> This seems fine.  I do wonder if the "real" bug is that this ought to be 
> handled properly in EmitReturnFromThunk, but regardless, the fix seems 
> acceptable.


Since `EmitReturnFromThunk` is used only by `EmitCallAndReturnForThunk`, I 
think it's better to just avoid the copy in the first place. Perhaps we should 
teach `EmitReturnOfRValue` to handle aggregates with non-trivial copy or move 
assignments correctly, but it seems that it won't have any effect once we 
commit the changes in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82513



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


[PATCH] D83514: [Lexer] Fix missing coverage line after #endif

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu reopened this revision.
zequanwu added a comment.
This revision is now accepted and ready to land.

Reverted.
It broke unit test SemanticHighlighting.GetsCorrectTokens in clangd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83514



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


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-09 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added a reviewer: bollu.
Herald added subscribers: llvm-commits, cfe-commits, jfb, dexonsmith, 
steven_wu, hiraditya.
Herald added projects: clang, LLVM.

This uses pass instrumentation callbacks to skip optional passes.
PassInfoMixin now declares that passes inheriting from it are by default
optional. Using RequiredPassInfoMixin overrides the pass to be required.
The new OptNoneInstrumentation is part of StandardInstrumentations.

The feature of skipping optional passes for optnone functions under NPM
is gated on a -enable-npm-optnone flag. Currently it is by default
false. That is because we still need to mark all required passes to be
required. Otherwise optnone functions will start behaving incorrectly.
After that is done in following changes, we can remove the flag and
always enable this.

All adaptors/managers must be required, since the pass(es) they are
wrapping may be required.

In the future, opt-bisect will use this same mechanmism of determining
which passes are required/optional.

Depends on D83498 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83519

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerInternal.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Feature/optnone-opt.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/IR/PassBuilderCallbacksTest.cpp
  polly/include/polly/ScopPass.h

Index: polly/include/polly/ScopPass.h
===
--- polly/include/polly/ScopPass.h
+++ polly/include/polly/ScopPass.h
@@ -204,7 +204,7 @@
 
 template 
 class FunctionToScopPassAdaptor
-: public PassInfoMixin> {
+: public RequiredPassInfoMixin> {
 public:
   explicit FunctionToScopPassAdaptor(ScopPassT Pass) : Pass(std::move(Pass)) {}
 
Index: llvm/unittests/IR/PassBuilderCallbacksTest.cpp
===
--- llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -317,18 +317,20 @@
   PassInstrumentationCallbacks Callbacks;
 
   MockPassInstrumentationCallbacks() {
-ON_CALL(*this, runBeforePass(_, _)).WillByDefault(Return(true));
+ON_CALL(*this, runBeforePass(_, _, _)).WillByDefault(Return(true));
   }
-  MOCK_METHOD2(runBeforePass, bool(StringRef PassID, llvm::Any));
+  MOCK_METHOD3(runBeforePass,
+   bool(StringRef PassID, bool PassIsRequired, llvm::Any));
   MOCK_METHOD2(runAfterPass, void(StringRef PassID, llvm::Any));
   MOCK_METHOD1(runAfterPassInvalidated, void(StringRef PassID));
   MOCK_METHOD2(runBeforeAnalysis, void(StringRef PassID, llvm::Any));
   MOCK_METHOD2(runAfterAnalysis, void(StringRef PassID, llvm::Any));
 
   void registerPassInstrumentation() {
-Callbacks.registerBeforePassCallback([this](StringRef P, llvm::Any IR) {
-  return this->runBeforePass(P, IR);
-});
+Callbacks.registerBeforePassCallback(
+[this](StringRef P, bool PassIsRequired, llvm::Any IR) {
+  return this->runBeforePass(P, PassIsRequired, IR);
+});
 Callbacks.registerAfterPassCallback(
 [this](StringRef P, llvm::Any IR) { this->runAfterPass(P, IR); });
 Callbacks.registerAfterPassInvalidatedCallback(
@@ -347,7 +349,7 @@
 // Make sure to avoid ignoring Mock passes/analysis, we definitely want
 // to check these explicitly.
 EXPECT_CALL(*this,
-runBeforePass(Not(HasNameRegex("Mock")), HasName(IRName)))
+runBeforePass(Not(HasNameRegex("Mock")), _, HasName(IRName)))
 .Times(AnyNumber());
 EXPECT_CALL(*this, runAfterPass(Not(HasNameRegex("Mock")), HasName(IRName)))
 .Times(AnyNumber());
@@ -497,7 +499,7 @@
   // PassInstrumentation calls should happen in-sequence, in the same order
   // as passes/analyses are scheduled.
   ::testing::Sequence PISequence;
-  EXPECT_CALL(CallbacksHandle, runBeforePass(HasNameRegex("MockPassHandle"),
+  EXPECT_CALL(CallbacksHandle, runBeforePass(HasNameRegex("MockPassHandle"), _,
  HasName("")))
   .InSequence(PISequence);
   EXPECT_CALL(CallbacksHandle,
@@ -525,7 +527,7 @@
   CallbacksHandle.ignoreNonMockPassInstrumentation("");
 
   // Skip the pass by returning false.
-  EXPECT_CALL(CallbacksHandle, runBeforePass(HasNameRegex("MockPassHandle"),
+  EXPECT_CALL(CallbacksHandle, runBeforePass(HasNameRegex("MockPassHandle"), _,
  HasName("")))
   .WillOnce(Return(false));
 
@@ -575,7 +577,7 @@
   // as passes/analyses are scheduled.
   ::testing::Sequence PISequence;
   EXP

[clang] 8be204f - Revert "[Lexer] Fix missing coverage line after #endif"

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

Author: Zequan Wu
Date: 2020-07-09T15:51:02-07:00
New Revision: 8be204fe75caac4ce6ed1e2cf5659011476bde79

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

LOG: Revert "[Lexer] Fix missing coverage line after #endif"

This reverts commit 672ae621e91ff5cdefb2535bdd530641536685ea.

Added: 


Modified: 
clang/lib/Lex/PPDirectives.cpp
clang/test/CoverageMapping/preprocessor.c

Removed: 




diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 17dc64b93a99..396ba529fc9a 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -432,7 +432,6 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
 // Skip to the next '#endif' / '#else' / '#elif'.
 CurLexer->skipOver(*SkipLength);
   }
-  SourceLocation endifLoc;
   while (true) {
 CurLexer->Lex(Tok);
 
@@ -539,7 +538,7 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
   // Restore the value of LexingRawMode so that trailing comments
   // are handled correctly, if we've reached the outermost block.
   CurPPLexer->LexingRawMode = false;
-  endifLoc = CheckEndOfDirective("endif");
+  CheckEndOfDirective("endif");
   CurPPLexer->LexingRawMode = true;
   if (Callbacks)
 Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc);
@@ -622,9 +621,7 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
   // by the end of the preamble; we'll resume parsing after the preamble.
   if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble()))
 Callbacks->SourceRangeSkipped(
-SourceRange(HashTokenLoc, endifLoc.isValid()
-  ? endifLoc
-  : CurPPLexer->getSourceLocation()),
+SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()),
 Tok.getLocation());
 }
 

diff  --git a/clang/test/CoverageMapping/preprocessor.c 
b/clang/test/CoverageMapping/preprocessor.c
index 9225c9f162a2..b3ebc7bd4ec0 100644
--- a/clang/test/CoverageMapping/preprocessor.c
+++ b/clang/test/CoverageMapping/preprocessor.c
@@ -3,7 +3,7 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0
   int x = i;
 #endif
 }
@@ -11,7 +11,7 @@ void func() {// CHECK: File 0, [[@LINE]]:13 -> 
[[@LINE+5]]:2 = #0
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> 
[[@LINE+4]]:29 = 0
+#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 
= 0
   if(i == 0) {
 i = 1;
   }
@@ -22,44 +22,44 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> 
{{[0-9]+}}:2 = #0
   if(i == 0) {   // CHECK: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1
 i = 1;
   }
-#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0
+#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0
   if(i == 1) {
 i = 0;
   }
 }
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
 #\
   if 0
 #\
   endif // also skipped
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
 #\
   elif 0
 #endif
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
 #\
   else
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
 #\
   ifdef NOT_DEFINED
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
 #\
   ifndef __FILE__
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1
 #\
   ifdef NOT_DEFINED
 #\



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


[PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary

2020-07-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 276858.
ahatanak added a comment.

Add test case for `trivial_abi`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82513

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp
  clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm


Index: clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
===
--- clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
+++ clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
@@ -178,3 +178,32 @@
 void testCallContainsNonTrivial(ContainsNonTrivial *a) {
   testParamContainsNonTrivial(*a);
 }
+
+namespace testThunk {
+
+// CHECK-LABEL: define i64 @_ZThn8_N9testThunk2D02m0Ev(
+// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONG]], align 8
+// CHECK: %[[CALL:.*]] = tail call i64 @_ZN9testThunk2D02m0Ev(
+// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], 
%[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0
+// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i8*
+// CHECK: store i8* %[[COERCE_VAL_IP]], i8** %[[COERCE_DIVE]], align 8
+// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], 
%[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0
+// CHECK: %[[V3:.*]] = load i8*, i8** %[[COERCE_DIVE2]], align 8
+// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i8* %[[V3]] to i64
+// CHECK: ret i64 %[[COERCE_VAL_PI]]
+
+struct B0 {
+  virtual Strong m0();
+};
+
+struct B1 {
+  virtual Strong m0();
+};
+
+struct D0 : B0, B1 {
+  Strong m0() override;
+};
+
+Strong D0::m0() { return {}; }
+
+}
Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -43,6 +43,31 @@
   NonTrivial m;
 };
 
+struct B0 {
+  virtual Small m0();
+};
+
+struct B1 {
+  virtual Small m0();
+};
+
+struct D0 : B0, B1 {
+  Small m0() override;
+};
+
+// CHECK-LABEL: define i64 @_ZThn8_N2D02m0Ev(
+// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_SMALL]], align 8
+// CHECK: %[[CALL:.*]] = tail call i64 @_ZN2D02m0Ev(
+// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], 
%[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0
+// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i32*
+// CHECK: store i32* %[[COERCE_VAL_IP]], i32** %[[COERCE_DIVE]], align 8
+// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], 
%[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0
+// CHECK: %[[V3:.*]] = load i32*, i32** %[[COERCE_DIVE2]], align 8
+// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i32* %[[V3]] to i64
+// CHECK: ret i64 %[[COERCE_VAL_PI]]
+
+Small D0::m0() { return {}; }
+
 // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]])
 // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], 
%[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -363,7 +363,8 @@
   : FPT->getReturnType();
   ReturnValueSlot Slot;
   if (!ResultType->isVoidType() &&
-  CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect)
+  (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect ||
+   hasAggregateEvaluationKind(ResultType)))
 Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified(),
/*IsUnused=*/false, 
/*IsExternallyDestructed=*/true);
 


Index: clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
===
--- clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
+++ clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
@@ -178,3 +178,32 @@
 void testCallContainsNonTrivial(ContainsNonTrivial *a) {
   testParamContainsNonTrivial(*a);
 }
+
+namespace testThunk {
+
+// CHECK-LABEL: define i64 @_ZThn8_N9testThunk2D02m0Ev(
+// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONG]], align 8
+// CHECK: %[[CALL:.*]] = tail call i64 @_ZN9testThunk2D02m0Ev(
+// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0
+// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i8*
+// CHECK: store i8* %[[COERCE_VAL_IP]], i8** %[[COERCE_DIVE]], align 8
+// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0
+// CHECK: %[[V3:.*]] = load i8*, i8** %[[COERCE_DIVE2]], align 8
+// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i8* %[[V3]] to i64
+// CHECK: ret i64 %[[COERCE_VAL_PI]]
+
+struct B0 {
+  virtual Strong m0();
+};
+
+struct B1 {
+  virtual Strong m0();
+};
+
+struct D0 : B0, B1 {
+  Strong m0() override;
+};
+
+Strong D0::m0() { return {}; }
+
+}
Index: cla

[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-09 Thread Amy Kwan via Phabricator via cfe-commits
amyk requested changes to this revision.
amyk added a comment.
This revision now requires changes to proceed.

This will need to be rebased against your 2608 instruction definitions patch. 
But yes, I believe you are missing the clang and llc test case for this patch. 
Requesting changes due to missing tests.




Comment at: clang/lib/Headers/altivec.h:17099
+
+/* vector shifts for quadwords */
+static __inline__ vector unsigned __int128 __ATTRS_o_ai

`/* vs[l | r | raq] */` (with a new line after the comment)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83338



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


[clang] 227db86 - Switch to using -debug-info-kind=constructor as default (from =limited)

2020-07-09 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2020-07-09T15:26:46-07:00
New Revision: 227db86a1b7dd6f96f7df14890fcd071bc4fe1f5

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

LOG: Switch to using -debug-info-kind=constructor as default (from =limited)

Summary:
-debug-info-kind=constructor reduces the amount of class debug info that
is emitted; this patch switches to using this as the default.

Constructor homing emits the complete type info for a class only when the
constructor is emitted, so it is expected that there will be some classes that
are not defined in the debug info anymore because they are never constructed,
and we shouldn't need debug info for these classes.

I compared the PDB files for clang, and there are 273 class types that are 
defined with `=limited`
but not with `=constructor` (out of ~60,000 total class types).
We've looked at a number of the types that are no longer defined with 
=constructor. The vast
majority of cases are something like class A is used as a parameter in a member 
function of
some other class B, which is emitted. But the function that uses class A is 
never called, and class A
is never constructed, and therefore isn't emitted in the debug info.

Bug: https://bugs.llvm.org/show_bug.cgi?id=46537

Subscribers: aprantl, cfe-commits, lldb-commits

Tags: #clang, #lldb

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cl-options.c
clang/test/Driver/clang-g-opts.c
clang/test/Driver/cuda-dwarf-2.cu
clang/test/Driver/debug-options-as.c
clang/test/Driver/debug-options.c
clang/test/Driver/integrated-as.s
clang/test/Driver/myriad-toolchain.c
clang/test/Driver/openmp-offload-gpu.c
clang/test/Driver/split-debug.c
lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ed365c608387..9b424beec428 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -498,7 +498,7 @@ static codegenoptions::DebugInfoKind 
DebugLevelToInfoKind(const Arg &A) {
 return codegenoptions::DebugLineTablesOnly;
   if (A.getOption().matches(options::OPT_gline_directives_only))
 return codegenoptions::DebugDirectivesOnly;
-  return codegenoptions::LimitedDebugInfo;
+  return codegenoptions::DebugInfoConstructor;
 }
 
 static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) {
@@ -2380,7 +2380,7 @@ static void CollectArgsForIntegratedAssembler(Compilation 
&C,
   CmdArgs.push_back(Value.data());
 } else {
   RenderDebugEnablingArgs(Args, CmdArgs,
-  codegenoptions::LimitedDebugInfo,
+  codegenoptions::DebugInfoConstructor,
   DwarfVersion, llvm::DebuggerKind::Default);
 }
   } else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") ||
@@ -3653,7 +3653,7 @@ static void RenderDebugOptions(const ToolChain &TC, const 
Driver &D,
   if (const Arg *A =
   Args.getLastArg(options::OPT_g_Group, options::OPT_gsplit_dwarf,
   options::OPT_gsplit_dwarf_EQ)) {
-DebugInfoKind = codegenoptions::LimitedDebugInfo;
+DebugInfoKind = codegenoptions::DebugInfoConstructor;
 
 // If the last option explicitly specified a debug-info level, use it.
 if (checkDebugInfoOption(A, Args, D, TC) &&
@@ -3758,7 +3758,7 @@ static void RenderDebugOptions(const ToolChain &TC, const 
Driver &D,
 if (checkDebugInfoOption(A, Args, D, TC)) {
   if (DebugInfoKind != codegenoptions::DebugLineTablesOnly &&
   DebugInfoKind != codegenoptions::DebugDirectivesOnly) {
-DebugInfoKind = codegenoptions::LimitedDebugInfo;
+DebugInfoKind = codegenoptions::DebugInfoConstructor;
 CmdArgs.push_back("-dwarf-ext-refs");
 CmdArgs.push_back("-fmodule-format=obj");
   }
@@ -3778,7 +3778,9 @@ static void RenderDebugOptions(const ToolChain &TC, const 
Driver &D,
   TC.GetDefaultStandaloneDebug());
   if (const Arg *A = Args.getLastArg(options::OPT_fstandalone_debug))
 (void)checkDebugInfoOption(A, Args, D, TC);
-  if (DebugInfoKind == codegenoptions::LimitedDebugInfo && NeedFullDebug)
+  if ((DebugInfoKind == codegenoptions::LimitedDebugInfo ||
+   DebugInfoKind == codegenoptions::DebugInfoConstructor) &&
+  NeedFullDebug)
 DebugInfoKind = codegenoptions::FullDebugInfo;
 
   if (Args.hasFlag(options::OPT_gembed_source, options::OPT_gno_embed_source,
@@ -6552,7 +6554,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID 
InputType,
   options::OPT_gline_tables_only)) 

[PATCH] D79147: Switch to using -debug-info-kind=constructor as default (from =limited)

2020-07-09 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG227db86a1b7d: Switch to using -debug-info-kind=constructor 
as default (from =limited) (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79147

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-g-opts.c
  clang/test/Driver/cuda-dwarf-2.cu
  clang/test/Driver/debug-options-as.c
  clang/test/Driver/debug-options.c
  clang/test/Driver/integrated-as.s
  clang/test/Driver/myriad-toolchain.c
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/split-debug.c
  lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp

Index: lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
===
--- lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
+++ lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
@@ -106,6 +106,7 @@
 int main() {
   MemberTest::Base B1;
   B1.Get();
+  MemberTest::Class C1;
   MemberTest::Class::StaticMemberFunc(1, 10, 2);
   return 0;
 }
Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -68,18 +68,18 @@
 // RUN: FileCheck -check-prefix=CHECK-NOINLINE-WITHOUT-SPLIT < %t %s
 //
 // CHECK-NOINLINE-WITHOUT-SPLIT: "-fno-split-dwarf-inlining"
-// CHECK-NOINLINE-WITHOUT-SPLIT: "-debug-info-kind=limited"
+// CHECK-NOINLINE-WITHOUT-SPLIT: "-debug-info-kind=constructor"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -fno-split-dwarf-inlining -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-GMLT < %t %s
 //
-// CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=limited"
+// CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=constructor"
 // CHECK-SPLIT-WITH-GMLT: "-split-dwarf-output"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -fno-split-dwarf-inlining -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-NOINL < %t %s
 //
-// CHECK-SPLIT-WITH-NOINL: "-debug-info-kind=limited"
+// CHECK-SPLIT-WITH-NOINL: "-debug-info-kind=constructor"
 // CHECK-SPLIT-WITH-NOINL: "-split-dwarf-output"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gmlt -fsplit-dwarf-inlining -S -### %s 2> %t
@@ -92,7 +92,7 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-GMLT < %t %s
 //
-// CHECK-SPLIT-OVER-GMLT: "-debug-info-kind=limited"
+// CHECK-SPLIT-OVER-GMLT: "-debug-info-kind=constructor"
 // CHECK-SPLIT-OVER-GMLT: "-split-dwarf-file"
 // CHECK-SPLIT-OVER-GMLT: "-split-dwarf-output"
 
@@ -117,6 +117,6 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -g0 -gsplit-dwarf=split -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-G0 < %t %s
 //
-// CHECK-SPLIT-OVER-G0: "-debug-info-kind=limited"
+// CHECK-SPLIT-OVER-G0: "-debug-info-kind=constructor"
 // CHECK-SPLIT-OVER-G0: "-split-dwarf-file"
 // CHECK-SPLIT-OVER-G0: "-split-dwarf-output"
Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -241,7 +241,7 @@
 
 // HAS_DEBUG-NOT: warning: debug
 // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
-// HAS_DEBUG-SAME: "-debug-info-kind={{limited|line-tables-only}}"
+// HAS_DEBUG-SAME: "-debug-info-kind={{constructor|line-tables-only}}"
 // HAS_DEBUG-SAME: "-dwarf-version=2"
 // HAS_DEBUG-SAME: "-fopenmp-is-device"
 // HAS_DEBUG: ptxas
Index: clang/test/Driver/myriad-toolchain.c
===
--- clang/test/Driver/myriad-toolchain.c
+++ clang/test/Driver/myriad-toolchain.c
@@ -83,7 +83,7 @@
 // NOSTDLIB-NOT: "-lc"
 
 // RUN: %clang -### -c -g %s -target sparc-myriad 2>&1 | FileCheck -check-prefix=G_SPARC %s
-// G_SPARC: "-debug-info-kind=limited" "-dwarf-version=2"
+// G_SPARC: "-debug-info-kind=constructor" "-dwarf-version=2"
 
 // RUN: %clang -### -c %s -target sparc-myriad-rtems -fuse-init-array 2>&1 \
 // RUN: | FileCheck -check-prefix=USE-INIT-ARRAY %s
Index: clang/test/Driver/integrated-as.s
===
--- clang/test/Driver/integrated-as.s
+++ clang/test/Driver/integrated-as.s
@@ -27,19 +27,19 @@
 // XA_INCLUDE2: "-Ifoo_dir"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-4 -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2 %s
-// DWARF2: "-debug-info-kind=limited" "-dwarf-version=2"
+// DWARF2: "-debug-info-kind=constructor" "-dwarf-version=2"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-3 2>&1 | FileCheck --check-prefix=DWARF3 %s
-// DWARF3: "-debug-info-kind=limited" "-dwarf-version=3"
+// DWARF3:

[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-07-09 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 276853.
amyk added a comment.

Fix assignment of variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83500

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c

Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -24,10 +24,14 @@
 vector unsigned __int128 vui128a, vui128b, vui128c;
 vector float vfa, vfb;
 vector double vda, vdb;
+signed int sia;
 unsigned int uia, uib;
 unsigned char uca;
 unsigned short usa;
+signed long long slla;
 unsigned long long ulla;
+float fa;
+double da;
 
 vector unsigned long long test_vpdepd(void) {
   // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
@@ -581,3 +585,123 @@
   // CHECK: ret <4 x float>
   return vec_splati_ins(vfa, 0, 1.0f);
 }
+
+vector signed int test_vec_replace_elt_si(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <4 x i32>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 12
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_replace_elt(vsia, sia, 0);
+}
+
+vector unsigned int test_vec_replace_elt_ui(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-BE-NEXT: ret <4 x i32>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_replace_elt(vuia, uia, 1);
+}
+
+vector float test_vec_replace_elt_f(void) {
+  // CHECK-BE: bitcast float %{{.+}} to i32
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <4 x float>
+  // CHECK-BE-NEXT: ret <4 x float>
+  // CHECK: bitcast float %{{.+}} to i32
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <4 x float>
+  // CHECK-NEXT: ret <4 x float>
+  return vec_replace_elt(vfa, fa, 2);
+}
+
+vector signed long long test_vec_replace_elt_sll(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <2 x i64>
+  // CHECK: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_replace_elt(vslla, slla, 0);
+}
+
+vector unsigned long long test_vec_replace_elt_ull(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <2 x i64>
+  // CHECK: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_replace_elt(vulla, ulla, 0);
+}
+
+vector double test_vec_replace_elt_d(void) {
+  // CHECK-BE: bitcast double %{{.+}} to i64
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <2 x i64> %{{.*}} to <2 x double>
+  // CHECK-BE-NEXT: ret <2 x double>
+  // CHECK: bitcast double %{{.+}} to i64
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-NEXT: bitcast <2 x i64> %{{.*}} to <2 x double>
+  // CHECK-NEXT: ret <2 x double>
+  return vec_replace_elt(vda, da, 1);
+}
+
+vector unsigned char test_vec_replace_unaligned_si(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 6
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 6
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vsia, sia, 6);
+}
+
+vector unsigned char test_vec_replace_unaligned_ui(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vuia, uia, 8);
+}
+
+vector unsigned char test_vec_replace_unaligned_f(void) {
+  // CHECK-BE: bitcast float %{{.+}} to i32
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 12
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: bitcast float %{{.+}} to i32
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 0
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vfa, fa, 12);
+}
+
+vector unsigned char test_vec_replace_unaligned_sll(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.

[PATCH] D83516: [PowerPC][Power10] RFC 2608 Instruction definitions and MC Tests

2020-07-09 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: power-llvm-team, PowerPC, saghir, nemanjai, hfinkel.
Conanap added projects: LLVM, clang, PowerPC.

This implements instruction definitions and MC tests for RFC2608. Please note 
that some instrs have classes that will need to be changed later as their 
classes have not been implemented yet - they will be implemented in their 
respective patches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83516

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,84 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: [0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3   # encoding: [0xcf,0x1b,0x22,0x10]
 vinsdrx 1, 2, 3
+# CHECK-BE: vmulesd 1, 2, 3   # encoding: [0x10,0x22,0x1b,0xc8]
+# CHECK-LE: vmulesd 1, 2, 3   # encoding: [0xc8,0x1b,0x22,0x10]
+vmulesd 1, 2, 3
+# CHECK-BE: vmulosd 1, 2, 3   # encoding: [0x10,0x22,0x19,0xc8]
+# CHECK-LE: vmulosd 1, 2, 3   # encoding: [0xc8,0x19,0x22,0x10]
+vmulosd 1, 2, 3
+# CHECK-BE: vmuleud 1, 2, 3   # encoding: [0x10,0x22,0x1a,0xc8]
+# CHECK-LE: vmuleud 1, 2, 3   # encoding: [0xc8,0x1a,0x22,0x10]
+vmuleud 1, 2, 3
+# CHECK-BE: vmuloud 1, 2, 3   # encoding: [0x10,0x22,0x18,0xc8]
+# CHECK-LE: vmuloud 1, 2, 3   # encoding: [0xc8,0x18,0x22,0x10]
+vmuloud 1, 2, 3
+# CHECK-BE: vmsumcud 1, 2, 3, 4   # encoding: [0x10,0x22,0x19,0x17]
+# CHECK-LE: vmsumcud 1, 2, 3, 4   # encoding: [0x17,0x19,0x22,0x10]
+vmsumcud 1, 2, 3, 4
+# CHECK-BE: vdivsq 3, 4, 5# encoding: [0x10,0x64,0x29,0x0b]
+# CHECK-LE: vdivsq 3, 4, 5# encoding: [0x0b,0x29,0x64,0x10]
+vdivsq 3, 4, 5
+# CHECK-BE: vdivuq 3, 4, 5# encoding: [0x10,0x64,0x28,0x0b]
+# CHECK-LE: vdivuq 3, 4, 5# encoding: [0x0b,0x28,0x64,0x10]
+vdivuq 3, 4, 5
+# CHECK-BE: vdivesq 3, 4, 5   # encoding: [0x10,0x64,0x2b,0x0b]
+# CHECK-LE: vdivesq 3, 4, 5   # encoding: [0x0b,0x2b,0x64,0x10]
+vdivesq 3, 4, 5
+# CHECK-BE: vdiveuq 3, 4, 5   # encoding: [0x10,0x64,0x2a,0x0b]
+# CHECK-LE: vdiveuq 3, 4, 5   # encoding: [0x0b,0x2a,0x64,0x10]
+vdiveuq 3, 4, 5
+# CHECK-BE: vcmpequq 4, 5, 6  # encoding: [0x10,0x85,0x31,0xc7]
+# CHECK-LE: vcmpequq 4, 5, 6  # encoding: [0xc7,0x31,0x85,0x10]
+vcmpequq 4, 5, 6
+# CHECK-BE: vcmpequq. 4, 5, 6 # encoding: [0x10,0x85,0x35,0xc7]
+# CHECK-LE: vcmpequq. 4, 5, 6 # encoding: [0xc7,0x35,0x85,0x10]
+vcmpequq. 4, 5, 6
+# CHECK-BE: vcmpgtsq 4, 5, 6  # encoding: [0x10,0x85,0x33,0x87]
+# CHECK-LE: vcmpgtsq 4, 5, 6  # encoding: [0x87,0x33,0x85,0x10]
+vcmpgtsq 4, 5, 6
+# CHECK-BE: vcmpgtsq. 4, 5, 6 # encoding: [0x10,0x85,0x37,0x87]
+# CHECK-LE: vcmpgtsq. 4, 5, 6 # encoding: [0x87,0x37,0x85,0x10]
+vcmpgtsq. 4, 5, 6
+# CHECK-BE: vcmpgtuq 4, 5, 6  # encoding: [0x10,0x85,0x32,0x87]
+# CHECK-LE: vcmpgtuq 4, 5, 6  # encoding: [0x87,0x32,0x85,0x10]
+vcmpgtuq 4, 5, 6
+# CHECK-BE: vcmpgtuq. 4, 5, 6 # encoding: [0x10,0x85,0x36,0x87]
+# CHECK-LE: vcmpgtuq. 4, 5, 6 # encoding: [0x87,0x36,0x85,0x10]
+vcmpgtuq. 4, 5, 6
+# CHECK-BE: vmoduq 3, 4, 5# encoding: [0x10,0x64,0x2e,0x0b]
+# CHECK-LE: vmoduq 3, 4, 5# encoding: [0x0b,0x2e,0x64,0x10]
+vmoduq 3, 4, 5
+# CHECK-BE: vextsd2q 20, 25   # encoding: [0x12,0x9b,0xce,0x02]
+# CHECK-LE: vextsd2q 20, 25   # encoding: [0x02,0xce,0x9b,0x12]
+vextsd2q 20, 25
+# CHECK-BE: vrlq 4, 5, 6  # encoding: [0x10,0x85,0x30,0x05]
+# CHECK-LE: vrlq 4, 5, 6  # encoding: [0x05,0x30,0x85,0x10]
+vrlq 4, 5, 6
+# CHECK-BE: vrlqnm 4, 5, 6# encoding: [0x10,0x85,0x31,0x45]
+# CHECK-LE: vrlqnm 4, 5, 6# encoding: [0x45,0x31,0x85,0x10]
+vrlqnm 4, 5, 6
+# CHECK-BE: vrlqmi 4, 5, 6# encoding: [0x10,0x85,0x30,0x45]
+# CHECK-LE: vrlqmi 4, 5, 6# e

[clang] 672ae62 - [Lexer] Fix missing coverage line after #endif

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

Author: Zequan Wu
Date: 2020-07-09T15:15:40-07:00
New Revision: 672ae621e91ff5cdefb2535bdd530641536685ea

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

LOG: [Lexer] Fix missing coverage line after #endif

Summary: bug reported here: https://bugs.llvm.org/show_bug.cgi?id=46660

Reviewers: vsk, efriedma, arphaman

Reviewed By: vsk

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Lex/PPDirectives.cpp
clang/test/CoverageMapping/preprocessor.c

Removed: 




diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 396ba529fc9a..17dc64b93a99 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -432,6 +432,7 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
 // Skip to the next '#endif' / '#else' / '#elif'.
 CurLexer->skipOver(*SkipLength);
   }
+  SourceLocation endifLoc;
   while (true) {
 CurLexer->Lex(Tok);
 
@@ -538,7 +539,7 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
   // Restore the value of LexingRawMode so that trailing comments
   // are handled correctly, if we've reached the outermost block.
   CurPPLexer->LexingRawMode = false;
-  CheckEndOfDirective("endif");
+  endifLoc = CheckEndOfDirective("endif");
   CurPPLexer->LexingRawMode = true;
   if (Callbacks)
 Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc);
@@ -621,7 +622,9 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
   // by the end of the preamble; we'll resume parsing after the preamble.
   if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble()))
 Callbacks->SourceRangeSkipped(
-SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()),
+SourceRange(HashTokenLoc, endifLoc.isValid()
+  ? endifLoc
+  : CurPPLexer->getSourceLocation()),
 Tok.getLocation());
 }
 

diff  --git a/clang/test/CoverageMapping/preprocessor.c 
b/clang/test/CoverageMapping/preprocessor.c
index b3ebc7bd4ec0..9225c9f162a2 100644
--- a/clang/test/CoverageMapping/preprocessor.c
+++ b/clang/test/CoverageMapping/preprocessor.c
@@ -3,7 +3,7 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0
   int x = i;
 #endif
 }
@@ -11,7 +11,7 @@ void func() {// CHECK: File 0, [[@LINE]]:13 -> 
[[@LINE+5]]:2 = #0
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 
= 0
+#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> 
[[@LINE+4]]:29 = 0
   if(i == 0) {
 i = 1;
   }
@@ -22,44 +22,44 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> 
{{[0-9]+}}:2 = #0
   if(i == 0) {   // CHECK: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1
 i = 1;
   }
-#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0
+#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0
   if(i == 1) {
 i = 0;
   }
 }
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24
 #\
   if 0
 #\
   endif // also skipped
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
 #\
   elif 0
 #endif
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
 #\
   else
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
 #\
   ifdef NOT_DEFINED
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
 #\
   ifndef __FILE__
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26
 #\
   ifdef NOT_DEFINED
 #\



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


[PATCH] D83514: [Lexer] Fix missing coverage line after #endif

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG672ae621e91f: [Lexer] Fix missing coverage line after #endif 
(authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83514

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/CoverageMapping/preprocessor.c

Index: clang/test/CoverageMapping/preprocessor.c
===
--- clang/test/CoverageMapping/preprocessor.c
+++ clang/test/CoverageMapping/preprocessor.c
@@ -3,7 +3,7 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0
   int x = i;
 #endif
 }
@@ -11,7 +11,7 @@
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0
+#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+4]]:29 = 0
   if(i == 0) {
 i = 1;
   }
@@ -22,44 +22,44 @@
   if(i == 0) {   // CHECK: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1
 i = 1;
   }
-#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0
+#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0
   if(i == 1) {
 i = 0;
   }
 }
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24
 #\
   if 0
 #\
   endif // also skipped
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
 #\
   elif 0
 #endif
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
 #\
   else
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
 #\
   ifdef NOT_DEFINED
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
 #\
   ifndef __FILE__
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26
 #\
   ifdef NOT_DEFINED
 #\
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -432,6 +432,7 @@
 // Skip to the next '#endif' / '#else' / '#elif'.
 CurLexer->skipOver(*SkipLength);
   }
+  SourceLocation endifLoc;
   while (true) {
 CurLexer->Lex(Tok);
 
@@ -538,7 +539,7 @@
   // Restore the value of LexingRawMode so that trailing comments
   // are handled correctly, if we've reached the outermost block.
   CurPPLexer->LexingRawMode = false;
-  CheckEndOfDirective("endif");
+  endifLoc = CheckEndOfDirective("endif");
   CurPPLexer->LexingRawMode = true;
   if (Callbacks)
 Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc);
@@ -621,7 +622,9 @@
   // by the end of the preamble; we'll resume parsing after the preamble.
   if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble()))
 Callbacks->SourceRangeSkipped(
-SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()),
+SourceRange(HashTokenLoc, endifLoc.isValid()
+  ? endifLoc
+  : CurPPLexer->getSourceLocation()),
 Tok.getLocation());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-09 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked 3 inline comments as done.
kpn added a comment.

Thanks for the reviews and the fast turnaround! I do appreciate it!


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

https://reviews.llvm.org/D80952



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


[PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend

2020-07-09 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ffec4672028: [PowerPC][Power10] Add Instruction 
definition/MC Tests for Load/Store Rightmost… (authored by Conanap, committed 
by amyk).

Changed prior to commit:
  https://reviews.llvm.org/D83364?vs=276564&id=276850#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83364

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s


Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,27 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: 
[0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3   # encoding: 
[0xcf,0x1b,0x22,0x10]
 vinsdrx 1, 2, 3
+# CHECK-BE: lxvrbx 32, 1, 2   # encoding: 
[0x7c,0x01,0x10,0x1b]
+# CHECK-LE: lxvrbx 32, 1, 2   # encoding: 
[0x1b,0x10,0x01,0x7c]
+lxvrbx 32, 1, 2
+# CHECK-BE: lxvrhx 33, 1, 2   # encoding: 
[0x7c,0x21,0x10,0x5b]
+# CHECK-LE: lxvrhx 33, 1, 2   # encoding: 
[0x5b,0x10,0x21,0x7c]
+lxvrhx 33, 1, 2
+# CHECK-BE: lxvrdx 34, 1, 2   # encoding: 
[0x7c,0x41,0x10,0xdb]
+# CHECK-LE: lxvrdx 34, 1, 2   # encoding: 
[0xdb,0x10,0x41,0x7c]
+lxvrdx 34, 1, 2
+# CHECK-BE: lxvrwx 35, 1, 2   # encoding: 
[0x7c,0x61,0x10,0x9b]
+# CHECK-LE: lxvrwx 35, 1, 2   # encoding: 
[0x9b,0x10,0x61,0x7c]
+lxvrwx 35, 1, 2
+# CHECK-BE: stxvrbx 32, 3, 1  # encoding: 
[0x7c,0x03,0x09,0x1b]
+# CHECK-LE: stxvrbx 32, 3, 1  # encoding: 
[0x1b,0x09,0x03,0x7c]
+stxvrbx 32, 3, 1
+# CHECK-BE: stxvrhx 33, 3, 1  # encoding: 
[0x7c,0x23,0x09,0x5b]
+# CHECK-LE: stxvrhx 33, 3, 1  # encoding: 
[0x5b,0x09,0x23,0x7c]
+stxvrhx 33, 3, 1
+# CHECK-BE: stxvrwx 34, 3, 1  # encoding: 
[0x7c,0x43,0x09,0x9b]
+# CHECK-LE: stxvrwx 34, 3, 1  # encoding: 
[0x9b,0x09,0x43,0x7c]
+stxvrwx 34, 3, 1
+# CHECK-BE: stxvrdx 35, 3, 1  # encoding: 
[0x7c,0x63,0x09,0xdb]
+# CHECK-LE: stxvrdx 35, 3, 1  # encoding: 
[0xdb,0x09,0x63,0x7c]
+stxvrdx 35, 3, 1
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -278,3 +278,27 @@
 
 # CHECK: vinsdrx 1, 2, 3
 0x10 0x22 0x1b 0xcf
+
+# CHECK: lxvrbx 32, 1, 2
+0x7c 0x01 0x10 0x1b
+
+# CHECK: lxvrhx 33, 1, 2
+0x7c 0x21 0x10 0x5b
+
+# CHECK: lxvrdx 34, 1, 2
+0x7c 0x41 0x10 0xdb
+
+# CHECK: lxvrwx 35, 1, 2
+0x7c 0x61 0x10 0x9b
+
+# CHECK: stxvrbx 32, 3, 1
+0x7c 0x03 0x09 0x1b
+
+# CHECK: stxvrhx 33, 3, 1
+0x7c 0x23 0x09 0x5b
+
+# CHECK: stxvrwx 34, 3, 1
+0x7c 0x43 0x09 0x9b
+
+# CHECK: stxvrdx 35, 3, 1
+0x7c 0x63 0x09 0xdb
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -942,8 +942,26 @@
  "vclrrb $vD, $vA, $rB", IIC_VecGeneral,
  [(set v16i8:$vD,
(int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>;
+
+  // The XFormMemOp flag for the following 8 instructions is set on
+  // the instruction format.
+  let mayLoad = 1, mayStore = 0 in {
+def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>;
+def LXVRHX : X_XT6_RA5_RB5<31, 45, "lxvrhx", vsrc, []>;
+def LXVRWX : X_XT6_RA5_RB5<31, 77, "lxvrwx", vsrc, []>;
+def LXVRDX : X_XT6_RA5_RB5<31, 109, "lxvrdx", vsrc, []>;
+  }
+
+  let mayLoad = 0, mayStore = 1 in {
+def STXVRBX : X_XS6_RA5_RB5<31, 141, "stxvrbx", vsrc, []>;
+def STXVRHX : X_XS6_RA5_RB5<31, 173, "stxvrhx", vsrc, []>;
+def STXVRWX : X_XS6_RA5_RB5<31, 205, "stxvrwx", vsrc, []>;
+def STXVRDX : X_XS6_RA5_RB5<31, 237, "stxvrdx", vsrc, []>;
+  }
 }
 
+
+
 // Anonymous Patterns 
//
 let Predicates = [IsISA3_1] in {
   def : Pat<(v16i8 (int_ppc_vsx_xxgenpcvbm v16i8:$VRB, imm:$IMM)),


Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,27 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: [0x10

[PATCH] D83514: [Lexer] Fix missing coverage line after #endif

2020-07-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Lgtm, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83514



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


[PATCH] D83514: [Lexer] Fix missing coverage line after #endif

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added reviewers: vsk, efriedma, arphaman.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

bug reported here: https://bugs.llvm.org/show_bug.cgi?id=46660


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83514

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/CoverageMapping/preprocessor.c

Index: clang/test/CoverageMapping/preprocessor.c
===
--- clang/test/CoverageMapping/preprocessor.c
+++ clang/test/CoverageMapping/preprocessor.c
@@ -3,7 +3,7 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0
   int x = i;
 #endif
 }
@@ -11,7 +11,7 @@
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0
+#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+4]]:29 = 0
   if(i == 0) {
 i = 1;
   }
@@ -22,44 +22,44 @@
   if(i == 0) {   // CHECK: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1
 i = 1;
   }
-#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0
+#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0
   if(i == 1) {
 i = 0;
   }
 }
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24
 #\
   if 0
 #\
   endif // also skipped
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
 #\
   elif 0
 #endif
 
 #if 1
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7
 #\
   else
 #endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
 #\
   ifdef NOT_DEFINED
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8
 #\
   ifndef __FILE__
 #\
   endif
 
-  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26
 #\
   ifdef NOT_DEFINED
 #\
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -432,6 +432,7 @@
 // Skip to the next '#endif' / '#else' / '#elif'.
 CurLexer->skipOver(*SkipLength);
   }
+  SourceLocation endifLoc;
   while (true) {
 CurLexer->Lex(Tok);
 
@@ -538,7 +539,7 @@
   // Restore the value of LexingRawMode so that trailing comments
   // are handled correctly, if we've reached the outermost block.
   CurPPLexer->LexingRawMode = false;
-  CheckEndOfDirective("endif");
+  endifLoc = CheckEndOfDirective("endif");
   CurPPLexer->LexingRawMode = true;
   if (Callbacks)
 Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc);
@@ -621,7 +622,9 @@
   // by the end of the preamble; we'll resume parsing after the preamble.
   if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble()))
 Callbacks->SourceRangeSkipped(
-SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()),
+SourceRange(HashTokenLoc, endifLoc.isValid()
+  ? endifLoc
+  : CurPPLexer->getSourceLocation()),
 Tok.getLocation());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

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

LG with some nits




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3287
+  if (Args.hasArg(OPT_fexperimental_strict_floating_point)) {
+Opts.ExpStrictFP = true;
+  }

Delete redundant braces



Comment at: clang/test/CodeGen/fp-strictfp.cpp:12
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}

Append a punctuation, i.e. `_Z12fp_precise_1fff:`



Comment at: clang/test/CodeGen/fp-strictfp.cpp:17
+}
+
+

Delete trailing empty lines


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

https://reviews.llvm.org/D80952



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


[PATCH] D82436: [clangd] Implement textDocument/foldingRange

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

In D82436#2142631 , @kbobyrev wrote:

> In D82436#2141953 , @sammccall wrote:
>
> > Tests :-)
>
>
> I was hoping glorious DocumentSymbols super tested API would shield me from 
> that :P


While the implementation is shared, a very small set of tests is fine. We 
should at least include some of the ranges that are "incorrect" that we want to 
fix.

> Didn't think of reasonable testing strategy but fair enough, will do!

I think you can literally just use an `Annotations` marked with all the ranges 
you expect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82436



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


[PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional.

2020-07-09 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added a comment.

I tested locally the standalone build of Clang with D83426 
.
I just want to make sure that we all agree this is right way moving forward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83454



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


[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-07-09 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 276844.
amyk added a comment.

Address review comments

- update comments
- pull out common code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83500

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c

Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -24,10 +24,14 @@
 vector unsigned __int128 vui128a, vui128b, vui128c;
 vector float vfa, vfb;
 vector double vda, vdb;
+signed int sia;
 unsigned int uia, uib;
 unsigned char uca;
 unsigned short usa;
+signed long long slla;
 unsigned long long ulla;
+float fa;
+double da;
 
 vector unsigned long long test_vpdepd(void) {
   // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
@@ -581,3 +585,123 @@
   // CHECK: ret <4 x float>
   return vec_splati_ins(vfa, 0, 1.0f);
 }
+
+vector signed int test_vec_replace_elt_si(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <4 x i32>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 12
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_replace_elt(vsia, sia, 0);
+}
+
+vector unsigned int test_vec_replace_elt_ui(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-BE-NEXT: ret <4 x i32>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_replace_elt(vuia, uia, 1);
+}
+
+vector float test_vec_replace_elt_f(void) {
+  // CHECK-BE: bitcast float %{{.+}} to i32
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <4 x float>
+  // CHECK-BE-NEXT: ret <4 x float>
+  // CHECK: bitcast float %{{.+}} to i32
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <4 x float>
+  // CHECK-NEXT: ret <4 x float>
+  return vec_replace_elt(vfa, fa, 2);
+}
+
+vector signed long long test_vec_replace_elt_sll(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <2 x i64>
+  // CHECK: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_replace_elt(vslla, slla, 0);
+}
+
+vector unsigned long long test_vec_replace_elt_ull(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <2 x i64>
+  // CHECK: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_replace_elt(vulla, ulla, 0);
+}
+
+vector double test_vec_replace_elt_d(void) {
+  // CHECK-BE: bitcast double %{{.+}} to i64
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <2 x i64> %{{.*}} to <2 x double>
+  // CHECK-BE-NEXT: ret <2 x double>
+  // CHECK: bitcast double %{{.+}} to i64
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-NEXT: bitcast <2 x i64> %{{.*}} to <2 x double>
+  // CHECK-NEXT: ret <2 x double>
+  return vec_replace_elt(vda, da, 1);
+}
+
+vector unsigned char test_vec_replace_unaligned_si(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 6
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 6
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vsia, sia, 6);
+}
+
+vector unsigned char test_vec_replace_unaligned_ui(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vuia, uia, 8);
+}
+
+vector unsigned char test_vec_replace_unaligned_f(void) {
+  // CHECK-BE: bitcast float %{{.+}} to i32
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 12
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: bitcast float %{{.+}} to i32
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 0
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vfa, fa, 12);
+}
+
+vector unsigned char test_vec_replace_unaligned_sll(void) {
+  // CHECK-BE: 

[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-07-09 Thread Amy Kwan via Phabricator via cfe-commits
amyk marked 3 inline comments as done.
amyk added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14273
+// The third argument to vec_replace_elt will be emitted to either
+// the vinsw or vinsd instruction. It must be a compile time constant.
+ConstantInt *ArgCI = dyn_cast(Ops[2]);

lei wrote:
> Do you mean?
> ```
> // The third argument of vec_replace_elt must be a compile time constant 
> and will be emitted either
> //  to the vinsw or vinsd instruction.
> ```
Yes. Thank you - I will update the wording here and in the other builtin.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14320
+Call = Builder.CreateCall(F, Ops);
+}
+return Call;

lei wrote:
> What are the chances of reaching to the end of this if/else-if section and 
> `Call` is null? ie `getPrimitiveSizeInBits() != [32|64]`
> I feel like it would be better if we can structure it so that we are not 
> doing all these nesting of `if`s and just do returns within the diff 
> if-conditions.
> 
> Have you tried to pull out the diff handling of 32/64bit arg and 
> consolidating the code a bit?
Thanks - I realize that I should probably pull the `Call` out. I'll update 
this. 
I've actually consolidated the code quite a bit already, but I'll see if I can 
make any further improvements on this.


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

https://reviews.llvm.org/D83500



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


[PATCH] D83513: [AST][ObjC] Fix crash when printing invalid objc categories

2020-07-09 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added reviewers: sammccall, gribozavr.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If no valid interface definition was found previously we would crash.

With this change instead we just print `<>` in place
of the NULL interface. In the future this could be improved by
saving the invalid interface's name and using that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83513

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/unittests/AST/DeclPrinterTest.cpp


Index: clang/unittests/AST/DeclPrinterTest.cpp
===
--- clang/unittests/AST/DeclPrinterTest.cpp
+++ clang/unittests/AST/DeclPrinterTest.cpp
@@ -76,14 +76,16 @@
 PrintedDeclMatches(StringRef Code, const std::vector &Args,
const DeclarationMatcher &NodeMatch,
StringRef ExpectedPrinted, StringRef FileName,
-   PrintingPolicyModifier PolicyModifier = nullptr) {
+   PrintingPolicyModifier PolicyModifier = nullptr,
+   bool AllowError = false) {
   PrintMatch Printer(PolicyModifier);
   MatchFinder Finder;
   Finder.addMatcher(NodeMatch, &Printer);
   std::unique_ptr Factory(
   newFrontendActionFactory(&Finder));
 
-  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName))
+  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName) &&
+  !AllowError)
 return testing::AssertionFailure()
   << "Parsing error in \"" << Code.str() << "\"";
 
@@ -170,16 +172,12 @@
 "input.cc");
 }
 
-::testing::AssertionResult PrintedDeclObjCMatches(
-  StringRef Code,
-  const DeclarationMatcher &NodeMatch,
-  StringRef ExpectedPrinted) {
+::testing::AssertionResult
+PrintedDeclObjCMatches(StringRef Code, const DeclarationMatcher &NodeMatch,
+   StringRef ExpectedPrinted, bool AllowError = false) {
   std::vector Args(1, "");
-  return PrintedDeclMatches(Code,
-Args,
-NodeMatch,
-ExpectedPrinted,
-"input.m");
+  return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, "input.m",
+/*PolicyModifier*/ nullptr, AllowError);
 }
 
 } // unnamed namespace
@@ -1321,3 +1319,17 @@
 namedDecl(hasName("P1")).bind("id"),
 "@protocol P1\n@end"));
 }
+
+TEST(DeclPrinter, TestObjCCategoryInvalidInterface) {
+  ASSERT_TRUE(PrintedDeclObjCMatches(
+  "@interface I (Extension) @end",
+  namedDecl(hasName("Extension")).bind("id"),
+  "@interface <>(Extension)\n@end", /*AllowError*/ true));
+}
+
+TEST(DeclPrinter, TestObjCCategoryImplInvalidInterface) {
+  ASSERT_TRUE(PrintedDeclObjCMatches(
+  "@implementation I (Extension) @end",
+  namedDecl(hasName("Extension")).bind("id"),
+  "@implementation <>(Extension)\n@end", /*AllowError*/ true));
+}
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -1374,7 +1374,12 @@
 }
 
 void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) {
-  Out << "@implementation " << *PID->getClassInterface() << '(' << *PID 
<<")\n";
+  Out << "@implementation ";
+  if (const auto *CID = PID->getClassInterface())
+Out << *CID;
+  else
+Out << "<>";
+  Out << '(' << *PID << ")\n";
 
   VisitDeclContext(PID, false);
   Out << "@end";
@@ -1382,7 +1387,11 @@
 }
 
 void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) {
-  Out << "@interface " << *PID->getClassInterface();
+  Out << "@interface ";
+  if (const auto *CID = PID->getClassInterface())
+Out << *CID;
+  else
+Out << "<>";
   if (auto TypeParams = PID->getTypeParamList()) {
 PrintObjCTypeParams(TypeParams);
   }


Index: clang/unittests/AST/DeclPrinterTest.cpp
===
--- clang/unittests/AST/DeclPrinterTest.cpp
+++ clang/unittests/AST/DeclPrinterTest.cpp
@@ -76,14 +76,16 @@
 PrintedDeclMatches(StringRef Code, const std::vector &Args,
const DeclarationMatcher &NodeMatch,
StringRef ExpectedPrinted, StringRef FileName,
-   PrintingPolicyModifier PolicyModifier = nullptr) {
+   PrintingPolicyModifier PolicyModifier = nullptr,
+   bool AllowError = false) {
   PrintMatch Printer(PolicyModifier);
   MatchFinder Finder;
   Finder.addMatcher(NodeMatch, &Printer);
   std::unique_ptr Factory(
   newFrontendActionFactory(&Finder));
 
-  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName))
+  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName) &&
+  !AllowError)
 return testing::Assertio

[PATCH] D83511: [clangd] Config: If.PathExclude

2020-07-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83511

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp


Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -67,6 +67,13 @@
   EXPECT_TRUE(compileAndApply());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
 
+  // Excluded regex.
+  Frag = {};
+  Frag.If.PathMatch.emplace_back("b.*");
+  Frag.If.PathExclude.emplace_back(".*r");
+  EXPECT_FALSE(compileAndApply());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+
   // Invalid regex.
   Frag = {};
   Frag.If.PathMatch.emplace_back("**]@theu");
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -50,6 +50,10 @@
   if (auto Values = scalarValues(N))
 F.PathMatch = std::move(*Values);
 });
+Dict.handle("PathExclude", [&](Node &N) {
+  if (auto Values = scalarValues(N))
+F.PathExclude = std::move(*Values);
+});
 Dict.parse(N);
   }
 
Index: clang-tools-extra/clangd/ConfigFragment.h
===
--- clang-tools-extra/clangd/ConfigFragment.h
+++ clang-tools-extra/clangd/ConfigFragment.h
@@ -108,6 +108,9 @@
   struct IfBlock {
 /// The file being processed must fully match a regular expression.
 std::vector> PathMatch;
+/// The file being processed must *not* fully match a regular expression.
+std::vector> PathExclude;
+
 /// An unrecognized key was found while parsing the condition.
 /// The condition will evaluate to false.
 bool HasUnrecognizedCondition = false;
Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -103,6 +103,22 @@
 });
   });
 }
+
+auto PathExclude = std::make_unique>();
+for (auto &Entry : F.PathExclude) {
+  if (auto RE = compileRegex(Entry))
+PathExclude->push_back(std::move(*RE));
+}
+if (!PathExclude->empty()) {
+  Out.Conditions.push_back(
+  [PathExclude(std::move(PathExclude))](const Params &P) {
+if (P.Path.empty())
+  return false;
+return llvm::none_of(*PathExclude, [&](const llvm::Regex &RE) {
+  return RE.match(P.Path);
+});
+  });
+}
   }
 
   void compile(Fragment::CompileFlagsBlock &&F) {


Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -67,6 +67,13 @@
   EXPECT_TRUE(compileAndApply());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
 
+  // Excluded regex.
+  Frag = {};
+  Frag.If.PathMatch.emplace_back("b.*");
+  Frag.If.PathExclude.emplace_back(".*r");
+  EXPECT_FALSE(compileAndApply());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+
   // Invalid regex.
   Frag = {};
   Frag.If.PathMatch.emplace_back("**]@theu");
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -50,6 +50,10 @@
   if (auto Values = scalarValues(N))
 F.PathMatch = std::move(*Values);
 });
+Dict.handle("PathExclude", [&](Node &N) {
+  if (auto Values = scalarValues(N))
+F.PathExclude = std::move(*Values);
+});
 Dict.parse(N);
   }
 
Index: clang-tools-extra/clangd/ConfigFragment.h
===
--- clang-tools-extra/clangd/ConfigFragment.h
+++ clang-tools-extra/clangd/ConfigFragment.h
@@ -108,6 +108,9 @@
   struct IfBlock {
 /// The file being processed must fully match a regular expression.
 std::vector> PathMatch;
+/// The file being processed must *not* fully match a regular expression.
+std::vector> PathExclude;
+
 /// An unrecognized key was found while parsing the condition.
 /// The condition will evaluate to false.
 bool HasUnrecognizedCondition = false;
Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/c

[PATCH] D83509: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock

2020-07-09 Thread Oliver Hunt via Phabricator via cfe-commits
ojhunt updated this revision to Diff 276837.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83509

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/Frontend/SerializedDiagnosticPrinter.cpp


Index: clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
===
--- clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -239,6 +239,9 @@
   /// generated from child processes.
   bool MergeChildRecords;
 
+  /// Whether we've started finishing and tearing down this instance.
+  bool IsFinishing = false;
+
   /// State that is shared among the various clones of this diagnostic
   /// consumer.
   struct SharedState {
@@ -568,6 +571,17 @@
 
 void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const Diagnostic &Info) {
+  assert(!IsFinishing &&
+ "Received a diagnostic after we've already started teardown.");
+  if (IsFinishing) {
+SmallString<256> diagnostic;
+Info.FormatDiagnostic(diagnostic);
+getMetaDiags()->Report(
+diag::warn_fe_serialized_diag_failure_during_finalisation)
+<< diagnostic;
+return;
+  }
+
   // Enter the block for a non-note diagnostic immediately, rather than waiting
   // for beginDiagnostic, in case associated notes are emitted before we get
   // there.
@@ -761,6 +775,9 @@
 }
 
 void SDiagsWriter::finish() {
+  assert(!IsFinishing);
+  IsFinishing = true;
+
   // The original instance is responsible for writing the file.
   if (!OriginalInstance)
 return;
@@ -786,12 +803,20 @@
   if (EC) {
 getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
 << State->OutputFile << EC.message();
+OS->clear_error();
 return;
   }
 
   // Write the generated bitstream to "Out".
   OS->write((char *)&State->Buffer.front(), State->Buffer.size());
   OS->flush();
+
+  assert(!OS->has_error());
+  if (OS->has_error()) {
+getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
+<< State->OutputFile << OS->error().message();
+OS->clear_error();
+  }
 }
 
 std::error_code SDiagsMerger::visitStartOfDiagnostic() {
Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -119,6 +119,9 @@
 def warn_fe_serialized_diag_failure : Warning<
 "unable to open file %0 for serializing diagnostics (%1)">,
 InGroup;
+def warn_fe_serialized_diag_failure_during_finalisation : Warning<
+"Received warning after diagnostic serialization teardown was underway: 
%0">,
+InGroup;
 
 def err_verify_missing_line : Error<
 "missing or invalid line number following '@' in expected %0">;


Index: clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
===
--- clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -239,6 +239,9 @@
   /// generated from child processes.
   bool MergeChildRecords;
 
+  /// Whether we've started finishing and tearing down this instance.
+  bool IsFinishing = false;
+
   /// State that is shared among the various clones of this diagnostic
   /// consumer.
   struct SharedState {
@@ -568,6 +571,17 @@
 
 void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const Diagnostic &Info) {
+  assert(!IsFinishing &&
+ "Received a diagnostic after we've already started teardown.");
+  if (IsFinishing) {
+SmallString<256> diagnostic;
+Info.FormatDiagnostic(diagnostic);
+getMetaDiags()->Report(
+diag::warn_fe_serialized_diag_failure_during_finalisation)
+<< diagnostic;
+return;
+  }
+
   // Enter the block for a non-note diagnostic immediately, rather than waiting
   // for beginDiagnostic, in case associated notes are emitted before we get
   // there.
@@ -761,6 +775,9 @@
 }
 
 void SDiagsWriter::finish() {
+  assert(!IsFinishing);
+  IsFinishing = true;
+
   // The original instance is responsible for writing the file.
   if (!OriginalInstance)
 return;
@@ -786,12 +803,20 @@
   if (EC) {
 getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
 << State->OutputFile << EC.message();
+OS->clear_error();
 return;
   }
 
   // Write the generated bitstream to "Out".
   OS->write((char *)&State->Buffer.front(), State->Buffer.size());
   OS->flush();
+
+  assert(!OS->has_error());
+  if (OS->has_error()) {
+getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
+<< State->OutputFile << OS->error().message();
+OS->clear_error();
+  }
 }
 
 std::error_code SDiagsMerger::visitStartOfDiagnostic() {
Index: c

[PATCH] D83509: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock

2020-07-09 Thread JF Bastien via Phabricator via cfe-commits
jfb accepted this revision.
jfb added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:123
+def warn_fe_serialized_diag_failure_during_finalisation : Warning<
+"Received warning after diagnostic serialisation teardown was underway: 
%0">,
+InGroup;

```
$ git grep -i "serializ"  | wc -l
6053
$ git grep -i "serialis"  | wc -l
   5
```
**Z** it is 😉


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83509



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


[PATCH] D83509: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock

2020-07-09 Thread Oliver Hunt via Phabricator via cfe-commits
ojhunt created this revision.
ojhunt added a reviewer: jfb.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Add a guard for re-entering an SDiagsWriter's HandleDiagnostics
method after we've started finalizing. This is a generic catch
all for unexpected fatal errors so we don't recursive crash inside
the generic llvm error handler.

We also add logic to handle the actual error case in
llvm::~raw_fd_ostream caused by failing to clear errors before
it is destroyed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83509

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/Frontend/SerializedDiagnosticPrinter.cpp


Index: clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
===
--- clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -239,6 +239,9 @@
   /// generated from child processes.
   bool MergeChildRecords;
 
+  /// Whether we've started finishing and tearing down this instance.
+  bool IsFinishing = false;
+
   /// State that is shared among the various clones of this diagnostic
   /// consumer.
   struct SharedState {
@@ -568,6 +571,17 @@
 
 void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const Diagnostic &Info) {
+  assert(!IsFinishing &&
+ "Received a diagnostic after we've already started teardown.");
+  if (IsFinishing) {
+SmallString<256> diagnostic;
+Info.FormatDiagnostic(diagnostic);
+getMetaDiags()->Report(
+diag::warn_fe_serialized_diag_failure_during_finalisation)
+<< diagnostic;
+return;
+  }
+
   // Enter the block for a non-note diagnostic immediately, rather than waiting
   // for beginDiagnostic, in case associated notes are emitted before we get
   // there.
@@ -761,6 +775,9 @@
 }
 
 void SDiagsWriter::finish() {
+  assert(!IsFinishing);
+  IsFinishing = true;
+
   // The original instance is responsible for writing the file.
   if (!OriginalInstance)
 return;
@@ -786,12 +803,20 @@
   if (EC) {
 getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
 << State->OutputFile << EC.message();
+OS->clear_error();
 return;
   }
 
   // Write the generated bitstream to "Out".
   OS->write((char *)&State->Buffer.front(), State->Buffer.size());
   OS->flush();
+
+  assert(!OS->has_error());
+  if (OS->has_error()) {
+getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
+<< State->OutputFile << OS->error().message();
+OS->clear_error();
+  }
 }
 
 std::error_code SDiagsMerger::visitStartOfDiagnostic() {
Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -119,6 +119,9 @@
 def warn_fe_serialized_diag_failure : Warning<
 "unable to open file %0 for serializing diagnostics (%1)">,
 InGroup;
+def warn_fe_serialized_diag_failure_during_finalisation : Warning<
+"Received warning after diagnostic serialisation teardown was underway: 
%0">,
+InGroup;
 
 def err_verify_missing_line : Error<
 "missing or invalid line number following '@' in expected %0">;


Index: clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
===
--- clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -239,6 +239,9 @@
   /// generated from child processes.
   bool MergeChildRecords;
 
+  /// Whether we've started finishing and tearing down this instance.
+  bool IsFinishing = false;
+
   /// State that is shared among the various clones of this diagnostic
   /// consumer.
   struct SharedState {
@@ -568,6 +571,17 @@
 
 void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const Diagnostic &Info) {
+  assert(!IsFinishing &&
+ "Received a diagnostic after we've already started teardown.");
+  if (IsFinishing) {
+SmallString<256> diagnostic;
+Info.FormatDiagnostic(diagnostic);
+getMetaDiags()->Report(
+diag::warn_fe_serialized_diag_failure_during_finalisation)
+<< diagnostic;
+return;
+  }
+
   // Enter the block for a non-note diagnostic immediately, rather than waiting
   // for beginDiagnostic, in case associated notes are emitted before we get
   // there.
@@ -761,6 +775,9 @@
 }
 
 void SDiagsWriter::finish() {
+  assert(!IsFinishing);
+  IsFinishing = true;
+
   // The original instance is responsible for writing the file.
   if (!OriginalInstance)
 return;
@@ -786,12 +803,20 @@
   if (EC) {
 getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure)
 << State->OutputFile << EC.message();
+OS->clear_error();
 return;
   }
 
   // Write the g

[PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor.

2020-07-09 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

This patch fixes redundant hover with information about Decl which is not under 
cursor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83508

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -942,6 +942,13 @@
   template  void foo() {
 (void)[[size^of]](T);
   })cpp",
+  R"cpp(// No Decl for token under cursor.
+  namespace ns {
+  #define FOO B^AR;
+  })cpp",
+  R"cpp(//error-ok
+  unknown f(i^nt);
+  )cpp",
   // literals
   "auto x = t^rue;",
   "auto x = '^A';",
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -820,6 +820,18 @@
 SelectionTree::createRight(AST.getASTContext(), TB, Offset, Offset);
 std::vector Result;
 if (const SelectionTree::Node *N = ST.commonAncestor()) {
+  // Don't allow Decls which are not related with tokens under cursor.
+  if (const auto *D = N->ASTNode.get()) {
+bool IsDeclTouchingCursor = false;
+for (const auto &Tok : TokensTouchingCursor) {
+  if (D->getLocation() == Tok.location()) {
+IsDeclTouchingCursor = true;
+break;
+  }
+}
+if (!IsDeclTouchingCursor)
+  return llvm::None;
+  }
   // FIXME: Fill in HighlightRange with range coming from N->ASTNode.
   auto Decls = explicitReferenceTargets(N->ASTNode, DeclRelation::Alias);
   if (!Decls.empty()) {


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -942,6 +942,13 @@
   template  void foo() {
 (void)[[size^of]](T);
   })cpp",
+  R"cpp(// No Decl for token under cursor.
+  namespace ns {
+  #define FOO B^AR;
+  })cpp",
+  R"cpp(//error-ok
+  unknown f(i^nt);
+  )cpp",
   // literals
   "auto x = t^rue;",
   "auto x = '^A';",
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -820,6 +820,18 @@
 SelectionTree::createRight(AST.getASTContext(), TB, Offset, Offset);
 std::vector Result;
 if (const SelectionTree::Node *N = ST.commonAncestor()) {
+  // Don't allow Decls which are not related with tokens under cursor.
+  if (const auto *D = N->ASTNode.get()) {
+bool IsDeclTouchingCursor = false;
+for (const auto &Tok : TokensTouchingCursor) {
+  if (D->getLocation() == Tok.location()) {
+IsDeclTouchingCursor = true;
+break;
+  }
+}
+if (!IsDeclTouchingCursor)
+  return llvm::None;
+  }
   // FIXME: Fill in HighlightRange with range coming from N->ASTNode.
   auto Decls = explicitReferenceTargets(N->ASTNode, DeclRelation::Alias);
   if (!Decls.empty()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-09 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a subscriber: tgt.
nlopes added a comment.

In D83360#2142457 , @efriedma wrote:

> > that's fine but I still don't understand why the counterexample to my 
> > version says %x2 in @src can be undef
>
> If I'm understanding correctly, this reduces to something like the following:
>
> define i32 @src() {
>
>   %x2 = freeze i32 undef
>   ret i32 %x2
>
> }
>
> define i32 @tgt() {
>
>   ret i32 undef
>
> }
>
> This seems a little suspect, yes.


This is a known bug: https://github.com/AliveToolkit/alive2/issues/3
gotta fix this soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked 5 inline comments as done.
zequanwu added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/CGProfile.cpp:64
   // Ignore error here.  Indirect calls are ignored if this fails.
-  (void)(bool)Symtab.create(M);
+  (void)(bool) Symtab.create(M);
   for (auto &F : M) {

echristo wrote:
> Extra space? Did clang-format put this in?
Yes, `clang-format` put this in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 276834.
zequanwu added a comment.

Add comments and fix test failure in http://45.33.8.238/linux/22500/step_7.txt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll

Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -266,6 +266,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -285,6 +285,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O2-pipeline.ll
===
--- llvm/test/Other/opt-O2-pipeline.ll
+++ llvm/test/Other/opt-O2-pipeline.ll
@@ -280,6 +280,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/new-pm-cgprofile.ll
===
--- llvm/test/Other/new-pm-cgprofile.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: opt -debug-pass-manager -passes='default' %s 2>&1 |FileCheck %s --check-prefixes=DEFAULT
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=0 %s 2>&1 |FileCheck %s --check-prefixes=OFF
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=1 %s 2>&1 |FileCheck %s --check-prefixes=ON
-;
-; DEFAULT: Running pass: CGProfilePass
-; OFF-NOT: Running pass: CGProfilePass
-; ON: Running pass: CGProfilePass
-
-define void @foo() {
-  ret void
-}
Index: llvm/test/Instrumentation/cgprofile.ll
===
--- llvm/test/Instrumentation/cgprofile.ll
+++ llvm/test/Instrumentation/cgprofile.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -passes cg-profile -S | FileCheck %s
+; RUN: opt < %s -cg-profile -S | FileCheck %s
 
 declare void @b()
 
Index: llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
@@ -276,6 +276,12 @@
 ; GCN-O1-NEXT:   Warn about non-applied transformations
 ; GCN-O1-NEXT:   Alignment from assumptions
 ; GCN-O1-NEXT: Strip Unused Function Prototypes
+; GCN-O1-NEXT: Call Graph Profile
+; GCN-O1-NEXT:   FunctionPass Manager
+; GCN-O1-NEXT: Dominator Tree Construction
+; GCN-O1-NEXT: Natural Loop Information
+; GCN-O1-NEXT: 

[PATCH] D82436: [clangd] Implement textDocument/foldingRange

2020-07-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

In D82436#2141953 , @sammccall wrote:

> Tests :-)


I was hoping glorious DocumentSymbols super tested API would shield me from 
that :P Didn't think of reasonable testing strategy but fair enough, will do!




Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:300
+opt FoldingRanges{
+"folding-rangees",
+cat(Features),

sammccall wrote:
> rangees -> ranges
My broken keyboard puts multiple symbols all over the place :( Catching them 
all is hard, sorry, the other patch also had a couple of those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82436



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


[PATCH] D83502: Change behavior with zero-sized static array extents

2020-07-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2515
+} else {
+  AI->addAttr(llvm::Attribute::NonNull);
+}

Isn't the old logic still correct?  If the element size is static and the 
element count is positive, the argument is dereferenceable out to their 
product; otherwise it's nonnull if null is the zero value and we aren't 
semantically allowing that to be a valid pointer.


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

https://reviews.llvm.org/D83502



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


[PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code

2020-07-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:10068
+isa(D) && cast(D)->isFileVarDecl() &&
+cast(D)->getStorageClass() == SC_Static) {
+  return GVA_StrongExternal;

JonChesterfield wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > Are you sure this doesn't apply to e.g. local statics?  Can't you have 
> > > kernel lambdas, or am I confusing HIP with another language?
> > function-scope static var in a device function is only visible to the 
> > device function. Host code cannot access it, therefore no need to 
> > externalize it.
> This doesn't sound right. An inline function can return a pointer to a 
> function scope static variable, e.g. to implement a singleton in a header 
> file.  I think host code can then access said variable.
Right, and IIRC you can declare __host__ __device__ functions as well, which 
ought to agree on the variable if they agree on globals.



Comment at: clang/lib/Driver/Action.cpp:170
+  if (!Id)
+Id = llvm::sys::Process::GetRandomNumber();
+}

yaxunl wrote:
> rjmccall wrote:
> > I'm sure GetRandomNumber can return 0, so this logic is faulty.
> > 
> > This also seems like an unfortunate intrusion of HIP-specific semantics on 
> > the rest of the driver.  Maybe HIP can generate the shared id when it's 
> > setting up and cloning the job.
> Changed type of ID to string. Now empty ID means disabled. 0 is now allowed 
> as a usual ID.
> 
> Moved initialization of ID to HIP action builder.
Thanks, that works.


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

https://reviews.llvm.org/D80858



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:83
+return PD->getDefinition();
+  // Objective-C classes can have three types of declarations:
+  //

This is a really useful comment, thanks!



Comment at: clang-tools-extra/clangd/XRefs.cpp:88-92
+  if (const auto *ID = dyn_cast(D)) {
+if (const auto *IMD = ID->getImplementation())
+  return IMD;
+return ID->getDefinition();
+  }

dgoldman wrote:
> Let me know if there's a better way to handle this multi-"definition" support
I think there might be (what you've done seems reasonable in isolation but I'm 
not sure it'll yield the best behavior).

Consider this code:
```
int foo(); // A
int foo(); // B
int foo(){} // C
```
We have 3 declarations. A will be chosen as the canonical declaration (because 
it's first, though things get more complicated when the index is involved). C 
is the definition. So go-to-definition will land on C, and then triggering it 
again will take you to A, and then back to C. go-to-declaration is the 
opposite. B is basically just a reference for our purposes, we won't navigate 
you there (except by find-refs).

Now let's look at your example again:
```
@class MyClass; // A
@interface MyClass ... @end // B
@implementation MyClass ... @end // C
```
Thinking about where you might want to navigate to, A is certainly the least 
important of these, right?
It seems clear we want B to be considered the canonical declaration and C the 
definition.

So I think:
 - we should only return the implementation here if it exists, and otherwise 
nullptr rather than the inferface.
 - getCanonicalDecl in AddResultDecl should special case ObjCInterfaceDecl to 
get the definition (i.e. @interface) if possible
 - we need to convince other parts of clangd that these are the same symbol:
   - targetDecl should resolve any reference to an ObjCImplDecl to the 
corresponding ObjCInterfaceDecl instead
   - the indexer (`SymbolCollector`) also needs to handle this (the 
ObjCImplDecl should end up being the stored Definition under the 
ObjCInterfaceDecl's SymbolID)

Some code will only see the forward declaration and that's OK. The index's 
merge rules are that a candidate "canonical declaration" which has an 
associated definition is preferred over one that doesn't. Since the 
implementation can always see the interface, the interface will end up being 
the canonical declaration after merge.



Comment at: clang-tools-extra/clangd/XRefs.cpp:276
getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {

dgoldman wrote:
> Think it would make sense to special case ObjCInterfaceDecl here to get at 
> both the interface definition + implementation if available?
Rather than returning both results, I think it's more consistent to return them 
as a declaration/definition pair.

(This means special-casing ObjCImplDecl in namedDecl or at least 
getDeclAsPosition, so you always end up with the ObjCInterfaceDecl instead)



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:723
+std::string ObjcPrefix = "//objc";
+if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) {
+  TU.Filename = "TestTU.m";

Hm, I quite like this. You can probably also just do 
TU.ExtraArgs.push_back("-xobjective-c++") though, it probably won't break 
anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


[PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary

2020-07-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This seems fine.  I do wonder if the "real" bug is that this ought to be 
handled properly in EmitReturnFromThunk, but regardless, the fix seems 
acceptable.

Is there a similar bug with trivial_abi?  Should we have a test case for that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82513



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


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-09 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

Seems like the general approach we want.

Could you:

- Fix the lint warnings
- Find out why the unit tests failed
- Add strcmp
- Modify the memcmp/strcmp unit tests to show that we can solve them 
with/without ASan

After that I'll take a closer look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494



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


[PATCH] D83426: Unbreak Clang standalone build.

2020-07-09 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added a comment.

Thanks.

Would you be able to land this on my behalf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83426



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


[clang] c025bdf - Revert D83013 "[LPM] Port CGProfilePass from NPM to LPM"

2020-07-09 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-07-09T13:34:04-07:00
New Revision: c025bdf25a59a79d60a2e99962c8653547a825d8

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

LOG: Revert D83013 "[LPM] Port CGProfilePass from NPM to LPM"

This reverts commit c92a8c0a0f68fbbb23e3fdde071007e63a552e82.

It breaks builds and has unaddressed review comments.

Added: 
llvm/test/Other/new-pm-cgprofile.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Transforms/IPO.h
llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/Instrumentation/CGProfile.cpp
llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Instrumentation/cgprofile.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index f3e43919eeca..d465e00d4c70 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -252,6 +252,7 @@ CODEGENOPT(UnwindTables  , 1, 0) ///< Emit unwind 
tables.
 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
 CODEGENOPT(VectorizeSLP  , 1, 0) ///< Run SLP vectorizer.
 CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
+CODEGENOPT(CallGraphProfile  , 1, 0) ///< Run call graph profile.
 
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3ada1aaa4ed8..9e6d5e4593d3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -620,7 +620,6 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager 
&MPM,
   PMBuilder.SizeLevel = CodeGenOpts.OptimizeSize;
   PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP;
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
-  PMBuilder.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   // Loop interleaving in the loop vectorizer has historically been set to be
@@ -1145,7 +1144,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
-  PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
+  PTO.CallGraphProfile = CodeGenOpts.CallGraphProfile;
   PTO.Coroutines = LangOpts.Coroutines;
 
   PassInstrumentationCallbacks PIC;
@@ -1563,7 +1562,7 @@ static void runThinLTOBackend(
   Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops;
   Conf.PTO.LoopVectorization = CGOpts.VectorizeLoop;
   Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP;
-  Conf.PTO.CallGraphProfile = !CGOpts.DisableIntegratedAS;
+  Conf.PTO.CallGraphProfile = CGOpts.CallGraphProfile;
 
   // Context sensitive profile.
   if (CGOpts.hasProfileCSIRInstr()) {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index fd34c6b8a955..6f6af917e3a3 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -860,6 +860,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList 
&Args, InputKind IK,
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
+  Opts.CallGraphProfile = !Opts.DisableIntegratedAS;
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile =
   std::string(Args.getLastArgValue(OPT_fprofile_sample_use_EQ));

diff  --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index 06e8507036ac..f0d5accf13c5 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -103,7 +103,6 @@ void initializeCFGViewerLegacyPassPass(PassRegistry&);
 void initializeCFIInstrInserterPass(PassRegistry&);
 void initializeCFLAndersAAWrapperPassPass(PassRegistry&);
 void initializeCFLSteensAAWrapperPassPass(PassRegistry&);
-void initializeCGProfileLegacyPassPass(PassRegistry &);
 void initializeCallGraphDOTPrinterPass(PassRegistry&);
 void initializeCallGraphPrinterLegacyPassPass(PassRegistry&);
 void initializeCallGraphViewerPass(PassRegistry&);

diff  --git a/llvm/include/llvm/Transforms/IPO.h 
b/llvm/include/llvm/Trans

[PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend

2020-07-09 Thread Albion Fung via Phabricator via cfe-commits
Conanap marked an inline comment as done.
Conanap added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:939
+  // The XFormMemOp flag for the following 8 insts is set on the instruction 
format.
+  let mayLoad = 1, mayStore = 1 in {
+def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>;

bsaleil wrote:
> Shouldn't `mayStore` be 0 instead of 1 here ?
yes, thanks; will fix on the commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83364



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

This seems to have broken the build
http://45.33.8.238/linux/22500/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[clang] 53e38c8 - [CMake][Fuchsia] Support for building with MSVC

2020-07-09 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-07-09T13:07:12-07:00
New Revision: 53e38c85a8a6cdcf7776b936d72fb94ec737dc84

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

LOG: [CMake][Fuchsia] Support for building with MSVC

This change adds the necessary flags for building the full Fuchsia
toolchain on Windows with MSVC.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 9ecf8f300e75..4d9b8526d0c4 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -5,7 +5,6 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING 
"")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 if(NOT APPLE)
@@ -22,6 +21,10 @@ set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 
+if(MSVC)
+  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+endif()
+
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
@@ -39,6 +42,8 @@ set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 if (APPLE)
   set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
+elseif(MSVC)
+  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
 endif()
 
 if(APPLE)
@@ -65,6 +70,26 @@ if(APPLE)
   set(DARWIN_iossim_ARCHS i386;x86_64 CACHE STRING "")
   set(DARWIN_osx_ARCHS x86_64 CACHE STRING "")
   set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "")
+  set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE 
STRING "")
+endif()
+
+if(WIN32)
+  set(target "x86_64-pc-windows-msvc")
+
+  list(APPEND BUILTIN_TARGETS "${target}")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+
+  list(APPEND RUNTIME_TARGETS "${target}")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(RUNTIMES_${target}_LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE 
STRING "")
 endif()
 
 foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)
@@ -73,6 +98,9 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING 
"")
+set(BUILTINS_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING 
"")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -82,6 +110,9 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING 
"")
+set(RUNTIMES_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING 
"")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -100,9 +131,9 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-

[PATCH] D73810: [CMake][Fuchsia] Support for building on Windows

2020-07-09 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53e38c85a8a6: [CMake][Fuchsia] Support for building with 
MSVC (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D73810?vs=241822&id=276815#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73810

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake

Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -5,7 +5,6 @@
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
@@ -16,6 +15,10 @@
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 
+if(MSVC)
+  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+endif()
+
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
@@ -32,8 +35,10 @@
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
-if (APPLE)
+if(APPLE)
   set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
+elseif(MSVC)
+  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
 endif()
 
 if(APPLE)
@@ -52,8 +57,19 @@
 set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
-set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
-set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+if(WIN32)
+  set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF CACHE BOOL "")
+  set(BUILTINS_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
+  set(RUNTIMES_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
+  set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+else()
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
+  set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
+endif()
 
 if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
   set(target "${BOOTSTRAP_CMAKE_CXX_COMPILER_TARGET}")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -5,7 +5,6 @@
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 if(NOT APPLE)
@@ -22,6 +21,10 @@
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 
+if(MSVC)
+  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+endif()
+
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
@@ -39,6 +42,8 @@
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 if (APPLE)
   set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
+elseif(MSVC)
+  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
 endif()
 
 if(APPLE)
@@ -65,6 +70,26 @@
   set(DARWIN_iossim_ARCHS i386;x86_64 CACHE STRING "")
   set(DARWIN_osx_ARCHS x86_64 CACHE STRING "")
   set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "")
+  set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
+endif()
+
+if(WIN32)
+  set(target "x86_64-pc-windows-msvc")
+
+  list(APPEND BUILTIN_TARGETS "${target}")
+  set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+
+  list(APPEND RUNTIME_TARGETS "${target}")
+  set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
+  set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
+  set(RUNTIMES_${target}_LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
 endif()
 
 foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu

[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-09 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Some inline nits. I see you've already committed and that's fine - I still 
don't think we should do it, but we can delete it again soon :)




Comment at: clang/lib/CodeGen/BackendUtil.cpp:623
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
+  PMBuilder.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
 

Comment here as to why.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1148
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
-  PTO.CallGraphProfile = CodeGenOpts.CallGraphProfile;
+  PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
   PTO.Coroutines = LangOpts.Coroutines;

Comment here as to why.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1566
   Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP;
-  Conf.PTO.CallGraphProfile = CGOpts.CallGraphProfile;
+  Conf.PTO.CallGraphProfile = !CGOpts.DisableIntegratedAS;
 

Ditto :)



Comment at: llvm/lib/Transforms/Instrumentation/CGProfile.cpp:64
   // Ignore error here.  Indirect calls are ignored if this fails.
-  (void)(bool)Symtab.create(M);
+  (void)(bool) Symtab.create(M);
   for (auto &F : M) {

Extra space? Did clang-format put this in?



Comment at: llvm/lib/Transforms/Instrumentation/CGProfile.cpp:66
   for (auto &F : M) {
-if (F.isDeclaration())
+if (F.isDeclaration() || !F.getEntryCount())
   continue;

Comment? What's the change for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a subscriber: tgt.
efriedma added a comment.

> that's fine but I still don't understand why the counterexample to my version 
> says %x2 in @src can be undef

If I'm understanding correctly, this reduces to something like the following:

define i32 @src() {

  %x2 = freeze i32 undef
  ret i32 %x2

}

define i32 @tgt() {

  ret i32 undef

}

This seems a little suspect, yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[clang] c92a8c0 - [LPM] Port CGProfilePass from NPM to LPM

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

Author: Zequan Wu
Date: 2020-07-09T13:03:42-07:00
New Revision: c92a8c0a0f68fbbb23e3fdde071007e63a552e82

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

LOG: [LPM] Port CGProfilePass from NPM to LPM

Reviewers: hans, chandlerc!, asbirlea, nikic

Reviewed By: hans, nikic

Subscribers: steven_wu, dexonsmith, nikic, echristo, void, zhizhouy, 
cfe-commits, aeubanks, MaskRay, jvesely, nhaehnle, hiraditya, kerbowa, 
llvm-commits

Tags: #llvm, #clang

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

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Transforms/IPO.h
llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/Instrumentation/CGProfile.cpp
llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Instrumentation/cgprofile.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll

Removed: 
llvm/test/Other/new-pm-cgprofile.ll



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index d465e00d4c70..f3e43919eeca 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -252,7 +252,6 @@ CODEGENOPT(UnwindTables  , 1, 0) ///< Emit unwind 
tables.
 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
 CODEGENOPT(VectorizeSLP  , 1, 0) ///< Run SLP vectorizer.
 CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
-CODEGENOPT(CallGraphProfile  , 1, 0) ///< Run call graph profile.
 
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 9e6d5e4593d3..3ada1aaa4ed8 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -620,6 +620,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager 
&MPM,
   PMBuilder.SizeLevel = CodeGenOpts.OptimizeSize;
   PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP;
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
+  PMBuilder.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   // Loop interleaving in the loop vectorizer has historically been set to be
@@ -1144,7 +1145,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
-  PTO.CallGraphProfile = CodeGenOpts.CallGraphProfile;
+  PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
   PTO.Coroutines = LangOpts.Coroutines;
 
   PassInstrumentationCallbacks PIC;
@@ -1562,7 +1563,7 @@ static void runThinLTOBackend(
   Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops;
   Conf.PTO.LoopVectorization = CGOpts.VectorizeLoop;
   Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP;
-  Conf.PTO.CallGraphProfile = CGOpts.CallGraphProfile;
+  Conf.PTO.CallGraphProfile = !CGOpts.DisableIntegratedAS;
 
   // Context sensitive profile.
   if (CGOpts.hasProfileCSIRInstr()) {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 6f6af917e3a3..fd34c6b8a955 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -860,7 +860,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList 
&Args, InputKind IK,
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
-  Opts.CallGraphProfile = !Opts.DisableIntegratedAS;
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile =
   std::string(Args.getLastArgValue(OPT_fprofile_sample_use_EQ));

diff  --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index f0d5accf13c5..06e8507036ac 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -103,6 +103,7 @@ void initializeCFGViewerLegacyPassPass(PassRegistry&);
 void initializeCFIInstrInserterPass(PassRegistry&);
 void initializeCFLAndersAAWrapperPassPass(PassRegistry&);
 void initializeCFLSteensAAWrapperPassPass(PassRegistry&);
+void initializeCGProfileLegacyPassPass(PassRegistry &);
 void initializeCallGraphDOTPrinterPass(PassRegistry&);
 void initializeCallGra

[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc92a8c0a0f68: [LPM] Port CGProfilePass from NPM to LPM 
(authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll

Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -266,6 +266,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -285,6 +285,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O2-pipeline.ll
===
--- llvm/test/Other/opt-O2-pipeline.ll
+++ llvm/test/Other/opt-O2-pipeline.ll
@@ -280,6 +280,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/new-pm-cgprofile.ll
===
--- llvm/test/Other/new-pm-cgprofile.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: opt -debug-pass-manager -passes='default' %s 2>&1 |FileCheck %s --check-prefixes=DEFAULT
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=0 %s 2>&1 |FileCheck %s --check-prefixes=OFF
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=1 %s 2>&1 |FileCheck %s --check-prefixes=ON
-;
-; DEFAULT: Running pass: CGProfilePass
-; OFF-NOT: Running pass: CGProfilePass
-; ON: Running pass: CGProfilePass
-
-define void @foo() {
-  ret void
-}
Index: llvm/test/Instrumentation/cgprofile.ll
===
--- llvm/test/Instrumentation/cgprofile.ll
+++ llvm/test/Instrumentation/cgprofile.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -passes cg-profile -S | FileCheck %s
+; RUN: opt < %s -cg-profile -S | FileCheck %s
 
 declare void @b()
 
Index: llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
@@ -276,6 +276,12 @@
 ; GCN-O1-NEXT:   Warn about non-applied transformations
 ; GCN-O1-NEXT:   Alignment from assumptions
 ; GCN-O1-NEXT: Strip Unused Function Prototypes
+; GCN-O1-NEXT: Call Graph Profile
+; GCN-O1-NEXT:   FunctionPass Manager
+; GCN-O1-NEXT: 

[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 276813.
zequanwu added a comment.

rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll

Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -266,6 +266,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -285,6 +285,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O2-pipeline.ll
===
--- llvm/test/Other/opt-O2-pipeline.ll
+++ llvm/test/Other/opt-O2-pipeline.ll
@@ -280,6 +280,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/new-pm-cgprofile.ll
===
--- llvm/test/Other/new-pm-cgprofile.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: opt -debug-pass-manager -passes='default' %s 2>&1 |FileCheck %s --check-prefixes=DEFAULT
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=0 %s 2>&1 |FileCheck %s --check-prefixes=OFF
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=1 %s 2>&1 |FileCheck %s --check-prefixes=ON
-;
-; DEFAULT: Running pass: CGProfilePass
-; OFF-NOT: Running pass: CGProfilePass
-; ON: Running pass: CGProfilePass
-
-define void @foo() {
-  ret void
-}
Index: llvm/test/Instrumentation/cgprofile.ll
===
--- llvm/test/Instrumentation/cgprofile.ll
+++ llvm/test/Instrumentation/cgprofile.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -passes cg-profile -S | FileCheck %s
+; RUN: opt < %s -cg-profile -S | FileCheck %s
 
 declare void @b()
 
Index: llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
@@ -276,6 +276,12 @@
 ; GCN-O1-NEXT:   Warn about non-applied transformations
 ; GCN-O1-NEXT:   Alignment from assumptions
 ; GCN-O1-NEXT: Strip Unused Function Prototypes
+; GCN-O1-NEXT: Call Graph Profile
+; GCN-O1-NEXT:   FunctionPass Manager
+; GCN-O1-NEXT: Dominator Tree Construction
+; GCN-O1-NEXT: Natural Loop Information
+; GCN-O1-NEXT: Lazy Branch Probability Analysis
+; GCN-O1-NEXT: Lazy Bl

[PATCH] D83502: Change behavior with zero-sized static array extents

2020-07-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, echristo, dblaikie, rjmccall.

Currently, Clang diagnoses this code by default: `void f(int a[static 0]);` 
saying that "static has no effect on zero-length arrays" and this diagnostic is 
accurate for our implementation.

However, static array extents require that the caller of the function pass a 
nonnull pointer to an array of *at least* that number of elements, but it can 
pass more (see C17 6.7.6.3p6). Given that we allow zero-sized arrays as a GNU 
extension and that it's valid to pass more elements than specified by the 
static array extent, I think we should support zero-sized static array extents 
with the usual semantics because it can be useful, as pointed out to me on 
Twitter (https://twitter.com/rep_stosq_void/status/1280892279998291973):

  void my_bzero(char p[static 0], int n);
  my_bzero(&c+1, 0); //ok
  my_bzero(t+k,n-k); //ok, pattern from actual code


https://reviews.llvm.org/D83502

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/vla.c
  clang/test/Sema/static-array.c


Index: clang/test/Sema/static-array.c
===
--- clang/test/Sema/static-array.c
+++ clang/test/Sema/static-array.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks 
-verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks 
-pedantic -verify %s
 
-void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on 
zero-length arrays}}
+void cat0(int a[static 0]) {} // expected-warning {{zero size arrays are an 
extension}} \
+  // expected-note {{callee declares array 
parameter as static here}}
 
 void cat(int a[static 3]) {} // expected-note 4 {{callee declares array 
parameter as static here}} expected-note 2 {{passing argument to parameter 'a' 
here}}
 
@@ -9,7 +10,7 @@
 void f(int *p) {
   int a[2], b[3], c[4];
 
-  cat0(0);
+  cat0(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
 
   cat(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
   cat(a); // expected-warning {{array argument is too small; contains 2 
elements, callee requires at least 3}}
Index: clang/test/CodeGen/vla.c
===
--- clang/test/CodeGen/vla.c
+++ clang/test/CodeGen/vla.c
@@ -206,3 +206,6 @@
 // NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
 // NULL-VALID: define void @test9(i32 %n, i32* %a)
 
+// Make sure a zero-sized static array extent is still required to be nonnull.
+void test10(int a[static 0]) {}
+// CHECK: define void @test10(i32* nonnull %a)
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2393,13 +2393,6 @@
  ? diag::err_typecheck_zero_array_size
  : diag::ext_typecheck_zero_array_size)
   << ArraySize->getSourceRange();
-
-  if (ASM == ArrayType::Static) {
-Diag(ArraySize->getBeginLoc(),
- diag::warn_typecheck_zero_static_array_size)
-<< ArraySize->getSourceRange();
-ASM = ArrayType::Normal;
-  }
 } else if (!T->isDependentType() && !T->isVariablyModifiedType() &&
!T->isIncompleteType() && !T->isUndeducedType()) {
   // Is the array too large?
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2500,12 +2500,20 @@
 if (ArrTy->getSizeModifier() == ArrayType::Static) {
   QualType ETy = ArrTy->getElementType();
   uint64_t ArrSize = ArrTy->getSize().getZExtValue();
-  if (!ETy->isIncompleteType() && ETy->isConstantSizeType() &&
-  ArrSize) {
-llvm::AttrBuilder Attrs;
-Attrs.addDereferenceableAttr(
-  getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize);
-AI->addAttrs(Attrs);
+  if (!ETy->isIncompleteType() && ETy->isConstantSizeType()) {
+// If the type is complete and we know the array size is non-
+// zero, then we know the dereferencable range of memory.
+// Otherwise, if the array size is zero, we only know that the
+// memory must be nonnull.
+if (ArrSize) {
+  llvm::AttrBuilder Attrs;
+  Attrs.addDereferenceableAttr(
+  getContext().getTypeSizeInChars(ETy).getQuantity() *
+  ArrSize);
+  AI->addAttrs(Attrs);
+} else {
+  

[PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional.

2020-07-09 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

LGTM. I verified this works for the build-tree standalone build of LLDB, but 
please still keep an eye on 
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/ after you 
land this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83454



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


[PATCH] D79730: [NFCi] Switch ordering of ParseLangArgs and ParseCodeGenArgs.

2020-07-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Either way, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79730



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


[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-07-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Would it be sensible to use a technical design more like what the matrix folks 
are doing, where LLVM provides a small interface for emitting operations with 
various semantics?  FixedPointSemantics would move to that header, and Clang 
would just call into it.  That way you get a lot more flexibility in how you 
generate code, and the Clang IRGen logic is still transparently correct.  If 
you want to add intrinsics or otherwise change the IR patterns used for various 
operations, you don't have to rewrite a bunch of Clang IRGen logic every time, 
you just have to update the tests.  It'd then be pretty straightforward to have 
internal helper functions in that interface for computing things like whether 
you should use signed or unsigned intrinsics given the desired 
FixedPointSemantics.

My interest here is mainly in (1) keeping IRGen's logic as obviously correct as 
possible, (2) not hard-coding a bunch of things that really feel like 
workarounds for backend limitations, and (3) not complicating core abstractions 
like FixedPointSemantics with unnecessary extra rules for appropriate use, like 
having to pass an extra "for codegen" flag to get optimal codegen.  If IRGen 
can just pass down the high-level semantics it wants to some library that will 
make intelligent decisions about how to emit IR, that seems best.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82663



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


[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-07-09 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14273
+// The third argument to vec_replace_elt will be emitted to either
+// the vinsw or vinsd instruction. It must be a compile time constant.
+ConstantInt *ArgCI = dyn_cast(Ops[2]);

Do you mean?
```
// The third argument of vec_replace_elt must be a compile time constant 
and will be emitted either
//  to the vinsw or vinsd instruction.
```



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14289
+  else
+ConstArg = (ConstArg * 4);
+  Ops[2] = ConstantInt::getSigned(Int32Ty, ConstArg);

```
ConstArg *= 4;
// Fix the constant according to endianess.
if (getTarget().isLittleEndian())
   ConstArg = 12 - ConstArg;
```



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14320
+Call = Builder.CreateCall(F, Ops);
+}
+return Call;

What are the chances of reaching to the end of this if/else-if section and 
`Call` is null? ie `getPrimitiveSizeInBits() != [32|64]`
I feel like it would be better if we can structure it so that we are not doing 
all these nesting of `if`s and just do returns within the diff if-conditions.

Have you tried to pull out the diff handling of 32/64bit arg and consolidating 
the code a bit?


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

https://reviews.llvm.org/D83500



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 276808.
zequanwu added a comment.

Update test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll

Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -266,6 +266,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -285,6 +285,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O2-pipeline.ll
===
--- llvm/test/Other/opt-O2-pipeline.ll
+++ llvm/test/Other/opt-O2-pipeline.ll
@@ -280,6 +280,12 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/new-pm-cgprofile.ll
===
--- llvm/test/Other/new-pm-cgprofile.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: opt -debug-pass-manager -passes='default' %s 2>&1 |FileCheck %s --check-prefixes=DEFAULT
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=0 %s 2>&1 |FileCheck %s --check-prefixes=OFF
-; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=1 %s 2>&1 |FileCheck %s --check-prefixes=ON
-;
-; DEFAULT: Running pass: CGProfilePass
-; OFF-NOT: Running pass: CGProfilePass
-; ON: Running pass: CGProfilePass
-
-define void @foo() {
-  ret void
-}
Index: llvm/test/Instrumentation/cgprofile.ll
===
--- llvm/test/Instrumentation/cgprofile.ll
+++ llvm/test/Instrumentation/cgprofile.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -passes cg-profile -S | FileCheck %s
+; RUN: opt < %s -cg-profile -S | FileCheck %s
 
 declare void @b()
 
Index: llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
@@ -276,6 +276,12 @@
 ; GCN-O1-NEXT:   Warn about non-applied transformations
 ; GCN-O1-NEXT:   Alignment from assumptions
 ; GCN-O1-NEXT: Strip Unused Function Prototypes
+; GCN-O1-NEXT: Call Graph Profile
+; GCN-O1-NEXT:   FunctionPass Manager
+; GCN-O1-NEXT: Dominator Tree Construction
+; GCN-O1-NEXT: Natural Loop Information
+; GCN-O1-NEXT: Lazy Branch Probability Analysis
+; GCN-O1-NEXT:  

[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-09 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:276
getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {

Think it would make sense to special case ObjCInterfaceDecl here to get at both 
the interface definition + implementation if available?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


[PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts.

2020-07-09 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3857
+
+  // TODO: This misses out on the sanitizer check below.
+  if (Ops.isFixedPointOp())

I don't suppose you could file a bug for this and CC me on it so we can 
remember to do this sometime after this lands?



Comment at: clang/test/Frontend/fixed_point_compound.c:384
+  // CHECK-NEXT:[[TMP4:%.*]] = load i16, i16* @suf, align 2
+  // CHECK-NEXT:[[TMP5:%.*]] = trunc i32 [[TMP3]] to i16
+  // SIGNED-NEXT:   [[TMP6:%.*]] = call i16 @llvm.ushl.sat.i16(i16 [[TMP4]], 
i16 [[TMP5]])

ebevhan wrote:
> leonardchan wrote:
> > This seems very unlikely, but if `i` in this case was a value at least 
> > 2^16, the upper half would be cut off and we'd potentially shift by an 
> > improper amount for some values of `i` when we should actually clamp to the 
> > max value. We should probably still   find the common semantics for both 
> > sides if we're doing a shift.
> If the value is so large to be cut off by that truncation then the value is 
> greater than the bitwidth, which is UB. So I don't think it's an issue.
Ah right I forgot that.



Comment at: clang/test/Frontend/fixed_point_compound.c:388-390
+  // UNSIGNED-NEXT: [[TMP7:%.*]] = icmp slt i16 [[TMP6]], 0
+  // UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP7]], i16 0, i16 [[TMP6]]
+  // UNSIGNED-NEXT: store i16 [[SATMIN]], i16* @suf, align 2

I'm assuming these checks are also a result of D82663? I don't think for the 
padding case, we should need to do the compare and select if we're already 
using the signed sat intrinsic. But I'm guessing it might make the 
implementation more complicated by having to check for this.

If this codegen comes from the `EmitFixedPointConversion` at the end of 
`EmitFixedPointBinOp`, perhaps it might be worthwhile adding a parameter in 
`EmitFixedPointConversion` to indicate that we shouldn't emit this. I think 
there's some cases in D82663 also where we might not need to do these checks 
afterwards with other operations like with:

```
// UNSIGNED-NEXT: [[TMP25:%.*]] = call i16 @llvm.sadd.sat.i16(i16 [[TMP22]], 
i16 32767)
// UNSIGNED-NEXT: [[TMP26:%.*]] = icmp slt i16 [[TMP25]], 0
// UNSIGNED-NEXT: [[SATMIN2:%.*]] = select i1 [[TMP26]], i16 0, i16 [[TMP25]]
// UNSIGNED-NEXT: store i16 [[SATMIN2]], i16* @suf, align 2
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83294



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


[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-07-09 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 276804.
amyk added a comment.

Updated for clang format changes.


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

https://reviews.llvm.org/D83500

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c

Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -24,10 +24,14 @@
 vector unsigned __int128 vui128a, vui128b, vui128c;
 vector float vfa, vfb;
 vector double vda, vdb;
+signed int sia;
 unsigned int uia, uib;
 unsigned char uca;
 unsigned short usa;
+signed long long slla;
 unsigned long long ulla;
+float fa;
+double da;
 
 vector unsigned long long test_vpdepd(void) {
   // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
@@ -581,3 +585,123 @@
   // CHECK: ret <4 x float>
   return vec_splati_ins(vfa, 0, 1.0f);
 }
+
+vector signed int test_vec_replace_elt_si(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <4 x i32>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 12
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_replace_elt(vsia, sia, 0);
+}
+
+vector unsigned int test_vec_replace_elt_ui(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-BE-NEXT: ret <4 x i32>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_replace_elt(vuia, uia, 1);
+}
+
+vector float test_vec_replace_elt_f(void) {
+  // CHECK-BE: bitcast float %{{.+}} to i32
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <4 x float>
+  // CHECK-BE-NEXT: ret <4 x float>
+  // CHECK: bitcast float %{{.+}} to i32
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <4 x float>
+  // CHECK-NEXT: ret <4 x float>
+  return vec_replace_elt(vfa, fa, 2);
+}
+
+vector signed long long test_vec_replace_elt_sll(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <2 x i64>
+  // CHECK: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_replace_elt(vslla, slla, 0);
+}
+
+vector unsigned long long test_vec_replace_elt_ull(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-BE-NEXT: ret <2 x i64>
+  // CHECK: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_replace_elt(vulla, ulla, 0);
+}
+
+vector double test_vec_replace_elt_d(void) {
+  // CHECK-BE: bitcast double %{{.+}} to i64
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <2 x i64> %{{.*}} to <2 x double>
+  // CHECK-BE-NEXT: ret <2 x double>
+  // CHECK: bitcast double %{{.+}} to i64
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 0
+  // CHECK-NEXT: bitcast <2 x i64> %{{.*}} to <2 x double>
+  // CHECK-NEXT: ret <2 x double>
+  return vec_replace_elt(vda, da, 1);
+}
+
+vector unsigned char test_vec_replace_unaligned_si(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 6
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 6
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vsia, sia, 6);
+}
+
+vector unsigned char test_vec_replace_unaligned_ui(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 4
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vuia, uia, 8);
+}
+
+vector unsigned char test_vec_replace_unaligned_f(void) {
+  // CHECK-BE: bitcast float %{{.+}} to i32
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 12
+  // CHECK-BE-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-BE-NEXT: ret <16 x i8>
+  // CHECK: bitcast float %{{.+}} to i32
+  // CHECK-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 0
+  // CHECK-NEXT: bitcast <4 x i32> %{{.*}} to <16 x i8>
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_replace_unaligned(vfa, fa, 12);
+}
+
+vector unsigned char test_vec_replace_unaligned_sll(void) {
+  // CHECK-BE: @llvm.ppc.altivec.vinsd(<2 x i64> %{{.+}}, i64 %{{.+}}, i32 6
+  // CHE

[clang] 25ec96d - [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting

2020-07-09 Thread David Tenty via cfe-commits

Author: David Tenty
Date: 2020-07-09T15:15:30-04:00
New Revision: 25ec96d91a3a5326a403496fa5532ff0bdb6a15b

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

LOG: [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting

Summary:
AIX uses an environment variable called OBJECT_MODE to indicate to
utilities in the toolchain whether they should be operating in 32-bit or
64-bit mode. This patch makes the clang driver recognize the current
OBJECT_MODE setting when we are operating with an AIX target and adds a
custom diagnostic for invalid settings.

For more details about OBJECT_MODE on AIX see:

https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.3/com.ibm.xlc1313.aix.doc/compiler_ref/tusetenv1.html
https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.3/com.ibm.xlc1313.aix.doc/compiler_ref/opt_3264.html

Reviewers: stevewan, hubert.reinterpretcast, ShuhongL, jasonliu

Reviewed By: hubert.reinterpretcast, jasonliu

Subscribers: jasonliu, cfe-commits

Tags: #clang

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

Added: 
clang/test/Driver/aix-object-mode.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index dcb3b96cd057..baf01d853233 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -509,4 +509,6 @@ def warn_drv_libstdcxx_not_found : Warning<
   InGroup>;
 
 def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
+
+def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not 
recognized and is not a valid setting.">;
 }

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 596e694760d0..ece8222dcf24 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -475,6 +475,26 @@ static llvm::Triple computeTargetTriple(const Driver &D,
   Target.getOS() == llvm::Triple::Minix)
 return Target;
 
+  // On AIX, the env OBJECT_MODE may affect the resulting arch variant.
+  if (Target.isOSAIX()) {
+if (Optional ObjectModeValue =
+llvm::sys::Process::GetEnv("OBJECT_MODE")) {
+  StringRef ObjectMode = *ObjectModeValue;
+  llvm::Triple::ArchType AT = llvm::Triple::UnknownArch;
+
+  if (ObjectMode.equals("64")) {
+AT = Target.get64BitArchVariant().getArch();
+  } else if (ObjectMode.equals("32")) {
+AT = Target.get32BitArchVariant().getArch();
+  } else {
+D.Diag(diag::err_drv_invalid_object_mode) << ObjectMode;
+  }
+
+  if (AT != llvm::Triple::UnknownArch && AT != Target.getArch())
+Target.setArch(AT);
+}
+  }
+
   // Handle pseudo-target flags '-m64', '-mx32', '-m32' and '-m16'.
   Arg *A = Args.getLastArg(options::OPT_m64, options::OPT_mx32,
options::OPT_m32, options::OPT_m16);

diff  --git a/clang/test/Driver/aix-object-mode.c 
b/clang/test/Driver/aix-object-mode.c
new file mode 100644
index ..a4bc79a4b41d
--- /dev/null
+++ b/clang/test/Driver/aix-object-mode.c
@@ -0,0 +1,22 @@
+// Check that setting an OBJECT_MODE converts the AIX triple to the right 
variant.
+// RUN: env OBJECT_MODE=64 \
+// RUN: %clang -target powerpc-ibm-aix -print-target-triple | FileCheck 
-check-prefix=CHECK64 %s
+
+// RUN: env OBJECT_MODE=32 \
+// RUN: %clang -target powerpc64-ibm-aix -print-target-triple | FileCheck 
-check-prefix=CHECK32 %s
+
+// Command-line options win.
+// RUN: env OBJECT_MODE=64 \
+// RUN: %clang -target powerpc64-ibm-aix -print-target-triple -m32 | FileCheck 
-check-prefix=CHECK32 %s
+
+// RUN: env OBJECT_MODE=32 \
+// RUN: %clang -target powerpc-ibm-aix -print-target-triple -m64 | FileCheck 
-check-prefix=CHECK64 %s
+
+// CHECK32: powerpc-ibm-aix
+// CHECK64: powerpc64-ibm-aix
+
+// Emit a diagnostic if there is an invalid mode.
+// RUN: env OBJECT_MODE=31 \
+// RUN: not %clang -target powerpc-ibm-aix 2>&1 | FileCheck -check-prefix=DIAG 
%s
+
+// DIAG: error: OBJECT_MODE setting 31 is not recognized and is not a valid 
setting.



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


[PATCH] D82476: [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting

2020-07-09 Thread David Tenty via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG25ec96d91a3a: [Clang][Driver] Recognize the AIX OBJECT_MODE 
environment setting (authored by daltenty).

Changed prior to commit:
  https://reviews.llvm.org/D82476?vs=273071&id=276803#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82476

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/aix-object-mode.c


Index: clang/test/Driver/aix-object-mode.c
===
--- /dev/null
+++ clang/test/Driver/aix-object-mode.c
@@ -0,0 +1,22 @@
+// Check that setting an OBJECT_MODE converts the AIX triple to the right 
variant.
+// RUN: env OBJECT_MODE=64 \
+// RUN: %clang -target powerpc-ibm-aix -print-target-triple | FileCheck 
-check-prefix=CHECK64 %s
+
+// RUN: env OBJECT_MODE=32 \
+// RUN: %clang -target powerpc64-ibm-aix -print-target-triple | FileCheck 
-check-prefix=CHECK32 %s
+
+// Command-line options win.
+// RUN: env OBJECT_MODE=64 \
+// RUN: %clang -target powerpc64-ibm-aix -print-target-triple -m32 | FileCheck 
-check-prefix=CHECK32 %s
+
+// RUN: env OBJECT_MODE=32 \
+// RUN: %clang -target powerpc-ibm-aix -print-target-triple -m64 | FileCheck 
-check-prefix=CHECK64 %s
+
+// CHECK32: powerpc-ibm-aix
+// CHECK64: powerpc64-ibm-aix
+
+// Emit a diagnostic if there is an invalid mode.
+// RUN: env OBJECT_MODE=31 \
+// RUN: not %clang -target powerpc-ibm-aix 2>&1 | FileCheck -check-prefix=DIAG 
%s
+
+// DIAG: error: OBJECT_MODE setting 31 is not recognized and is not a valid 
setting.
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -475,6 +475,26 @@
   Target.getOS() == llvm::Triple::Minix)
 return Target;
 
+  // On AIX, the env OBJECT_MODE may affect the resulting arch variant.
+  if (Target.isOSAIX()) {
+if (Optional ObjectModeValue =
+llvm::sys::Process::GetEnv("OBJECT_MODE")) {
+  StringRef ObjectMode = *ObjectModeValue;
+  llvm::Triple::ArchType AT = llvm::Triple::UnknownArch;
+
+  if (ObjectMode.equals("64")) {
+AT = Target.get64BitArchVariant().getArch();
+  } else if (ObjectMode.equals("32")) {
+AT = Target.get32BitArchVariant().getArch();
+  } else {
+D.Diag(diag::err_drv_invalid_object_mode) << ObjectMode;
+  }
+
+  if (AT != llvm::Triple::UnknownArch && AT != Target.getArch())
+Target.setArch(AT);
+}
+  }
+
   // Handle pseudo-target flags '-m64', '-mx32', '-m32' and '-m16'.
   Arg *A = Args.getLastArg(options::OPT_m64, options::OPT_mx32,
options::OPT_m32, options::OPT_m16);
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -509,4 +509,6 @@
   InGroup>;
 
 def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
+
+def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not 
recognized and is not a valid setting.">;
 }


Index: clang/test/Driver/aix-object-mode.c
===
--- /dev/null
+++ clang/test/Driver/aix-object-mode.c
@@ -0,0 +1,22 @@
+// Check that setting an OBJECT_MODE converts the AIX triple to the right variant.
+// RUN: env OBJECT_MODE=64 \
+// RUN: %clang -target powerpc-ibm-aix -print-target-triple | FileCheck -check-prefix=CHECK64 %s
+
+// RUN: env OBJECT_MODE=32 \
+// RUN: %clang -target powerpc64-ibm-aix -print-target-triple | FileCheck -check-prefix=CHECK32 %s
+
+// Command-line options win.
+// RUN: env OBJECT_MODE=64 \
+// RUN: %clang -target powerpc64-ibm-aix -print-target-triple -m32 | FileCheck -check-prefix=CHECK32 %s
+
+// RUN: env OBJECT_MODE=32 \
+// RUN: %clang -target powerpc-ibm-aix -print-target-triple -m64 | FileCheck -check-prefix=CHECK64 %s
+
+// CHECK32: powerpc-ibm-aix
+// CHECK64: powerpc64-ibm-aix
+
+// Emit a diagnostic if there is an invalid mode.
+// RUN: env OBJECT_MODE=31 \
+// RUN: not %clang -target powerpc-ibm-aix 2>&1 | FileCheck -check-prefix=DIAG %s
+
+// DIAG: error: OBJECT_MODE setting 31 is not recognized and is not a valid setting.
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -475,6 +475,26 @@
   Target.getOS() == llvm::Triple::Minix)
 return Target;
 
+  // On AIX, the env OBJECT_MODE may affect the resulting arch variant.
+  if (Target.isOSAIX()) {
+if (Optional ObjectModeValue =
+llvm::sys::Process::GetEnv("OBJECT_MODE")) {
+  StringRef ObjectMode = *ObjectModeValue;
+  llvm::Triple::Arc

[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-09 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil added a comment.

Shouldn't we have test cases to test `vec_sl`, `vec_sr` and `vec_sra` ?




Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:800
 def int_ppc_altivec_vsrw  : PowerPC_Vec_WWW_Intrinsic<"vsrw">;
+def int_ppc_altivec_vsrq   : PowerPC_Vec_QQQ_Intrinsic<"vsrq">;
 def int_ppc_altivec_vsrab : PowerPC_Vec_BBB_Intrinsic<"vsrab">;

nit: indentation issue



Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:919
+
+  def VSLQ   : VX1_Int_Ty< 261, "vslq", int_ppc_altivec_vslq, v1i128>;
+  def VSRAQ  : VX1_Int_Ty< 773, "vsraq", int_ppc_altivec_vsraq, v1i128>;

nit: extra spaces before `:` here and in the next two lines


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83338



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


[clang] e81f9cd - [AST][test] Add regression test forPointerExprEvaluator::VisitCXXNewExpr

2020-07-09 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-07-09T12:11:08-07:00
New Revision: e81f9cd2137f258fd1ec6a169db836387bcca84a

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

LOG: [AST][test] Add regression test forPointerExprEvaluator::VisitCXXNewExpr

This assert was failing:
assert(CAT && "unexpected type for array initializer");

until this patch landed:
9a7eda1bece887ca9af085d79fe6e4fb8826dcda
PR45350: Handle unsized array CXXConstructExprs in constant evaluation

Added: 
clang/test/AST/regression-new-expr-crash.cpp

Modified: 


Removed: 




diff  --git a/clang/test/AST/regression-new-expr-crash.cpp 
b/clang/test/AST/regression-new-expr-crash.cpp
new file mode 100644
index ..81dd193b93e8
--- /dev/null
+++ b/clang/test/AST/regression-new-expr-crash.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only %s
+
+struct Bar {int a;};
+const Bar arr[2] = {{1}};
+
+struct Foo {};
+
+const int b = 2;
+
+void foo(int a) {
+  Foo *foo_array;
+  foo_array = new Foo[arr[0].a];
+}



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


[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-07-09 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

> It wouldn't just be restricted to fixed-point intrinsics, though. It would 
> have to be added to intrinsics like uadd.sat and usub.sat as well, which 
> aren't really tied to fixed-point at all.

Oh wait, sorry. I think I'm starting to understand now. You're saying that if 
you're using the padding bit in the first place, ISel shouldn't need to perform 
the underlying shift during integral promotions, but we do it anyway still. 
Yeah it seems a lot of this could be addressed simply by just using the 
corresponding signed intrinsics.

I guess I'd be ok with purely making this a clang change for now, but if other 
frontends see interest in the unsigned padding bit then we could migrate this 
to LLVM down the line.




Comment at: clang/lib/Basic/FixedPoint.cpp:143-158
+  // For codegen purposes, make unsigned with padding semantics signed instead.
+  // This means that we will generate signed operations. The result from these
+  // operations is defined, since ending up with a negative result is undefined
+  // for nonsaturating semantics, and for saturating semantics we will
+  // perform a clamp-to-zero in the last conversion to result semantics (since
+  // we are going from saturating signed to saturating unsigned).
+  //

ebevhan wrote:
> leonardchan wrote:
> > If this is exclusively for codegen purposes with binary operations, would 
> > it be clearer to move this to `EmitFixedPointBinOp`? If 
> > `UnsignedPaddingIsSigned` doesn't need to be used for stuff like constant 
> > evaluation, it might be clearer not to provide it for everyone.
> FixedPointSemantics is immutable except for saturation, unfortunately. I'd 
> end up having to reconstruct the semantics object from scratch immediately 
> after calling getCommonSemantics.
Fair.

Minor nit: Could you rename the parameter to `UnsignedPaddingIsSignedForCG`? 
Just want to make it clearer that this should specifically be used for codegen 
only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82663



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

In D83013#2142271 , @nikic wrote:

> New compile-time numbers: 
> https://llvm-compile-time-tracker.com/compare.php?from=0b39d2d75275b80994dac06b7ad05031cbd09393&to=fd070b79e063fff2fad3cd4a467f64dfca83eb90&stat=instructions
>  It's nearly neutral now.


Sounds great!

lgtm2 (with the test update Nikita mentioned)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend

2020-07-09 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:939
+  // The XFormMemOp flag for the following 8 insts is set on the instruction 
format.
+  let mayLoad = 1, mayStore = 1 in {
+def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>;

Shouldn't `mayStore` be 0 instead of 1 here ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83364



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


[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-07-09 Thread Amy Kwan via Phabricator via cfe-commits
amyk marked 2 inline comments as done.
amyk added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:339
+BUILTIN(__builtin_altivec_vec_replace_elt, "V4UiV4UiULLiIi", "t")
+BUILTIN(__builtin_altivec_vec_replace_unaligned, "V4UiV4UiULLiIi", "t")
 

I originally intended to implement this like the `xxpermdi` builtin:
```
BUILTIN(__builtin_vsx_xxpermdi, "v.", "t")
```
to use `v.` but I am not able to declare these builtins as void. For now, 
they're more or less an arbitrary signature that would match `vinsw`. 



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:606
+vector float test_vec_replace_elt_f(void) {
+  // CHECK-BE: bitcast float %{{.+}} to i32
+  // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, 
i32 8

I've utilized tests that were from Biplob's original patch 
(https://reviews.llvm.org/D82359), but added the `bitcasts` to the float/double 
cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83500



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-09 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:88-92
+  if (const auto *ID = dyn_cast(D)) {
+if (const auto *IMD = ID->getImplementation())
+  return IMD;
+return ID->getDefinition();
+  }

Let me know if there's a better way to handle this multi-"definition" support



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:722
 
+std::string ObjcPrefix = "//objc";
+if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) {

Figured this would be easier than copy + paste, LMK


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


  1   2   3   >