[llvm-branch-commits] [clang] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-07-31 Thread Alexander Kornienko via llvm-branch-commits

alexfh wrote:

> > @ilya-biryukov, could we have another try of this PR on your end?
> 
> Sorry for missing this, we will rerun the testing and get back to you.

In the meantime, could you rebase the patch on top of current ToT?

https://github.com/llvm/llvm-project/pull/83237
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-07-31 Thread Alexander Kornienko via llvm-branch-commits

alexfh wrote:

I'm getting this error when trying to bootstrap Clang:
```
In file included from clang/lib/Serialization/ASTReaderDecl.cpp:15:
clang/lib/Serialization/ASTReaderInternals.h:160:19: error: ISO C++20 considers 
use of overloaded operator '==' (with operand types 
'clang::serialization::reader::LazySpecializationInfo' and 
'LazySpecializationInfo') to be ambiguous despite there being a unique best 
viable function [-Werror,-Wambiguous-reversed-operator]
  160 | if (I == Info)
  | ~ ^  
clang/lib/Serialization/ASTReaderInternals.h:128:8: note: ambiguity is between 
a regular call to this operator and a call with the argument order reversed
  128 |   bool operator==(const LazySpecializationInfo &Other) {
  |^
clang/lib/Serialization/ASTReaderInternals.h:128:8: note: mark 'operator==' as 
const or add a matching 'operator!=' to resolve the ambiguity
```

I can mute it for testing, but this also needs to be fixed.

https://github.com/llvm/llvm-project/pull/83237
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-08-01 Thread Alexander Kornienko via llvm-branch-commits

alexfh wrote:

> bool operator==(const LazySpecializationInfo &Other)

Making this `operator==` `const` helps with the warning in C++20. And it's the 
right thing to do anyway.

https://github.com/llvm/llvm-project/pull/83237
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] af7a145 - Revert "[SLP][NFC]Make collectValuesToDemote member of BoUpSLP to avoid using"

2023-11-23 Thread Alexander Kornienko via llvm-branch-commits

Author: Alexander Kornienko
Date: 2023-11-24T01:18:46+01:00
New Revision: af7a1453526a88a0e242baf156244aa4ae42ae4b

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

LOG: Revert "[SLP][NFC]Make collectValuesToDemote member of BoUpSLP to avoid 
using"

