[PATCH] D104096: [Clang-Format] Add ReferenceAlignment directive

2021-06-12 Thread Seraphime Kirkovski (VMware) via Phabricator via cfe-commits
skirkovski updated this revision to Diff 351645.
skirkovski added a comment.

Remove PAS_Pointer from Webkit style (since it derives from LLVM which already 
has it)
Add empty lines between style change in the test case
Split a verifyFormat with 3 different cases into different ones
Add test cases for declaration alignemnts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104096

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1230,6 +1230,98 @@
getLLVMStyleWithColumns(62));
 }
 
+TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
+  FormatStyle Style = getLLVMStyle();
+  // Check first the default LLVM style
+  // Style.PointerAlignment = FormatStyle::PAS_Right;
+  // Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
+  verifyFormat("int *f1(int *a, int &b, int &&c);", Style);
+  verifyFormat("int &f2(int &&c, int *a, int &b);", Style);
+  verifyFormat("int &&f3(int &b, int &&c, int *a);", Style);
+  verifyFormat("int *f1(int &a) const &;", Style);
+  verifyFormat("int *f1(int &a) const & = 0;", Style);
+  verifyFormat("int *a = f1();", Style);
+  verifyFormat("int &b = f2();", Style);
+  verifyFormat("int &&c = f3();", Style);
+
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("Const unsigned int *c;\n"
+   "const unsigned int *d;\n"
+   "Const unsigned int &e;\n"
+   "const unsigned int &f;\n"
+   "const unsigned&&g;\n"
+   "Const unsigned  h;",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
+  verifyFormat("int* f1(int* a, int& b, int&& c);", Style);
+  verifyFormat("int& f2(int&& c, int* a, int& b);", Style);
+  verifyFormat("int&& f3(int& b, int&& c, int* a);", Style);
+  verifyFormat("int* f1(int& a) const& = 0;", Style);
+  verifyFormat("int* a = f1();", Style);
+  verifyFormat("int& b = f2();", Style);
+  verifyFormat("int&& c = f3();", Style);
+
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("Const unsigned int* c;\n"
+   "const unsigned int* d;\n"
+   "Const unsigned int& e;\n"
+   "const unsigned int& f;\n"
+   "const unsigned&&g;\n"
+   "Const unsigned  h;",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  Style.ReferenceAlignment = FormatStyle::RAS_Left;
+  verifyFormat("int *f1(int *a, int& b, int&& c);", Style);
+  verifyFormat("int& f2(int&& c, int *a, int& b);", Style);
+  verifyFormat("int&& f3(int& b, int&& c, int *a);", Style);
+  verifyFormat("int *a = f1();", Style);
+  verifyFormat("int& b = f2();", Style);
+  verifyFormat("int&& c = f3();", Style);
+
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("Const unsigned int *c;\n"
+   "const unsigned int *d;\n"
+   "Const unsigned int& e;\n"
+   "const unsigned int& f;\n"
+   "const unsigned  g;\n"
+   "Const unsigned  h;",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  Style.ReferenceAlignment = FormatStyle::RAS_Middle;
+  verifyFormat("int* f1(int* a, int & b, int && c);", Style);
+  verifyFormat("int & f2(int && c, int* a, int & b);", Style);
+  verifyFormat("int && f3(int & b, int && c, int* a);", Style);
+  verifyFormat("int* a = f1();", Style);
+  verifyFormat("int & b = f2();", Style);
+  verifyFormat("int && c = f3();", Style);
+
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("Const unsigned int*  c;\n"
+   "const unsigned int*  d;\n"
+   "Const unsigned int & e;\n"
+   "const unsigned int & f;\n"
+   "const unsigned &&g;\n"
+   "Const unsigned   h;",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Middle;
+  Style.ReferenceAlignment = FormatStyle::RAS_Right;
+  verifyFormat("int * f1(int * a, int &b, int &&c);", Style);
+  verifyFormat("int &f2(int &&c, int * a, int &b);", Style);
+  verifyFormat("int &&f3(int &b, int &&c, int * a);", Style);
+  verifyFormat("int * a = f1();", Style);
+  verifyFormat("int &b = f2();", Style);
+  verifyFormat("int &&c = f3();", Style);
+
+  // FIXME: we don't handle this yet, so output may be arbitrary until it's
+  // specifically handled
+  // verifyFormat("int Add2(BTree * &Root, char * szToAdd)", Style);
+}
+
 TEST_F(Forma

[PATCH] D104096: [Clang-Format] Add ReferenceAlignment directive

2021-06-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/include/clang/Format/Format.h:2647
 
-  /// The ``&`` and ``*`` alignment style.
+  /// The ``&``, ``&&`` and ``*`` alignment style.
   enum PointerAlignmentStyle : unsigned char {

nice catch!



Comment at: clang/lib/Format/Format.cpp:678
 IO.mapOptional("PointerAlignment", Style.PointerAlignment);
+IO.mapOptional("ReferenceAlignment", Style.ReferenceAlignment);
 IO.mapOptional("PPIndentWidth", Style.PPIndentWidth);

Nit: so normally these would be alphabetic, totally understand why you would 
put them together but I think we should probably follow convention and put 
Reference type after RawStringFormats


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104096

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


[PATCH] D19066: clang-format: `SpaceAfterTemplate` and `SpacesInBraces` options

2021-06-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

This is already resolved with `SpaceAfterTemplateKeyword` and 
`SpaceInEmptyBlock` I'm going to commandeer and abandon


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

https://reviews.llvm.org/D19066

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


[PATCH] D94500: [clang-format] Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-06-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

A crash (https://bugs.llvm.org/show_bug.cgi?id=50663)  in 12.0.1 is fixed by 
your changes here when merged to the 12 branch, I'm not sure if this needs to 
be backported to 12 I guess it might depend on if we think it's critical enough 
or if there will more 12 release candidates before 13 @timwoj  any thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D104096: [Clang-Format] Add ReferenceAlignment directive

2021-06-12 Thread Seraphime Kirkovski (VMware) via Phabricator via cfe-commits
skirkovski updated this revision to Diff 351649.
skirkovski marked 3 inline comments as done.
skirkovski added a comment.

Sort ReferenceAlignment after RawStringFormats in mapping()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104096

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1230,6 +1230,98 @@
getLLVMStyleWithColumns(62));
 }
 
+TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
+  FormatStyle Style = getLLVMStyle();
+  // Check first the default LLVM style
+  // Style.PointerAlignment = FormatStyle::PAS_Right;
+  // Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
+  verifyFormat("int *f1(int *a, int &b, int &&c);", Style);
+  verifyFormat("int &f2(int &&c, int *a, int &b);", Style);
+  verifyFormat("int &&f3(int &b, int &&c, int *a);", Style);
+  verifyFormat("int *f1(int &a) const &;", Style);
+  verifyFormat("int *f1(int &a) const & = 0;", Style);
+  verifyFormat("int *a = f1();", Style);
+  verifyFormat("int &b = f2();", Style);
+  verifyFormat("int &&c = f3();", Style);
+
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("Const unsigned int *c;\n"
+   "const unsigned int *d;\n"
+   "Const unsigned int &e;\n"
+   "const unsigned int &f;\n"
+   "const unsigned&&g;\n"
+   "Const unsigned  h;",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
+  verifyFormat("int* f1(int* a, int& b, int&& c);", Style);
+  verifyFormat("int& f2(int&& c, int* a, int& b);", Style);
+  verifyFormat("int&& f3(int& b, int&& c, int* a);", Style);
+  verifyFormat("int* f1(int& a) const& = 0;", Style);
+  verifyFormat("int* a = f1();", Style);
+  verifyFormat("int& b = f2();", Style);
+  verifyFormat("int&& c = f3();", Style);
+
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("Const unsigned int* c;\n"
+   "const unsigned int* d;\n"
+   "Const unsigned int& e;\n"
+   "const unsigned int& f;\n"
+   "const unsigned&&g;\n"
+   "Const unsigned  h;",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  Style.ReferenceAlignment = FormatStyle::RAS_Left;
+  verifyFormat("int *f1(int *a, int& b, int&& c);", Style);
+  verifyFormat("int& f2(int&& c, int *a, int& b);", Style);
+  verifyFormat("int&& f3(int& b, int&& c, int *a);", Style);
+  verifyFormat("int *a = f1();", Style);
+  verifyFormat("int& b = f2();", Style);
+  verifyFormat("int&& c = f3();", Style);
+
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("Const unsigned int *c;\n"
+   "const unsigned int *d;\n"
+   "Const unsigned int& e;\n"
+   "const unsigned int& f;\n"
+   "const unsigned  g;\n"
+   "Const unsigned  h;",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  Style.ReferenceAlignment = FormatStyle::RAS_Middle;
+  verifyFormat("int* f1(int* a, int & b, int && c);", Style);
+  verifyFormat("int & f2(int && c, int* a, int & b);", Style);
+  verifyFormat("int && f3(int & b, int && c, int* a);", Style);
+  verifyFormat("int* a = f1();", Style);
+  verifyFormat("int & b = f2();", Style);
+  verifyFormat("int && c = f3();", Style);
+
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("Const unsigned int*  c;\n"
+   "const unsigned int*  d;\n"
+   "Const unsigned int & e;\n"
+   "const unsigned int & f;\n"
+   "const unsigned &&g;\n"
+   "Const unsigned   h;",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Middle;
+  Style.ReferenceAlignment = FormatStyle::RAS_Right;
+  verifyFormat("int * f1(int * a, int &b, int &&c);", Style);
+  verifyFormat("int &f2(int &&c, int * a, int &b);", Style);
+  verifyFormat("int &&f3(int &b, int &&c, int * a);", Style);
+  verifyFormat("int * a = f1();", Style);
+  verifyFormat("int &b = f2();", Style);
+  verifyFormat("int &&c = f3();", Style);
+
+  // FIXME: we don't handle this yet, so output may be arbitrary until it's
+  // specifically handled
+  // verifyFormat("int Add2(BTree * &Root, char * szToAdd)", Style);
+}
+
 TEST_F(FormatTest, FormatsForLoop) {
   verifyFormat(
   "for (int VeryVeryLongLoopVariable = 0; VeryVeryLongLoopVariable < 10;\n"
@@ -17031,6 +17123,1

[PATCH] D104096: [Clang-Format] Add ReferenceAlignment directive

2021-06-12 Thread Seraphime Kirkovski (VMware) via Phabricator via cfe-commits
skirkovski added a comment.

@MyDeveloperDay,

Thanks for the review. I do not have submit access. Can you take care of 
landing the revision when you have some free time ?




Comment at: clang/unittests/Format/FormatTest.cpp:1243
+  verifyFormat("int *f1(int &a) const & = 0;", Style);
+  verifyFormat("int *a = f1();\nint &b = f2();\nint &&c = f3();", Style);
+  Style.PointerAlignment = FormatStyle::PAS_Left;

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > could you put each line on its own line. makes it easier to reason about
> Please also add the empty line.
Transformed each assignment to a separate verifyFormat. Is this what you meant 
? 

Added test case for consecutive alignments which covers the previous 
verifyFormat with multiple assignemnts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104096

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


[clang] 1e50c3d - [clang] NRVO: Improvements and handling of more cases.

2021-06-12 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2021-06-12T16:43:32+02:00
New Revision: 1e50c3d785f4563873ab1ce86559f2a1285b5678

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

LOG: [clang] NRVO: Improvements and handling of more cases.

This expands NRVO propagation for more cases:

Parse analysis improvement:
* Lambdas and Blocks with dependent return type can have their variables
  marked as NRVO Candidates.

Variable instantiation improvements:
* Fixes crash when instantiating NRVO variables in Blocks.
* Functions, Lambdas, and Blocks which have auto return type have their
  variables' NRVO status propagated. For Blocks with non-auto return type,
  as a limitation, this propagation does not consider the actual return
  type.

This also implements exclusion of VarDecls which are references to
dependent types.

Signed-off-by: Matheus Izvekov 

Reviewed By: Quuxplusone

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGen/nrvo-tracking.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6ade9d7691266..f7ec89a33e00c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3455,12 +3455,6 @@ class Sema final {
   bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
   bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg);
 
-  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
- const VarDecl *NRVOCandidate,
- QualType ResultType,
- Expr *Value,
- bool AllowNRVO = true);
-
   bool CanPerformAggregateInitializationForOverloadResolution(
   const InitializedEntity &Entity, InitListExpr *From);
 
@@ -4760,28 +4754,30 @@ class Sema final {
SourceLocation Loc,
unsigned NumParams);
 
-  enum CopyElisionSemanticsKind {
-CES_Strict = 0,
-CES_AllowParameters = 1,
-CES_AllowDifferentTypes = 2,
-CES_AllowExceptionVariables = 4,
-CES_AllowRValueReferenceType = 8,
-CES_ImplicitlyMovableCXX11CXX14CXX17 =
-(CES_AllowParameters | CES_AllowDifferentTypes),
-CES_ImplicitlyMovableCXX20 =
-(CES_AllowParameters | CES_AllowDifferentTypes |
- CES_AllowExceptionVariables | CES_AllowRValueReferenceType),
+  struct NamedReturnInfo {
+const VarDecl *Candidate;
+
+enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
+Status S;
+
+bool isMoveEligible() const { return S != None; };
+bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
   };
+  NamedReturnInfo getNamedReturnInfo(const Expr *E, bool ForceCXX20 = false);
+  NamedReturnInfo getNamedReturnInfo(const VarDecl *VD,
+ bool ForceCXX20 = false);
+  const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
+ QualType ReturnType);
 
-  VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E,
-   CopyElisionSemanticsKind CESK);
-  bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
-  CopyElisionSemanticsKind CESK);
+  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
+ const NamedReturnInfo &NRInfo,
+ Expr *Value);
 
   StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
  Scope *CurScope);
   StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
-  StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr 
*RetValExp);
+  StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
+ NamedReturnInfo &NRInfo);
 
   StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
  bool IsVolatile, unsigned NumOutputs,

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 850c189cc51a3..cdde9a83a6d02 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1962,9 +1962,10 @@ static void checkEscapingByref(VarDecl *VD, Sema &S) {
   SourceLocation Loc = VD->getLocation();
   Expr *VarRef =
   new (S.Context) DeclRefExpr(S.Context, VD, false, T

[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-06-12 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e50c3d785f4: [clang] NRVO: Improvements and handling of 
more cases. (authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGen/nrvo-tracking.cpp

Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -29,8 +29,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2l3v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 L(3, t, T);
@@ -152,7 +150,11 @@
   }; }()();\
 }
 
-//B(1, X); // Uncomment this line at your own peril ;)
+// CHECK-LABEL: define{{.*}} void @_Z2b1v
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call void @llvm.lifetime.end
+// CHECK-NEXT:  ret void
+B(1, X);
 
 // CHECK-LABEL: define{{.*}} void @_Z2b2v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
@@ -164,8 +166,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2b3v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 B(3, T);
@@ -187,3 +187,24 @@
 B(5, );
 
 #undef B
+
+// CHECK-LABEL: define{{.*}} void @_Z6f_attrv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call void @llvm.lifetime.end
+// CHECK-NEXT:  ret void
+template [[gnu::cdecl]] static inline auto tf_attr() -> X {
+T t;
+return t;
+}
+void f_attr() { auto t = tf_attr(); }
+
+// CHECK-LABEL: define{{.*}} void @_Z6b_attrv
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call void @llvm.lifetime.end
+// CHECK-NEXT:  ret void
+void b_attr() {
+  auto t = []() { return ^ X () [[clang::vectorcall]] {
+  T t;
+  return t;
+  }; }()();
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -23,6 +23,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/Template.h"
 #include "clang/Sema/TemplateInstCallback.h"
@@ -1085,11 +1086,30 @@
 
   SemaRef.BuildVariableInstantiation(Var, D, TemplateArgs, LateAttrs, Owner,
  StartingScope, InstantiatingVarTemplate);
-
   if (D->isNRVOVariable()) {
-QualType ReturnType = cast(DC)->getReturnType();
-if (SemaRef.isCopyElisionCandidate(ReturnType, Var, Sema::CES_Strict))
-  Var->setNRVOVariable(true);
+QualType RT;
+if (auto *F = dyn_cast(DC))
+  RT = F->getReturnType();
+else if (isa(DC))
+  RT = cast(SemaRef.getCurBlock()->FunctionType)
+   ->getReturnType();
+else
+  llvm_unreachable("Unknown context type");
+
+// This is the last chance we have of checking copy elision eligibility
+// for functions in depdendent contexts. The sema actions for building
+// the return statement during template instantiation will have no effect
+// regarding copy elision, since NRVO propagation runs on the scope exit
+// actions, and these are not run on instantiation.
+// This might run through some VarDecls which were returned from non-taken
+// 'if constexpr' branches, and these will end up being constructed on the
+// return slot even if they will never be returned, as a sort of accidental
+// 'optimization'. Notably, functions with 'auto' return types won't have it
+// deduced by this point. Coupled with the limitation described
+// previously, this makes it very hard to support copy elision for these.
+Sema::NamedReturnInfo Info = SemaRef.getNamedReturnInfo(Var);
+bool NRVO = SemaRef.getCopyElisionCandidate(Info, RT) != nullptr;
+Var->setNRVOVariable(NRVO);
   }
 
   Var->setImplicit(D->isImplicit());
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3307,99 +3307,153 @@
   return new (Context) BreakStmt(BreakLoc);
 }
 
-/// Determine whether the given expression is a candidate for
-/// copy elision in either a return statement or a throw expression.
+/// Determine whether the given expression might be move-eligible or
+/// copy-elidable in either a (co_)retur

[PATCH] D104096: [Clang-Format] Add ReferenceAlignment directive

2021-06-12 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

Thanks for the work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104096

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


[PATCH] D104182: [clang][NFC] Add IsAnyDestructorNoReturn field to CXXRecord instead of calculating it on demand

2021-06-12 Thread Markus Böck via Phabricator via cfe-commits
zero9178 created this revision.
zero9178 added reviewers: davrec, bruno, rsmith, aaron.ballman.
zero9178 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch addresses a performance issue I noticed when using clang-12 to 
compile projects of mine. Even though the files weren't too large (around 1k 
cpp), the compiler was taking more than a minute to compile the source file, 
much longer than either GCC or MSVC.

Using a profiler it turned out the issue was the `isAnyDestructorNoReturn` 
function in CXXRecordDecl:
F17356915: image.png 

In particular it being recursive, recalculating the property for every 
invocation, for every field and base class. This showed up in tracebacks in the 
profiler as follows:
F17356931: image.png 

This patch instead adds `IsAnyDestructorNoReturn` as a Field to the data inside 
of CXXRecord and updates when a new base class, destructor, or record field 
member is added.

After this patch the problematic file of mine went from a compile time of 81s, 
down to 12s. The hotspots now look more normal as well:
F17356944: image.png 

The patch itself should not change any functionality, just improve performance.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104182

Files:
  clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/DeclCXX.cpp


Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -108,7 +108,8 @@
   ImplicitCopyConstructorCanHaveConstParamForNonVBase(true),
   ImplicitCopyAssignmentHasConstParam(true),
   HasDeclaredCopyConstructorWithConstParam(false),
-  HasDeclaredCopyAssignmentWithConstParam(false), IsLambda(false),
+  HasDeclaredCopyAssignmentWithConstParam(false),
+  IsAnyDestructorNoReturn(false), IsLambda(false),
   IsParsingBaseSpecifiers(false), ComputedVisibleConversions(false),
   HasODRHash(false), Definition(D) {}
 
@@ -424,6 +425,9 @@
 if (!BaseClassDecl->hasIrrelevantDestructor())
   data().HasIrrelevantDestructor = false;
 
+if (BaseClassDecl->isAnyDestructorNoReturn())
+  data().IsAnyDestructorNoReturn = true;
+
 // C++11 [class.copy]p18:
 //   The implicitly-declared copy assignment operator for a class X will
 //   have the form 'X& X::operator=(const X&)' if each direct base class B
@@ -836,6 +840,9 @@
   data().HasTrivialSpecialMembers &= ~SMF_Destructor;
   data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor;
 }
+
+if (DD->isNoReturn())
+  data().IsAnyDestructorNoReturn = true;
   }
 
   // Handle member functions.
@@ -1233,6 +1240,8 @@
   data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor;
 if (!FieldRec->hasIrrelevantDestructor())
   data().HasIrrelevantDestructor = false;
+if (FieldRec->isAnyDestructorNoReturn())
+  data().IsAnyDestructorNoReturn = true;
 if (FieldRec->hasObjectMember())
   setHasObjectMember(true);
 if (FieldRec->hasVolatileMember())
@@ -1888,29 +1897,6 @@
   return R.empty() ? nullptr : dyn_cast(R.front());
 }
 
-bool CXXRecordDecl::isAnyDestructorNoReturn() const {
-  // Destructor is noreturn.
-  if (const CXXDestructorDecl *Destructor = getDestructor())
-if (Destructor->isNoReturn())
-  return true;
-
-  // Check base classes destructor for noreturn.
-  for (const auto &Base : bases())
-if (const CXXRecordDecl *RD = Base.getType()->getAsCXXRecordDecl())
-  if (RD->isAnyDestructorNoReturn())
-return true;
-
-  // Check fields for noreturn.
-  for (const auto *Field : fields())
-if (const CXXRecordDecl *RD =
-Field->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl())
-  if (RD->isAnyDestructorNoReturn())
-return true;
-
-  // All destructors are not noreturn.
-  return false;
-}
-
 static bool isDeclContextInNamespace(const DeclContext *DC) {
   while (!DC->isTranslationUnit()) {
 if (DC->isNamespace())
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -1480,7 +1480,7 @@
 
   /// Returns true if the class destructor, or any implicitly invoked
   /// destructors are marked noreturn.
-  bool isAnyDestructorNoReturn() const;
+  bool isAnyDestructorNoReturn() const { return 
data().IsAnyDestructorNoReturn; }
 
   /// If the class is a local class [class.local], returns
   /// the enclosing function declaration.
Index: clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
===
--- clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ clang/include/clang/A

[PATCH] D88666: DirectoryWatcher: add an implementation for Windows

2021-06-12 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I was able to play around with this further yesterday evening.  You are correct 
- the issue is the load preventing the watcher thread from spinning up.  I was 
able to reproduce this issue and resolve it by adding in a synchronization 
point (boolean + mutex + condition variable) before returning the directory 
watcher to ensure that the RDC was setup.  I looked through all the previous 
failure cases as well as the one that I was finally able to reproduce - it is 
always the initial notification that we missed (because the thread took too 
long to come up).  In the process I did do a few minor alterations as well.  I 
would like to get additional testing over the weekend on the bots so people 
aren't impacted if there turns out to be some other subtle threading issue.  
However, running this in a tight loop locally seemed to be pretty stable 
(switching the builds to a SSD locally did help uncover the flakiness) so I am 
confident that this should be safe.  I'm happy to address any additional 
comments in post-commit review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88666

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


[clang] 76f1baa - Revert "Revert "DirectoryWatcher: add an implementation for Windows""

2021-06-12 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2021-06-12T09:27:44-07:00
New Revision: 76f1baa7875acd88bdd4b431eed6e2d2decfc0fe

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

LOG: Revert "Revert "DirectoryWatcher: add an implementation for Windows""

This reverts commit 0ec1cf13f2a4e31aa2c5ccc665c5fbdcd3a94577.

Restore the implementation with some minor tweaks:
- Use std::unique_ptr for the path instead of std::vector
  * Stylistic improvement as the buffer is already heap allocated, this
just makes it clearer.
- Correct the notification buffer allocation size
  * Memory usage fix: we were allocating 4x the computed size
- Correct the passing of the buffer size to RDC
  * Memory usage fix: we were reporting 1/4th of the size
- Convert the operation event to auto-reset
  * Bug Fix: we never reset the event
- Remove `FILE_NOTIFY_CHANGE_LAST_ACCESS` from RDC events
  * Memory usage fix: we never needed this notification
- Fold events for the notification action
  * Stylistic improvement to be clear how the events map
- Update comment
  * Stylistic improvement to be clear what the RAII controls
- Fix the race condition that was uncovered previously
  * We would return from the construction before the watcher thread
began execution.  The test would then proceed to begin execution,
and we would miss the initial notifications.  We now ensure that the
watcher thread is initialized before we return.  This ensures that
we do not miss the initial notifications.

Running the test on a SSD was able to uncover the access pattern.  This
now seems to pass reliably where it was previously flaky locally.

Added: 


Modified: 
clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
clang/unittests/DirectoryWatcher/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp 
b/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
index 25cbcf536388a..6bcfb86e7f99e 100644
--- a/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
+++ b/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
@@ -6,19 +6,12 @@
 //
 
//===--===//
 
-// TODO: This is not yet an implementation, but it will make it so Windows
-//   builds don't fail.
-
 #include "DirectoryScanner.h"
 #include "clang/DirectoryWatcher/DirectoryWatcher.h"
-
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/ScopeExit.h"
-#include "llvm/Support/AlignOf.h"
-#include "llvm/Support/Errno.h"
-#include "llvm/Support/Mutex.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Path.h"
-#include 
+#include "llvm/Support/Windows/WindowsSupport.h"
 #include 
 #include 
 #include 
@@ -28,23 +21,271 @@
 
 namespace {
 
+using DirectoryWatcherCallback =
+std::function, bool)>;
+
 using namespace llvm;
 using namespace clang;
 
 class DirectoryWatcherWindows : public clang::DirectoryWatcher {
+  OVERLAPPED Overlapped;
+
+  std::vector Notifications;
+
+  std::thread WatcherThread;
+  std::thread HandlerThread;
+  std::function, bool)> Callback;
+  SmallString Path;
+  HANDLE Terminate;
+
+  std::mutex Mutex;
+  bool WatcherActive = false;
+  std::condition_variable Ready;
+
+  class EventQueue {
+std::mutex M;
+std::queue Q;
+std::condition_variable CV;
+
+  public:
+void emplace(DirectoryWatcher::Event::EventKind Kind, StringRef Path) {
+  {
+std::unique_lock L(M);
+Q.emplace(Kind, Path);
+  }
+  CV.notify_one();
+}
+
+DirectoryWatcher::Event pop_front() {
+  std::unique_lock L(M);
+  while (true) {
+if (!Q.empty()) {
+  DirectoryWatcher::Event E = Q.front();
+  Q.pop();
+  return E;
+}
+CV.wait(L, [this]() { return !Q.empty(); });
+  }
+}
+  } Q;
+
 public:
-  ~DirectoryWatcherWindows() override { }
-  void InitialScan() { }
-  void EventReceivingLoop() { }
-  void StopWork() { }
+  DirectoryWatcherWindows(HANDLE DirectoryHandle, bool WaitForInitialSync,
+  DirectoryWatcherCallback Receiver);
+
+  ~DirectoryWatcherWindows() override;
+
+  void InitialScan();
+  void WatcherThreadProc(HANDLE DirectoryHandle);
+  void NotifierThreadProc(bool WaitForInitialSync);
 };
+
+DirectoryWatcherWindows::DirectoryWatcherWindows(
+HANDLE DirectoryHandle, bool WaitForInitialSync,
+DirectoryWatcherCallback Receiver)
+: Callback(Receiver), Terminate(INVALID_HANDLE_VALUE) {
+  // Pre-compute the real location as we will be handing over the directory
+  // handle to the watcher and performing synchronous operations.
+  {
+DWORD Size = GetFinalPathNameByHandleW(DirectoryHandle, NULL, 0, 0);
+std::unique_ptr Buffer{new WCHAR[Size]};

[PATCH] D103131: support debug info for alias variable

2021-06-12 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D103131#2814595 , @kamleshbhalui 
wrote:

> In D103131#2814015 , @dblaikie 
> wrote:
>
>> In D103131#2811969 , 
>> @kamleshbhalui wrote:
>>
>>> In D103131#2811220 , @dblaikie 
>>> wrote:
>>>
 Any idea if the GDB test suite covers this functionality? I'd hope so, but 
 maybe it doesn't.

 But yeah, at the moment I don't have any great reason to avoid the 
 imported declaration form - so happy to go with that.
>>>
>>> Hi David,
>>>
>>> with imported declaration patch and with current patch(in review or say gcc 
>>> way) this case works ok(we can print type and value of newname)
>>> $cat test.c
>>> int oldname = 1;
>>> extern int newname attribute((alias("oldname")));
>>>
>>> but when we make newname static it works with current patch(in review or 
>>> say gcc way) but it does not work with imported decl 
>>> patch(https://reviews.llvm.org/D103131?id=347883).
>>>
>>> Should we go with gcc way or am I missing something?
>>> note: used gdb debugger.
>>
>> An ideas what's happening when `newname` is static? Is the DWARF any 
>> different/interesting there? (since the DWARF for imported decl seems like 
>> it would have nothing to do with the linkange of the alias - since it 
>> doesn't refer to the actual alias in the object file, etc)
>
> There not much different apart from extern has external attribute.
> **case 1) when `newname` is static**
>
>   .debug_info contents:
>   0x: Compile Unit: length = 0x0072, format = DWARF32, version = 
> 0x0004, abbr_offset = 0x, addr_size = 0x08 (next unit at 0x0076)
>   
>   0x000b: DW_TAG_compile_unit
> DW_AT_producer("clang version 13.0.0 
> (g...@github.com:llvm/llvm-project.git 
> 4cd7169f5517167ef456e82c6dcae669bde6c725)")
> DW_AT_language(DW_LANG_C99)
> DW_AT_name("test.c")
> DW_AT_stmt_list   (0x)
> DW_AT_comp_dir
> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin")
> DW_AT_low_pc  (0x)
> DW_AT_high_pc (0x0008)
>   
>   0x002a:   DW_TAG_variable
>   DW_AT_name  ("oldname")
>   DW_AT_type  (0x003f "int")
>   DW_AT_external  (true)
>   DW_AT_decl_file 
> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
>   DW_AT_decl_line (1)
>   DW_AT_location  (DW_OP_addr 0x0)
>   
>   0x003f:   DW_TAG_base_type
>   DW_AT_name  ("int")
>   DW_AT_encoding  (DW_ATE_signed)
>   DW_AT_byte_size (0x04)
>   
>   0x0046:   DW_TAG_variable
>   DW_AT_name  ("newname")
>   DW_AT_type  (0x003f "int")
>   DW_AT_decl_file 
> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
>   DW_AT_decl_line (2)
>   DW_AT_declaration   (true)
>   
>   0x0051:   DW_TAG_imported_declaration
>   DW_AT_decl_file 
> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
>   DW_AT_decl_line (2)
>   DW_AT_import(0x0046)
>   DW_AT_name  ("newname")
>   
>   0x005c:   DW_TAG_subprogram
>   DW_AT_low_pc(0x)
>   DW_AT_high_pc   (0x0008)
>   DW_AT_frame_base(DW_OP_reg6 RBP)
>   DW_AT_name  ("main")
>   DW_AT_decl_file 
> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
>   DW_AT_decl_line (3)
>   DW_AT_type  (0x003f "int")
>   DW_AT_external  (true)
>   
>   0x0075:   NULL
>
> **case 2) when `newname` is extern**
>
>   .debug_info contents:
>   0x: Compile Unit: length = 0x0072, format = DWARF32, version = 
> 0x0004, abbr_offset = 0x, addr_size = 0x08 (next unit at 0x0076)
>   
>   0x000b: DW_TAG_compile_unit
> DW_AT_producer("clang version 13.0.0 
> (g...@github.com:llvm/llvm-project.git 
> 4cd7169f5517167ef456e82c6dcae669bde6c725)")
> DW_AT_language(DW_LANG_C99)
> DW_AT_name("test.c")
> DW_AT_stmt_list   (0x)
> DW_AT_comp_dir
> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin")
> DW_AT_low_pc  (0x)
> DW_AT_high_pc (0x0008)
>   
>   0x002a:   DW_TAG_variable
>   DW_AT_name  ("oldname")
>   DW_AT_type  (0x003f "int")
>   DW_AT_external  (true)
>   DW_AT_decl_file 
> ("/folk/kkumar/tcllvm/llvm-build-lldb

RE: [PATCH] D103131: support debug info for alias variable

2021-06-12 Thread via cfe-commits
> >   0x002a:   DW_TAG_variable
> >   DW_AT_name  ("oldname")
> >   DW_AT_type  (0x003f "int")
> >   DW_AT_external  (true)
> >   DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-
> rel/bin/test.c")
> >   DW_AT_decl_line (1)
> >   DW_AT_location  (DW_OP_addr 0x0)
> >
> >   0x003f:   DW_TAG_base_type
> >   DW_AT_name  ("int")
> >   DW_AT_encoding  (DW_ATE_signed)
> >   DW_AT_byte_size (0x04)
> >
> >   0x0046:   DW_TAG_variable
> >   DW_AT_name  ("newname")
> >   DW_AT_type  (0x003f "int")
> >   DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-
> rel/bin/test.c")
> >   DW_AT_decl_line (2)
> >   DW_AT_declaration   (true)
> >
> >   0x0051:   DW_TAG_imported_declaration
> >   DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-
> rel/bin/test.c")
> >   DW_AT_decl_line (2)
> >   DW_AT_import(0x0046)
> >   DW_AT_name  ("newname")

I agree with David, this sequence doesn't seem to do what's desired.
There's nothing that ties "newname" to "oldname" here.  What you 
want is something more like this:

0x002a: DW_TAG_variable
  DW_AT_name ("oldname")
  ...
0x003a: DW_TAG_imported_declaration
  DW_AT_import (0x002a)
  DW_AT_name ("newname")

That is, there would not be a separate DW_TAG_variable for "newname";
instead, the imported_declaration would import the DIE for "oldname"
giving it the name "newname".

--paulr

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


[PATCH] D104182: [clang][NFC] Add IsAnyDestructorNoReturn field to CXXRecord instead of calculating it on demand

2021-06-12 Thread David Rector via Phabricator via cfe-commits
davrec added a comment.

Was this performance hit when using the static analyzer?  A quick search 
suggests `isAnyDestructorNoReturn()` is only called within the analyzer, 
whereas comparable CXXRecordDecl methods whose results are stored 
(`hasIrrelevantDestructor()` etc.) seem to be called somewhere by Sema.

So non-users of the analyzer would not benefit from this change, and will incur 
a slight cost, IIUC.  Is that cost remotely noticeable?  Probably not, but a 
quick test along those lines would be helpful.

All in all this is probably good and advisable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104182

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


[PATCH] D104182: [clang][NFC] Add IsAnyDestructorNoReturn field to CXXRecord instead of calculating it on demand

2021-06-12 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

In D104182#2815397 , @davrec wrote:

> Was this performance hit when using the static analyzer?  A quick search 
> suggests `isAnyDestructorNoReturn()` is only called within the analyzer, 
> whereas comparable CXXRecordDecl methods whose results are stored 
> (`hasIrrelevantDestructor()` etc.) seem to be called somewhere by Sema.
>
> So non-users of the analyzer would not benefit from this change, and will 
> incur a slight cost, IIUC.  Is that cost remotely noticeable?  Probably not, 
> but a quick test along those lines would be helpful.
>
> All in all this is probably good and advisable.

The only place where it is called in the static analyzer is in 
ExprEngineCXX.cpp:650. I was doing a normal compilation of a C++ file of mine, 
and they were coming from Analysis/CFG.cpp:1871 in `addAutomaticObjDtors` as 
well as CFG.cpp:4836 in `VisitCXXBindTemporaryForDtors`. So depending on the 
contents of the users C++ file it could improve their compilation speed as 
well. I suspect that in my case it was producing such a deep stacktrace due to 
a template class that is using a lot of layers of inheritance to preserve 
triviallity of constructors and more, tho that is just a guess. Nevertheless 
I'd wager it will more than likely improve the compile time for some other 
people as well.

As another test I just compared the compilation of X86ISelLowering.cpp from 
LLVM using clang-cl trunk, with and without this patch and could not measure 
any difference but margin of error. So it's definitely not guaranteed to be an 
improvement, but least isn't any worse.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104182

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


[PATCH] D104099: [NewPM] Remove SpeculateAroundPHIs pass from pipeline

2021-06-12 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

In D104099#2814167 , @davidxl wrote:

> Adding Wei to help measure performance impact on our internal workloads.  
> Also add Wenlei to help measure impact with FB's workloads.

Measured perf using FB internal workload w/ and w/o this pass, result is 
neutral.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104099

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


[PATCH] D104192: [clang][RISCV] Change implicit ARCH for explicitly specified ABI

2021-06-12 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: asb, luismarques, MaskRay, craig.topper.
Herald added subscribers: vkmr, frasercrmck, evandro, apazos, sameer.abuasal, 
s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar.
benshi001 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As discussed in
https://github.com/riscv/riscv-toolchain-conventions/issues/13,

the implicit ARCH for explicitly specified ABI should be

ilp32e => rv32e
ilp32  => rv32imac
ilp32f => rv32imacf
ilp32d => rv32imacfd
lp64   => rv64imac
lp64f  => rv64imacf
lp64d  => rv64imacfd


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104192

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -44,9 +44,9 @@
 
 // CHECK-ILP32:  "-target-feature" "+m"
 // CHECK-ILP32-SAME: {{^}} "-target-feature" "+a"
-// CHECK-ILP32-SAME: {{^}} "-target-feature" "+f"
-// CHECK-ILP32-SAME: {{^}} "-target-feature" "+d"
 // CHECK-ILP32-SAME: {{^}} "-target-feature" "+c"
+// CHECK-ILP32-NOT:  "-target-feature" "+f"
+// CHECK-ILP32-NOT:  "-target-feature" "+d"
 
 // RUN: %clang -target riscv32-unknown-elf -mabi=ilp32f -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32F %s
@@ -54,8 +54,8 @@
 // CHECK-ILP32F:  "-target-feature" "+m"
 // CHECK-ILP32F-SAME: {{^}} "-target-feature" "+a"
 // CHECK-ILP32F-SAME: {{^}} "-target-feature" "+f"
-// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+d"
 // CHECK-ILP32F-SAME: {{^}} "-target-feature" "+c"
+// CHECK-ILP32F-NOT:  "-target-feature" "+d"
 
 // RUN: %clang -target riscv32-unknown-elf -mabi=ilp32d -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32D %s
@@ -110,25 +110,25 @@
 // RUN: %clang -target riscv64-unknown-elf -mabi=lp64 -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64 %s
 
-// CHECK-LP64: "-target-feature" "+m"
+// CHECK-LP64:  "-target-feature" "+m"
 // CHECK-LP64-SAME: {{^}} "-target-feature" "+a"
-// CHECK-LP64-SAME: {{^}} "-target-feature" "+f"
-// CHECK-LP64-SAME: {{^}} "-target-feature" "+d"
 // CHECK-LP64-SAME: {{^}} "-target-feature" "+c"
+// CHECK-LP64-NOT:  "-target-feature" "+f"
+// CHECK-LP64-NOT:  "-target-feature" "+d"
 
 // RUN: %clang -target riscv64-unknown-elf -mabi=lp64f -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64F %s
 
-// CHECK-LP64F: "-target-feature" "+m"
+// CHECK-LP64F:  "-target-feature" "+m"
 // CHECK-LP64F-SAME: {{^}} "-target-feature" "+a"
 // CHECK-LP64F-SAME: {{^}} "-target-feature" "+f"
-// CHECK-LP64F-SAME: {{^}} "-target-feature" "+d"
 // CHECK-LP64F-SAME: {{^}} "-target-feature" "+c"
+// CHECK-LP64F-NOT: "-target-feature" "+d"
 
 // RUN: %clang -target riscv64-unknown-elf -mabi=lp64d -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64D %s
 
-// CHECK-LP64D: "-target-feature" "+m"
+// CHECK-LP64D:  "-target-feature" "+m"
 // CHECK-LP64D-SAME: {{^}} "-target-feature" "+a"
 // CHECK-LP64D-SAME: {{^}} "-target-feature" "+f"
 // CHECK-LP64D-SAME: {{^}} "-target-feature" "+d"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -698,9 +698,17 @@
 
 if (MABI.equals_lower("ilp32e"))
   return "rv32e";
-else if (MABI.startswith_lower("ilp32"))
+else if (MABI.equals_lower("ilp32"))
+  return "rv32imac";
+else if (MABI.equals_lower("ilp32f"))
+  return "rv32imafc";
+else if (MABI.equals_lower("ilp32d"))
   return "rv32imafdc";
-else if (MABI.startswith_lower("lp64"))
+else if (MABI.equals_lower("lp64"))
+  return "rv64imac";
+else if (MABI.equals_lower("lp64f"))
+  return "rv64imafc";
+else if (MABI.equals_lower("lp64d"))
   return "rv64imafdc";
   }
 


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -44,9 +44,9 @@
 
 // CHECK-ILP32:  "-target-feature" "+m"
 // CHECK-ILP32-SAME: {{^}} "-target-feature" "+a"
-// CHECK-ILP32-SAME: {{^}} "-target-feature" "+f"
-// CHECK-ILP32-SAME: {{^}} "-target-feature" "+d"
 // CHECK-ILP32-SAME: {{^}} "-target-feature" "+c"
+// CHECK-ILP32-NOT:  "-target-feature" "+f"
+// CHECK-ILP32-NOT:  "-target-feature" "+d"
 
 // RUN: %clang -target riscv32-unknown-elf -mabi=ilp32f -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32F %s
@@ -54,8 +54,8 @@
 // CHECK-ILP32F:  "-target-feature" "+m"
 // CHECK-ILP32F-