This reverts commit 52df67ba76a03ad33132d1d4f4202d5a2313a3cd, which causes
spurious clang crashes. See
https://github.com/llvm/llvm-project/commit/52df67ba76a03ad33132d1d4f4202d5a2313a3cd#commitcomment-133381701

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index b73de2ed6ff9a38..1484c4d3aca427f 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2283,14 +2283,6 @@ class BoUpSLP {
   ~BoUpSLP();
 
 private:
-  /// Determine if a vectorized value \p V in can be demoted to
-  /// a smaller type with a truncation. We collect the values that will be
-  /// demoted in ToDemote and additional roots that require investigating in
-  /// Roots.
-  bool collectValuesToDemote(Value *V, SmallVectorImpl &ToDemote,
- SmallVectorImpl &Roots,
- DenseSet &Visited) const;
-
   /// Check if the operands on the edges \p Edges of the \p UserTE allows
   /// reordering (i.e. the operands can be reordered because they have only one
   /// user and reordarable).
@@ -9052,7 +9044,8 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef 
VectorizedVals) {
 // for the extract and the added cost of the sign extend if needed.
 auto *VecTy = FixedVectorType::get(EU.Scalar->getType(), BundleWidth);
 TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
-auto It = MinBWs.find(EU.Scalar);
+auto *ScalarRoot = VectorizableTree[0]->Scalars[0];
+auto It = MinBWs.find(ScalarRoot);
 if (It != MinBWs.end()) {
   auto *MinTy = IntegerType::get(F->getContext(), It->second.first);
   unsigned Extend =
@@ -13081,20 +13074,19 @@ unsigned BoUpSLP::getVectorElementSize(Value *V) {
 // Determine if a value V in a vectorizable expression Expr can be demoted to a
 // smaller type with a truncation. We collect the values that will be demoted
 // in ToDemote and additional roots that require investigating in Roots.
-bool BoUpSLP::collectValuesToDemote(Value *V,
-SmallVectorImpl &ToDemote,
-SmallVectorImpl &Roots,
-DenseSet &Visited) const {
+static bool collectValuesToDemote(Value *V, SmallPtrSetImpl &Expr,
+  SmallVectorImpl &ToDemote,
+  SmallVectorImpl &Roots) {
   // We can always demote constants.
   if (isa(V)) {
 ToDemote.push_back(V);
 return true;
   }
 
-  // If the value is not a vectorized instruction in the expression with only
-  // one use, it cannot be demoted.
+  // If the value is not an instruction in the expression with only one use, it
+  // cannot be demoted.
   auto *I = dyn_cast(V);
-  if (!I || !I->hasOneUse() || !getTreeEntry(I) || !Visited.insert(I).second)
+  if (!I || !I->hasOneUse() || !Expr.count(I))
 return false;
 
   switch (I->getOpcode()) {
@@ -13118,16 +13110,16 @@ bool BoUpSLP::collectValuesToDemote(Value *V,
   case Instruction::And:
   case Instruction::Or:
   case Instruction::Xor:
-if (!collectValuesToDemote(I->getOperand(0), ToDemote, Roots, Visited) ||
-!collectValuesToDemote(I->getOperand(1), ToDemote, Roots, Visited))
+if (!collectValuesToDemote(I->getOperand(0), Expr, ToDemote, Roots) ||
+!collectValuesToDemote(I->getOperand(1), Expr, ToDemote, Roots))
   return false;
 break;
 
   // We can demote selects if we can demote their true and false values.
   case Instruction::Select: {
 SelectInst *SI = cast(I);
-if (!collectValuesToDemote(SI->getTrueValue(), ToDemote, Roots, Visited) ||
-!collectValuesToDemote(SI->getFalseValue(), ToDemote, Roots, Visited))
+if (!collectValuesToDemote(SI->getTrueValue(), Expr, ToDemote, Roots) ||
+!collectValuesToDemote(SI->getFalseValue(), Expr, ToDemote, Roots))
   return false;
 break;
   }
@@ -13137,7 +13129,7 @@ bool BoUpSLP::collectValuesToDemote(Value *V,
   case Instruction::PHI: {
 PHINode *PN = cast(I);
 for (Value *IncValue : PN->incoming_values())
-  if (!collectValuesToDemote(IncValue, ToDemote, Roots, Visited))
+  if (!collectValuesToDemote(IncValue, Expr, ToDemote, Roots))
 return false;
 break;
   }
@@ -13164,16 +13156,36 @@ void BoUpSLP::computeMinimumValueSizes() {
   if (!TreeRootIT)
 return;
 
+  // If the

[llvm-branch-commits] [llvm] 0f8745b - Revert "[SimplifyCFG] When only one case value is missing, replace default with that case (#76669)"

2024-01-17 Thread Alexander Kornienko via llvm-branch-commits

Author: Alexander Kornienko
Date: 2024-01-17T17:49:25+01:00
New Revision: 0f8745b4b77d1c1fd0699adb024ed08bcb1233d3

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

LOG: Revert "[SimplifyCFG] When only one case value is missing, replace default 
with that case (#76669)"

This reverts commit 7d81e072712f4e6a150561b5538ccebda289aa13, which introduces a
compiler memory usage regression. See
https://github.com/llvm/llvm-project/pull/76669#issuecomment-1887659952

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/switch-dead-default.ll

Removed: 
llvm/test/Transforms/SimplifyCFG/switch-dead-default-lookup-table.ll



diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 7515e539e7fb78..f3994b6cc39fef 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -5414,13 +5414,11 @@ static bool 
CasesAreContiguous(SmallVectorImpl &Cases) {
 }
 
 static void createUnreachableSwitchDefault(SwitchInst *Switch,
-   DomTreeUpdater *DTU,
-   bool RemoveOrigDefaultBlock = true) 
{
+   DomTreeUpdater *DTU) {
   LLVM_DEBUG(dbgs() << "SimplifyCFG: switch default is dead.\n");
   auto *BB = Switch->getParent();
   auto *OrigDefaultBlock = Switch->getDefaultDest();
-  if (RemoveOrigDefaultBlock)
-OrigDefaultBlock->removePredecessor(BB);
+  OrigDefaultBlock->removePredecessor(BB);
   BasicBlock *NewDefaultBlock = BasicBlock::Create(
   BB->getContext(), BB->getName() + ".unreachabledefault", BB->getParent(),
   OrigDefaultBlock);
@@ -5429,8 +5427,7 @@ static void createUnreachableSwitchDefault(SwitchInst 
*Switch,
   if (DTU) {
 SmallVector Updates;
 Updates.push_back({DominatorTree::Insert, BB, &*NewDefaultBlock});
-if (RemoveOrigDefaultBlock &&
-!is_contained(successors(BB), OrigDefaultBlock))
+if (!is_contained(successors(BB), OrigDefaultBlock))
   Updates.push_back({DominatorTree::Delete, BB, &*OrigDefaultBlock});
 DTU->applyUpdates(Updates);
   }
@@ -5612,28 +5609,10 @@ static bool eliminateDeadSwitchCases(SwitchInst *SI, 
DomTreeUpdater *DTU,
   Known.getBitWidth() - (Known.Zero | Known.One).popcount();
   assert(NumUnknownBits <= Known.getBitWidth());
   if (HasDefault && DeadCases.empty() &&
-  NumUnknownBits < 64 /* avoid overflow */) {
-uint64_t AllNumCases = 1ULL << NumUnknownBits;
-if (SI->getNumCases() == AllNumCases) {
-  createUnreachableSwitchDefault(SI, DTU);
-  return true;
-}
-// When only one case value is missing, replace default with that case.
-// Eliminating the default branch will provide more opportunities for
-// optimization, such as lookup tables.
-if (SI->getNumCases() == AllNumCases - 1) {
-  assert(NumUnknownBits > 1 && "Should be canonicalized to a branch");
-  uint64_t MissingCaseVal = 0;
-  for (const auto &Case : SI->cases())
-MissingCaseVal ^= Case.getCaseValue()->getValue().getLimitedValue();
-  auto *MissingCase =
-  cast(ConstantInt::get(Cond->getType(), MissingCaseVal));
-  SwitchInstProfUpdateWrapper SIW(*SI);
-  SIW.addCase(MissingCase, SI->getDefaultDest(), 
SIW.getSuccessorWeight(0));
-  createUnreachableSwitchDefault(SI, DTU, /*RemoveOrigDefaultBlock*/ 
false);
-  SIW.setSuccessorWeight(0, 0);
-  return true;
-}
+  NumUnknownBits < 64 /* avoid overflow */ &&
+  SI->getNumCases() == (1ULL << NumUnknownBits)) {
+createUnreachableSwitchDefault(SI, DTU);
+return true;
   }
 
   if (DeadCases.empty())

diff  --git 
a/llvm/test/Transforms/SimplifyCFG/switch-dead-default-lookup-table.ll 
b/llvm/test/Transforms/SimplifyCFG/switch-dead-default-lookup-table.ll
deleted file mode 100644
index bead0dc4c567a8..00
--- a/llvm/test/Transforms/SimplifyCFG/switch-dead-default-lookup-table.ll
+++ /dev/null
@@ -1,61 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
-; RUN: opt %s -S -passes='simplifycfg' 
-simplifycfg-require-and-preserve-domtree=1 -switch-range-to-icmp | FileCheck %s
-
-target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-
-define i64 @test_1(i64 %0) {
-; CHECK-LABEL: define i64 @test_1(
-; CHECK-SAME: i64 [[TMP0:%.*]]) {
-; CHECK-NEXT:  switch.lookup:
-; CHECK-NEXT:[[TMP1:%.*]] = urem i64 [[TMP0]], 4
-; CHECK-NEXT:[[SWITCH_GEP:%.*]] = getelementptr inbounds [4 x i64], ptr 
@switch.table.test_1, i32 0, i64 [[TMP1]]
-; CHECK-NEXT:[[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]], align 8
-; CHECK-NEXT:ret i64 [[

Re: [llvm-branch-commits] [clang] c3a21e5 - [ASTMatchers] Ensure that we can match inside lambdas

2021-01-27 Thread Alexander Kornienko via llvm-branch-commits
This patch causes practically infinite traversal times on code that
contains deeply nested lambdas. Please fix or revert the commit.

There's a very simple test case (add more nesting, if it's still fast ;):

void f() {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  [] {
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
  }();
}

Three nested lambdas are enough to demonstrate the issue by looking at the
AST dump. The body of the innermost lambda (0x45593fda99a0) is printed 8
times, and it will be traversed 8 times as well by AST matchers:
`-FunctionDecl 0x45593fda9198 
line:1:6 f 'void ()'
  `-CompoundStmt 0x45593fdce970 
`-ExprWithCleanups 0x45593fdce958  'void':'void'
  `-CXXOperatorCallExpr 0x45593fdce928 
'void':'void' '()'
|-ImplicitCastExpr 0x45593fdce8b0  'auto (*)() const
-> void' 
| `-DeclRefExpr 0x45593fdce890  'auto () const ->
void' lvalue CXXMethod 0x45593fda9490 'operator()' 'auto () const -> void'
`-ImplicitCastExpr 0x45593fdce910  'const
(lambda at /tmp/nested-lambdas.cc:2:3)' lvalue 
  `-MaterializeTemporaryExpr 0x45593fdce8f8 
'(lambda at /tmp/nested-lambdas.cc:2:3)' lvalue
`-LambdaExpr 0x45593fdce788  '(lambda at
/tmp/nested-lambdas.cc:2:3)'
  |-CXXRecordDecl 0x45593fda9350  col:3 implicit
class definition
  | |-DefinitionData lambda pass_in_registers empty
standard_layout trivially_copyable literal can_const_default_init
  | | |-DefaultConstructor defaulted_is_constexpr
  | | |-CopyConstructor simple trivial has_const_param
needs_implicit implicit_has_const_param
  | | |-MoveConstructor exists simple trivial needs_implicit
  | | |-CopyAssignment trivial has_const_param needs_implicit
implicit_has_const_param
  | | |-MoveAssignment
  | | `-Destructor simple irrelevant trivial
  | |-CXXMethodDecl 0x45593fda9490  line:2:3
used constexpr operator() 'auto () const -> void' inline
  | | `-CompoundStmt 0x45593fdce4e0 
  | |   `-ExprWithCleanups 0x45593fdce4c8 
'void':'void'
  | | `-CXXOperatorCallExpr 0x45593fdce498  'void':'void' '()'
  | |   |-ImplicitCastExpr 0x45593fdce420 
'auto (*)() const -> void' 
  | |   | `-DeclRefExpr 0x45593fdce400  'auto
() const -> void' lvalue CXXMethod 0x45593fda96c0 'operator()' 'auto ()
const -> void'
  | |   `-ImplicitCastExpr 0x45593fdce480  'const (lambda at /tmp/nested-lambdas.cc:3:3)' lvalue 
  | | `-MaterializeTemporaryExpr 0x45593fdce468
 '(lambda at /tmp/nested-lambdas.cc:3:3)' lvalue
  | |   `-LambdaExpr 0x45593fdce2f0  '(lambda at /tmp/nested-lambdas.cc:3:3)'
  | | |-CXXRecordDecl 0x45593fda9588 
col:3 implicit class definition
  | | | |-DefinitionData lambda pass_in_registers
empty standard_layout trivially_copyable literal can_const_default_init
  | | | | |-DefaultConstructor
defaulted_is_constexpr
  | | | | |-CopyConstructor simple trivial
has_const_param needs_implicit implicit_has_const_param
  | | | | |-MoveConstructor exists simple trivial
needs_implicit
  | | | | |-CopyAssignment trivial has_const_param
needs_implicit implicit_has_const_param
  | | | | |-MoveAssignment
  | | | | `-Destructor simple irrelevant trivial
  | | | |-CXXMethodDecl 0x45593fda96c0  line:3:3 used constexpr operator() 'auto () const -> void' inline
  | | | | `-CompoundStmt 0x45593fdce048 
  | | | |   `-ExprWithCleanups 0x45593fdce030
 'void':'void'
  | | | | `-CXXOperatorCallExpr 0x45593fdce000
 'void':'void' '()'
  | | | |   |-ImplicitCastExpr 0x45593fda9f88
 'auto (*)() const -> void' 
  | | | |   | `-DeclRefExpr 0x45593fda9f08
 'auto () const -> void' lvalue CXXMethod 0x45593fda98f0
'operator()' 'auto () const -> void'
  | | | |   `-ImplicitCastExpr 0x45593fda9fe0
 'const (lambda at /tmp/nested-lambdas.cc:4:3)' lvalue

  | | | | `-MaterializeTemporaryExpr
0x45593fda9fc8  '(lambda at
/tmp/nested-lambdas.cc:4:3)' lvalue
  | | | |   `-LambdaExpr 0x45593fda9dd0
 '(lambda at /tmp/nested-lambdas.cc:4:3)'
  | | | | |-CXXRecordDecl
0x45593fda97b8  col:3 implicit class definition
  | | | | | |-Defin

Re: [llvm-branch-commits] [clang] c3a21e5 - [ASTMatchers] Ensure that we can match inside lambdas

2021-01-28 Thread Alexander Kornienko via llvm-branch-commits
Thanks for the prompt response!

On Thu, Jan 28, 2021 at 12:52 AM Stephen Kelly  wrote:

>
> Thanks for reporting. Please try https://reviews.llvm.org/D95573
>
> Thanks,
>
> Stephen.
> On 27/01/2021 22:58, Alexander Kornienko wrote:
>
> This patch causes practically infinite traversal times on code that
> contains deeply nested lambdas. Please fix or revert the commit.
>
> There's a very simple test case (add more nesting, if it's still fast ;):
>
> void f() {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   [] {
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
>   }();
> }
>
> Three nested lambdas are enough to demonstrate the issue by looking at the
> AST dump. The body of the innermost lambda (0x45593fda99a0) is printed 8
> times, and it will be traversed 8 times as well by AST matchers:
> `-FunctionDecl 0x45593fda9198 
> line:1:6 f 'void ()'
>   `-CompoundStmt 0x45593fdce970 
> `-ExprWithCleanups 0x45593fdce958  'void':'void'
>   `-CXXOperatorCallExpr 0x45593fdce928 
> 'void':'void' '()'
> |-ImplicitCastExpr 0x45593fdce8b0  'auto (*)() const
> -> void' 
> | `-DeclRefExpr 0x45593fdce890  'auto () const ->
> void' lvalue CXXMethod 0x45593fda9490 'operator()' 'auto () const -> void'
> `-ImplicitCastExpr 0x45593fdce910  'const
> (lambda at /tmp/nested-lambdas.cc:2:3)' lvalue 
>   `-MaterializeTemporaryExpr 0x45593fdce8f8 
> '(lambda at /tmp/nested-lambdas.cc:2:3)' lvalue
> `-LambdaExpr 0x45593fdce788  '(lambda at
> /tmp/nested-lambdas.cc:2:3)'
>   |-CXXRecordDecl 0x45593fda9350  col:3 implicit
> class definition
>   | |-DefinitionData lambda pass_in_registers empty
> standard_layout trivially_copyable literal can_const_default_init
>   | | |-DefaultConstructor defaulted_is_constexpr
>   | | |-CopyConstructor simple trivial has_const_param
> needs_implicit implicit_has_const_param
>   | | |-MoveConstructor exists simple trivial needs_implicit
>   | | |-CopyAssignment trivial has_const_param needs_implicit
> implicit_has_const_param
>   | | |-MoveAssignment
>   | | `-Destructor simple irrelevant trivial
>   | |-CXXMethodDecl 0x45593fda9490  line:2:3
> used constexpr operator() 'auto () const -> void' inline
>   | | `-CompoundStmt 0x45593fdce4e0 
>   | |   `-ExprWithCleanups 0x45593fdce4c8 
> 'void':'void'
>   | | `-CXXOperatorCallExpr 0x45593fdce498  line:6:5> 'void':'void' '()'
>   | |   |-ImplicitCastExpr 0x45593fdce420 
> 'auto (*)() const -> void' 
>   | |   | `-DeclRefExpr 0x45593fdce400 
> 'auto () const -> void' lvalue CXXMethod 0x45593fda96c0 'operator()' 'auto
> () const -> void'
>   | |   `-ImplicitCastExpr 0x45593fdce480  line:6:3> 'const (lambda at /tmp/nested-lambdas.cc:3:3)' lvalue 
>   | | `-MaterializeTemporaryExpr 0x45593fdce468
>  '(lambda at /tmp/nested-lambdas.cc:3:3)' lvalue
>   | |   `-LambdaExpr 0x45593fdce2f0  line:6:3> '(lambda at /tmp/nested-lambdas.cc:3:3)'
>   | | |-CXXRecordDecl 0x45593fda9588 
> col:3 implicit class definition
>   | | | |-DefinitionData lambda pass_in_registers
> empty standard_layout trivially_copyable literal can_const_default_init
>   | | | | |-DefaultConstructor
> defaulted_is_constexpr
>   | | | | |-CopyConstructor simple trivial
> has_const_param needs_implicit implicit_has_const_param
>   | | | | |-MoveConstructor exists simple trivial
> needs_implicit
>   | | | | |-CopyAssignment trivial has_const_param
> needs_implicit implicit_has_const_param
>   | | | | |-MoveAssignment
>   | | | | `-Destructor simple irrelevant trivial
>   | | | |-CXXMethodDecl 0x45593fda96c0  line:6:3> line:3:3 used constexpr operator() 'auto () const -> void' inline
>   | | | | `-CompoundStmt 0x45593fdce048  line:6:3>
>   | | | |   `-ExprWithCleanups 0x45593fdce030
>  'void':'void'
>   | | | | `-CXXOperatorCallExpr 0x45593fdce000
>  'void':'void' '()'
>   | | | |   |-ImplicitCastExpr 0x45593fda9f88
>  'auto (*)() const -> void' 
>   | | | |   | `-DeclRefExpr 0x45593fda9f08
>  'auto () const -> void' lvalue CXXMethod 0x45593fda98f0
> 'operator()' 'auto () c

[llvm-branch-commits] [cfe-branch] r263715 - Add clang-tidy release notes.

2016-03-19 Thread Alexander Kornienko via llvm-branch-commits
Author: alexfh
Date: Thu Mar 17 09:58:32 2016
New Revision: 263715

URL: http://llvm.org/viewvc/llvm-project?rev=263715&view=rev
Log:
Add clang-tidy release notes.

Modified:
cfe/branches/release_38/docs/ReleaseNotes.rst

Modified: cfe/branches/release_38/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/docs/ReleaseNotes.rst?rev=263715&r1=263714&r2=263715&view=diff
==
--- cfe/branches/release_38/docs/ReleaseNotes.rst (original)
+++ cfe/branches/release_38/docs/ReleaseNotes.rst Thu Mar 17 09:58:32 2016
@@ -339,6 +339,76 @@ Several new checks were added:
   ``-enable-checker optin.osx.cocoa.localizability``.
 
 
+Clang-tidy
+--
+
+New checks have been added to clang-tidy:
+
+* Checks enforcing certain rules of the `CERT Secure Coding Standards
+  
`_:
+
+  * `cert-dcl03-c 
`_
+  * `cert-dcl50-cpp 
`_
+  * `cert-err52-cpp 
`_
+  * `cert-err58-cpp 
`_
+  * `cert-err60-cpp 
`_
+  * `cert-err61-cpp 
`_
+  * `cert-fio38-c 
`_
+  * `cert-oop11-cpp 
`_
+
+* Checks supporting the `C++ Core Guidelines
+  
`_:
+
+  * `cppcoreguidelines-pro-bounds-array-to-pointer-decay 
`_
+  * `cppcoreguidelines-pro-bounds-constant-array-index 
`_
+  * `cppcoreguidelines-pro-bounds-pointer-arithmetic 
`_
+  * `cppcoreguidelines-pro-type-const-cast 
`_
+  * `cppcoreguidelines-pro-type-cstyle-cast 
`_
+  * `cppcoreguidelines-pro-type-reinterpret-cast 
`_
+  * `cppcoreguidelines-pro-type-static-cast-downcast 
`_
+  * `cppcoreguidelines-pro-type-union-access 
`_
+  * `cppcoreguidelines-pro-type-vararg 
`_
+
+* The functionality of the clang-modernize tool has been moved to the new
+  ``modernize`` module in clang-tidy along with a few new checks:
+
+  * `modernize-loop-convert 
`_
+  * `modernize-make-unique 
`_
+  * `modernize-pass-by-value 
`_
+  * `modernize-redundant-void-arg 
`_
+  * `modernize-replace-auto-ptr 
`_
+  * `modernize-shrink-to-fit 
`_
 (renamed from readability-shrink-to-fit)
+  * `modernize-use-auto 
`_
+  * `modernize-use-default 


[llvm-branch-commits] [clang] 9c49b0b - Remove the ast_type_traits namespace.

2020-12-14 Thread Alexander Kornienko via llvm-branch-commits

Author: Alexander Kornienko
Date: 2020-12-15T02:16:12+01:00
New Revision: 9c49b0bba0fcbe8b10c0f44ce60a8d26e6f30479

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

LOG: Remove the ast_type_traits namespace.

This is the final cleanup after https://reviews.llvm.org/D74499

Reviewed By: steveire

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

Added: 


Modified: 
clang/include/clang/AST/ASTTypeTraits.h

Removed: 




diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index 8791e41b9ac3..2141f85911be 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -529,18 +529,6 @@ template  struct 
DynTypedNode::BaseConverter {
   }
 };
 
-// Previously these types were defined in the clang::ast_type_traits namespace.
-// Provide typedefs so that legacy code can be fixed asynchronously.
-namespace ast_type_traits {
-using DynTypedNode = ::clang::DynTypedNode;
-using ASTNodeKind = ::clang::ASTNodeKind;
-using TraversalKind = ::clang::TraversalKind;
-
-constexpr TraversalKind TK_AsIs = ::clang::TK_AsIs;
-constexpr TraversalKind TK_IgnoreUnlessSpelledInSource =
-::clang::TK_IgnoreUnlessSpelledInSource;
-} // namespace ast_type_traits
-
 } // end namespace clang
 
 namespace llvm {



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


[llvm-branch-commits] [clang-tools-extra] 4c5e0c7 - Remove references to the ast_type_traits namespace

2020-12-11 Thread Alexander Kornienko via llvm-branch-commits

Author: Alexander Kornienko
Date: 2020-12-11T12:39:33+01:00
New Revision: 4c5e0c7fd801ccc52d3b137fa685d4215a6c57ed

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

LOG: Remove references to the ast_type_traits namespace

Follow up to https://reviews.llvm.org/D92994

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.cpp
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.cpp
index ab55dd7f9019..5ded02a2097b 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.cpp
@@ -21,7 +21,7 @@ void DurationDivisionCheck::registerMatchers(MatchFinder 
*finder) {
   const auto DurationExpr =
   expr(hasType(cxxRecordDecl(hasName("::absl::Duration";
   finder->addMatcher(
-  traverse(ast_type_traits::TK_AsIs,
+  traverse(TK_AsIs,
implicitCastExpr(
hasSourceExpression(ignoringParenCasts(
cxxOperatorCallExpr(hasOverloadedOperatorName("/"),

diff  --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
index 8e81e1bebd1f..3d8a0b7b3970 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -19,7 +19,6 @@
 #include 
 
 using namespace clang::ast_matchers;
-using namespace clang::ast_type_traits;
 
 namespace clang {
 

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
index 72e7cd5a2527..d7a7852925db 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
@@ -49,13 +49,13 @@ class DumpAST : public Tweak {
   bool hidden() const override { return true; }
 
 private:
-  static bool dumpable(const ast_type_traits::DynTypedNode &N) {
+  static bool dumpable(const DynTypedNode &N) {
 // Sadly not all node types can be dumped, and there's no API to check.
 // See DynTypedNode::dump().
 return N.get() || N.get() || N.get();
   }
 
-  llvm::Optional Node;
+  llvm::Optional Node;
 };
 REGISTER_TWEAK(DumpAST)
 



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


[llvm-branch-commits] [clang] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-10-22 Thread Alexander Kornienko via llvm-branch-commits

alexfh wrote:

@usx95 may be able to help with the reproducer.

In the meantime, I'm trying to collect some information on the compile times. 
So far it looks like we have a ~10-15x compile time regression on some 
translation units. Without this patch `-ftime-report` shows:
```
===-===
  Clang front-end time report
===-===
  Total Execution Time: 39.1940 seconds (39.7238 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- 
Name ---
  28.2611 ( 77.5%)   1.8439 ( 67.3%)  30.1050 ( 76.8%)  30.5230 ( 76.8%)  Clang 
front-end timer
   8.1911 ( 22.5%)   0.8980 ( 32.7%)   9.0891 ( 23.2%)   9.2009 ( 23.2%)  
Reading modules
  36.4522 (100.0%)   2.7419 (100.0%)  39.1940 (100.0%)  39.7238 (100.0%)  Total
```

With it:
```
===-===
Clang front-end time report
===-===
Total Execution Time: 466.7373 seconds (1251.6300 wall clock)
---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name 
---
 404.7200 ( 96.1%)  40.6383 ( 88.8%)  445.3583 ( 95.4%)  471.9647 ( 37.7%)  
Clang front-end timer
 15.2098 (  3.6%)   3.3586 (  7.3%)  18.5684 (  4.0%)  398.1242 ( 31.8%)  
Reading modules
 420.9899 (100.0%)  45.7474 (100.0%)  466.7373 (100.0%)  1251.6300 (100.0%)  
Total
```

`perf record -g` / `perf report` give the following picture:
```
  Children  Self  Command  Shared Object   Symbol
+   94.85% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) [clone 
.__uniq.16014532493918845222783194145290083557] ◆
+   93.47% 0.00%  clangclang   [.] 
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, 
clang::FunctionDecl*, bool, bool, bool) 
▒
+   93.37%83.51%  clangclang   [.] 
clang::ASTReader::LoadExternalSpecializations(clang::Decl const*, bool) 
  ▒
+   93.19% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, 
bool) [clone .__uniq.16014532493918845222783194▒
+   93.08% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformUnresolvedLookupExpr(clang::UnresolvedLookupExpr*,
 bool) [clone .__uniq.1601453249▒
+   92.98% 0.00%  clangclang   [.] 
clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec const&, 
clang::SourceLocation, clang::LookupResult&, bool, 
clang::TemplateArgumentListInfo const*)   ▒
+   92.44% 0.00%  clangclang   [.] 
clang::Sema::CheckVarTemplateId(clang::VarTemplateDecl*, clang::SourceLocation, 
clang::SourceLocation, clang::TemplateArgumentListInfo const&)▒
+   92.08% 0.00%  clangclang   [.] 
clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, 
clang::MultiLevelTemplateArgumentList const&)   
▒
+   91.87% 0.00%  clangclang   [.] 
clang::VarTemplateDecl::getPartialSpecializations(llvm::SmallVectorImpl&)
 const ▒
+   91.18% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformBinaryOperator(clang::BinaryOperator*)
 [clone .__uniq.1601453249391884522278319414▒
+   91.07% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformExprs(clang::Expr* const*, unsigned 
int, bool, llvm::SmallVectorImpl▒
+   90.70% 0.01%  clangclang   [.] 
clang::Sema::InstantiateVariableDefinition(clang::SourceLocation, 
clang::VarDecl*, bool, bool, bool)  
▒
+   90.41% 0.01%  clangclang   [.] 
clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&, 
clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*, 
clang::TemplateArgu▒
+   90.29% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformInitListExpr(clang::InitListExpr*) 
[clone .__uniq.16014532493918845222783194145290▒
+   89.92% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformParenExpr(clang::ParenExpr*) [clone 
.__uniq.16014532493918845222783194145290083557▒
+   89.23% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::

[llvm-branch-commits] [clang] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-10-23 Thread Alexander Kornienko via llvm-branch-commits

alexfh wrote:

Compiling Clang with more debug information and without FDO+ThinLTO indeed 
shows 
`clang::serialization::MultiOnDiskHashTable::findAll()`
 as the main time sink:
```
+   96.99% 0.00%  clangclang   [.] 
clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, 
llvm::function_ref)
  ◆
+   93.50% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*)  
  ▒
+   91.97% 0.00%  clangclang   [.] 
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, 
clang::FunctionDecl*, bool, bool, bool) 
▒
+   91.62% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, 
bool)  ▒
+   91.58% 0.00%  clangclang   [.] 
clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList 
const&) 
   ▒
+   91.12% 0.00%  clangclang   [.] 
clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformUnresolvedLookupExpr(clang::UnresolvedLookupExpr*,
 bool)  ▒
+   91.00% 0.00%  clangclang   [.] 
clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec const&, 
clang::SourceLocation, clang::LookupResult&, bool, 
clang::TemplateArgumentListInfo const*)   ▒
+   90.97% 1.27%  clangclang   [.] 
clang::ASTReader::LoadExternalSpecializations(clang::Decl const*, bool) 
  ▒
+   90.69% 0.00%  clangclang   [.] 
MarkExprReferenced(clang::Sema&, clang::SourceLocation, clang::Decl*, 
clang::Expr*, bool, llvm::DenseMap&)
 const ▒
-   89.35%61.19%  clangclang   [.] 
clang::serialization::MultiOnDiskHashTable::findAll()
▒
   - 28.16% 
clang::serialization::MultiOnDiskHashTable::findAll()

   ▒
  - 20.71% 
llvm::DenseMap, 
llvm::detail::DenseS▒
 + 0.82% 0x8b4012a6 

 ▒
  + 7.26% llvm::SmallVectorBase::grow_pod(void*, unsigned 
long, unsigned long)
 ▒
   - 14.45% clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&,
 clang::TemplateSpecializationTypeLoc, clang::TemplateName)▒
  - 14.44% clang::Sema::CheckTemplateIdType(clang::TemplateName, 
clang::SourceLocation, clang::TemplateArgumentListInfo&)
▒
   clang::Sema::SubstType(clang::QualType, 
clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, 
clang::DeclarationName, bool*)  
 ▒
 + clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*)

  ▒
   + 13.46% clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*)  
   ▒
   + 11.65% _start  

 ▒
   + 11.18% 
clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(clang::TypedefNameDecl*,
 bool)  
 ▒
   + 7.98% clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, 
clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*)
  ▒
   + 1.75% clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&,
 clang::TemplateSpecializationTypeLoc)  ▒
```

https://github.com/llvm/llvm-project/pull/83237
___
llvm-branch-commits mailing list
llvm-br

[llvm-branch-commits] [clang] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-10-23 Thread Alexander Kornienko via llvm-branch-commits

alexfh wrote:

BTW, if you wonder about the callers of `LoadExternalSpecializations`:
```
-   90.30% 0.00%  clang  clang   [.] 
clang::Sema::CheckVarTemplateId(clang::VarTemplateDecl*, clang::SourceLocation, 
clang::SourceLocation, clang::TemplateArgumentListInfo const&)  
▒
   - 90.30% clang::Sema::CheckVarTemplateId(clang::VarTemplateDecl*, 
clang::SourceLocation, clang::SourceLocation, clang::TemplateArgumentListInfo 
const&)   ▒
  - 89.47% 
clang::VarTemplateDecl::getPartialSpecializations(llvm::SmallVectorImpl&)
 const ▒
 - 89.46% clang::ASTReader::LoadExternalSpecializations(clang::Decl 
const*, bool)   
 ▒
- 88.08% 
clang::serialization::MultiOnDiskHashTable::findAll()
  ▒
   - 20.24% 
llvm::DenseMap, 
llvm::detai▒
  + 0.82% 0x8b4012a6

 ▒
   - 7.22% llvm::SmallVectorBase::grow_pod(void*, 
unsigned long, unsigned long)   
 ▒
  - 7.11% memcpy_prefetch   

 ▒
 + 1.52% 0x8b4012a6 

 ▒
```

https://github.com/llvm/llvm-project/pull/83237
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits