[llvm-branch-commits] [llvm] 34958d1 - [Flang][openmp][3/5] Make ProcBind clause part of OmpClause

2020-12-22 Thread Sameeran joshi via llvm-branch-commits

Author: sameeran joshi
Date: 2020-12-22T13:40:38+05:30
New Revision: 34958d11c3457c8e05bbe2b31d5e013c04aecb55

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

LOG: [Flang][openmp][3/5] Make ProcBind clause part of OmpClause

After discussion in `D93482` we found that the some of the clauses were not
following the common OmpClause convention.

The benefits of using OmpClause:
- Functionalities from structure checker are mostly aligned to work with
  `llvm::omp::Clause`.
- The unparsing as well can take advantage.
- Homogeneity with OpenACC and rest of the clauses in OpenMP.
- Could even generate the parser with TableGen, when there is homogeneity.
- It becomes confusing when to use `flangClass` and `flangClassValue` inside
  TableGen, if incase we generate parser using TableGen we could have only a
  single `let expression`.

This patch makes `OmpProcBindClause` clause part of `OmpClause`.
The unparse function is dropped as the unparsing is done by `WALK_NESTED_ENUM`
for `OmpProcBindClause`.

Reviewed By: clementval, kiranktp

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

Added: 


Modified: 
flang/lib/Lower/OpenMP.cpp
flang/lib/Parser/openmp-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.cpp
flang/lib/Semantics/check-omp-structure.h
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index f73dd09fbe68..f765723bb9ae 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -214,8 +214,9 @@ genOMP(Fortran::lower::AbstractConverter &converter,
 }
   }
   if (const auto &procBindClause =
-  std::get_if(&clause.u)) {
-switch (procBindClause->v) {
+  std::get_if(&clause.u)) {
+const auto &ompProcBindClause{procBindClause->v};
+switch (ompProcBindClause.v) {
 case Fortran::parser::OmpProcBindClause::Type::Master:
   parallelOp.proc_bind_valAttr(
   firOpBuilder.getStringAttr(omp::stringifyClauseProcBindKind(

diff  --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index e982dd19e498..50999bef8f52 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -216,8 +216,8 @@ TYPE_PARSER(
   parenthesized(scalarIntExpr))) ||
 "PRIVATE" >> construct(construct(
  parenthesized(Parser{}))) ||
-"PROC_BIND" >>
-construct(parenthesized(Parser{})) ||
+"PROC_BIND" >> construct(construct(
+   parenthesized(Parser{}))) ||
 "REDUCTION" >>
 construct(parenthesized(Parser{})) ||
 "RELAXED" >> construct(construct()) ||

diff  --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index a4b0c64011fc..6be063c1b1bc 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2058,11 +2058,6 @@ class UnparseVisitor {
   },
 x.u);
   }
-  bool Pre(const OmpProcBindClause &) {
-Word("PROC_BIND(");
-return true;
-  }
-  void Post(const OmpProcBindClause &) { Put(")"); }
   void Unparse(const OmpDefaultmapClause &x) {
 Word("DEFAULTMAP(");
 Walk(std::get(x.t));

diff  --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index 6ed7106bb9f4..481099b34966 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -428,6 +428,7 @@ CHECK_SIMPLE_CLAUSE(SeqCst, OMPC_seq_cst)
 CHECK_SIMPLE_CLAUSE(Release, OMPC_release)
 CHECK_SIMPLE_CLAUSE(Relaxed, OMPC_relaxed)
 CHECK_SIMPLE_CLAUSE(Hint, OMPC_hint)
+CHECK_SIMPLE_CLAUSE(ProcBind, OMPC_proc_bind)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator)
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
@@ -493,7 +494,6 @@ void OmpStructureChecker::CheckIsVarPartOfAnotherVar(
 // Following clauses have a seperate node in parse-tree.h.
 CHECK_SIMPLE_PARSER_CLAUSE(OmpDistScheduleClause, OMPC_dist_schedule)
 CHECK_SIMPLE_PARSER_CLAUSE(OmpNowait, OMPC_nowait)
-CHECK_SIMPLE_PARSER_CLAUSE(OmpProcBindClause, OMPC_proc_bind)
 CHECK_SIMPLE_PARSER_CLAUSE(OmpReductionClause, OMPC_reduction)
 // Atomic-clause
 CHECK_SIMPLE_PARSER_CLAUSE(OmpAtomicRead, OMPC_read)

diff  --git a/flang/lib/Semantics/check-omp-structure.h 
b/flang/lib/Semantics/check-omp-structure.h
index dcc2deeb348c..89fc3d9faa21 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -150,6 +150,7 @@ class OmpStructureChecker
   void Enter(const parser::OmpClause::Ordered &);
   void Enter(const parser::OmpClause::Priority &);
   void Enter(const parser::OmpClause::Private &);
+  void 

[llvm-branch-commits] [llvm] a562800 - [LV] Avoid needless fold tail

2020-12-22 Thread Gil Rapaport via llvm-branch-commits

Author: Gil Rapaport
Date: 2020-12-22T10:25:20+02:00
New Revision: a56280094e08792516b035390a946ea337a27b97

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

LOG: [LV] Avoid needless fold tail

When the trip-count is provably divisible by the maximal/chosen VF, folding the
loop's tail during vectorization is redundant. This commit extends the existing
test for constant trip-counts to any trip-count known to be divisible by
maximal/selected VF by SCEV.

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

Added: 
llvm/test/Transforms/LoopVectorize/dont-fold-tail-for-const-TC.ll
llvm/test/Transforms/LoopVectorize/dont-fold-tail-for-divisible-TC.ll

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

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 25deab6d2b35..680106bcb7c6 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5512,6 +5512,19 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount 
UserVF, unsigned UserIC) {
 return MaxVF;
   }
 
+  // Avoid tail folding if the trip count is known to be a multiple of any VF 
we
+  // chose.
+  ScalarEvolution *SE = PSE.getSE();
+  const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
+  const SCEV *ExitCount = SE->getAddExpr(
+  BackedgeTakenCount, SE->getOne(BackedgeTakenCount->getType()));
+  unsigned TCisMultipleOf = 1 << SE->GetMinTrailingZeros(ExitCount);
+  if (TCisMultipleOf % MaxVFtimesIC == 0) {
+// Accept MaxVF if we do not have a tail.
+LLVM_DEBUG(dbgs() << "LV: No tail will remain for any chosen VF.\n");
+return MaxVF;
+  }
+
   // If we don't know the precise trip count, or if the trip count that we
   // found modulo the vectorization factor is not zero, try to fold the tail
   // by masking.

diff  --git a/llvm/test/Transforms/LoopVectorize/dont-fold-tail-for-const-TC.ll 
b/llvm/test/Transforms/LoopVectorize/dont-fold-tail-for-const-TC.ll
new file mode 100644
index ..0dba201e73fb
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/dont-fold-tail-for-const-TC.ll
@@ -0,0 +1,69 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -loop-vectorize -force-vector-interleave=3 
-force-vector-width=2 -S | 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"
+
+; Make sure the loop is vectorized and unrolled under -Os without folding its
+; tail based on its trip-count being provably divisible by chosen VFxIC.
+
+define dso_local void @constTC(i32* noalias nocapture %A) optsize {
+; CHECK-LABEL: @constTC(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
+; CHECK:   vector.ph:
+; CHECK-NEXT:br label [[VECTOR_BODY:%.*]]
+; CHECK:   vector.body:
+; CHECK-NEXT:[[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i32> 
undef, i32 [[INDEX]], i32 0
+; CHECK-NEXT:[[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i32> 
[[BROADCAST_SPLATINSERT]], <2 x i32> undef, <2 x i32> zeroinitializer
+; CHECK-NEXT:[[INDUCTION:%.*]] = add <2 x i32> [[BROADCAST_SPLAT]], 
+; CHECK-NEXT:[[INDUCTION1:%.*]] = add <2 x i32> [[BROADCAST_SPLAT]], 
+; CHECK-NEXT:[[INDUCTION2:%.*]] = add <2 x i32> [[BROADCAST_SPLAT]], 
+; CHECK-NEXT:[[TMP0:%.*]] = add i32 [[INDEX]], 0
+; CHECK-NEXT:[[TMP1:%.*]] = add i32 [[INDEX]], 2
+; CHECK-NEXT:[[TMP2:%.*]] = add i32 [[INDEX]], 4
+; CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], 
i32 [[TMP0]]
+; CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds i32, i32* [[A]], i32 
[[TMP1]]
+; CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds i32, i32* [[A]], i32 
[[TMP2]]
+; CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds i32, i32* [[TMP3]], i32 0
+; CHECK-NEXT:[[TMP7:%.*]] = bitcast i32* [[TMP6]] to <2 x i32>*
+; CHECK-NEXT:store <2 x i32> , <2 x i32>* [[TMP7]], align 1
+; CHECK-NEXT:[[TMP8:%.*]] = getelementptr inbounds i32, i32* [[TMP3]], i32 
2
+; CHECK-NEXT:[[TMP9:%.*]] = bitcast i32* [[TMP8]] to <2 x i32>*
+; CHECK-NEXT:store <2 x i32> , <2 x i32>* [[TMP9]], align 1
+; CHECK-NEXT:[[TMP10:%.*]] = getelementptr inbounds i32, i32* [[TMP3]], 
i32 4
+; CHECK-NEXT:[[TMP11:%.*]] = bitcast i32* [[TMP10]] to <2 x i32>*
+; CHECK-NEXT:store <2 x i32> , <2 x i32>* [[TMP11]], align 
1
+; CHECK-NEXT:[[INDEX_NEXT]] = add i32 [[INDEX]], 6
+; CHECK-NEXT:[[TMP12:%.*]] = icmp eq i32 [[INDEX_NEXT]], 1800
+; CHECK-NEXT:br i1 [[TMP12]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECT

[llvm-branch-commits] [flang] e282ae5 - [Flang][openmp][4/5] Make nowait clause part of OmpClause

2020-12-22 Thread Sameeran joshi via llvm-branch-commits

Author: sameeran joshi
Date: 2020-12-22T14:02:19+05:30
New Revision: e282ae57da29a37e143ab6d640f68e794f5cd614

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

LOG: [Flang][openmp][4/5] Make nowait clause part of OmpClause

After discussion in `D93482` we found that the some of the clauses were not
following the common OmpClause convention.

The benefits of using OmpClause:
- Functionalities from structure checker are mostly aligned to work with
  `llvm::omp::Clause`.
- The unparsing as well can take advantage.
- Homogeneity with OpenACC and rest of the clauses in OpenMP.
- Could even generate the parser with TableGen, when there is homogeneity.
- It becomes confusing when to use `flangClass` and `flangClassValue` inside
  TableGen, if incase we generate parser using TableGen we could have only a
  single `let expression`.

This patch makes `OmpNoWait` clause part of `OmpClause`.

Reviewed By: clementval, kiranktp

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

Added: 


Modified: 
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
flang/lib/Parser/openmp-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.cpp
flang/lib/Semantics/check-omp-structure.h
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/flang/include/flang/Parser/dump-parse-tree.h 
b/flang/include/flang/Parser/dump-parse-tree.h
index f69dd149e0a3..05152f8c49c6 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -508,7 +508,6 @@ class ParseTreeDumper {
 "llvm::omp::Clause = ", llvm::omp::getOpenMPClauseName(x))
 .str();
   }
-  NODE(parser, OmpNowait)
   NODE(parser, OmpObject)
   NODE(parser, OmpObjectList)
   NODE(parser, OmpProcBindClause)

diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index 59fa278e0029..09c61477d2e7 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3456,9 +3456,6 @@ struct OmpDependClause {
   std::variant u;
 };
 
-// 2.7.1 nowait-clause -> NOWAIT
-EMPTY_CLASS(OmpNowait);
-
 // dist_schedule clause does not fit in generic clause class for tablegen.
 // Therefore it is declared separatly here.
 WRAPPER_CLASS(OmpDistScheduleClause, std::optional);

diff  --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 50999bef8f52..62dd0d1e7d29 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -203,7 +203,7 @@ TYPE_PARSER(
 "NOGROUP" >> construct(construct()) ||
 "NOTINBRANCH" >>
 construct(construct()) ||
-"NOWAIT" >> construct(construct()) ||
+"NOWAIT" >> construct(construct()) ||
 "NUM_TASKS" >> construct(construct(
parenthesized(scalarIntExpr))) ||
 "NUM_TEAMS" >> construct(construct(

diff  --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 6be063c1b1bc..5dbf9940e26e 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2065,7 +2065,6 @@ class UnparseVisitor {
 std::get>(x.t));
 Word(")");
   }
-  void Unparse(const OmpNowait &) { Word("NOWAIT"); }
   void Unparse(const OmpDistScheduleClause &x) {
 Word("DIST_SCHEDULE(STATIC");
 Walk(", ", x.v);

diff  --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index 481099b34966..c901630c098b 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -418,6 +418,7 @@ CHECK_SIMPLE_CLAUSE(Link, OMPC_link)
 CHECK_SIMPLE_CLAUSE(Mergeable, OMPC_mergeable)
 CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
 CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
+CHECK_SIMPLE_CLAUSE(Nowait, OMPC_nowait)
 CHECK_SIMPLE_CLAUSE(To, OMPC_to)
 CHECK_SIMPLE_CLAUSE(Uniform, OMPC_uniform)
 CHECK_SIMPLE_CLAUSE(Untied, OMPC_untied)
@@ -493,7 +494,6 @@ void OmpStructureChecker::CheckIsVarPartOfAnotherVar(
 }
 // Following clauses have a seperate node in parse-tree.h.
 CHECK_SIMPLE_PARSER_CLAUSE(OmpDistScheduleClause, OMPC_dist_schedule)
-CHECK_SIMPLE_PARSER_CLAUSE(OmpNowait, OMPC_nowait)
 CHECK_SIMPLE_PARSER_CLAUSE(OmpReductionClause, OMPC_reduction)
 // Atomic-clause
 CHECK_SIMPLE_PARSER_CLAUSE(OmpAtomicRead, OMPC_read)

diff  --git a/flang/lib/Semantics/check-omp-structure.h 
b/flang/lib/Semantics/check-omp-structure.h
index 89fc3d9faa21..72bb9a523366 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -126,12 +126,12 @@ class OmpStructureChecker
 
   void Leave(const parser::OmpClauseList &);
   void Enter(const parser::OmpClause &);
-  void E

[llvm-branch-commits] [mlir] 2f5569f - [mlir] remove deprecated string-based OpBuilder from ODS

2020-12-22 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-12-22T09:57:49+01:00
New Revision: 2f5569f6f67a30f7774f7c2d2f3d726752a862ae

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

LOG: [mlir] remove deprecated string-based OpBuilder from ODS

It has been deprecated with a warning for two months, removing.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/include/mlir/IR/OpBase.td
mlir/test/mlir-tblgen/op-decl.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 




diff  --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index 0f060b2b1a0a..0ae572c38f49 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -1939,15 +1939,6 @@ def region;
 // Marker used to identify the successor list for an op.
 def successor;
 
-// Base class for custom builders. This is a transient class that will go away
-// when the transition to the DAG form of builder declaration is complete.
-// Should not be used directly.
-class OpBuilderBase {
-  string params = ?;
-  dag dagParams = dp;
-  code body = b;
-}
-
 // Class for defining a custom builder.
 //
 // TableGen generates several generic builders for each op by default (see
@@ -1986,11 +1977,9 @@ class OpBuilderBase {
 // If an empty string is passed in for `body`, then *only* the builder
 // declaration will be generated; this provides a way to define complicated
 // builders entirely in C++.
-class OpBuilderDAG : OpBuilderBase;
-
-// Deprecated version of OpBuilder that takes the builder signature as string.
-class OpBuilder : OpBuilderBase<(ins), b> {
-  let params = p;
+class OpBuilderDAG {
+  dag dagParams = p;
+  code body = b;
 }
 
 // A base decorator class that may optionally be added to OpVariables.
@@ -2068,7 +2057,7 @@ class Op 
props = []> {
   //   ValueRange operands,
   //   ArrayRef attributes);
   // ```
-  list builders = ?;
+  list builders = ?;
 
   // Avoid generating default build functions.  Custom builders must be
   // provided.

diff  --git a/mlir/test/mlir-tblgen/op-decl.td 
b/mlir/test/mlir-tblgen/op-decl.td
index 29438f1836a7..13daca67c475 100644
--- a/mlir/test/mlir-tblgen/op-decl.td
+++ b/mlir/test/mlir-tblgen/op-decl.td
@@ -34,8 +34,7 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, 
IsolatedFromAbove]> {
 VariadicRegion:$someRegions
   );
   let builders = [OpBuilderDAG<(ins "Value":$val)>,
-  OpBuilderDAG<(ins CArg<"int", "0">:$integer)>,
-  OpBuilder<"double deprecatedForm">];
+  OpBuilderDAG<(ins CArg<"int", "0">:$integer)>];
   let parser = [{ foo }];
   let printer = [{ bar }];
   let verifier = [{ baz }];
@@ -84,7 +83,6 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, 
IsolatedFromAbove]> {
 // CHECK:   ::llvm::Optional< ::llvm::APFloat > attr2();
 // CHECK:   static void build(::mlir::OpBuilder &odsBuilder, 
::mlir::OperationState &odsState, Value val);
 // CHECK:   static void build(::mlir::OpBuilder &odsBuilder, 
::mlir::OperationState &odsState, int integer = 0);
-// CHECK:   static void build(::mlir::OpBuilder &odsBuilder, 
::mlir::OperationState &odsState, double deprecatedForm);
 // CHECK:   static void build(::mlir::OpBuilder &odsBuilder, 
::mlir::OperationState &odsState, ::mlir::Type r, ::mlir::TypeRange s, 
::mlir::Value a, ::mlir::ValueRange b, ::mlir::IntegerAttr attr1, 
/*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount)
 // CHECK:   static void build(::mlir::OpBuilder &odsBuilder, 
::mlir::OperationState &odsState, ::mlir::Type r, ::mlir::TypeRange s, 
::mlir::Value a, ::mlir::ValueRange b, uint32_t attr1, 
/*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount)
 // CHECK:   static void build(::mlir::OpBuilder &, ::mlir::OperationState 
&odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, 
::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions)

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp 
b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 1c8cbfb9db38..40e1c355daf8 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -1304,8 +1304,7 @@ void OpEmitter::genUseAttrAsResultTypeBuilder() {
 /// Updates the context `fctx` to enable replacement of $_builder and $_state
 /// in the body. Reports errors at `loc`.
 static std::string builderSignatureFromDAG(const DagInit *init,
-   ArrayRef loc,
-   FmtContext &fctx) {
+   ArrayRef loc) {
   auto *defInit = dyn_cast(init->getOperator());
   if (!defInit || !defInit->getDef()->getName().equals("ins"))
 PrintFatalError(loc

[llvm-branch-commits] [flang] 1a6f439 - [Flang][openmp][5/5] Make dist_schedule clause part of OmpClause

2020-12-22 Thread Sameeran joshi via llvm-branch-commits

Author: sameeran joshi
Date: 2020-12-22T14:32:33+05:30
New Revision: 1a6f43991ff7e5249f24660074f0dd784aeecd5f

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

LOG: [Flang][openmp][5/5] Make dist_schedule clause part of OmpClause

After discussion in `D93482` we found that the some of the clauses were not
following the common OmpClause convention.

The benefits of using OmpClause:
- Functionalities from structure checker are mostly aligned to work with
  `llvm::omp::Clause`.
- The unparsing as well can take advantage.
- Homogeneity with OpenACC and rest of the clauses in OpenMP.
- Could even generate the parser with TableGen, when there is homogeneity.
- It becomes confusing when to use `flangClass` and `flangClassValue` inside
  TableGen, if incase we generate parser using TableGen we could have only a
  single `let expression`.

This patch makes `OmpDistScheduleClause` clause part of `OmpClause`.
The unparse function for `OmpDistScheduleClause` is adapted since the keyword
and parenthesis are issued by the corresponding unparse function for
`parser::OmpClause::DistSchedule`.

Reviewed By: clementval, kiranktp

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

Added: 


Modified: 
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
flang/lib/Parser/openmp-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.cpp
flang/lib/Semantics/check-omp-structure.h
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/flang/include/flang/Parser/dump-parse-tree.h 
b/flang/include/flang/Parser/dump-parse-tree.h
index 05152f8c49c6..60e2a2df 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -485,7 +485,6 @@ class ParseTreeDumper {
   NODE_ENUM(OmpDependenceType, Type)
   NODE(parser, OmpDependSinkVec)
   NODE(parser, OmpDependSinkVecLength)
-  NODE(parser, OmpDistScheduleClause)
   NODE(parser, OmpEndAtomic)
   NODE(parser, OmpEndBlockDirective)
   NODE(parser, OmpEndCriticalDirective)

diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index 09c61477d2e7..7e258b668576 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3456,10 +3456,6 @@ struct OmpDependClause {
   std::variant u;
 };
 
-// dist_schedule clause does not fit in generic clause class for tablegen.
-// Therefore it is declared separatly here.
-WRAPPER_CLASS(OmpDistScheduleClause, std::optional);
-
 // OpenMP Clauses
 struct OmpClause {
   UNION_CLASS_BOILERPLATE(OmpClause);

diff  --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 62dd0d1e7d29..1386b2b16a78 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -176,7 +176,7 @@ TYPE_PARSER(
 "DEVICE" >> construct(construct(
 parenthesized(scalarIntExpr))) ||
 "DIST_SCHEDULE" >>
-construct(construct(
+construct(construct(
 parenthesized("STATIC" >> maybe("," >> scalarIntExpr ||
 "FINAL" >> construct(construct(
parenthesized(scalarLogicalExpr))) ||

diff  --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 5dbf9940e26e..fdb694f3d26f 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2065,11 +2065,6 @@ class UnparseVisitor {
 std::get>(x.t));
 Word(")");
   }
-  void Unparse(const OmpDistScheduleClause &x) {
-Word("DIST_SCHEDULE(STATIC");
-Walk(", ", x.v);
-Put(")");
-  }
 #define GEN_FLANG_CLAUSE_UNPARSE
 #include "llvm/Frontend/OpenMP/OMP.inc"
   void Unparse(const OmpLoopDirective &x) {

diff  --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index c901630c098b..e2c8333ce7ee 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -430,6 +430,7 @@ CHECK_SIMPLE_CLAUSE(Release, OMPC_release)
 CHECK_SIMPLE_CLAUSE(Relaxed, OMPC_relaxed)
 CHECK_SIMPLE_CLAUSE(Hint, OMPC_hint)
 CHECK_SIMPLE_CLAUSE(ProcBind, OMPC_proc_bind)
+CHECK_SIMPLE_CLAUSE(DistSchedule, OMPC_dist_schedule)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator)
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
@@ -493,7 +494,6 @@ void OmpStructureChecker::CheckIsVarPartOfAnotherVar(
   }
 }
 // Following clauses have a seperate node in parse-tree.h.
-CHECK_SIMPLE_PARSER_CLAUSE(OmpDistScheduleClause, OMPC_dist_schedule)
 CHECK_SIMPLE_PARSER_CLAUSE(OmpReductionClause, OMPC_reduction)
 // Atomic-clause
 CHECK_SIMPLE_PARSER_CLAUSE(OmpAtomicRead, OMPC_read)

diff  --git a/flang/lib/Semantics/check-omp-structure.h 
b

[llvm-branch-commits] [llvm] a6783cd - [llvm][ARM/AArch64] Convert Target Parser CPU tests to fixtures

2020-12-22 Thread David Spickett via llvm-branch-commits

Author: David Spickett
Date: 2020-12-22T09:07:20Z
New Revision: a6783cd7b65d6c739c4dc20ec5191b2e862a4237

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

LOG: [llvm][ARM/AArch64] Convert Target Parser CPU tests to fixtures

Also convert the test function to use EXPECT_EQ and
remove the special case for the AEK_NONE extension.

This means that each test is marked as failing separatley
and the accumultated EXPECT failures are printed next
to that test, with its parameters.

Before they would be hidden by the "pass &=" pattern
and failures would print in one block since it was a
"single" test.

Example of the new failure messages:
```
ARMCPUTestsPart1/ARMCPUTestFixture.ARMCPUTests/6
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from ARMCPUTestsPart1/ARMCPUTestFixture
[ RUN  ] ARMCPUTestsPart1/ARMCPUTestFixture.ARMCPUTests/6
/work/open_source/nightly-llvm/llvm-project/llvm/unittests/Support/TargetParserTest.cpp:66:
Failure
  Expected: params.ExpectedFlags
  Which is: 3405705229
To be equal to: default_extensions
  Which is: 1
[  FAILED  ] ARMCPUTestsPart1/ARMCPUTestFixture.ARMCPUTests/6, where
GetParam() = "arm8", "armv4", "none", 0xcafef00d, "4" (0 ms)
```

Reviewed By: MarkMurrayARM

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

Added: 


Modified: 
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/llvm/unittests/Support/TargetParserTest.cpp 
b/llvm/unittests/Support/TargetParserTest.cpp
index 8407397e4ed8..5208f6a75b02 100644
--- a/llvm/unittests/Support/TargetParserTest.cpp
+++ b/llvm/unittests/Support/TargetParserTest.cpp
@@ -31,308 +31,315 @@ const char *ARMArch[] = {
 "armv8m.main", "iwmmxt",   "iwmmxt2", "xscale",   
"armv8.1-m.main",
 };
 
-bool testARMCPU(StringRef CPUName, StringRef ExpectedArch,
-StringRef ExpectedFPU, uint64_t ExpectedFlags,
-StringRef CPUAttr) {
-  ARM::ArchKind AK = ARM::parseCPUArch(CPUName);
-  bool pass = ARM::getArchName(AK).equals(ExpectedArch);
-  unsigned FPUKind = ARM::getDefaultFPU(CPUName, AK);
-  pass &= ARM::getFPUName(FPUKind).equals(ExpectedFPU);
-
-  uint64_t ExtKind = ARM::getDefaultExtensions(CPUName, AK);
-  if (ExtKind > 1 && (ExtKind & ARM::AEK_NONE))
-pass &= ((ExtKind ^ ARM::AEK_NONE) == ExpectedFlags);
-  else
-pass &= (ExtKind == ExpectedFlags);
-  pass &= ARM::getCPUAttr(AK).equals(CPUAttr);
-
-  return pass;
+struct ARMCPUTestParams {
+  ARMCPUTestParams(StringRef CPUName, StringRef ExpectedArch,
+   StringRef ExpectedFPU, uint64_t ExpectedFlags,
+   StringRef CPUAttr)
+  : CPUName(CPUName), ExpectedArch(ExpectedArch), ExpectedFPU(ExpectedFPU),
+ExpectedFlags(ExpectedFlags), CPUAttr(CPUAttr) {}
+
+  friend std::ostream &operator<<(std::ostream &os,
+  const ARMCPUTestParams ¶ms) {
+return os << "\"" << params.CPUName.str() << "\", \""
+  << params.ExpectedArch.str() << "\", \""
+  << params.ExpectedFPU.str() << "\", 0x" << std::hex
+  << params.ExpectedFlags << ", \"" << params.CPUAttr.str() << 
"\"";
+  }
+
+  StringRef CPUName;
+  StringRef ExpectedArch;
+  StringRef ExpectedFPU;
+  uint64_t ExpectedFlags;
+  StringRef CPUAttr;
+};
+
+class ARMCPUTestFixture : public ::testing::TestWithParam {};
+
+TEST_P(ARMCPUTestFixture, ARMCPUTests) {
+  auto params = GetParam();
+
+  ARM::ArchKind AK = ARM::parseCPUArch(params.CPUName);
+  EXPECT_EQ(params.ExpectedArch, ARM::getArchName(AK));
+
+  unsigned FPUKind = ARM::getDefaultFPU(params.CPUName, AK);
+  EXPECT_EQ(params.ExpectedFPU, ARM::getFPUName(FPUKind));
+
+  uint64_t default_extensions = ARM::getDefaultExtensions(params.CPUName, AK);
+  EXPECT_EQ(params.ExpectedFlags, default_extensions);
+
+  EXPECT_EQ(params.CPUAttr, ARM::getCPUAttr(AK));
 }
 
-TEST(TargetParserTest, testARMCPU) {
-  EXPECT_TRUE(testARMCPU("invalid", "invalid", "invalid",
- ARM::AEK_NONE, ""));
-  EXPECT_TRUE(testARMCPU("generic", "invalid", "none",
- ARM::AEK_NONE, ""));
-
-  EXPECT_TRUE(testARMCPU("arm2", "armv2", "none",
- ARM::AEK_NONE, "2"));
-  EXPECT_TRUE(testARMCPU("arm3", "armv2a", "none",
- ARM::AEK_NONE, "2A"));
-  EXPECT_TRUE(testARMCPU("arm6", "armv3", "none",
- ARM::AEK_NONE, "3"));
-  EXPECT_TRUE(testARMCPU("arm7m", "armv3m", "none",
- ARM::AEK_NONE, "3M"));
-  EXPECT_TRUE(testARMCPU("arm8", "armv4", "none",
- ARM::AEK_NONE, "4"));
-  EXPECT_TRUE(testARMCPU("arm810", "armv4", "none",
- ARM::AEK_NONE, "4"));
-  EXPECT_TRU

[llvm-branch-commits] [lldb] 0a8a245 - [lldb/test] Add GdbRemoteTestCaseFactory to avoid duplication in lldb-server tests

2020-12-22 Thread Pavel Labath via llvm-branch-commits

Author: Pavel Labath
Date: 2020-12-22T10:07:47+01:00
New Revision: 0a8a2453fb843cf2e0f43e389b58d516525f0b8c

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

LOG: [lldb/test] Add GdbRemoteTestCaseFactory to avoid duplication in 
lldb-server tests

This uses the same approach as the debug info tests to avoid needing to
explicitly spell out the two kinds of tests. I convert a handful of
tests to the new mechanism. The rest will be converted in follow-up
patches.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py
lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py
lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
lldb/test/API/tools/lldb-server/TestGdbRemoteSingleStep.py
lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index a17cd6ea33ab..ff445fa0b926 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -373,13 +373,11 @@ def should_skip_simulator_test():
 
 def debugserver_test(func):
 """Decorate the item as a debugserver test."""
-func.debug_server = "debugserver"
 return add_test_categories(["debugserver"])(func)
 
 
 def llgs_test(func):
 """Decorate the item as a lldb-server test."""
-func.debug_server = "llgs"
 return add_test_categories(["llgs"])(func)
 
 

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 0e3cde01520a..d9289251d89d 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -27,6 +27,39 @@ class _ConnectionRefused(IOError):
 pass
 
 
+class GdbRemoteTestCaseFactory(type):
+
+def __new__(cls, name, bases, attrs):
+newattrs = {}
+for attrname, attrvalue in attrs.items():
+if not attrname.startswith("test"):
+newattrs[attrname] = attrvalue
+continue
+
+# If any debug server categories were explicitly tagged, assume
+# that list to be authoritative. If none were specified, try
+# all of them.
+all_categories = set(["debugserver", "llgs"])
+categories = set(
+getattr(attrvalue, "categories", [])) & all_categories
+if not categories:
+categories = all_categories
+
+for cat in categories:
+@decorators.add_test_categories([cat])
+@wraps(attrvalue)
+def test_method(self, attrvalue=attrvalue):
+return attrvalue(self)
+
+method_name = attrname + "_" + cat
+test_method.__name__ = method_name
+test_method.debug_server = cat
+newattrs[method_name] = test_method
+
+return super(GdbRemoteTestCaseFactory, cls).__new__(
+cls, name, bases, newattrs)
+
+@add_metaclass(GdbRemoteTestCaseFactory)
 class GdbRemoteTestCaseBase(Base):
 
 # Default time out in seconds. The timeout is increased tenfold under Asan.

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py
index 96ebbfb09bdc..b42f8431c51e 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteExitCode.py
@@ -12,46 +12,23 @@ class TestGdbRemoteExitCode(GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def inferior_exit_0(self):
-self.prep_debug_monitor_and_inferior()
-self.test_sequence.add_log_lines(
-["read packet: $vCont;c#a8",
- "send packet: $W00#00"],
-True)
-
-self.expect_gdbremote_sequence()
-
-@debugserver_test
-@skipIfDarwinEmbedded #  lldb-server tests not 
updated to work on ios etc yet
-def test_inferior_exit_0_debugserver(self):
+def _test_inferior_exit(self, retval):
 self.build()
-self.inferior_exit_0()
-
-@llgs_test
-def test_inferior_exit_0_llgs(self):
-self.build()
-self.inferior_exit_0()
-
-def inferior_exit_42(self):
-RETVAL = 42
 
 procs = self.prep_debug_monitor_and_inferi

[llvm-branch-commits] [llvm] 8d75d90 - [DebugInfo] Don't use DW_OP_implicit_value for fragments

2020-12-22 Thread Pavel Labath via llvm-branch-commits

Author: Pavel Labath
Date: 2020-12-22T10:07:47+01:00
New Revision: 8d75d902a955602feb7e2501e34f814ff5630415

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

LOG: [DebugInfo] Don't use DW_OP_implicit_value for fragments

Currently using DW_OP_implicit_value in fragments produces invalid DWARF
expressions. (Such a case can occur in complex floats, for example.)

This problem manifests itself as a missing DW_OP_piece operation after
the last fragment. This happens because the function for printing
constant float value skips printing the accompanying DWARF expression,
as that would also print DW_OP_stack_value (which is not desirable in
this case). However, this also results in DW_OP_piece being skipped.

The reason that DW_OP_piece is missing only for the last piece is that
the act of printing the next fragment corrects this. However, it does
that for the wrong reason -- the code emitting this DW_OP_piece thinks
that the previous fragment was missing, and so it thinks that it needs
to skip over it in order to be able to print itself.

In a simple scenario this works out, but it's likely that in a more
complex setup (where some pieces are in fact missing), this logic would
go badly wrong. In a simple setup gdb also seems to not mind the fact
that the DW_OP_piece is missing, but it would also likely not handle
more complex use cases.

For this reason, this patch disables the usage of DW_OP_implicit_value
in the frament scenario (we will use DW_OP_const*** instead), until we
figure out the right way to deal with this. This guarantees that we
produce valid expressions, and gdb can handle both kinds of inputs
anyway.

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

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/X86/implicit_value-double.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 75b4a2831b0f..6127c503404f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2477,13 +2477,13 @@ void DwarfDebug::emitDebugLocValue(const AsmPrinter 
&AP, const DIBasicType *BT,
   DwarfExpr.addExpression(std::move(ExprCursor));
   return;
   } else if (Value.isConstantFP()) {
-if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE()) {
+if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE() &&
+!ExprCursor) {
   DwarfExpr.addConstantFP(Value.getConstantFP()->getValueAPF(), AP);
   return;
-} else if (Value.getConstantFP()
-   ->getValueAPF()
-   .bitcastToAPInt()
-   .getBitWidth() <= 64 /*bits*/)
+}
+if (Value.getConstantFP()->getValueAPF().bitcastToAPInt().getBitWidth() <=
+64 /*bits*/)
   DwarfExpr.addUnsignedConstant(
   Value.getConstantFP()->getValueAPF().bitcastToAPInt());
 else

diff  --git a/llvm/test/DebugInfo/X86/implicit_value-double.ll 
b/llvm/test/DebugInfo/X86/implicit_value-double.ll
index f205cb9a68ee..956c896b8d34 100644
--- a/llvm/test/DebugInfo/X86/implicit_value-double.ll
+++ b/llvm/test/DebugInfo/X86/implicit_value-double.ll
@@ -1,8 +1,8 @@
 ;; This test checks for emission of DW_OP_implicit_value operation
 ;; for double type.
 
-; RUN: llc -debugger-tune=gdb -filetype=obj %s -o -  | llvm-dwarfdump - | 
FileCheck %s
-; RUN: llc -debugger-tune=lldb -filetype=obj %s -o - | llvm-dwarfdump - | 
FileCheck %s
+; RUN: llc -O0 -debugger-tune=gdb -filetype=obj %s -o -  | llvm-dwarfdump - | 
FileCheck %s --check-prefixes=CHECK,BOTH
+; RUN: llc -O0 -debugger-tune=lldb -filetype=obj %s -o - | llvm-dwarfdump - | 
FileCheck %s --check-prefixes=CHECK,BOTH
 
 ; CHECK: .debug_info contents:
 ; CHECK: DW_TAG_variable
@@ -10,7 +10,7 @@
 ; CHECK-NEXT: [{{.*}}): DW_OP_implicit_value 0x8 0x1f 0x85 
0xeb 0x51 0xb8 0x1e 0x09 0x40)
 ; CHECK-NEXT:  DW_AT_name("d")
 
-; RUN: llc -debugger-tune=sce -filetype=obj %s -o -  | llvm-dwarfdump - | 
FileCheck %s -check-prefix=SCE-CHECK
+; RUN: llc -O0 -debugger-tune=sce -filetype=obj %s -o -  | llvm-dwarfdump - | 
FileCheck %s -check-prefixes=SCE-CHECK,BOTH
 
 ; SCE-CHECK: .debug_info contents:
 ; SCE-CHECK: DW_TAG_variable
@@ -18,13 +18,11 @@
 ; SCE-CHECK-NEXT: [{{.*}}): DW_OP_constu 
0x40091eb851eb851f, DW_OP_stack_value)
 ; SCE-CHECK-NEXT:  DW_AT_name("d")
 
-;; Generated from: clang -ggdb -O1
-;;int main() {
-;;double d = 3.14;
-;;printf("dummy\n");
-;;d *= d;
-;;return 0;
-;;}
+;; Using DW_OP_implicit_value for fragments is not currently supported.
+; BOTH: DW_TAG_variable
+; BOTH-NEXT:  DW_AT_location({{.*}}
+; BOTH-NEXT: [{{.*}}): DW_

[llvm-branch-commits] [llvm] 9a6de74 - [MachineLICM] Add llvm debug messages to SinkIntoLoop. NFC.

2020-12-22 Thread Sjoerd Meijer via llvm-branch-commits

Author: Sjoerd Meijer
Date: 2020-12-22T09:19:43Z
New Revision: 9a6de74d5a9e11a7865ce4873ff3297b7efbb673

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

LOG: [MachineLICM] Add llvm debug messages to SinkIntoLoop. NFC.

I am investigating sinking instructions back into the loop under high
register pressure. This is just a first NFC step to add some debug
messages that allows tracing of the decision making.

Added: 


Modified: 
llvm/lib/CodeGen/MachineLICM.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/MachineLICM.cpp 
b/llvm/lib/CodeGen/MachineLICM.cpp
index bc7bb66a82fb6..7c356cf0e15b0 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -800,8 +800,13 @@ void MachineLICMBase::SinkIntoLoop() {
I != Preheader->instr_end(); ++I) {
 // We need to ensure that we can safely move this instruction into the 
loop.
 // As such, it must not have side-effects, e.g. such as a call has.
-if (IsLoopInvariantInst(*I) && !HasLoopPHIUse(&*I))
+LLVM_DEBUG(dbgs() << "LICM: Analysing sink candidate: " << *I);
+if (IsLoopInvariantInst(*I) && !HasLoopPHIUse(&*I)) {
+  LLVM_DEBUG(dbgs() << "LICM: Added as sink candidate.\n");
   Candidates.push_back(&*I);
+  continue;
+}
+LLVM_DEBUG(dbgs() << "LICM: Not added as sink candidate.\n");
   }
 
   for (MachineInstr *I : Candidates) {
@@ -811,8 +816,11 @@ void MachineLICMBase::SinkIntoLoop() {
 if (!MRI->hasOneDef(MO.getReg()))
   continue;
 bool CanSink = true;
-MachineBasicBlock *B = nullptr;
+MachineBasicBlock *SinkBlock = nullptr;
+LLVM_DEBUG(dbgs() << "LICM: Try sinking: " << *I);
+
 for (MachineInstr &MI : MRI->use_instructions(MO.getReg())) {
+  LLVM_DEBUG(dbgs() << "LICM:Analysing use: "; MI.dump());
   // FIXME: Come up with a proper cost model that estimates whether sinking
   // the instruction (and thus possibly executing it on every loop
   // iteration) is more expensive than a register.
@@ -821,24 +829,40 @@ void MachineLICMBase::SinkIntoLoop() {
 CanSink = false;
 break;
   }
-  if (!B) {
-B = MI.getParent();
+  if (!SinkBlock) {
+SinkBlock = MI.getParent();
+LLVM_DEBUG(dbgs() << "LICM:   Setting sink block to: "
+  << printMBBReference(*SinkBlock) << "\n");
 continue;
   }
-  B = DT->findNearestCommonDominator(B, MI.getParent());
-  if (!B) {
+  SinkBlock = DT->findNearestCommonDominator(SinkBlock, MI.getParent());
+  if (!SinkBlock) {
+LLVM_DEBUG(dbgs() << "LICM:   Can't find nearest dominator\n");
 CanSink = false;
 break;
   }
+  LLVM_DEBUG(dbgs() << "LICM:   Setting nearest common dom block: " <<
+ printMBBReference(*SinkBlock) << "\n");
+}
+if (!CanSink) {
+  LLVM_DEBUG(dbgs() << "LICM: Can't sink instruction.\n");
+  continue;
 }
-if (!CanSink || !B || B == Preheader)
+if (!SinkBlock) {
+  LLVM_DEBUG(dbgs() << "LICM: Not sinking, can't find sink block.\n");
   continue;
+}
+if (SinkBlock == Preheader) {
+  LLVM_DEBUG(dbgs() << "LICM: Not sinking, sink block is the preheader\n");
+  continue;
+}
 
-LLVM_DEBUG(dbgs() << "Sinking to " << printMBBReference(*B) << " from "
-  << printMBBReference(*I->getParent()) << ": " << *I);
-B->splice(B->getFirstNonPHI(), Preheader, I);
+LLVM_DEBUG(dbgs() << "LICM: Sinking to " << printMBBReference(*SinkBlock)
+  << " from " << printMBBReference(*I->getParent())
+  << ": " << *I);
+SinkBlock->splice(SinkBlock->getFirstNonPHI(), Preheader, I);
 
-// The instruction is is moved from its basic block, so do not retain the
+// The instruction is moved from its basic block, so do not retain the
 // debug information.
 assert(!I->isDebugInstr() && "Should not sink debug inst");
 I->setDebugLoc(DebugLoc());
@@ -1028,6 +1052,7 @@ bool MachineLICMBase::IsLICMCandidate(MachineInstr &I) {
   bool DontMoveAcrossStore = true;
   if ((!I.isSafeToMove(AA, DontMoveAcrossStore)) &&
   !(HoistConstStores && isInvariantStore(I, TRI, MRI))) {
+LLVM_DEBUG(dbgs() << "LICM: Instruction not safe to move.\n");
 return false;
   }
 
@@ -1038,8 +1063,10 @@ bool MachineLICMBase::IsLICMCandidate(MachineInstr &I) {
   // indexed load from a jump table.
   // Stores and side effects are already checked by isSafeToMove.
   if (I.mayLoad() && !mayLoadFromGOTOrConstantPool(I) &&
-  !IsGuaranteedToExecute(I.getParent()))
+  !IsGuaranteedToExecute(I.getParent())) {
+LLVM_DEBUG(dbgs() << "LICM: Load not guaranteed to execute.\n");
 return false;
+  }
 
   // Convergent attribute

[llvm-branch-commits] [llvm] c0c0ae1 - [VPlan] Make VPInstruction a VPDef

2020-12-22 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-22T09:53:47Z
New Revision: c0c0ae16c3312578cd15fd9913aac3ce528b7602

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

LOG: [VPlan] Make VPInstruction a VPDef

This patch turns updates VPInstruction to manage the value it defines
using VPDef. The VPValue is used  during VPlan construction and
codegeneration instead of the plain IR reference where possible.

Reviewed By: gilr

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanValue.h

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 680106bcb7c6..0b9e660c987a 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8433,11 +8433,10 @@ VPlanPtr 
LoopVectorizationPlanner::buildVPlanWithVPRecipes(
 
   if (auto Recipe =
   RecipeBuilder.tryToCreateWidenRecipe(Instr, Range, Plan)) {
-// Check if the recipe can be converted to a VPValue. We need the extra
-// down-casting step until VPRecipeBase inherits from VPValue.
-VPValue *MaybeVPValue = Recipe->toVPValue();
-if (!Instr->getType()->isVoidTy() && MaybeVPValue)
-  Plan->addVPValue(Instr, MaybeVPValue);
+for (auto *Def : Recipe->definedValues()) {
+  auto *UV = Def->getUnderlyingValue();
+  Plan->addVPValue(UV, Def);
+}
 
 RecipeBuilder.setRecipe(Instr, Recipe);
 VPBB->appendRecipe(Recipe);
@@ -8613,10 +8612,11 @@ void 
LoopVectorizationPlanner::adjustRecipesForInLoopReductions(
  : nullptr;
   VPReductionRecipe *RedRecipe = new VPReductionRecipe(
   &RdxDesc, R, ChainOp, VecOp, CondOp, Legal->hasFunNoNaNAttr(), TTI);
-  WidenRecipe->toVPValue()->replaceAllUsesWith(RedRecipe);
+  WidenRecipe->getVPValue()->replaceAllUsesWith(RedRecipe);
   Plan->removeVPValueFor(R);
   Plan->addVPValue(R, RedRecipe);
   WidenRecipe->getParent()->insert(RedRecipe, WidenRecipe->getIterator());
+  WidenRecipe->getVPValue()->replaceAllUsesWith(RedRecipe);
   WidenRecipe->eraseFromParent();
 
   if (Kind == RecurrenceDescriptor::RK_IntegerMinMax ||
@@ -8625,7 +8625,7 @@ void 
LoopVectorizationPlanner::adjustRecipesForInLoopReductions(
 RecipeBuilder.getRecipe(cast(R->getOperand(0)));
 assert(isa(CompareRecipe) &&
"Expected to replace a VPWidenSC");
-assert(CompareRecipe->toVPValue()->getNumUsers() == 0 &&
+assert(cast(CompareRecipe)->getNumUsers() == 0 &&
"Expected no remaining users");
 CompareRecipe->eraseFromParent();
   }
@@ -8862,7 +8862,7 @@ void VPPredInstPHIRecipe::execute(VPTransformState 
&State) {
 void VPWidenMemoryInstructionRecipe::execute(VPTransformState &State) {
   VPValue *StoredValue = isStore() ? getStoredValue() : nullptr;
   State.ILV->vectorizeMemoryInstruction(&Ingredient, State,
-StoredValue ? nullptr : toVPValue(),
+StoredValue ? nullptr : getVPValue(),
 getAddr(), StoredValue, getMask());
 }
 

diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 601c406290b2..f5ce1a3ccafb 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -119,22 +119,6 @@ VPUser *VPRecipeBase::toVPUser() {
   return nullptr;
 }
 
-VPValue *VPRecipeBase::toVPValue() {
-  if (getNumDefinedValues() == 1)
-return getVPValue();
-  if (auto *V = dyn_cast(this))
-return V;
-  return nullptr;
-}
-
-const VPValue *VPRecipeBase::toVPValue() const {
-  if (getNumDefinedValues() == 1)
-return getVPValue();
-  if (auto *V = dyn_cast(this))
-return V;
-  return nullptr;
-}
-
 // Get the top-most entry block of \p Start. This is the entry block of the
 // containing VPlan. This function is templated to support both const and 
non-const blocks
 template  static T *getPlanEntry(T *Start) {
@@ -352,12 +336,8 @@ void VPBasicBlock::execute(VPTransformState *State) {
 
 void VPBasicBlock::dropAllReferences(VPValue *NewValue) {
   for (VPRecipeBase &R : Recipes) {
-if (VPValue *Def = R.toVPValue())
+for (auto *Def : R.definedValues())
   Def->replaceAllUsesWith(NewValue);
-else if (auto *IR = dyn_cast(&R)) {
-  for (auto *Def : IR->definedValues())
-Def->replaceAllUsesWith(NewValue);
-}
 
 if (auto *User = R.toVPUser())
   for (unsigned 

[llvm-branch-commits] [llvm] 6fcb039 - Fold comparison of __builtin_object_size expression with -1 for non-const size

2020-12-22 Thread via llvm-branch-commits

Author: Siddhesh Poyarekar
Date: 2020-12-22T10:56:31+01:00
New Revision: 6fcb039956483988fa4b82a9a3944084353d00a5

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

LOG: Fold comparison of __builtin_object_size expression with -1 for non-const 
size

When __builtin_dynamic_object_size returns a non-constant expression, it cannot
be -1 since that is an invalid return value for object size. However since
passes running after the substitution don't know this, they are unable to
optimize away the comparison and hence the comparison and branch stays in there.
This change generates an appropriate call to llvm.assume to help the optimizer
folding the test.

glibc is considering adopting __builtin_dynamic_object_size for additional
protection[1] and this change will help reduce branching overhead in fortified
implementations of all of the functions that don't have the __builtin___*_chk
type builtins, e.g. __ppoll_chk.

Also remove the test limit-max-iterations.ll because it was deemed unnecessary
during review.

[1] https://sourceware.org/pipermail/libc-alpha/2020-November/120191.html

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

Added: 


Modified: 
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll

Removed: 
llvm/test/Transforms/InstCombine/limit-max-iterations.ll



diff  --git a/llvm/lib/Analysis/MemoryBuiltins.cpp 
b/llvm/lib/Analysis/MemoryBuiltins.cpp
index cbb54e8efdc0..5d82d9dd6ea0 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -566,8 +566,16 @@ Value *llvm::lowerObjectSizeCall(IntrinsicInst *ObjectSize,
   Value *UseZero =
   Builder.CreateICmpULT(SizeOffsetPair.first, SizeOffsetPair.second);
   ResultSize = Builder.CreateZExtOrTrunc(ResultSize, ResultType);
-  return Builder.CreateSelect(UseZero, ConstantInt::get(ResultType, 0),
-  ResultSize);
+  Value *Ret = Builder.CreateSelect(
+  UseZero, ConstantInt::get(ResultType, 0), ResultSize);
+
+  // The non-constant size expression cannot evaluate to -1.
+  if (!isa(SizeOffsetPair.first) ||
+  !isa(SizeOffsetPair.second))
+Builder.CreateAssumption(
+Builder.CreateICmpNE(Ret, ConstantInt::get(ResultType, -1)));
+
+  return Ret;
 }
   }
 

diff  --git a/llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll 
b/llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll
index 4093a121060c..91c9d3c2827f 100644
--- a/llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll
+++ b/llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll
@@ -14,7 +14,7 @@ entry:
 
 ; CHECK:  define i64 @weird_identity_but_ok(i64 %sz)
 ; CHECK-NEXT: entry:
-; CHECK-NEXT:   ret i64 %sz
+; CHECK:   ret i64 %sz
 ; CHECK-NEXT: }
 
 define i64 @phis_are_neat(i1 %which) {
@@ -101,6 +101,57 @@ for.end:  ; preds 
= %for.body, %entry
 ; CHECK:   define void @f()
 ; CHECK: call i64 @llvm.objectsize.i64.p0i8(
 
+define void @bdos_cmpm1(i64 %alloc) {
+entry:
+  %obj = call i8* @malloc(i64 %alloc)
+  %objsize = call i64 @llvm.objectsize.i64.p0i8(i8* %obj, i1 0, i1 0, i1 1)
+  %cmp.not = icmp eq i64 %objsize, -1
+  br i1 %cmp.not, label %if.else, label %if.then
+
+if.then:
+  call void @fortified_chk(i8* %obj, i64 %objsize)
+  br label %if.end
+
+if.else:
+  call void @unfortified(i8* %obj, i64 %objsize)
+  br label %if.end
+
+if.end:   ; preds = %if.else, %if.then
+  ret void
+}
+
+; CHECK:  define void @bdos_cmpm1(
+; CHECK:[[TMP:%.*]] = icmp ne i64 %alloc, -1
+; CHECK-NEXT:call void @llvm.assume(i1 [[TMP]])
+; CHECK-NEXT:br i1 false, label %if.else, label %if.then
+; CHECK:call void @fortified_chk(i8* %obj, i64 %alloc)
+
+define void @bdos_cmpm1_expr(i64 %alloc, i64 %part) {
+entry:
+  %sz = udiv i64 %alloc, %part
+  %obj = call i8* @malloc(i64 %sz)
+  %objsize = call i64 @llvm.objectsize.i64.p0i8(i8* %obj, i1 0, i1 0, i1 1)
+  %cmp.not = icmp eq i64 %objsize, -1
+  br i1 %cmp.not, label %if.else, label %if.then
+
+if.then:
+  call void @fortified_chk(i8* %obj, i64 %objsize)
+  br label %if.end
+
+if.else:
+  call void @unfortified(i8* %obj, i64 %objsize)
+  br label %if.end
+
+if.end:   ; preds = %if.else, %if.then
+  ret void
+}
+
+; CHECK:  define void @bdos_cmpm1_expr(
+; CHECK:[[TMP:%.*]] = icmp ne i64 [[SZ:%.*]], -1
+; CHECK-NEXT:call void @llvm.assume(i1 [[TMP]])
+; CHECK-NEXT:br i1 false, label %if.else, label %if.then
+; CHECK:call void @fortified_chk(i8* %obj, i64 [[SZ]])
+
 declare void @bury(i32) local_unnamed_addr #2
 
 ; Function Attrs: nounwind all

[llvm-branch-commits] [clang] 4d59c8f - -fstack-clash-protection: Return an actual error when used on unsupported OS

2020-12-22 Thread Sylvestre Ledru via llvm-branch-commits

Author: Sylvestre Ledru
Date: 2020-12-22T12:06:08+01:00
New Revision: 4d59c8fdb955ea0d668b854f467e12bce05a8857

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

LOG: -fstack-clash-protection: Return an actual error when used on unsupported 
OS

$ clang-12: error: -fstack-clash-protection is not supported on Windows or Mac 
OS X

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Clang.cpp
llvm/test/CodeGen/X86/stack-clash-large.ll

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index e92a4bf1dac5..736950b0abb1 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -273,6 +273,8 @@ def err_drv_unsupported_embed_bitcode
 : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
+  "-fstack-clash-protection is not supported on %0">;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 300ab6e815e2..c04b350dae7d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3067,12 +3067,15 @@ static void RenderSSPOptions(const Driver &D, const 
ToolChain &TC,
   }
 }
 
-static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
+ const ArgList &Args, ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (EffectiveTriple.isOSWindows()) {
+D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain)
+<< EffectiveTriple.getOSName();
 return;
+  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
   !EffectiveTriple.isPPC64())
@@ -5550,7 +5553,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(TC, Args, CmdArgs);
+  RenderSCPOptions(D, TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign

diff  --git a/llvm/test/CodeGen/X86/stack-clash-large.ll 
b/llvm/test/CodeGen/X86/stack-clash-large.ll
index dd53cd8f6964..7deae310f617 100644
--- a/llvm/test/CodeGen/X86/stack-clash-large.ll
+++ b/llvm/test/CodeGen/X86/stack-clash-large.ll
@@ -1,5 +1,7 @@
 ; RUN: llc -mtriple=x86_64-linux-android < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s 
 ; RUN: llc -mtriple=i686-linux-android < %s | FileCheck 
-check-prefix=CHECK-X86-32 %s 
+; RUN: llc -mtriple=x86_64-unknown-freebsd < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s
 
 define i32 @foo() local_unnamed_addr #0 {
 



___
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] 781a816 - [llvm][Arm/AArch64] Format extension flags in CPU test failures

2020-12-22 Thread David Spickett via llvm-branch-commits

Author: David Spickett
Date: 2020-12-22T11:13:36Z
New Revision: 781a816d4cacbd0e73d36b12f82c87c0393b5a5b

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

LOG: [llvm][Arm/AArch64] Format extension flags in CPU test failures

Previously you just two hex numbers you had to decode manually.
This change adds a predicate formatter for extension flags
to produce failure messages like:
```
[ RUN  ] AArch64CPUTests/AArch64CPUTestFixture.testAArch64CPU/2
<...>llvm/unittests/Support/TargetParserTest.cpp:862:
Failure
Expected extension flags: +fp-armv8, +crc, +crypto (0xe)
 Got extension flags: +fp-armv8, +neon, +crc, +crypto (0x1e)
[  FAILED  ] AArch64CPUTests/AArch64CPUTestFixture.testAArch64CPU/2,
where GetParam() = "cortex-a34", "armv8-a", <...>
```

>From there you can take the feature name and map it back
to the enum in ARM/AArch64TargetParser.def.
(which isn't perfect but you've probably got both files
open if you're editing these tests)

Note that AEK_NONE is not meant to be user facing in the compiler
but here it is part of the tests. So failures may show an
extension "none" where the normal target parser wouldn't.

The formatter is implemented as a template on ARM::ISAKind
because the predicate formatters assume all parameters are used
for comparison.
(e.g. PRED_FORMAT3 is for comparing 3 values, not having 3
arguments in general)

Reviewed By: MarkMurrayARM

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

Added: 


Modified: 
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/llvm/unittests/Support/TargetParserTest.cpp 
b/llvm/unittests/Support/TargetParserTest.cpp
index 5208f6a75b02..bc2fd6243aa5 100644
--- a/llvm/unittests/Support/TargetParserTest.cpp
+++ b/llvm/unittests/Support/TargetParserTest.cpp
@@ -8,7 +8,9 @@
 
 #include "llvm/Support/TargetParser.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/ARMBuildAttributes.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "gtest/gtest.h"
 #include 
 
@@ -31,6 +33,47 @@ const char *ARMArch[] = {
 "armv8m.main", "iwmmxt",   "iwmmxt2", "xscale",   
"armv8.1-m.main",
 };
 
+template 
+std::string FormatExtensionFlags(uint64_t Flags) {
+  std::vector Features;
+
+  if (ISAKind == ARM::ISAKind::AARCH64) {
+// AEK_NONE is not meant to be shown to the user so the target parser
+// does not recognise it. It is relevant here though.
+if (Flags & AArch64::AEK_NONE)
+  Features.push_back("none");
+AArch64::getExtensionFeatures(Flags, Features);
+  } else {
+if (Flags & ARM::AEK_NONE)
+  Features.push_back("none");
+ARM::getExtensionFeatures(Flags, Features);
+  }
+
+  // The target parser also includes every extension you don't have.
+  // E.g. if AEK_CRC is not set then it adds "-crc". Not useful here.
+  Features.erase(std::remove_if(Features.begin(), Features.end(),
+[](StringRef extension) {
+  return extension.startswith("-");
+}),
+ Features.end());
+
+  return llvm::join(Features, ", ");
+}
+
+template 
+testing::AssertionResult
+AssertSameExtensionFlags(const char *m_expr, const char *n_expr,
+ uint64_t ExpectedFlags, uint64_t GotFlags) {
+  if (ExpectedFlags == GotFlags)
+return testing::AssertionSuccess();
+
+  return testing::AssertionFailure() << llvm::formatv(
+ "Expected extension flags: {0} ({1:x})\n"
+ " Got extension flags: {2} ({3:x})\n",
+ FormatExtensionFlags(ExpectedFlags), ExpectedFlags,
+ FormatExtensionFlags(GotFlags), GotFlags);
+}
+
 struct ARMCPUTestParams {
   ARMCPUTestParams(StringRef CPUName, StringRef ExpectedArch,
StringRef ExpectedFPU, uint64_t ExpectedFlags,
@@ -65,7 +108,8 @@ TEST_P(ARMCPUTestFixture, ARMCPUTests) {
   EXPECT_EQ(params.ExpectedFPU, ARM::getFPUName(FPUKind));
 
   uint64_t default_extensions = ARM::getDefaultExtensions(params.CPUName, AK);
-  EXPECT_EQ(params.ExpectedFlags, default_extensions);
+  EXPECT_PRED_FORMAT2(AssertSameExtensionFlags,
+  params.ExpectedFlags, default_extensions);
 
   EXPECT_EQ(params.CPUAttr, ARM::getCPUAttr(AK));
 }
@@ -816,7 +860,8 @@ TEST_P(AArch64CPUTestFixture, testAArch64CPU) {
 
   uint64_t default_extensions =
   AArch64::getDefaultExtensions(params.CPUName, AK);
-  EXPECT_EQ(params.ExpectedFlags, default_extensions);
+  EXPECT_PRED_FORMAT2(AssertSameExtensionFlags,
+  params.ExpectedFlags, default_extensions);
 
   unsigned FPUKind = AArch64::getDefaultFPU(params.CPUName, AK);
   EXPECT_EQ(params.ExpectedFPU, ARM::getFPUName(FPUKind));



_

[llvm-branch-commits] [clang-tools-extra] 4b3633c - [clangd] Reuse buffer for JSONTransport::sendMessage

2020-12-22 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-22T11:30:56Z
New Revision: 4b3633cf2cb67220763494427f6db250bbd87494

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

LOG: [clangd] Reuse buffer for JSONTransport::sendMessage

Allocate a Buffer in the JSONTransport to be used when sending messages to the 
client.
This gets reused each time a message is sent, reducing in fewer malloc, which 
is always a bonus.

Reviewed By: sammccall

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/JSONTransport.cpp 
b/clang-tools-extra/clangd/JSONTransport.cpp
index eb5a83882b2b..662e5df4e27b 100644
--- a/clang-tools-extra/clangd/JSONTransport.cpp
+++ b/clang-tools-extra/clangd/JSONTransport.cpp
@@ -126,13 +126,13 @@ class JSONTransport : public Transport {
   bool handleMessage(llvm::json::Value Message, MessageHandler &Handler);
   // Writes outgoing message to Out stream.
   void sendMessage(llvm::json::Value Message) {
-std::string S;
-llvm::raw_string_ostream OS(S);
+OutputBuffer.clear();
+llvm::raw_svector_ostream OS(OutputBuffer);
 OS << llvm::formatv(Pretty ? "{0:2}" : "{0}", Message);
-OS.flush();
-Out << "Content-Length: " << S.size() << "\r\n\r\n" << S;
+Out << "Content-Length: " << OutputBuffer.size() << "\r\n\r\n"
+<< OutputBuffer;
 Out.flush();
-vlog(">>> {0}\n", S);
+vlog(">>> {0}\n", OutputBuffer);
   }
 
   // Read raw string messages from input stream.
@@ -143,6 +143,7 @@ class JSONTransport : public Transport {
   llvm::Optional readDelimitedMessage();
   llvm::Optional readStandardMessage();
 
+  llvm::SmallVector OutputBuffer;
   std::FILE *In;
   llvm::raw_ostream &Out;
   llvm::raw_ostream &InMirror;



___
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] 853770f - [gn build] (manually) port b8c37153d5393

2020-12-22 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-22T06:35:40-05:00
New Revision: 853770f24130cabc763995bd72419a29670ee3ca

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

LOG: [gn build] (manually) port b8c37153d5393

Added: 


Modified: 
llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
index 908dce6a12e5..c07a61fe61e4 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
@@ -11,13 +11,15 @@ config("features_config") {
 write_cmake_config("features") {
   input = "Features.inc.in"
   output = "$target_gen_dir/Features.inc"
-  values = []
+  values = [
+"CLANGD_ENABLE_REMOTE=0",
+"CLANGD_MALLOC_TRIM=1",
+  ]
   if (clangd_build_xpc) {
 values += [ "CLANGD_BUILD_XPC=1" ]
   } else {
 values += [ "CLANGD_BUILD_XPC=0" ]
   }
-  values += [ "CLANGD_ENABLE_REMOTE=0" ]
   public_configs = [ ":features_config" ]
 }
 



___
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] [compiler-rt] ba1202a - [PowerPC] Restore stack ptr from base ptr when available

2020-12-22 Thread Nemanja Ivanovic via llvm-branch-commits

Author: Nemanja Ivanovic
Date: 2020-12-22T05:44:03-06:00
New Revision: ba1202a1e4f75d8f234d01730ac65a913e9baa01

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

LOG: [PowerPC] Restore stack ptr from base ptr when available

On subtargets that have a red zone, we will copy the stack pointer to the base
pointer in the prologue prior to updating the stack pointer. There are no other
updates to the base pointer after that. This suggests that we should be able to
restore the stack pointer from the base pointer rather than loading it from the
back chain or adding the frame size back to either the stack pointer or the
frame pointer.
This came about because functions that call setjmp need to restore the SP from
the FP because the back chain might have been clobbered
(see https://reviews.llvm.org/D92906). However, if the stack is realigned, the
restored SP might be incorrect (which is what caused the failures in the two
ASan test cases).

This patch was tested quite extensivelly both with sanitizer runtimes and
general code.

Differential revision: https://reviews.llvm.org/D93327

Added: 


Modified: 
compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
compiler-rt/test/asan/TestCases/longjmp.cpp
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
llvm/test/CodeGen/PowerPC/aix-base-pointer.ll
llvm/test/CodeGen/PowerPC/pr46759.ll
llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll
llvm/test/CodeGen/PowerPC/stack-realign.ll

Removed: 




diff  --git 
a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp 
b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
index 9da47facac27..4774993cdf32 100644
--- a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
@@ -1,4 +1,3 @@
-// UNSUPPORTED: powerpc64
 // Tests that __asan_handle_no_return properly unpoisons the signal alternate
 // stack.
 

diff  --git a/compiler-rt/test/asan/TestCases/longjmp.cpp 
b/compiler-rt/test/asan/TestCases/longjmp.cpp
index bc4165ffd813..8e9f2ae195c7 100644
--- a/compiler-rt/test/asan/TestCases/longjmp.cpp
+++ b/compiler-rt/test/asan/TestCases/longjmp.cpp
@@ -1,4 +1,3 @@
-// UNSUPPORTED: powerpc64
 // RUN: %clangxx_asan -O %s -o %t && %run %t
 
 #include 

diff  --git a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
index b93322c15534..50ce11b8374f 100644
--- a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
@@ -1644,11 +1644,18 @@ void PPCFrameLowering::emitEpilogue(MachineFunction &MF,
 // offset by the STDU/STDUX/STWU/STWUX instruction. For targets with red
 // zone add this offset back now.
 
+// If the function has a base pointer, the stack pointer has been copied
+// to it so we can restore it by copying in the other direction.
+if (HasRedZone && HasBP) {
+  BuildMI(MBB, MBBI, dl, OrInst, RBReg).
+addReg(BPReg).
+addReg(BPReg);
+}
 // If this function contained a fastcc call and GuaranteedTailCallOpt is
 // enabled (=> hasFastCall()==true) the fastcc call might contain a tail
 // call which invalidates the stack pointer value in SP(0). So we use the
 // value of R31 in this case. Similar situation exists with setjmp.
-if (FI->hasFastCall() || MF.exposesReturnsTwice()) {
+else if (FI->hasFastCall() || MF.exposesReturnsTwice()) {
   assert(HasFP && "Expecting a valid frame pointer.");
   if (!HasRedZone)
 RBReg = FPReg;

diff  --git a/llvm/test/CodeGen/PowerPC/aix-base-pointer.ll 
b/llvm/test/CodeGen/PowerPC/aix-base-pointer.ll
index 2b1cc0c45db4..c6e1107d4738 100644
--- a/llvm/test/CodeGen/PowerPC/aix-base-pointer.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-base-pointer.ll
@@ -27,7 +27,7 @@ declare void @callee(i32*)
 ; 32BIT: stwux 1, 1, 0
 ; 32BIT: addi 3, 1, 64
 ; 32BIT: bl .callee
-; 32BIT: lwz 1, 0(1)
+; 32BIT: mr 1, 30
 ; 32BIT: lwz 30, -16(1)
 
 ; 64BIT-LABEL: .caller:
@@ -38,5 +38,5 @@ declare void @callee(i32*)
 ; 64BIT: stdux 1, 1, 0
 ; 64BIT: addi 3, 1, 128
 ; 64BIT: bl .callee
-; 64BIT: ld 1, 0(1)
+; 64BIT: mr 1, 30
 ; 64BIT: ld 30, -24(1)

diff  --git a/llvm/test/CodeGen/PowerPC/pr46759.ll 
b/llvm/test/CodeGen/PowerPC/pr46759.ll
index 716e050cdbee..33b44b720b6e 100644
--- a/llvm/test/CodeGen/PowerPC/pr46759.ll
+++ b/llvm/test/CodeGen/PowerPC/pr46759.ll
@@ -61,7 +61,7 @@ define void @foo(i32 %vla_size) #0 {
 ; CHECK-LE-NEXT:  .LBB0_6: # %entry
 ; CHECK-LE-NEXT:addi r3, r1, 2048
 ; CHECK-LE-NEXT:lbz r3, 0(r3)
-; CHECK-LE-NEXT:ld r1, 0(r1)
+; CHECK-LE-NEXT:mr r1, r30
 ; CHECK-

[llvm-branch-commits] [llvm] 00065d5 - Revert "-fstack-clash-protection: Return an actual error when used on unsupported OS"

2020-12-22 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-22T06:51:19-05:00
New Revision: 00065d5cbd02b0f3fccb34881b58bcd0852b3970

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

LOG: Revert "-fstack-clash-protection: Return an actual error when used on 
unsupported OS"

This reverts commit 4d59c8fdb955ea0d668b854f467e12bce05a8857.
Breaks tens of thousands of tests, and had pending review comments, see
comments on https://reviews.llvm.org/D92245 (and e.g.
http://lab.llvm.org:8011/#/builders/109/builds/5236 for failures).

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Clang.cpp
llvm/test/CodeGen/X86/stack-clash-large.ll

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 736950b0abb1..e92a4bf1dac5 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -273,8 +273,6 @@ def err_drv_unsupported_embed_bitcode
 : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
-def err_drv_stack_clash_protection_unsupported_on_toolchain : Error<
-  "-fstack-clash-protection is not supported on %0">;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c04b350dae7d..300ab6e815e2 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3067,15 +3067,12 @@ static void RenderSSPOptions(const Driver &D, const 
ToolChain &TC,
   }
 }
 
-static void RenderSCPOptions(const Driver &D, const ToolChain &TC,
- const ArgList &Args, ArgStringList &CmdArgs) {
+static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
+ ArgStringList &CmdArgs) {
   const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple();
 
-  if (EffectiveTriple.isOSWindows()) {
-D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain)
-<< EffectiveTriple.getOSName();
+  if (!EffectiveTriple.isOSLinux())
 return;
-  }
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
   !EffectiveTriple.isPPC64())
@@ -5553,7 +5550,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
-  RenderSCPOptions(D, TC, Args, CmdArgs);
+  RenderSCPOptions(TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
   // Translate -mstackrealign

diff  --git a/llvm/test/CodeGen/X86/stack-clash-large.ll 
b/llvm/test/CodeGen/X86/stack-clash-large.ll
index 7deae310f617..dd53cd8f6964 100644
--- a/llvm/test/CodeGen/X86/stack-clash-large.ll
+++ b/llvm/test/CodeGen/X86/stack-clash-large.ll
@@ -1,7 +1,5 @@
 ; RUN: llc -mtriple=x86_64-linux-android < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s 
 ; RUN: llc -mtriple=i686-linux-android < %s | FileCheck 
-check-prefix=CHECK-X86-32 %s 
-; RUN: llc -mtriple=x86_64-unknown-freebsd < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s | FileCheck 
-check-prefix=CHECK-X86-64 %s
 
 define i32 @foo() local_unnamed_addr #0 {
 



___
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] [libcxx] 0f81598 - [libc++] Add a 'is-lockfree-runtime-function' lit feature

2020-12-22 Thread Alex Richardson via llvm-branch-commits

Author: Alex Richardson
Date: 2020-12-22T11:56:20Z
New Revision: 0f81598cc1f46b9919b3500d7c4743dd7a5eac1a

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

LOG: [libc++] Add a 'is-lockfree-runtime-function' lit feature

On macOS 10.14 /usr/lib/system/libcompiler_rt.dylib contains all the
`__atomic_load*`, etc. functions but does not include the 
`__atomic_is_lock_free`
function. The lack of this function causes the non-lockfree-atomics feature
to be set to false even though large atomic operations are actually
supported, it's just the is_lock_free() function that is missing.

This is required so that the !non-lockfree-atomics feature can be used
to XFAIL tests that require runtime library support (D88818).

Reviewed By: #libc, ldionne

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

Added: 


Modified: 
libcxx/test/libcxx/atomics/atomics.align/align.pass.pass.cpp
libcxx/utils/libcxx/test/features.py

Removed: 




diff  --git a/libcxx/test/libcxx/atomics/atomics.align/align.pass.pass.cpp 
b/libcxx/test/libcxx/atomics/atomics.align/align.pass.pass.cpp
index ebe8fc82775c..96a34e22069c 100644
--- a/libcxx/test/libcxx/atomics/atomics.align/align.pass.pass.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.align/align.pass.pass.cpp
@@ -7,7 +7,7 @@
 
//===--===//
 //
 // UNSUPPORTED: libcpp-has-no-threads, c++03
-// REQUIRES: non-lockfree-atomics
+// REQUIRES: is-lockfree-runtime-function
 
 // GCC currently fails because it needs -fabi-version=6 to fix mangling of
 // std::atomic when used with __attribute__((vector(X))).

diff  --git a/libcxx/utils/libcxx/test/features.py 
b/libcxx/utils/libcxx/test/features.py
index 3023caeea5d3..a435a938fdcd 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -55,7 +55,16 @@
 #include 
 struct Large { int storage[100]; };
 std::atomic x;
-int main(int, char**) { return x.load(), x.is_lock_free(); }
+int main(int, char**) { (void)x.load(); return 0; }
+  """)),
+  # TODO: Remove this feature once compiler-rt includes __atomic_is_lockfree()
+  # on all supported platforms.
+  Feature(name='is-lockfree-runtime-function',
+  when=lambda cfg: sourceBuilds(cfg, """
+#include 
+struct Large { int storage[100]; };
+std::atomic x;
+int main(int, char**) { return x.is_lock_free(); }
   """)),
 
   Feature(name='apple-clang',  
when=_isAppleClang),



___
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] [compiler-rt] 6277bd7 - [compiler-rt] Fix atomic_test.c on macOS

2020-12-22 Thread Alex Richardson via llvm-branch-commits

Author: Alex Richardson
Date: 2020-12-22T11:56:20Z
New Revision: 6277bd75dc71ab6cf856ae9a778cab2c90840ca6

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

LOG: [compiler-rt] Fix atomic_test.c on macOS

The macOS name mangling adds another underscore. Therefore, on macOS
the __atomic_* functions are actually ___atomic_* in libcompiler_rt.dylib.
To handle this case, prepend the asm() argument with __USER_LABEL_PREFIX__
in the same way that atomic.c does.

Reviewed By: ldionne

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

Added: 


Modified: 
compiler-rt/test/builtins/Unit/atomic_test.c

Removed: 




diff  --git a/compiler-rt/test/builtins/Unit/atomic_test.c 
b/compiler-rt/test/builtins/Unit/atomic_test.c
index 955c08769e08..7c00841e2c0b 100644
--- a/compiler-rt/test/builtins/Unit/atomic_test.c
+++ b/compiler-rt/test/builtins/Unit/atomic_test.c
@@ -24,9 +24,13 @@
 // should avoid confounding factors, ensuring that we actually test the
 // functions themselves, regardless of how the builtins are lowered. We need to
 // use asm labels because we can't redeclare the builtins.
+// Note: we need to prepend an underscore to this name for e.g. macOS.
+#define _STRINGIFY(x) #x
+#define STRINGIFY(x) _STRINGIFY(x)
+#define EXTERNAL_NAME(name) asm(STRINGIFY(__USER_LABEL_PREFIX__) #name)
 
-void __atomic_load_c(int size, const void *src, void *dest,
- int model) asm("__atomic_load");
+void __atomic_load_c(int size, void *src, void *dest,
+ int model) EXTERNAL_NAME(__atomic_load);
 
 uint8_t __atomic_load_1(uint8_t *src, int model);
 uint16_t __atomic_load_2(uint16_t *src, int model);
@@ -34,7 +38,7 @@ uint32_t __atomic_load_4(uint32_t *src, int model);
 uint64_t __atomic_load_8(uint64_t *src, int model);
 
 void __atomic_store_c(int size, void *dest, const void *src,
-  int model) asm("__atomic_store");
+  int model) EXTERNAL_NAME(__atomic_store);
 
 void __atomic_store_1(uint8_t *dest, uint8_t val, int model);
 void __atomic_store_2(uint16_t *dest, uint16_t val, int model);
@@ -42,7 +46,7 @@ void __atomic_store_4(uint32_t *dest, uint32_t val, int 
model);
 void __atomic_store_8(uint64_t *dest, uint64_t val, int model);
 
 void __atomic_exchange_c(int size, void *ptr, const void *val, void *old,
- int model) asm("__atomic_exchange");
+ int model) EXTERNAL_NAME(__atomic_exchange);
 
 uint8_t __atomic_exchange_1(uint8_t *dest, uint8_t val, int model);
 uint16_t __atomic_exchange_2(uint16_t *dest, uint16_t val, int model);
@@ -51,7 +55,7 @@ uint64_t __atomic_exchange_8(uint64_t *dest, uint64_t val, 
int model);
 
 int __atomic_compare_exchange_c(int size, void *ptr, void *expected,
 const void *desired, int success, int failure)
-asm("__atomic_compare_exchange");
+EXTERNAL_NAME(__atomic_compare_exchange);
 
 bool __atomic_compare_exchange_1(uint8_t *ptr, uint8_t *expected,
  uint8_t desired, int success, int failure);



___
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] 3b879fc - [ASTMatchers] Traverse-ignore range-for implementation details

2020-12-22 Thread Stephen Kelly via llvm-branch-commits

Author: Stephen Kelly
Date: 2020-12-22T12:09:32Z
New Revision: 3b879fc97305849026db0e856920d318fadbc04b

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

LOG: [ASTMatchers] Traverse-ignore range-for implementation details

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

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 61e524793ec7..1426e569eabe 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -468,6 +468,8 @@ template  class RecursiveASTVisitor {
   DEF_TRAVERSE_TMPL_INST(Function)
 #undef DEF_TRAVERSE_TMPL_INST
 
+  bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
+
 private:
   // These are helper methods used by more than one Traverse* method.
   bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
@@ -497,7 +499,6 @@ template  class RecursiveASTVisitor {
   bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
   bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
 
-  bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
   bool PostVisitStmt(Stmt *S);
 };
 

diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index cc9537144524..762885fa0052 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -463,6 +463,22 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
   bool TraverseConstructorInitializer(CXXCtorInitializer *CtorInit);
   bool TraverseTemplateArgumentLoc(TemplateArgumentLoc TAL);
 
+  bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue) {
+if (auto *RF = dyn_cast(S)) {
+  for (auto *SubStmt : RF->children()) {
+if (SubStmt == RF->getInit() || SubStmt == RF->getLoopVarStmt() ||
+SubStmt == RF->getRangeInit() || SubStmt == RF->getBody()) {
+  TraverseStmt(SubStmt, Queue);
+} else {
+  ASTNodeNotSpelledInSourceScope RAII(this, true);
+  TraverseStmt(SubStmt, Queue);
+}
+  }
+  return true;
+}
+return RecursiveASTVisitor::dataTraverseNode(S, Queue);
+  }
+
   // Matches children or descendants of 'Node' with 'BaseMatcher'.
   bool memoizedMatchesRecursively(const DynTypedNode &Node, ASTContext &Ctx,
   const DynTypedMatcher &Matcher,

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index 10d2d6ec3916..a3a3a911b85c 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2580,6 +2580,31 @@ struct CtorInitsNonTrivial : NonTrivial
 EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
 EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
   }
+  {
+auto M = binaryOperator(hasOperatorName("!="));
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = unaryOperator(hasOperatorName("++"));
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = declStmt(hasSingleDecl(varDecl(matchesName("__range";
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = declStmt(hasSingleDecl(varDecl(matchesName("__begin";
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = declStmt(hasSingleDecl(varDecl(matchesName("__end";
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
 
   Code = R"cpp(
   void rangeFor()



___
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] b9b62c2 - [AArch64] Add a test for MachineLICM SinkIntoLoop. NFC.

2020-12-22 Thread Sjoerd Meijer via llvm-branch-commits

Author: Sjoerd Meijer
Date: 2020-12-22T12:22:24Z
New Revision: b9b62c28677d2c812604e29bab27c1e2a2144e4b

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

LOG: [AArch64] Add a test for MachineLICM SinkIntoLoop. NFC.

Added: 
llvm/test/CodeGen/AArch64/machine-licm-sink-instr.ll

Modified: 


Removed: 




diff  --git a/llvm/test/CodeGen/AArch64/machine-licm-sink-instr.ll 
b/llvm/test/CodeGen/AArch64/machine-licm-sink-instr.ll
new file mode 100644
index ..f8d53a574dd2
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/machine-licm-sink-instr.ll
@@ -0,0 +1,176 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=aarch64 -sink-insts-to-avoid-spills | FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+
+@A = external dso_local global [100 x i32], align 4
+
+define i32 @sink_load_and_copy(i32 %n) {
+; CHECK-LABEL: sink_load_and_copy:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:stp x30, x21, [sp, #-32]! // 16-byte Folded Spill
+; CHECK-NEXT:stp x20, x19, [sp, #16] // 16-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 32
+; CHECK-NEXT:.cfi_offset w19, -8
+; CHECK-NEXT:.cfi_offset w20, -16
+; CHECK-NEXT:.cfi_offset w21, -24
+; CHECK-NEXT:.cfi_offset w30, -32
+; CHECK-NEXT:mov w19, w0
+; CHECK-NEXT:cmp w0, #1 // =1
+; CHECK-NEXT:b.lt .LBB0_3
+; CHECK-NEXT:  // %bb.1: // %for.body.preheader
+; CHECK-NEXT:adrp x8, A
+; CHECK-NEXT:ldr w21, [x8, :lo12:A]
+; CHECK-NEXT:mov w20, w19
+; CHECK-NEXT:  .LBB0_2: // %for.body
+; CHECK-NEXT:// =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:mov w0, w21
+; CHECK-NEXT:bl _Z3usei
+; CHECK-NEXT:subs w19, w19, #1 // =1
+; CHECK-NEXT:sdiv w20, w20, w0
+; CHECK-NEXT:b.ne .LBB0_2
+; CHECK-NEXT:b .LBB0_4
+; CHECK-NEXT:  .LBB0_3:
+; CHECK-NEXT:mov w20, w19
+; CHECK-NEXT:  .LBB0_4: // %for.cond.cleanup
+; CHECK-NEXT:mov w0, w20
+; CHECK-NEXT:ldp x20, x19, [sp, #16] // 16-byte Folded Reload
+; CHECK-NEXT:ldp x30, x21, [sp], #32 // 16-byte Folded Reload
+; CHECK-NEXT:ret
+entry:
+  %cmp63 = icmp sgt i32 %n, 0
+  br i1 %cmp63, label %for.body.preheader, label %for.cond.cleanup
+
+for.body.preheader:
+  %0 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, 
i64 0, i64 0), align 4
+  br label %for.body
+
+for.cond.cleanup:
+  %sum.0.lcssa = phi i32 [ %n, %entry ], [ %div, %for.body ]
+  ret i32 %sum.0.lcssa
+
+for.body:
+  %lsr.iv = phi i32 [ %n, %for.body.preheader ], [ %lsr.iv.next, %for.body ]
+  %sum.065 = phi i32 [ %div, %for.body ], [ %n, %for.body.preheader ]
+  %call = tail call i32 @_Z3usei(i32 %0)
+  %div = sdiv i32 %sum.065, %call
+  %lsr.iv.next = add i32 %lsr.iv, -1
+  %exitcond.not = icmp eq i32 %lsr.iv.next, 0
+  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
+}
+
+define i32 @cant_sink_successive_call(i32 %n) {
+; CHECK-LABEL: cant_sink_successive_call:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:stp x30, x21, [sp, #-32]! // 16-byte Folded Spill
+; CHECK-NEXT:stp x20, x19, [sp, #16] // 16-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 32
+; CHECK-NEXT:.cfi_offset w19, -8
+; CHECK-NEXT:.cfi_offset w20, -16
+; CHECK-NEXT:.cfi_offset w21, -24
+; CHECK-NEXT:.cfi_offset w30, -32
+; CHECK-NEXT:mov w19, w0
+; CHECK-NEXT:cmp w0, #1 // =1
+; CHECK-NEXT:b.lt .LBB1_3
+; CHECK-NEXT:  // %bb.1: // %for.body.preheader
+; CHECK-NEXT:adrp x8, A
+; CHECK-NEXT:ldr w20, [x8, :lo12:A]
+; CHECK-NEXT:mov w0, w19
+; CHECK-NEXT:bl _Z3usei
+; CHECK-NEXT:mov w21, w19
+; CHECK-NEXT:  .LBB1_2: // %for.body
+; CHECK-NEXT:// =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:mov w0, w20
+; CHECK-NEXT:bl _Z3usei
+; CHECK-NEXT:subs w19, w19, #1 // =1
+; CHECK-NEXT:sdiv w21, w21, w0
+; CHECK-NEXT:b.ne .LBB1_2
+; CHECK-NEXT:b .LBB1_4
+; CHECK-NEXT:  .LBB1_3:
+; CHECK-NEXT:mov w21, w19
+; CHECK-NEXT:  .LBB1_4: // %for.cond.cleanup
+; CHECK-NEXT:ldp x20, x19, [sp, #16] // 16-byte Folded Reload
+; CHECK-NEXT:mov w0, w21
+; CHECK-NEXT:ldp x30, x21, [sp], #32 // 16-byte Folded Reload
+; CHECK-NEXT:ret
+entry:
+  %cmp63 = icmp sgt i32 %n, 0
+  br i1 %cmp63, label %for.body.preheader, label %for.cond.cleanup
+
+for.body.preheader:
+  %0 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, 
i64 0, i64 0), align 4
+  %call0 = tail call i32 @_Z3usei(i32 %n)
+  br label %for.body
+
+for.cond.cleanup:
+  %sum.0.lcssa = phi i32 [ %n, %entry ], [ %div, %for.body ]
+  ret i32 %sum.0.lcssa
+
+for.body:
+  %lsr.iv = phi i32 [ %n, %for.body.preheader ], [ %lsr.iv.next, %for.body ]
+  %sum.065 = phi i32 [ %div, %for.body ], [ %n,

[llvm-branch-commits] [clang] c4fc8a2 - [clang-format] NFC keep the code clang-formatted

2020-12-22 Thread via llvm-branch-commits

Author: mydeveloperday
Date: 2020-12-22T12:46:14Z
New Revision: c4fc8a21d1dbfd2e269a59533808913b46faa8ce

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

LOG: [clang-format] NFC keep the code clang-formatted

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
old mode 100644
new mode 100755
index 821b46b75f6b..733ca1e0e852
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1964,9 +1964,9 @@ class AnnotatingParser {
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
-   tok::kw_co_return, tok::kw_co_await, 
tok::kw_co_yield,
-   tok::equal, tok::kw_delete, tok::kw_sizeof,
-   tok::kw_throw) ||
+   tok::kw_co_return, tok::kw_co_await,
+   tok::kw_co_yield, tok::equal, tok::kw_delete,
+   tok::kw_sizeof, tok::kw_throw) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
TT_UnaryOperator, TT_CastRParen))
   return TT_UnaryOperator;



___
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] [flang] 44e74c7 - [flang][driver] Refactor unit tests for frontend actions (nfc)

2020-12-22 Thread Andrzej Warzynski via llvm-branch-commits

Author: Andrzej Warzynski
Date: 2020-12-22T13:06:56Z
New Revision: 44e74c75e614af453f4824cb9bf1f0056d7cf426

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

LOG: [flang][driver] Refactor unit tests for frontend actions (nfc)

These patch implements a few non-functional-changes:
  * switch to using test fixtures for better code sharing
  * rename some variables (e.g. to communicate their purpose a bit better)
This patch doesn't change _what_ is being tested.

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

Added: 


Modified: 
flang/unittests/Frontend/FrontendActionTest.cpp

Removed: 




diff  --git a/flang/unittests/Frontend/FrontendActionTest.cpp 
b/flang/unittests/Frontend/FrontendActionTest.cpp
index b49b7312525a..fb4de6d307cd 100644
--- a/flang/unittests/Frontend/FrontendActionTest.cpp
+++ b/flang/unittests/Frontend/FrontendActionTest.cpp
@@ -8,6 +8,7 @@
 
 #include "gtest/gtest.h"
 #include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/CompilerInvocation.h"
 #include "flang/Frontend/FrontendOptions.h"
 #include "flang/FrontendTool/Utils.h"
 #include "llvm/Support/FileSystem.h"
@@ -17,119 +18,120 @@ using namespace Fortran::frontend;
 
 namespace {
 
-TEST(FrontendAction, PrintPreprocessedInput) {
-  std::string inputFile = "pp-test-file.f";
-  std::error_code ec;
+class FrontendActionTest : public ::testing::Test {
+protected:
+  // AllSources (which is used to manage files inside every compiler
+  // instance), works with paths. So we need a filename and a path for the
+  // input file.
+  // TODO: We could use `-` for inputFilePath_, but then we'd need a way to
+  // write to stdin that's then read by AllSources. Ideally, AllSources should
+  // be capable of reading from any stream.
+  std::string inputFileName_;
+  std::string inputFilePath_;
+  // The output stream for the input file. Use this to populate the input.
+  std::unique_ptr inputFileOs_;
+
+  std::error_code ec_;
+
+  CompilerInstance compInst_;
+  std::shared_ptr invocation_;
+
+  void SetUp() override {
+// Generate a unique test file name.
+const testing::TestInfo *const test_info =
+testing::UnitTest::GetInstance()->current_test_info();
+inputFileName_ = std::string(test_info->name()) + "_test-file.f";
+
+// Create the input file stream. Note that this stream is populated
+// separately in every test (i.e. the input is test specific).
+inputFileOs_ = std::make_unique(
+inputFileName_, ec_, llvm::sys::fs::OF_None);
+if (ec_)
+  FAIL() << "Failed to create the input file";
+
+// Get the path of the input file.
+llvm::SmallString<256> cwd;
+if (std::error_code ec_ = llvm::sys::fs::current_path(cwd))
+  FAIL() << "Failed to obtain the current working directory";
+inputFilePath_ = cwd.c_str();
+inputFilePath_ += "/" + inputFileName_;
+
+// Prepare the compiler (CompilerInvocation + CompilerInstance)
+compInst_.CreateDiagnostics();
+invocation_ = std::make_shared();
+
+compInst_.set_invocation(std::move(invocation_));
+compInst_.frontendOpts().inputs_.push_back(
+FrontendInputFile(inputFilePath_, Language::Fortran));
+  }
+
+  void TearDown() override {
+// Clear the input file.
+llvm::sys::fs::remove(inputFileName_);
+
+// Clear the output files.
+// Note that these tests use an output buffer (as opposed to an output
+// file), hence there are no physical output files to delete and
+// `EraseFiles` is set to `false`. Also, some actions (e.g.
+// `ParseSyntaxOnly`) don't generated output. In such cases there's no
+// output to clear and `ClearOutputFile` returns immediately.
+compInst_.ClearOutputFiles(/*EraseFiles=*/false);
+  }
+};
+
+TEST_F(FrontendActionTest, PrintPreprocessedInput) {
+  // Populate the input file with the pre-defined input and flush it.
+  *(inputFileOs_) << "#ifdef NEW\n"
+  << "  Program A \n"
+  << "#else\n"
+  << "  Program B\n"
+  << "#endif";
+  inputFileOs_.reset();
 
-  // 1. Create the input file for the file manager
-  // AllSources (which is used to manage files inside every compiler instance),
-  // works with paths. This means that it requires a physical file. Create one.
-  std::unique_ptr os{
-  new llvm::raw_fd_ostream(inputFile, ec, llvm::sys::fs::OF_None)};
-  if (ec)
-FAIL() << "Fail to create the file need by the test";
+  // Set-up the action kind.
+  compInst_.invocation().frontendOpts().programAction_ = 
PrintPreprocessedInput;
 
-  // Populate the input file with the pre-defined input and flush it.
-  *(os) << "! test-file.F:\n"
-<< "#ifdef NEW\n"
-<< "  Program A \n"
-<< "#else\n"
-<< "  Program B\n"
-

[llvm-branch-commits] [clang] 63a2481 - [clang][cli] Implement `getAllArgValues` marshalling

2020-12-22 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-22T14:11:16+01:00
New Revision: 63a24816f561a5d8e28ca7054892bd8602618be4

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

LOG: [clang][cli] Implement `getAllArgValues` marshalling

This infrastructure can be used ~30 more command line options.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 82c4e9399d9d..3373984b76ae 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1915,7 +1915,8 @@ def fsystem_module : Flag<["-"], "fsystem-module">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag<"FrontendOpts.IsSystemModule">;
 def fmodule_map_file : Joined<["-"], "fmodule-map-file=">,
   Group, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
-  HelpText<"Load this module map file">;
+  HelpText<"Load this module map file">,
+  MarshallingInfoStringVector<"FrontendOpts.ModuleMapFiles">;
 def fmodule_file : Joined<["-"], "fmodule-file=">,
   Group, Flags<[NoXarchOption,CC1Option]>, 
MetaVarName<"[=]">,
   HelpText<"Specify the mapping of module name to precompiled module file, or 
load a module file if name is omitted.">;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index fc5fd1547599..d7c1a6ffd600 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -323,6 +323,23 @@ static Optional 
normalizeStringIntegral(OptSpecifier Opt, int,
   return Res;
 }
 
+static Optional>
+normalizeStringVector(OptSpecifier Opt, int, const ArgList &Args,
+  DiagnosticsEngine &) {
+  return Args.getAllArgValues(Opt);
+}
+
+static void denormalizeStringVector(SmallVectorImpl &Args,
+const char *Spelling,
+CompilerInvocation::StringAllocator SA,
+Option::OptionClass OptClass,
+unsigned TableIndex,
+const std::vector &Values) {
+  for (const std::string &Value : Values) {
+denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
+  }
+}
+
 static Optional normalizeTriple(OptSpecifier Opt, int TableIndex,
  const ArgList &Args,
  DiagnosticsEngine &Diags) {
@@ -1715,7 +1732,6 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
   Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
   Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
   Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
-  Opts.ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
   // Only the -fmodule-file= form.
   for (const auto *A : Args.filtered(OPT_fmodule_file)) {
 StringRef Val = A->getValue();

diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 71e8d0907fc8..5738f7079171 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -18,6 +18,7 @@ using namespace llvm;
 using namespace clang;
 
 using ::testing::Contains;
+using ::testing::HasSubstr;
 using ::testing::StrEq;
 
 namespace {
@@ -408,6 +409,45 @@ TEST_F(CommandLineTest, JoinedEnumDefault) {
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("legacy";
 }
 
+TEST_F(CommandLineTest, StringVectorEmpty) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles.empty());
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file=";
+}
+
+TEST_F(CommandLineTest, StringVectorSingle) {
+  const char *Args[] = {"-fmodule-map-file=a"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getFrontendOpts().ModuleMapFiles,
+std::vector({"a"}));
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
+}
+
+TEST_F(CommandLineTest, StringVectorMultiple) {
+  const char *Args[] = {"-fmodule-map-file=a", "-fmodule-map-file=b"};
+
+  CompilerInvocation::CreateFromArgs(I

[llvm-branch-commits] [flang] 31b67d2 - [flang][driver] Fix formatting in a test (nfc)

2020-12-22 Thread Andrzej Warzynski via llvm-branch-commits

Author: Andrzej Warzynski
Date: 2020-12-22T13:38:13Z
New Revision: 31b67d2debd43b9854248b853a52ea989c7322a0

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

LOG: [flang][driver] Fix formatting in a test (nfc)

Added: 


Modified: 
flang/test/Frontend/print-preprocessed-file.f90

Removed: 




diff  --git a/flang/test/Frontend/print-preprocessed-file.f90 
b/flang/test/Frontend/print-preprocessed-file.f90
index 2ba4a4f957c6..873bb2b3e370 100644
--- a/flang/test/Frontend/print-preprocessed-file.f90
+++ b/flang/test/Frontend/print-preprocessed-file.f90
@@ -8,15 +8,13 @@
 ! RUN: %flang-new -E %s  2>&1 | FileCheck %s
 
 !-
-!   FRONTEND FLANG DRIVER (flang-new -fc1)
+! FRONTEND FLANG DRIVER (flang-new -fc1)
 !-
 ! RUN: %flang-new -fc1 -E %s  2>&1 | FileCheck %s
 
-
 !---
 ! EXPECTED OUTPUT
 !---
-! flang-new -E  %s
 ! CHECK:program a
 ! CHECK-NOT:program b
 ! CHECK-NEXT:x = 1



___
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] bef9eb8 - [clang] NFC: Refactor custom class into a lambda in CompilerInvocation

2020-12-22 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2020-12-22T14:45:29+01:00
New Revision: bef9eb84b2fb17b22ca771c8c5c34a85f141168d

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

LOG: [clang] NFC: Refactor custom class into a lambda in CompilerInvocation

Change `makeFlagToValueNormalizer` so that one specialization converts all 
integral/enum arguments into `uint64_t` and forwards them to the more generic 
version.

This makes it easy to replace the custom `FlagToValueNormalizer` struct with a 
lambda, which is the common approach in other (de)normalizers.

Finally, drop custom `is_int_convertbile` in favor of 
`llvm::is_integral_or_enum`.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d7c1a6ffd600..44453ad462c4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -157,33 +157,26 @@ static void denormalizeSimpleFlag(SmallVectorImpl &Args,
   Args.push_back(Spelling);
 }
 
-namespace {
-template  struct FlagToValueNormalizer {
-  T Value;
+template  static constexpr bool is_uint64_t_convertible() {
+  return !std::is_same::value &&
+ llvm::is_integral_or_enum::value;
+}
 
-  Optional operator()(OptSpecifier Opt, unsigned, const ArgList &Args,
- DiagnosticsEngine &) {
+template (), bool> = false>
+static auto makeFlagToValueNormalizer(T Value) {
+  return [Value](OptSpecifier Opt, unsigned, const ArgList &Args,
+ DiagnosticsEngine &) -> Optional {
 if (Args.hasArg(Opt))
   return Value;
 return None;
-  }
-};
-} // namespace
-
-template  static constexpr bool is_int_convertible() {
-  return sizeof(T) <= sizeof(uint64_t) &&
- std::is_trivially_constructible::value &&
- std::is_trivially_constructible::value;
-}
-
-template (), bool> = false>
-static FlagToValueNormalizer makeFlagToValueNormalizer(T Value) {
-  return FlagToValueNormalizer{Value};
+  };
 }
 
-template (), bool> = false>
-static FlagToValueNormalizer makeFlagToValueNormalizer(T Value) {
-  return FlagToValueNormalizer{std::move(Value)};
+template (), bool> = false>
+static auto makeFlagToValueNormalizer(T Value) {
+  return makeFlagToValueNormalizer(uint64_t(Value));
 }
 
 static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,



___
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] 5b37f0d - [MCInstrDesc] [TableGen] Reduce size of MCOperandInfo instances.

2020-12-22 Thread Paul C. Anagnostopoulos via llvm-branch-commits

Author: Paul C. Anagnostopoulos
Date: 2020-12-22T09:44:30-05:00
New Revision: 5b37f0d97087c39ef635b3f7574ace9aa173d417

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

LOG: [MCInstrDesc] [TableGen] Reduce size of MCOperandInfo instances.

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

Added: 


Modified: 
llvm/include/llvm/MC/MCInstrDesc.h
llvm/utils/TableGen/InstrInfoEmitter.cpp

Removed: 




diff  --git a/llvm/include/llvm/MC/MCInstrDesc.h 
b/llvm/include/llvm/MC/MCInstrDesc.h
index 17454e3134a2..cbb061fc6456 100644
--- a/llvm/include/llvm/MC/MCInstrDesc.h
+++ b/llvm/include/llvm/MC/MCInstrDesc.h
@@ -27,12 +27,22 @@ class MCInst;
 
//===--===//
 
 namespace MCOI {
-// Operand constraints
+/// Operand constraints. These are encoded in 16 bits with one of the
+/// low-order 3 bits specifying that a constraint is present and the
+/// corresponding high-order hex digit specifying the constraint value.
+/// This allows for a maximum of 3 constraints.
 enum OperandConstraint {
-  TIED_TO = 0,  // Must be allocated the same register as.
-  EARLY_CLOBBER // Operand is an early clobber register operand
+  TIED_TO = 0,  // Must be allocated the same register as specified value.
+  EARLY_CLOBBER // If present, operand is an early clobber register.
 };
 
+// Define a macro to produce each constraint value.
+#define MCOI_TIED_TO(op) \
+  ((1 << MCOI::TIED_TO) | ((op) << (4 + MCOI::TIED_TO * 4)))
+
+#define MCOI_EARLY_CLOBBER \
+  (1 << MCOI::EARLY_CLOBBER)
+
 /// These are flags set on operands, but should be considered
 /// private, all access should go through the MCOperandInfo accessors.
 /// See the accessors for a description of what these are.
@@ -84,10 +94,9 @@ class MCOperandInfo {
 
   /// Information about the type of the operand.
   uint8_t OperandType;
-  /// The lower 16 bits are used to specify which constraints are set.
-  /// The higher 16 bits are used to specify the value of constraints (4 bits
-  /// each).
-  uint32_t Constraints;
+
+  /// Operand constraints (see OperandConstraint enum).
+  uint16_t Constraints;
 
   /// Set if this operand is a pointer value and it requires a callback
   /// to look up its register class.
@@ -197,14 +206,14 @@ class MCInstrDesc {
   const MCPhysReg *ImplicitDefs; // Registers implicitly defined by this instr
   const MCOperandInfo *OpInfo;   // 'NumOperands' entries about operands
 
-  /// Returns the value of the specific constraint if
-  /// it is set. Returns -1 if it is not set.
+  /// Returns the value of the specified operand constraint if
+  /// it is present. Returns -1 if it is not present.
   int getOperandConstraint(unsigned OpNum,
MCOI::OperandConstraint Constraint) const {
 if (OpNum < NumOperands &&
 (OpInfo[OpNum].Constraints & (1 << Constraint))) {
-  unsigned Pos = 16 + Constraint * 4;
-  return (int)(OpInfo[OpNum].Constraints >> Pos) & 0xf;
+  unsigned ValuePos = 4 + Constraint * 4;
+  return (int)(OpInfo[OpNum].Constraints >> ValuePos) & 0x0f;
 }
 return -1;
   }

diff  --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp 
b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index 156fa6d18d2e..71d8eadaa61e 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -182,11 +182,10 @@ InstrInfoEmitter::GetOperandInfo(const CodeGenInstruction 
&Inst) {
   if (Constraint.isNone())
 Res += "0";
   else if (Constraint.isEarlyClobber())
-Res += "(1 << MCOI::EARLY_CLOBBER)";
+Res += "MCOI_EARLY_CLOBBER";
   else {
 assert(Constraint.isTied());
-Res += "((" + utostr(Constraint.getTiedOperand()) +
-" << 16) | (1 << MCOI::TIED_TO))";
+Res += "MCOI_TIED_TO(" + utostr(Constraint.getTiedOperand()) + ")";
   }
 
   Result.push_back(Res);



___
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] ef4dbb2 - [LV] Use ScalarEvolution::getURemExpr to reduce duplication.

2020-12-22 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-22T14:48:42Z
New Revision: ef4dbb2b7a85b47bfd84188bd1c6a9eddc5c536b

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

LOG: [LV] Use ScalarEvolution::getURemExpr to reduce duplication.

ScalarEvolution should be able to handle both constant and variable trip
counts using getURemExpr, so we do not have to handle them separately.

This is a small simplification of a56280094e08.

Reviewed By: gilr

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

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 0b9e660c987a..6ab8e5884a76 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5506,20 +5506,15 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount 
UserVF, unsigned UserIC) {
  "MaxVF must be a power of 2");
   unsigned MaxVFtimesIC =
   UserIC ? MaxVF.getFixedValue() * UserIC : MaxVF.getFixedValue();
-  if (TC > 0 && TC % MaxVFtimesIC == 0) {
-// Accept MaxVF if we do not have a tail.
-LLVM_DEBUG(dbgs() << "LV: No tail will remain for any chosen VF.\n");
-return MaxVF;
-  }
-
   // Avoid tail folding if the trip count is known to be a multiple of any VF 
we
   // chose.
   ScalarEvolution *SE = PSE.getSE();
   const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
   const SCEV *ExitCount = SE->getAddExpr(
   BackedgeTakenCount, SE->getOne(BackedgeTakenCount->getType()));
-  unsigned TCisMultipleOf = 1 << SE->GetMinTrailingZeros(ExitCount);
-  if (TCisMultipleOf % MaxVFtimesIC == 0) {
+  const SCEV *Rem = SE->getURemExpr(
+  ExitCount, SE->getConstant(BackedgeTakenCount->getType(), MaxVFtimesIC));
+  if (Rem->isZero()) {
 // Accept MaxVF if we do not have a tail.
 LLVM_DEBUG(dbgs() << "LV: No tail will remain for any chosen VF.\n");
 return MaxVF;



___
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] 28b00ba - [openacc][openmp][NFC] Fix typo in comments

2020-12-22 Thread via llvm-branch-commits

Author: clementval
Date: 2020-12-22T09:59:50-05:00
New Revision: 28b00ba731160f882f4e60e4a71896d5b878b52d

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

LOG: [openacc][openmp][NFC] Fix typo in comments

Added: 


Modified: 
llvm/utils/TableGen/DirectiveEmitter.cpp

Removed: 




diff  --git a/llvm/utils/TableGen/DirectiveEmitter.cpp 
b/llvm/utils/TableGen/DirectiveEmitter.cpp
index 6dee19389996..9e8aa4d9f74f 100644
--- a/llvm/utils/TableGen/DirectiveEmitter.cpp
+++ b/llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -649,7 +649,7 @@ void GenerateFlangClauseUnparse(const DirectiveLanguage 
&DirLang,
   }
 }
 
-// Generate the implemenation section for the enumeration in the directive
+// Generate the implementation section for the enumeration in the directive
 // language
 void EmitDirectivesFlangImpl(const DirectiveLanguage &DirLang,
  raw_ostream &OS) {
@@ -733,7 +733,7 @@ void GenerateClauseClassMacro(const DirectiveLanguage 
&DirLang,
   OS << "#undef CLAUSE\n";
 }
 
-// Generate the implemenation section for the enumeration in the directive
+// Generate the implementation section for the enumeration in the directive
 // language.
 void EmitDirectivesGen(RecordKeeper &Records, raw_ostream &OS) {
   const auto DirLang = DirectiveLanguage{Records};
@@ -745,7 +745,7 @@ void EmitDirectivesGen(RecordKeeper &Records, raw_ostream 
&OS) {
   GenerateClauseClassMacro(DirLang, OS);
 }
 
-// Generate the implemenation for the enumeration in the directive
+// Generate the implementation for the enumeration in the directive
 // language. This code can be included in library.
 void EmitDirectivesImpl(RecordKeeper &Records, raw_ostream &OS) {
   const auto DirLang = DirectiveLanguage{Records};



___
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] 0586f04 - [RISCV] Basic jump table lowering

2020-12-22 Thread Nandor Licker via llvm-branch-commits

Author: Nandor Licker
Date: 2020-12-22T15:05:54Z
New Revision: 0586f048d794673867f7307898114a111f6e80ba

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

LOG: [RISCV] Basic jump table lowering

This patch enables jump table lowering in the RISC-V backend.

In addition to the test case included, the new lowering was
tested by compiling the OCaml runtime and running it under qemu.

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/MachineInstrBuilder.h
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
llvm/test/CodeGen/RISCV/jumptable.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h 
b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
index b31e9cdb0e90..115c50175604 100644
--- a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -305,6 +305,9 @@ class MachineInstrBuilder {
   case MachineOperand::MO_BlockAddress:
 return addBlockAddress(Disp.getBlockAddress(), Disp.getOffset() + off,
TargetFlags);
+  case MachineOperand::MO_JumpTableIndex:
+assert(off == 0 && "cannot create offset into jump tables");
+return addJumpTableIndex(Disp.getIndex(), TargetFlags);
 }
   }
 

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 5334666baf22..22fe3688a46b 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -323,6 +323,7 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
   setOperationAction(ISD::GlobalAddress, XLenVT, Custom);
   setOperationAction(ISD::BlockAddress, XLenVT, Custom);
   setOperationAction(ISD::ConstantPool, XLenVT, Custom);
+  setOperationAction(ISD::JumpTable, XLenVT, Custom);
 
   setOperationAction(ISD::GlobalTLSAddress, XLenVT, Custom);
 
@@ -367,8 +368,7 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
   setMinFunctionAlignment(FunctionAlignment);
   setPrefFunctionAlignment(FunctionAlignment);
 
-  // Effectively disable jump table generation.
-  setMinimumJumpTableEntries(INT_MAX);
+  setMinimumJumpTableEntries(5);
 
   // Jumps are expensive, compared to logic
   setJumpIsExpensive();
@@ -565,6 +565,8 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
 return lowerBlockAddress(Op, DAG);
   case ISD::ConstantPool:
 return lowerConstantPool(Op, DAG);
+  case ISD::JumpTable:
+return lowerJumpTable(Op, DAG);
   case ISD::GlobalTLSAddress:
 return lowerGlobalTLSAddress(Op, DAG);
   case ISD::SELECT:
@@ -643,6 +645,11 @@ static SDValue getTargetNode(ConstantPoolSDNode *N, SDLoc 
DL, EVT Ty,
N->getOffset(), Flags);
 }
 
+static SDValue getTargetNode(JumpTableSDNode *N, SDLoc DL, EVT Ty,
+ SelectionDAG &DAG, unsigned Flags) {
+  return DAG.getTargetJumpTable(N->getIndex(), Ty, Flags);
+}
+
 template 
 SDValue RISCVTargetLowering::getAddr(NodeTy *N, SelectionDAG &DAG,
  bool IsLocal) const {
@@ -720,6 +727,13 @@ SDValue RISCVTargetLowering::lowerConstantPool(SDValue Op,
   return getAddr(N, DAG);
 }
 
+SDValue RISCVTargetLowering::lowerJumpTable(SDValue Op,
+SelectionDAG &DAG) const {
+  JumpTableSDNode *N = cast(Op);
+
+  return getAddr(N, DAG);
+}
+
 SDValue RISCVTargetLowering::getStaticTLSAddr(GlobalAddressSDNode *N,
   SelectionDAG &DAG,
   bool UseGOT) const {

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h 
b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index 28ce459e3027..dabf2b199a88 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -257,6 +257,7 @@ class RISCVTargetLowering : public TargetLowering {
   SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
+  SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const;
   SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;

diff  --git a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp 
b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
index 4fd060a65014..a93a1e38c656 100644
--- a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
+++ b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -122,6 +122,

[llvm-branch-commits] [mlir] 3e07b0b - [MLIR] Fix lowering of affine operations with return values

2020-12-22 Thread Uday Bondhugula via llvm-branch-commits

Author: Prateek Gupta
Date: 2020-12-22T21:44:31+05:30
New Revision: 3e07b0b9d3363fb767cbbaa2593fa91ac393fb7e

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

LOG: [MLIR] Fix lowering of affine operations with return values

This commit addresses the issue of lowering affine.for and
affine.parallel having return values. Relevant test cases are also
added.

Signed-off-by: Prateek Gupta 

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

Added: 


Modified: 
mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
mlir/test/Conversion/AffineToStandard/lower-affine.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp 
b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
index 58f44b6ed207..8721e6b96ed7 100644
--- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
+++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
@@ -334,7 +334,13 @@ class AffineYieldOpLowering : public 
OpRewritePattern {
 
   LogicalResult matchAndRewrite(AffineYieldOp op,
 PatternRewriter &rewriter) const override {
-rewriter.replaceOpWithNewOp(op);
+if (isa(op.getParentOp())) {
+  // scf.parallel does not yield any values via its terminator scf.yield 
but
+  // models reductions 
diff erently using additional ops in its region.
+  rewriter.replaceOpWithNewOp(op);
+  return success();
+}
+rewriter.replaceOpWithNewOp(op, op.operands());
 return success();
   }
 };
@@ -349,14 +355,55 @@ class AffineForLowering : public 
OpRewritePattern {
 Value lowerBound = lowerAffineLowerBound(op, rewriter);
 Value upperBound = lowerAffineUpperBound(op, rewriter);
 Value step = rewriter.create(loc, op.getStep());
-auto f = rewriter.create(loc, lowerBound, upperBound, step);
-rewriter.eraseBlock(f.getBody());
-rewriter.inlineRegionBefore(op.region(), f.region(), f.region().end());
-rewriter.eraseOp(op);
+auto scfForOp = rewriter.create(loc, lowerBound, upperBound,
+step, op.getIterOperands());
+rewriter.eraseBlock(scfForOp.getBody());
+rewriter.inlineRegionBefore(op.region(), scfForOp.region(),
+scfForOp.region().end());
+rewriter.replaceOp(op, scfForOp.results());
 return success();
   }
 };
 
+/// Returns the identity value associated with an AtomicRMWKind op.
+static Value getIdentityValue(AtomicRMWKind op, OpBuilder &builder,
+  Location loc) {
+  switch (op) {
+  case AtomicRMWKind::addf:
+return builder.create(loc, builder.getF32FloatAttr(0));
+  case AtomicRMWKind::addi:
+return builder.create(loc, builder.getI32IntegerAttr(0));
+  case AtomicRMWKind::mulf:
+return builder.create(loc, builder.getF32FloatAttr(1));
+  case AtomicRMWKind::muli:
+return builder.create(loc, builder.getI32IntegerAttr(1));
+  // TODO: Add remaining reduction operations.
+  default:
+emitOptionalError(loc, "Reduction operation type not supported");
+  }
+  return nullptr;
+}
+
+/// Return the value obtained by applying the reduction operation kind
+/// associated with a binary AtomicRMWKind op to `lhs` and `rhs`.
+static Value getReductionOp(AtomicRMWKind op, OpBuilder &builder, Location loc,
+Value lhs, Value rhs) {
+  switch (op) {
+  case AtomicRMWKind::addf:
+return builder.create(loc, lhs, rhs);
+  case AtomicRMWKind::addi:
+return builder.create(loc, lhs, rhs);
+  case AtomicRMWKind::mulf:
+return builder.create(loc, lhs, rhs);
+  case AtomicRMWKind::muli:
+return builder.create(loc, lhs, rhs);
+  // TODO: Add remaining reduction operations.
+  default:
+emitOptionalError(loc, "Reduction operation type not supported");
+  }
+  return nullptr;
+}
+
 /// Convert an `affine.parallel` (loop nest) operation into a `scf.parallel`
 /// operation.
 class AffineParallelLowering : public OpRewritePattern {
@@ -369,12 +416,13 @@ class AffineParallelLowering : public 
OpRewritePattern {
 SmallVector steps;
 SmallVector upperBoundTuple;
 SmallVector lowerBoundTuple;
+SmallVector identityVals;
 // Finding lower and upper bound by expanding the map expression.
 // Checking if expandAffineMap is not giving NULL.
-Optional> upperBound = expandAffineMap(
-rewriter, loc, op.upperBoundsMap(), op.getUpperBoundsOperands());
 Optional> lowerBound = expandAffineMap(
 rewriter, loc, op.lowerBoundsMap(), op.getLowerBoundsOperands());
+Optional> upperBound = expandAffineMap(
+rewriter, loc, op.upperBoundsMap(), op.getUpperBoundsOperands());
 if (!lowerBound || !upperBound)
   return failure();
 upperBoundTuple = *upperBound;
@@ -38

[llvm-branch-commits] [mlir] 0955d8d - [mlir] Add gpu.memcpy op.

2020-12-22 Thread Christian Sigg via llvm-branch-commits

Author: Christian Sigg
Date: 2020-12-22T17:39:55+01:00
New Revision: 0955d8df06355610bf539c53afd26bb62c500f44

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

LOG: [mlir] Add gpu.memcpy op.

Reviewed By: herhut

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

Added: 


Modified: 
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/test/Dialect/GPU/invalid.mlir
mlir/test/Dialect/GPU/ops.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td 
b/mlir/include/mlir/Dialect/GPU/GPUOps.td
index 953a2d5c282c9..457477f7f3c1a 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -879,4 +879,39 @@ def GPU_DeallocOp : GPU_Op<"dealloc", [
   }];
 }
 
+def GPU_MemcpyOp : GPU_Op<"memcpy", [
+GPU_AsyncOpInterface, MemoryEffects<[MemRead, MemWrite]>
+  ]> {
+
+  let summary = "GPU memcpy operation";
+
+  let description = [{
+The `gpu.memcpy` operation copies the content of one memref to another.
+
+The op does not execute before all async dependencies have finished
+executing.
+
+If the `async` keyword is present, the op is executed asynchronously (i.e.
+it does not block until the execution has finished on the device). In
+that case, it returns a !gpu.async.token.
+
+Example:
+
+```mlir
+%token = gpu.memcpy async [%dep] %dst, %src : memref, 
memref
+```
+  }];
+
+  let arguments = (ins Variadic:$asyncDependencies,
+   Arg:$dst,
+   Arg:$src);
+  let results = (outs Optional:$asyncToken);
+
+  let assemblyFormat = [{
+custom(type($asyncToken), $asyncDependencies)
+$dst`,` $src `:` type($dst)`,` type($src) attr-dict
+  }];
+  let verifier = [{ return ::verify(*this); }];
+}
+
 #endif // GPU_OPS

diff  --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp 
b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index e8a90acf8830f..d3fa2ccb6dcd2 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -22,6 +22,7 @@
 #include "mlir/IR/FunctionImplementation.h"
 #include "mlir/IR/OpImplementation.h"
 #include "mlir/IR/PatternMatch.h"
+#include "mlir/IR/TypeUtilities.h"
 #include "llvm/ADT/TypeSwitch.h"
 
 using namespace mlir;
@@ -842,6 +843,23 @@ static void print(OpAsmPrinter &p, GPUModuleOp op) {
 /*printBlockTerminators=*/false);
 }
 
+//===--===//
+// GPUMemcpyOp
+//===--===//
+
+static LogicalResult verify(MemcpyOp op) {
+  auto srcType = op.src().getType();
+  auto dstType = op.dst().getType();
+
+  if (getElementTypeOrSelf(srcType) != getElementTypeOrSelf(dstType))
+return op.emitOpError("arguments have incompatible element type");
+
+  if (failed(verifyCompatibleShape(srcType, dstType)))
+return op.emitOpError("arguments have incompatible shape");
+
+  return success();
+}
+
 static ParseResult parseAsyncDependencies(
 OpAsmParser &parser, Type &asyncTokenType,
 SmallVectorImpl &asyncDependencies) {

diff  --git a/mlir/test/Dialect/GPU/invalid.mlir 
b/mlir/test/Dialect/GPU/invalid.mlir
index 3dc5be405aac1..1f6058cde3974 100644
--- a/mlir/test/Dialect/GPU/invalid.mlir
+++ b/mlir/test/Dialect/GPU/invalid.mlir
@@ -444,3 +444,17 @@ func @async_wait_without_result() {
   // expected-error @+1 {{custom op 'gpu.wait' needs to be named when marked 
'async'}}
   gpu.wait async
 }
+
+// -
+
+func @memcpy_incompatible_type(%dst : memref, %src : memref) {
+  // expected-error @+1 {{'gpu.memcpy' op arguments have incompatible element 
type}}
+  gpu.memcpy %dst, %src  : memref, memref
+}
+
+// -
+
+func @memcpy_incompatible_shape(%dst : memref<7xf32>, %src : memref<9xf32>) {
+  // expected-error @+1 {{'gpu.memcpy' op arguments have incompatible shape}}
+  gpu.memcpy %dst, %src  : memref<7xf32>, memref<9xf32>
+}

diff  --git a/mlir/test/Dialect/GPU/ops.mlir b/mlir/test/Dialect/GPU/ops.mlir
index aed4368c22a71..5cea772ce5991 100644
--- a/mlir/test/Dialect/GPU/ops.mlir
+++ b/mlir/test/Dialect/GPU/ops.mlir
@@ -183,4 +183,15 @@ module attributes {gpu.container_module} {
 gpu.wait // Valid, but a no-op.
 return
   }
+
+  func @memcpy(%dst : memref<3x7xf32>, %src : memref<3x7xf32, 1>) {
+// CHECK-LABEL: func @memcpy
+// CHECK: gpu.memcpy {{.*}}, {{.*}} : memref<3x7xf32>, memref<3x7xf32, 1>
+gpu.memcpy %dst, %src : memref<3x7xf32>, memref<3x7xf32, 1>
+// CHECK: %[[t0:.*]] = gpu.wait async
+%0 = gpu.wait async
+// CHECK: {{.*}} = gpu.memcpy async [%[[t0]]] {{.*}}, {{.*}} : 
memref<3x7xf32>, memref<3x7xf32, 1>
+%1 = gpu.memcpy async [%0] %dst, %src : memref<3x7xf32>, memref<3x7xf32,

[llvm-branch-commits] [llvm] 8eec729 - [SVE] Lower vector BITREVERSE and BSWAP operations.

2020-12-22 Thread Paul Walker via llvm-branch-commits

Author: Paul Walker
Date: 2020-12-22T16:49:50Z
New Revision: 8eec7294fea87273215592a2dc5bee6afd47d456

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

LOG: [SVE] Lower vector BITREVERSE and BSWAP operations.

These operations are lowered to RBIT and REVB instructions
respectively.  In the case of fixed-length support using SVE we
also lower BITREVERSE operating on NEON sized vectors as this
results in fewer instructions.

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

Added: 
llvm/test/CodeGen/AArch64/sve-fixed-length-rev.ll
llvm/test/CodeGen/AArch64/sve-rev.ll

Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/CodeGen/AArch64/sve-intrinsics-reversal.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index e74bc739ddaf..48fbea840bad 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -182,6 +182,8 @@ static bool isMergePassthruOpcode(unsigned Opc) {
   switch (Opc) {
   default:
 return false;
+  case AArch64ISD::BITREVERSE_MERGE_PASSTHRU:
+  case AArch64ISD::BSWAP_MERGE_PASSTHRU:
   case AArch64ISD::DUP_MERGE_PASSTHRU:
   case AArch64ISD::FNEG_MERGE_PASSTHRU:
   case AArch64ISD::SIGN_EXTEND_INREG_MERGE_PASSTHRU:
@@ -1066,6 +1068,8 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine &TM,
 // splat of 0 or undef) once vector selects supported in SVE codegen. See
 // D68877 for more details.
 for (auto VT : {MVT::nxv16i8, MVT::nxv8i16, MVT::nxv4i32, MVT::nxv2i64}) {
+  setOperationAction(ISD::BITREVERSE, VT, Custom);
+  setOperationAction(ISD::BSWAP, VT, Custom);
   setOperationAction(ISD::INSERT_SUBVECTOR, VT, Custom);
   setOperationAction(ISD::UINT_TO_FP, VT, Custom);
   setOperationAction(ISD::SINT_TO_FP, VT, Custom);
@@ -1183,6 +1187,7 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine &TM,
 setOperationAction(ISD::FP_ROUND, VT, Expand);
 
   // These operations are not supported on NEON but SVE can do them.
+  setOperationAction(ISD::BITREVERSE, MVT::v1i64, Custom);
   setOperationAction(ISD::MUL, MVT::v1i64, Custom);
   setOperationAction(ISD::MUL, MVT::v2i64, Custom);
   setOperationAction(ISD::SDIV, MVT::v8i8, Custom);
@@ -1217,6 +1222,7 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine &TM,
   // Int operations with no NEON support.
   for (auto VT : {MVT::v8i8, MVT::v16i8, MVT::v4i16, MVT::v8i16,
   MVT::v2i32, MVT::v4i32, MVT::v2i64}) {
+setOperationAction(ISD::BITREVERSE, VT, Custom);
 setOperationAction(ISD::VECREDUCE_AND, VT, Custom);
 setOperationAction(ISD::VECREDUCE_OR, VT, Custom);
 setOperationAction(ISD::VECREDUCE_XOR, VT, Custom);
@@ -1330,6 +1336,8 @@ void AArch64TargetLowering::addTypeForFixedLengthSVE(MVT 
VT) {
   setOperationAction(ISD::ADD, VT, Custom);
   setOperationAction(ISD::AND, VT, Custom);
   setOperationAction(ISD::ANY_EXTEND, VT, Custom);
+  setOperationAction(ISD::BITREVERSE, VT, Custom);
+  setOperationAction(ISD::BSWAP, VT, Custom);
   setOperationAction(ISD::FADD, VT, Custom);
   setOperationAction(ISD::FCEIL, VT, Custom);
   setOperationAction(ISD::FDIV, VT, Custom);
@@ -1934,6 +1942,8 @@ const char 
*AArch64TargetLowering::getTargetNodeName(unsigned Opcode) const {
 MAKE_CASE(AArch64ISD::LDP)
 MAKE_CASE(AArch64ISD::STP)
 MAKE_CASE(AArch64ISD::STNP)
+MAKE_CASE(AArch64ISD::BITREVERSE_MERGE_PASSTHRU)
+MAKE_CASE(AArch64ISD::BSWAP_MERGE_PASSTHRU)
 MAKE_CASE(AArch64ISD::DUP_MERGE_PASSTHRU)
 MAKE_CASE(AArch64ISD::INDEX_VECTOR)
 MAKE_CASE(AArch64ISD::UABD)
@@ -3646,7 +3656,13 @@ SDValue 
AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
 return DAG.getNode(AArch64ISD::INSR, dl, Op.getValueType(),
Op.getOperand(1), Scalar);
   }
-
+  case Intrinsic::aarch64_sve_rbit:
+return DAG.getNode(AArch64ISD::BITREVERSE_MERGE_PASSTHRU, dl,
+   Op.getValueType(), Op.getOperand(2), Op.getOperand(3),
+   Op.getOperand(1));
+  case Intrinsic::aarch64_sve_revb:
+return DAG.getNode(AArch64ISD::BSWAP_MERGE_PASSTHRU, dl, Op.getValueType(),
+   Op.getOperand(2), Op.getOperand(3), Op.getOperand(1));
   case Intrinsic::aarch64_sve_sxtb:
 return DAG.getNode(
 AArch64ISD::SIGN_EXTEND_INREG_MERGE_PASSTHRU, dl, Op.getValueType(),
@@ -4357,6 +4373,11 @@ SDValue AArch64TargetLowering::LowerOperation(SDValue Op,
 return Lowe

[llvm-branch-commits] [flang] 9a7895d - [Flang][openmp][5.0] Add task_reduction clause.

2020-12-22 Thread Sameeran joshi via llvm-branch-commits

Author: sameeran joshi
Date: 2020-12-22T22:34:38+05:30
New Revision: 9a7895dc20852b662a66976d06871ec2a0b968c8

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

LOG: [Flang][openmp][5.0] Add task_reduction clause.

See OMP-5.0 2.19.5.5 task_reduction Clause.
To add a positive test case we need `taskgroup` directive which is not added 
hence skipping the test.
This is a dependency for `taskgroup` construct.

Reviewed By: clementval

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

Added: 


Modified: 
flang/include/flang/Parser/parse-tree.h
flang/lib/Parser/openmp-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.cpp
flang/lib/Semantics/check-omp-structure.h
flang/test/Semantics/omp-clause-validity01.f90
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index 7e258b668576..119a92bee211 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3415,7 +3415,7 @@ struct OmpReductionOperator {
 // variable-name-list)
 struct OmpReductionClause {
   TUPLE_CLASS_BOILERPLATE(OmpReductionClause);
-  std::tuple> t;
+  std::tuple t;
 };
 
 // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)

diff  --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 1386b2b16a78..3a0d28cd9c12 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -102,7 +102,7 @@ 
TYPE_PARSER(construct(Parser{}) ||
 construct(Parser{}))
 
 TYPE_PARSER(construct(
-Parser{} / ":", nonemptyList(designator)))
+Parser{} / ":", Parser{}))
 
 // OMP 5.0 2.11.4  ALLOCATE ([allocator:] variable-name-list)
 TYPE_PARSER(construct(
@@ -220,6 +220,9 @@ TYPE_PARSER(
parenthesized(Parser{}))) ||
 "REDUCTION" >>
 construct(parenthesized(Parser{})) ||
+"TASK_REDUCTION" >>
+construct(construct(
+parenthesized(Parser{}))) ||
 "RELAXED" >> construct(construct()) ||
 "RELEASE" >> construct(construct()) ||
 "SAFELEN" >> construct(construct(

diff  --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index fdb694f3d26f..ba54a0a84fa7 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2016,7 +2016,7 @@ class UnparseVisitor {
 Word("REDUCTION(");
 Walk(std::get(x.t));
 Put(":");
-Walk(std::get>(x.t), ",");
+Walk(std::get(x.t));
 Put(")");
   }
   void Unparse(const OmpAllocateClause &x) {

diff  --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index e2c8333ce7ee..a144c7a2b57b 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -419,6 +419,7 @@ CHECK_SIMPLE_CLAUSE(Mergeable, OMPC_mergeable)
 CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
 CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
 CHECK_SIMPLE_CLAUSE(Nowait, OMPC_nowait)
+CHECK_SIMPLE_CLAUSE(TaskReduction, OMPC_task_reduction)
 CHECK_SIMPLE_CLAUSE(To, OMPC_to)
 CHECK_SIMPLE_CLAUSE(Uniform, OMPC_uniform)
 CHECK_SIMPLE_CLAUSE(Untied, OMPC_untied)

diff  --git a/flang/lib/Semantics/check-omp-structure.h 
b/flang/lib/Semantics/check-omp-structure.h
index a966eaf8c4a7..ccd0e08a8c08 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -155,6 +155,7 @@ class OmpStructureChecker
   void Enter(const parser::OmpClause::Safelen &);
   void Enter(const parser::OmpClause::Shared &);
   void Enter(const parser::OmpClause::Simdlen &);
+  void Enter(const parser::OmpClause::TaskReduction &);
   void Enter(const parser::OmpClause::ThreadLimit &);
   void Enter(const parser::OmpClause::To &);
   void Enter(const parser::OmpClause::Link &);

diff  --git a/flang/test/Semantics/omp-clause-validity01.f90 
b/flang/test/Semantics/omp-clause-validity01.f90
index 3f5345137866..1d689ea91699 100644
--- a/flang/test/Semantics/omp-clause-validity01.f90
+++ b/flang/test/Semantics/omp-clause-validity01.f90
@@ -349,7 +349,8 @@
 !  collapse-clause
 
   a = 0.0
-  !$omp simd private(b) reduction(+:a)
+  !ERROR: TASK_REDUCTION clause is not allowed on the SIMD directive
+  !$omp simd private(b) reduction(+:a) task_reduction(+:a)
   do i = 1, N
  a = a + b + 3.14
   enddo
@@ -449,7 +450,8 @@
   enddo
 
   !ERROR: At most one NUM_TASKS clause can appear on the TASKLOOP directive
-  !$omp taskloop num_tasks(3) num_tasks(2)
+  !ERROR: TASK_REDUCTION clause is not allowed on the TASKLOOP directive
+  !$omp taskloop num_tasks(3) num_tasks(2) task_reduction(*

[llvm-branch-commits] [llvm] 8a58f21 - [PowerPC][Power10] Exploit store rightmost vector element instructions

2020-12-22 Thread Albion Fung via llvm-branch-commits

Author: Kamau Bridgeman
Date: 2020-12-22T12:06:43-05:00
New Revision: 8a58f21f5b6c228137a9b87906fe5b720c4d1dfb

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

LOG: [PowerPC][Power10] Exploit store rightmost vector element instructions

Using the store rightmost vector element instructions to do vector
element extraction and store. The rightmost vector element on little
endian is the zeroth vector element, with these patterns that element
can be extracted and stored in one instruction for all vector types.

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

Added: 
llvm/test/CodeGen/PowerPC/store-rightmost-vector-elt.ll

Modified: 
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td 
b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
index 54e9adae40d7..e7fa2affb730 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -2554,16 +2554,21 @@ let Predicates = [IsISA3_1, HasVSX] in {
 (COPY_TO_REGCLASS (XVCVBF16SPN RCCp.AToVSRC), VRRC)>;
 }
 
-let AddedComplexity = 400, Predicates = [IsISA3_1] in {
-  def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$rS, 0)), xoaddr:$src),
-(STXVRBX (COPY_TO_REGCLASS $rS, VSRC), xoaddr:$src)>;
-  def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$rS, 0)), xoaddr:$src),
-(STXVRHX (COPY_TO_REGCLASS $rS, VSRC), xoaddr:$src)>;
-  def : Pat<(store (i32 (vector_extract v4i32:$rS, 0)), xoaddr:$src),
-(STXVRWX (COPY_TO_REGCLASS $rS, VSRC), xoaddr:$src)>;
-  def : Pat<(store (i64 (vector_extract v2i64:$rS, 0)), xoaddr:$src),
-(STXVRDX (COPY_TO_REGCLASS $rS, VSRC), xoaddr:$src)>;
-}
+let AddedComplexity = 400, Predicates = [IsISA3_1, IsLittleEndian] in {
+  // Store element 0 of a VSX register to memory
+  def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$src, 0)), xoaddr:$dst),
+(STXVRBX (COPY_TO_REGCLASS v16i8:$src, VSRC), xoaddr:$dst)>;
+  def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$src, 0)), xoaddr:$dst),
+(STXVRHX (COPY_TO_REGCLASS v8i16:$src, VSRC), xoaddr:$dst)>;
+  def : Pat<(store (i32 (extractelt v4i32:$src, 0)), xoaddr:$dst),
+(STXVRWX (COPY_TO_REGCLASS v4i32:$src, VSRC), xoaddr:$dst)>;
+  def : Pat<(store (f32 (extractelt v4f32:$src, 0)), xoaddr:$dst),
+(STXVRWX (COPY_TO_REGCLASS v4f32:$src, VSRC), xoaddr:$dst)>;
+  def : Pat<(store (i64 (extractelt v2i64:$src, 0)), xoaddr:$dst),
+(STXVRDX (COPY_TO_REGCLASS v2i64:$src, VSRC), xoaddr:$dst)>;
+  def : Pat<(store (f64 (extractelt v2f64:$src, 0)), xoaddr:$dst),
+(STXVRDX (COPY_TO_REGCLASS v2f64:$src, VSRC), xoaddr:$dst)>;
+ }
 
 class xxevalPattern  imm> :
   Pat<(v4i32 pattern), (XXEVAL $vA, $vB, $vC, imm)> {}

diff  --git a/llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
index 17617e90a01f..9e8f8d073a1a 100644
--- a/llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
+++ b/llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -1,13 +1,13 @@
 ; 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
+; RUN:   FileCheck %s --check-prefixes=CHECK,CHECK-LE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
-; RUN:   FileCheck %s
+; RUN:   FileCheck %s --check-prefixes=CHECK,CHECK-BE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O0 \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
-; RUN:   FileCheck %s --check-prefix=CHECK-O0
+; RUN:   FileCheck %s --check-prefixes=CHECK,CHECK-O0
 
 ; These test cases aims to test the builtins for the Power10 VSX vector
 ; instructions introduced in ISA 3.1.
@@ -22,14 +22,6 @@ define signext i32 @test_vec_test_lsbb_all_ones(<16 x i8> 
%vuca) {
 ; CHECK-NEXT:srwi r3, r3, 31
 ; CHECK-NEXT:extsw r3, r3
 ; CHECK-NEXT:blr
-;
-; CHECK-O0-LABEL: test_vec_test_lsbb_all_ones:
-; CHECK-O0:   # %bb.0: # %entry
-; CHECK-O0-NEXT:xvtlsbb cr0, v2
-; CHECK-O0-NEXT:mfocrf r3, 128
-; CHECK-O0-NEXT:srwi r3, r3, 31
-; CHECK-O0-NEXT:extsw r3, r3
-; CHECK-O0-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 1)
   ret i32 %0
@@ -43,24 +35,22 @@ define signext i32 @test_vec_test_lsbb_all_zeros(<16 x i8> 
%vuca) {
 ; CHECK-NEXT:rlwinm r3, r3, 3, 31, 31
 ; CHECK-NEXT:extsw r3, r3
 ; CHECK-NEXT:blr
-;
-; CHECK-O0-LABEL: test_

[llvm-branch-commits] [lldb] 5c1c844 - [lldb] Abstract scoped timer logic behind LLDB_SCOPED_TIMER (NFC)

2020-12-22 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-22T09:10:27-08:00
New Revision: 5c1c8443eb7366e6e5086426b5d8dc7d24afc13b

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

LOG: [lldb] Abstract scoped timer logic behind LLDB_SCOPED_TIMER (NFC)

This patch introduces a LLDB_SCOPED_TIMER macro to hide the needlessly
repetitive creation of scoped timers in LLDB. It's similar to the
LLDB_LOG(F) macro.

Differential revision: https://reviews.llvm.org/D93663

Added: 


Modified: 
lldb/include/lldb/Utility/Timer.h
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Core/Disassembler.cpp
lldb/source/Core/Mangled.cpp
lldb/source/Core/Module.cpp
lldb/source/Initialization/SystemInitializerCommon.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
lldb/source/Symbol/CompileUnit.cpp
lldb/source/Symbol/DWARFCallFrameInfo.cpp
lldb/source/Symbol/LocateSymbolFile.cpp
lldb/source/Symbol/ObjectFile.cpp
lldb/source/Symbol/Symtab.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TargetList.cpp
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Timer.h 
b/lldb/include/lldb/Utility/Timer.h
index f97315b2db0f..91f9c57c03c1 100644
--- a/lldb/include/lldb/Utility/Timer.h
+++ b/lldb/include/lldb/Utility/Timer.h
@@ -73,4 +73,11 @@ class Timer {
 
 } // namespace lldb_private
 
+#define LLDB_SCOPED_TIMER()
\
+  static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
+  ::lldb_private::Timer _scoped_timer(_cat, LLVM_PRETTY_FUNCTION)
+#define LLDB_SCOPED_TIMERF(...)
\
+  static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION);   
\
+  ::lldb_private::Timer _scoped_timer(_cat, __VA_ARGS__)
+
 #endif // LLDB_UTILITY_TIMER_H

diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index a6421d8f10d0..0530f94580b3 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -69,9 +69,6 @@ llvm::Error SystemInitializerFull::Initialize() {
 }
 
 void SystemInitializerFull::Terminate() {
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
-
   Debugger::SettingsTerminate();
 
   // Terminate plug-ins in core LLDB

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index c033493d4196..4bce4e7e0734 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -299,8 +299,7 @@ class CommandObjectTargetCreate : public 
CommandObjectParsed {
   }
 
   const char *file_path = command.GetArgumentAtIndex(0);
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat, "(lldb) target create '%s'", file_path);
+  LLDB_SCOPED_TIMERF("(lldb) target create '%s'", file_path);
   FileSpec file_spec;
 
   if (file_path) {

diff  --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 1015eafd252e..3a975d9296f4 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -58,9 +58,7 @@ using namespace lldb_private;
 DisassemblerSP Disassembler::FindPlugin(const ArchSpec &arch,
 const char *flavor,
 const char *plugin_name) {
-  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-  Timer scoped_timer(func_cat,
- "Disassembler::FindPlugin (arch = %s, plugin_name = %s)",
+  LLDB_SCOPED_TIMERF("Disassembler::FindPlugin (arch = %s, plugin_name = %s)",
  

[llvm-branch-commits] [llvm] be85b3e - Fix some misnamed variables in sve-fixed-length-int-minmax.ll.

2020-12-22 Thread Paul Walker via llvm-branch-commits

Author: Paul Walker
Date: 2020-12-22T17:11:23Z
New Revision: be85b3e4324b5a03abd929815b7fc1c2184db97a

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

LOG: Fix some misnamed variables in sve-fixed-length-int-minmax.ll.

Added: 


Modified: 
llvm/test/CodeGen/AArch64/sve-fixed-length-int-minmax.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AArch64/sve-fixed-length-int-minmax.ll 
b/llvm/test/CodeGen/AArch64/sve-fixed-length-int-minmax.ll
index cc9e172de5f8..e94abe815f3c 100644
--- a/llvm/test/CodeGen/AArch64/sve-fixed-length-int-minmax.ll
+++ b/llvm/test/CodeGen/AArch64/sve-fixed-length-int-minmax.ll
@@ -69,14 +69,14 @@ define void @smax_v64i8(<64 x i8>* %a, <64 x i8>* %b) #0 {
 ; Ensure sensible type legalisation.
 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].b, vl32
 ; VBITS_EQ_256-DAG: mov w[[A:[0-9]+]], #32
-; VBITS_EQ_256-DAG: ld1b { [[OP1_LO:z[0-9]+]].b }, [[PG]]/z, [x0, x[[A]]]
-; VBITS_EQ_256-DAG: ld1b { [[OP1_HI:z[0-9]+]].b }, [[PG]]/z, [x0]
-; VBITS_EQ_256-DAG: ld1b { [[OP2_LO:z[0-9]+]].b }, [[PG]]/z, [x1, x[[A]]]
-; VBITS_EQ_256-DAG: ld1b { [[OP2_HI:z[0-9]+]].b }, [[PG]]/z, [x1]
+; VBITS_EQ_256-DAG: ld1b { [[OP1_LO:z[0-9]+]].b }, [[PG]]/z, [x0]
+; VBITS_EQ_256-DAG: ld1b { [[OP1_HI:z[0-9]+]].b }, [[PG]]/z, [x0, x[[A]]]
+; VBITS_EQ_256-DAG: ld1b { [[OP2_LO:z[0-9]+]].b }, [[PG]]/z, [x1]
+; VBITS_EQ_256-DAG: ld1b { [[OP2_HI:z[0-9]+]].b }, [[PG]]/z, [x1, x[[A]]]
 ; VBITS_EQ_256-DAG: smax [[RES_LO:z[0-9]+]].b, [[PG]]/m, [[OP1_LO]].b, 
[[OP2_LO]].b
 ; VBITS_EQ_256-DAG: smax [[RES_HI:z[0-9]+]].b, [[PG]]/m, [[OP1_HI]].b, 
[[OP2_HI]].b
-; VBITS_EQ_256-DAG: st1b { [[RES_LO]].b }, [[PG]], [x0, x[[A]]]
-; VBITS_EQ_256-DAG: st1b { [[RES_HI]].b }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1b { [[RES_LO]].b }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1b { [[RES_HI]].b }, [[PG]], [x0, x[[A]]]
 ; VBITS_EQ_256-NEXT: ret
   %op1 = load <64 x i8>, <64 x i8>* %a
   %op2 = load <64 x i8>, <64 x i8>* %b
@@ -442,14 +442,14 @@ define void @smin_v64i8(<64 x i8>* %a, <64 x i8>* %b) #0 {
 ; Ensure sensible type legalisation.
 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].b, vl32
 ; VBITS_EQ_256-DAG: mov w[[A:[0-9]+]], #32
-; VBITS_EQ_256-DAG: ld1b { [[OP1_LO:z[0-9]+]].b }, [[PG]]/z, [x0, x[[A]]]
-; VBITS_EQ_256-DAG: ld1b { [[OP1_HI:z[0-9]+]].b }, [[PG]]/z, [x0]
-; VBITS_EQ_256-DAG: ld1b { [[OP2_LO:z[0-9]+]].b }, [[PG]]/z, [x1, x[[A]]]
-; VBITS_EQ_256-DAG: ld1b { [[OP2_HI:z[0-9]+]].b }, [[PG]]/z, [x1]
+; VBITS_EQ_256-DAG: ld1b { [[OP1_LO:z[0-9]+]].b }, [[PG]]/z, [x0]
+; VBITS_EQ_256-DAG: ld1b { [[OP1_HI:z[0-9]+]].b }, [[PG]]/z, [x0, x[[A]]]
+; VBITS_EQ_256-DAG: ld1b { [[OP2_LO:z[0-9]+]].b }, [[PG]]/z, [x1]
+; VBITS_EQ_256-DAG: ld1b { [[OP2_HI:z[0-9]+]].b }, [[PG]]/z, [x1, x[[A]]]
 ; VBITS_EQ_256-DAG: smin [[RES_LO:z[0-9]+]].b, [[PG]]/m, [[OP1_LO]].b, 
[[OP2_LO]].b
 ; VBITS_EQ_256-DAG: smin [[RES_HI:z[0-9]+]].b, [[PG]]/m, [[OP1_HI]].b, 
[[OP2_HI]].b
-; VBITS_EQ_256-DAG: st1b { [[RES_LO]].b }, [[PG]], [x0, x[[A]]]
-; VBITS_EQ_256-DAG: st1b { [[RES_HI]].b }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1b { [[RES_LO]].b }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1b { [[RES_HI]].b }, [[PG]], [x0, x[[A]]]
   %op1 = load <64 x i8>, <64 x i8>* %a
   %op2 = load <64 x i8>, <64 x i8>* %b
   %res = call <64 x i8> @llvm.smin.v64i8(<64 x i8> %op1, <64 x i8> %op2)
@@ -814,14 +814,14 @@ define void @umax_v64i8(<64 x i8>* %a, <64 x i8>* %b) #0 {
 ; Ensure sensible type legalisation.
 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].b, vl32
 ; VBITS_EQ_256-DAG: mov w[[A:[0-9]+]], #32
-; VBITS_EQ_256-DAG: ld1b { [[OP1_LO:z[0-9]+]].b }, [[PG]]/z, [x0, x[[A]]]
-; VBITS_EQ_256-DAG: ld1b { [[OP1_HI:z[0-9]+]].b }, [[PG]]/z, [x0]
-; VBITS_EQ_256-DAG: ld1b { [[OP2_LO:z[0-9]+]].b }, [[PG]]/z, [x1, x[[A]]]
-; VBITS_EQ_256-DAG: ld1b { [[OP2_HI:z[0-9]+]].b }, [[PG]]/z, [x1]
+; VBITS_EQ_256-DAG: ld1b { [[OP1_LO:z[0-9]+]].b }, [[PG]]/z, [x0]
+; VBITS_EQ_256-DAG: ld1b { [[OP1_HI:z[0-9]+]].b }, [[PG]]/z, [x0, x[[A]]]
+; VBITS_EQ_256-DAG: ld1b { [[OP2_LO:z[0-9]+]].b }, [[PG]]/z, [x1]
+; VBITS_EQ_256-DAG: ld1b { [[OP2_HI:z[0-9]+]].b }, [[PG]]/z, [x1, x[[A]]]
 ; VBITS_EQ_256-DAG: umax [[RES_LO:z[0-9]+]].b, [[PG]]/m, [[OP1_LO]].b, 
[[OP2_LO]].b
 ; VBITS_EQ_256-DAG: umax [[RES_HI:z[0-9]+]].b, [[PG]]/m, [[OP1_HI]].b, 
[[OP2_HI]].b
-; VBITS_EQ_256-DAG: st1b { [[RES_LO]].b }, [[PG]], [x0, x[[A]]]
-; VBITS_EQ_256-DAG: st1b { [[RES_HI]].b }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1b { [[RES_LO]].b }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1b { [[RES_HI]].b }, [[PG]], [x0, x[[A]]]
 ; VBITS_EQ_256-NEXT: ret
   %op1 = load <64 x i8>, <64 x i8>* %a
   %op2 = load <64 x i8>, <64 x i8>* %b
@@ -1187,14 +1187,14 @@ define void @umin_v64i8(<64 x i8>* %a, <64 x i8>* %b) 
#0 {
 ; Ensure sensible type legalisation.
 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].b, vl32
 ; VBITS_EQ_256-DAG: mov w[[

[llvm-branch-commits] [llvm] 5d10b8a - [ADT] Add resize_for_overwrite method to SmallVector.

2020-12-22 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-22T17:18:59Z
New Revision: 5d10b8ad595da87bec8c66ad70a8daf86cd9266b

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

LOG: [ADT] Add resize_for_overwrite method to SmallVector.

Analagous to the std::make_(unqiue|shared)_for_overwrite added in c++20.
If T is POD, and the container gets larger, any new values added wont be 
initialized.
This is useful when using SmallVector as a buffer where its planned to 
overwrite any potential new values added.
If T is not POD, `new (Storage) T` functions identically to `new (Storage) T()` 
so this will function identically to `resize(size_type)`.

Reviewed By: dexonsmith

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

Added: 


Modified: 
llvm/include/llvm/ADT/SmallVector.h
llvm/unittests/ADT/SmallVectorTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/ADT/SmallVector.h 
b/llvm/include/llvm/ADT/SmallVector.h
index 0a0f09c68060..3bbde2d9c0fb 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -460,7 +460,8 @@ class SmallVectorImpl : public SmallVectorTemplateBase {
 this->Size = 0;
   }
 
-  void resize(size_type N) {
+private:
+  template  void resizeImpl(size_type N) {
 if (N < this->size()) {
   this->destroy_range(this->begin()+N, this->end());
   this->set_size(N);
@@ -468,11 +469,20 @@ class SmallVectorImpl : public SmallVectorTemplateBase 
{
   if (this->capacity() < N)
 this->grow(N);
   for (auto I = this->end(), E = this->begin() + N; I != E; ++I)
-new (&*I) T();
+if (ForOverwrite)
+  new (&*I) T;
+else
+  new (&*I) T();
   this->set_size(N);
 }
   }
 
+public:
+  void resize(size_type N) { resizeImpl(N); }
+
+  /// Like resize, but \ref T is POD, the new values won't be initialized.
+  void resize_for_overwrite(size_type N) { resizeImpl(N); }
+
   void resize(size_type N, const T &NV) {
 if (N == this->size())
   return;

diff  --git a/llvm/unittests/ADT/SmallVectorTest.cpp 
b/llvm/unittests/ADT/SmallVectorTest.cpp
index 957412f3083f..e02c3e709667 100644
--- a/llvm/unittests/ADT/SmallVectorTest.cpp
+++ b/llvm/unittests/ADT/SmallVectorTest.cpp
@@ -341,6 +341,31 @@ TYPED_TEST(SmallVectorTest, ResizeFillTest) {
   this->assertValuesInOrder(this->theVector, 3u, 77, 77, 77);
 }
 
+TEST(SmallVectorTest, ResizeForOverwrite) {
+  {
+// Heap allocated storage.
+SmallVector V;
+V.push_back(5);
+V.pop_back();
+V.resize_for_overwrite(V.size() + 1);
+EXPECT_EQ(5, V.back());
+V.pop_back();
+V.resize(V.size() + 1);
+EXPECT_EQ(0, V.back());
+  }
+  {
+// Inline storage.
+SmallVector V;
+V.push_back(5);
+V.pop_back();
+V.resize_for_overwrite(V.size() + 1);
+EXPECT_EQ(5, V.back());
+V.pop_back();
+V.resize(V.size() + 1);
+EXPECT_EQ(0, V.back());
+  }
+}
+
 // Overflow past fixed size.
 TYPED_TEST(SmallVectorTest, OverflowTest) {
   SCOPED_TRACE("OverflowTest");



___
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] f106b28 - [tests] precommit a test mentioned in review for D93317

2020-12-22 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-12-22T09:47:19-08:00
New Revision: f106b281be24df4b5ed4553c3c09c885610cd2b8

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

LOG: [tests] precommit a test mentioned in review for D93317

Added: 


Modified: 
llvm/test/Transforms/LoopVectorize/loop-form.ll

Removed: 




diff  --git a/llvm/test/Transforms/LoopVectorize/loop-form.ll 
b/llvm/test/Transforms/LoopVectorize/loop-form.ll
index 298143ba726c..72f2215bb934 100644
--- a/llvm/test/Transforms/LoopVectorize/loop-form.ll
+++ b/llvm/test/Transforms/LoopVectorize/loop-form.ll
@@ -338,3 +338,91 @@ if.end:
 if.end2:
   ret i32 1
 }
+
+define i32 @multiple_latch1(i16* %p) {
+; CHECK-LABEL: @multiple_latch1(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[FOR_BODY:%.*]]
+; CHECK:   for.body:
+; CHECK-NEXT:[[I_02:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], 
[[FOR_BODY_BACKEDGE:%.*]] ]
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I_02]], 1
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[INC]], 16
+; CHECK-NEXT:br i1 [[CMP]], label [[FOR_BODY_BACKEDGE]], label 
[[FOR_SECOND:%.*]]
+; CHECK:   for.second:
+; CHECK-NEXT:[[IPROM:%.*]] = sext i32 [[I_02]] to i64
+; CHECK-NEXT:[[B:%.*]] = getelementptr inbounds i16, i16* [[P:%.*]], i64 
[[IPROM]]
+; CHECK-NEXT:store i16 0, i16* [[B]], align 4
+; CHECK-NEXT:[[CMPS:%.*]] = icmp sgt i32 [[INC]], 16
+; CHECK-NEXT:br i1 [[CMPS]], label [[FOR_BODY_BACKEDGE]], label 
[[FOR_END:%.*]]
+; CHECK:   for.body.backedge:
+; CHECK-NEXT:br label [[FOR_BODY]]
+; CHECK:   for.end:
+; CHECK-NEXT:ret i32 0
+;
+entry:
+  br label %for.body
+
+for.body:
+  %i.02 = phi i32 [ 0, %entry ], [ %inc, %for.body.backedge]
+  %inc = add nsw i32 %i.02, 1
+  %cmp = icmp slt i32 %inc, 16
+  br i1 %cmp, label %for.body.backedge, label %for.second
+
+for.second:
+  %iprom = sext i32 %i.02 to i64
+  %b = getelementptr inbounds i16, i16* %p, i64 %iprom
+  store i16 0, i16* %b, align 4
+  %cmps = icmp sgt i32 %inc, 16
+  br i1 %cmps, label %for.body.backedge, label %for.end
+
+for.body.backedge:
+  br label %for.body
+
+for.end:
+  ret i32 0
+}
+
+
+; two back branches - loop simplify with convert this to the same form
+; as previous before vectorizer sees it, but show that.
+define i32 @multiple_latch2(i16* %p) {
+; CHECK-LABEL: @multiple_latch2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[FOR_BODY:%.*]]
+; CHECK:   for.body:
+; CHECK-NEXT:[[I_02:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], 
[[FOR_BODY_BACKEDGE:%.*]] ]
+; CHECK-NEXT:[[INC]] = add nsw i32 [[I_02]], 1
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[INC]], 16
+; CHECK-NEXT:br i1 [[CMP]], label [[FOR_BODY_BACKEDGE]], label 
[[FOR_SECOND:%.*]]
+; CHECK:   for.body.backedge:
+; CHECK-NEXT:br label [[FOR_BODY]]
+; CHECK:   for.second:
+; CHECK-NEXT:[[IPROM:%.*]] = sext i32 [[I_02]] to i64
+; CHECK-NEXT:[[B:%.*]] = getelementptr inbounds i16, i16* [[P:%.*]], i64 
[[IPROM]]
+; CHECK-NEXT:store i16 0, i16* [[B]], align 4
+; CHECK-NEXT:[[CMPS:%.*]] = icmp sgt i32 [[INC]], 16
+; CHECK-NEXT:br i1 [[CMPS]], label [[FOR_BODY_BACKEDGE]], label 
[[FOR_END:%.*]]
+; CHECK:   for.end:
+; CHECK-NEXT:ret i32 0
+;
+entry:
+  br label %for.body
+
+for.body:
+  %i.02 = phi i32 [ 0, %entry ], [ %inc, %for.body ], [%inc, %for.second]
+  %inc = add nsw i32 %i.02, 1
+  %cmp = icmp slt i32 %inc, 16
+  br i1 %cmp, label %for.body, label %for.second
+
+for.second:
+  %iprom = sext i32 %i.02 to i64
+  %b = getelementptr inbounds i16, i16* %p, i64 %iprom
+  store i16 0, i16* %b, align 4
+  %cmps = icmp sgt i32 %inc, 16
+  br i1 %cmps, label %for.body, label %for.end
+
+for.end:
+  ret i32 0
+}
+
+declare void @foo()



___
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] ac90bbc - [LoopDeletion] Add test case where outer loop needs to be deleted.

2020-12-22 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-22T17:49:20Z
New Revision: ac90bbc9cb8b905e4a8e7c9d2924a4d426c690aa

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

LOG: [LoopDeletion] Add test case where outer loop needs to be deleted.

In the test case @test1, the inner loop cannot be removed, because it
has a live-out value. But the outer loop is a no-op and can be removed.

Added: 
llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll 
b/llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll
new file mode 100644
index ..464c12f453a7
--- /dev/null
+++ b/llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll
@@ -0,0 +1,172 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -loop-deletion -verify-dom-info -S | FileCheck %s
+
+target datalayout = 
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
+
+%pair_t = type { i64, i64 }
+
+; The loop %inner cannot be removed, because it has outgoing values. But the
+; outer loop is a no-op and can be removed.
+define void @test1(i64 %N, i64 %M, %pair_t* %ptr) willreturn {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[OUTER_HEADER:%.*]]
+; CHECK:   outer.header:
+; CHECK-NEXT:[[OUTER_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ 
[[OUTER_IV_NEXT:%.*]], [[OUTER_LATCH:%.*]] ]
+; CHECK-NEXT:br label [[INNER:%.*]]
+; CHECK:   inner:
+; CHECK-NEXT:[[INNER_IV:%.*]] = phi i64 [ 0, [[OUTER_HEADER]] ], [ 
[[INNER_IV_NEXT:%.*]], [[INNER]] ]
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr [[PAIR_T:%.*]], %pair_t* 
[[PTR:%.*]], i64 [[INNER_IV]]
+; CHECK-NEXT:[[P:%.*]] = load [[PAIR_T]], %pair_t* [[GEP]], align 4
+; CHECK-NEXT:[[V_0:%.*]] = extractvalue [[PAIR_T]] [[P]], 0
+; CHECK-NEXT:[[V_1:%.*]] = extractvalue [[PAIR_T]] [[P]], 1
+; CHECK-NEXT:[[INNER_EC:%.*]] = icmp ult i64 [[V_0]], [[V_1]]
+; CHECK-NEXT:[[INNER_IV_NEXT]] = add i64 [[INNER_IV]], 1
+; CHECK-NEXT:br i1 [[INNER_EC]], label [[OUTER_LATCH]], label [[INNER]]
+; CHECK:   outer.latch:
+; CHECK-NEXT:[[LCSSA:%.*]] = phi i64 [ [[V_1]], [[INNER]] ]
+; CHECK-NEXT:[[OUTER_EC:%.*]] = icmp ult i64 [[OUTER_IV]], [[LCSSA]]
+; CHECK-NEXT:[[OUTER_IV_NEXT]] = add i64 [[OUTER_IV]], 1
+; CHECK-NEXT:br i1 [[OUTER_EC]], label [[EXIT:%.*]], label [[OUTER_HEADER]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %outer.header
+
+outer.header:
+  %outer.iv = phi i64 [ 0, %entry ], [ %outer.iv.next, %outer.latch ]
+
+  br label %inner
+
+inner:
+  %inner.iv = phi i64 [ 0, %outer.header ], [ %inner.iv.next, %inner ]
+  %gep = getelementptr %pair_t, %pair_t* %ptr, i64 %inner.iv
+  %p = load %pair_t, %pair_t* %gep
+  %v.0 = extractvalue %pair_t %p, 0
+  %v.1 = extractvalue %pair_t %p, 1
+  %inner.ec = icmp ult i64 %v.0, %v.1
+  %inner.iv.next = add i64 %inner.iv, 1
+  br i1 %inner.ec, label %outer.latch, label %inner
+
+outer.latch:
+  %lcssa = phi i64 [ %v.1, %inner ]
+  %outer.ec = icmp ult i64 %outer.iv, %lcssa
+  %outer.iv.next = add i64 %outer.iv, 1
+  br i1 %outer.ec, label %exit, label %outer.header
+
+exit:
+  ret void
+}
+
+declare void @sideeffect()
+
+; Same as @test1, but with a call in the outer loop. Nothing can be deleted.
+define void @test2_sideeffect_in_outer(i64 %N, i64 %M, %pair_t* %ptr) 
willreturn {
+; CHECK-LABEL: @test2_sideeffect_in_outer(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[OUTER_HEADER:%.*]]
+; CHECK:   outer.header:
+; CHECK-NEXT:[[OUTER_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ 
[[OUTER_IV_NEXT:%.*]], [[OUTER_LATCH:%.*]] ]
+; CHECK-NEXT:br label [[INNER:%.*]]
+; CHECK:   inner:
+; CHECK-NEXT:[[INNER_IV:%.*]] = phi i64 [ 0, [[OUTER_HEADER]] ], [ 
[[INNER_IV_NEXT:%.*]], [[INNER]] ]
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr [[PAIR_T:%.*]], %pair_t* 
[[PTR:%.*]], i64 [[INNER_IV]]
+; CHECK-NEXT:[[P:%.*]] = load [[PAIR_T]], %pair_t* [[GEP]], align 4
+; CHECK-NEXT:[[V_0:%.*]] = extractvalue [[PAIR_T]] [[P]], 0
+; CHECK-NEXT:[[V_1:%.*]] = extractvalue [[PAIR_T]] [[P]], 1
+; CHECK-NEXT:[[INNER_EC:%.*]] = icmp ult i64 [[V_0]], [[V_1]]
+; CHECK-NEXT:[[INNER_IV_NEXT]] = add i64 [[INNER_IV]], 1
+; CHECK-NEXT:br i1 [[INNER_EC]], label [[OUTER_LATCH]], label [[INNER]]
+; CHECK:   outer.latch:
+; CHECK-NEXT:[[LCSSA:%.*]] = phi i64 [ [[V_1]], [[INNER]] ]
+; CHECK-NEXT:[[OUTER_EC:%.*]] = icmp ult i64 [[OUTER_IV]], [[LCSSA]]
+; CHECK-NEXT:[[OUTER_IV_NEXT]] = add i64 [[OUTER_IV]], 1
+; CHECK-NEXT:call void @sideeffect()
+; CHECK-NEXT:br i1 [[OUTER_EC]], label [[EXIT:%.*]], label [

[llvm-branch-commits] [llvm] f507148 - [ADT] Fix some tests after 5d10b8ad

2020-12-22 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-22T18:06:19Z
New Revision: f5071489ea8cf2771d7375534c122467a000b356

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

LOG: [ADT] Fix some tests after 5d10b8ad

Some bots were failing due to signed/unsigned comparison.

Added: 


Modified: 
llvm/unittests/ADT/SmallVectorTest.cpp

Removed: 




diff  --git a/llvm/unittests/ADT/SmallVectorTest.cpp 
b/llvm/unittests/ADT/SmallVectorTest.cpp
index e02c3e709667..d97ab577524f 100644
--- a/llvm/unittests/ADT/SmallVectorTest.cpp
+++ b/llvm/unittests/ADT/SmallVectorTest.cpp
@@ -345,24 +345,24 @@ TEST(SmallVectorTest, ResizeForOverwrite) {
   {
 // Heap allocated storage.
 SmallVector V;
-V.push_back(5);
+V.push_back(5U);
 V.pop_back();
-V.resize_for_overwrite(V.size() + 1);
-EXPECT_EQ(5, V.back());
+V.resize_for_overwrite(V.size() + 1U);
+EXPECT_EQ(5U, V.back());
 V.pop_back();
 V.resize(V.size() + 1);
-EXPECT_EQ(0, V.back());
+EXPECT_EQ(0U, V.back());
   }
   {
 // Inline storage.
 SmallVector V;
-V.push_back(5);
+V.push_back(5U);
 V.pop_back();
-V.resize_for_overwrite(V.size() + 1);
-EXPECT_EQ(5, V.back());
+V.resize_for_overwrite(V.size() + 1U);
+EXPECT_EQ(5U, V.back());
 V.pop_back();
 V.resize(V.size() + 1);
-EXPECT_EQ(0, V.back());
+EXPECT_EQ(0U, V.back());
   }
 }
 



___
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] [lldb] e17a00f - [lldb] Add SBType::IsScopedEnumerationType method

2020-12-22 Thread Jonas Devlieghere via llvm-branch-commits

Author: Andy Yankovsky
Date: 2020-12-22T10:08:21-08:00
New Revision: e17a00fc87bc163cc2438ce10faca51d94b91ab3

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

LOG: [lldb] Add SBType::IsScopedEnumerationType method

Add a method to check if the type is a scoped enumeration (i.e. "enum
class/struct").

Differential revision: https://reviews.llvm.org/D93690

Added: 


Modified: 
lldb/bindings/interface/SBType.i
lldb/include/lldb/API/SBType.h
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBType.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp
lldb/test/API/python_api/type/TestTypeList.py
lldb/test/API/python_api/type/main.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBType.i 
b/lldb/bindings/interface/SBType.i
index fd2dda188454..b65eddb5fe29 100644
--- a/lldb/bindings/interface/SBType.i
+++ b/lldb/bindings/interface/SBType.i
@@ -220,6 +220,9 @@ public:
 bool
 IsAnonymousType ();
 
+bool
+IsScopedEnumerationType ();
+
 lldb::SBType
 GetPointerType();
 

diff  --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 5f487aa5d258..9ac385c492ed 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -131,6 +131,8 @@ class SBType {
 
   bool IsAnonymousType();
 
+  bool IsScopedEnumerationType();
+
   lldb::SBType GetPointerType();
 
   lldb::SBType GetPointeeType();

diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index f1cde0ac3084..1e0f520ab959 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -82,6 +82,8 @@ class CompilerType {
 
   bool IsAnonymousType() const;
 
+  bool IsScopedEnumerationType() const;
+
   bool IsBeingDefined() const;
 
   bool IsCharType() const;

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 4c51d290ad2c..b8393b9c39e1 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -175,6 +175,8 @@ class TypeSystem : public PluginInterface {
 return false;
   }
 
+  virtual bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) = 0;
+
   virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
  CompilerType *target_type, // Can pass 
NULL
  bool check_cplusplus, bool check_objc) = 
0;

diff  --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 0a99ac0f2292..7d8d4cfeef4f 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -271,6 +271,14 @@ bool SBType::IsAnonymousType() {
   return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
 }
 
+bool SBType::IsScopedEnumerationType() {
+  LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType);
+
+  if (!IsValid())
+return false;
+  return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType();
+}
+
 lldb::SBType SBType::GetFunctionReturnType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType);
 
@@ -935,6 +943,7 @@ void RegisterMethods(Registry &R) {
   LLDB_REGISTER_METHOD(bool, SBType, IsPolymorphicClass, ());
   LLDB_REGISTER_METHOD(bool, SBType, IsTypedefType, ());
   LLDB_REGISTER_METHOD(bool, SBType, IsAnonymousType, ());
+  LLDB_REGISTER_METHOD(bool, SBType, IsScopedEnumerationType, ());
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetFunctionReturnType, ());
   LLDB_REGISTER_METHOD(lldb::SBTypeList, SBType, GetFunctionArgumentTypes,
());

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 894faa847450..d1a9e9387292 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3147,6 +3147,20 @@ bool 
TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
   return false;
 }
 
+bool TypeSystemClang::IsScopedEnumerationType(
+lldb::opaque_compiler_type_t type) {
+  if (type) {
+const clang::EnumType *enum_type = llvm::dyn_cast(
+GetCanonicalQualType(type)->getCanonicalTypeInternal());
+
+if (enum_type) {
+  return enum_type->isScopedEnumeralType();
+}
+  }
+
+  return false;
+}
+
 bool TypeSystemClang::IsPointerType(lldb::opaque_compiler_type_t type,
 CompilerType *pointee_type) {
   if (type) {

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemC

[llvm-branch-commits] [lldb] 1432ae5 - [lldb] Add SBType::GetEnumerationIntegerType method

2020-12-22 Thread Jonas Devlieghere via llvm-branch-commits

Author: Andy Yankovsky
Date: 2020-12-22T10:08:22-08:00
New Revision: 1432ae57bf6e4022b6f4541c9225674ee6b19c23

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

LOG: [lldb] Add SBType::GetEnumerationIntegerType method

Add a method for getting the enumeration underlying type.

Differential revision: https://reviews.llvm.org/D93696

Added: 


Modified: 
lldb/bindings/interface/SBType.i
lldb/include/lldb/API/SBType.h
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBType.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp
lldb/test/API/python_api/type/TestTypeList.py
lldb/test/API/python_api/type/main.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBType.i 
b/lldb/bindings/interface/SBType.i
index b65eddb5fe29..2d9a4a4d11d1 100644
--- a/lldb/bindings/interface/SBType.i
+++ b/lldb/bindings/interface/SBType.i
@@ -244,6 +244,9 @@ public:
 lldb::SBType
 GetCanonicalType();
 
+lldb::SBType
+GetEnumerationIntegerType();
+
 lldb::SBType
 GetArrayElementType ();
 

diff  --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 9ac385c492ed..529b4d0eeffc 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -152,6 +152,9 @@ class SBType {
   lldb::SBType GetVectorElementType();
 
   lldb::SBType GetCanonicalType();
+
+  lldb::SBType GetEnumerationIntegerType();
+
   // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic
   // type eBasicTypeInvalid will be returned
   lldb::BasicType GetBasicType();

diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 1e0f520ab959..5a0e8e57200d 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -187,6 +187,8 @@ class CompilerType {
 
   CompilerType GetFullyUnqualifiedType() const;
 
+  CompilerType GetEnumerationIntegerType() const;
+
   /// Returns -1 if this isn't a function of if the function doesn't
   /// have a prototype Returns a value >= 0 if there is a prototype.
   int GetFunctionArgumentCount() const;

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b8393b9c39e1..1fad8f61ac37 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -227,6 +227,9 @@ class TypeSystem : public PluginInterface {
 
   virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0;
 
+  virtual CompilerType
+  GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) = 0;
+
   // Returns -1 if this isn't a function of if the function doesn't have a
   // prototype Returns a value >= 0 if there is a prototype.
   virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;

diff  --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 7d8d4cfeef4f..550c4b065914 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -344,6 +344,16 @@ lldb::SBType SBType::GetCanonicalType() {
   return LLDB_RECORD_RESULT(SBType());
 }
 
+SBType SBType::GetEnumerationIntegerType() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+
+  if (IsValid()) {
+return LLDB_RECORD_RESULT(
+
SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()));
+  }
+  return LLDB_RECORD_RESULT(SBType());
+}
+
 lldb::BasicType SBType::GetBasicType() {
   LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType, SBType, GetBasicType);
 
@@ -952,6 +962,7 @@ void RegisterMethods(Registry &R) {
GetMemberFunctionAtIndex, (uint32_t));
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetUnqualifiedType, ());
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetCanonicalType, ());
+  LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetEnumerationIntegerType, ());
   LLDB_REGISTER_METHOD(lldb::BasicType, SBType, GetBasicType, ());
   LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType));
   LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfDirectBaseClasses, ());

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index d1a9e9387292..4f55cf7cfa79 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4195,6 +4195,13 @@ 
TypeSystemClang::GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) {
   return CompilerType();
 }
 
+CompilerType
+TypeSystemClang::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
+  if (type)
+retur

[llvm-branch-commits] [openmp] 612ddc3 - [OpenMP][Docs] Updated the faq about building an OpenMP offloading capable compiler

2020-12-22 Thread Shilei Tian via llvm-branch-commits

Author: Shilei Tian
Date: 2020-12-22T13:14:53-05:00
New Revision: 612ddc3117ce7715a3634fa0e0c5c6cdd3619d6b

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

LOG: [OpenMP][Docs] Updated the faq about building an OpenMP offloading capable 
compiler

After some issues about building runtimes along with LLVM were fixed,
building an OpenMP offloading capable compiler is pretty simple. This patch 
updates
the FAQ part in the doc.

Reviewed By: jdoerfert

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

Added: 


Modified: 
openmp/docs/SupportAndFAQ.rst

Removed: 




diff  --git a/openmp/docs/SupportAndFAQ.rst b/openmp/docs/SupportAndFAQ.rst
index 6b8f0d2f72b0..37c5bcecfccc 100644
--- a/openmp/docs/SupportAndFAQ.rst
+++ b/openmp/docs/SupportAndFAQ.rst
@@ -52,22 +52,11 @@ All patches go through the regular `LLVM review process
 Q: How to build an OpenMP offload capable compiler?
 ^^^
 
-To build an *effective* OpenMP offload capable compiler we recommend a two
-stage build. The first stage Clang does not require to be offload capable but
-all backends that are targeted by OpenMP need to be enabled. By default, Clang
-will be build with all backends enabled. This initial (stage 1) Clang is used
-to create a second Clang compiler that is offload capable as well as the
-:ref:`device runtime libraries ` that will be linked into the
-offloaded code to provide OpenMP runtime support on the device.
-
-Generic information about building LLVM is available `here
-`__. The CMake options for the
-second stage Clang should include:
-
-- `LIBOMPTARGET_NVPTX_CUDA_COMPILER=$STAGE1/bin/clang` to use the stage one
-  compiler for the device runtime compilation.
-- `LIBOMPTARGET_NVPTX_ENABLE_BCLIB=ON` to enable efficient device runtimes in
-  bitcode format.
+To build an *effective* OpenMP offload capable compiler, only one extra CMake
+option, `LLVM_ENABLE_RUNTIMES="OPENMP"`, is needed when building LLVM (Generic
+information about building LLVM is available `here 
`__.).
+Make sure all backends that are targeted by OpenMP to be enabled. By default,
+Clang will be build with all backends enabled.
 
 If your build machine is not the target machine or automatic detection of the
 available GPUs failed, you should also set:



___
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] 85d4a4b - Revert "Fix memory leak complicated non-type template arguments."

2020-12-22 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-22T10:18:07-08:00
New Revision: 85d4a4bcc717a31ff40c4bd979dd6d78beb84b43

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

LOG: Revert "Fix memory leak complicated non-type template arguments."

This reverts commit ed13d8c66781b50ff007cb089c5905f9bb9e8af2.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See 
bug for repro.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/TemplateBase.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index a9bfdb4d5fa5..0c5d82b3e9aa 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2818,8 +2818,8 @@ class ASTContext : public RefCountedBase {
   /// for destruction.
   template  void addDestruction(T *Ptr) const {
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { ((T*)V)->~T(); };
-  AddDeallocation(DestroyPtr, (void*)Ptr);
+  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
+  AddDeallocation(DestroyPtr, Ptr);
 }
   }
 

diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index a746db315d85..0029c90a0ab6 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -137,7 +137,6 @@ TemplateArgument::TemplateArgument(const ASTContext &Ctx, 
QualType Type,
   else {
 Value.Kind = UncommonValue;
 Value.Value = new (Ctx) APValue(V);
-Ctx.addDestruction(Value.Value);
 Value.Type = Type.getAsOpaquePtr();
   }
 }



___
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] ab7a60e - Revert "Fix MSVC "not all control paths return a value" warnings. NFCI."

2020-12-22 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-22T10:18:07-08:00
New Revision: ab7a60eb4100ab197665b86f682dad0e787a4fed

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

LOG: Revert "Fix MSVC "not all control paths return a value" warnings. NFCI."

This reverts commit 7e84aa1b81e72d44bcc58ffe1731bfc7abb73ce0.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See 
bug for repro.

Added: 


Modified: 
clang/lib/Sema/SemaTemplate.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 9d31a8701241..74a31c0a1b65 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -7637,7 +7637,6 @@ static Expr 
*BuildExpressionFromNonTypeTemplateArgumentValue(
 auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);
 return ConstantExpr::Create(S.Context, OVE, Val);
   }
-  llvm_unreachable("Unhandled APValue::ValueKind enum");
 }
 
 ExprResult
@@ -7667,7 +7666,6 @@ Sema::BuildExpressionFromNonTypeTemplateArgument(const 
TemplateArgument &Arg,
 return BuildExpressionFromNonTypeTemplateArgumentValue(
 *this, Arg.getUncommonValueType(), Arg.getAsUncommonValue(), Loc);
   }
-  llvm_unreachable("Unhandled TemplateArgument::ArgKind enum");
 }
 
 /// Match two template parameters within template parameter lists.



___
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] af0dbaa - Revert "Following up on PR48517, fix handling of template arguments that refer"

2020-12-22 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-22T10:18:08-08:00
New Revision: af0dbaaa38f54b0366177aae43545a8848d3fe56

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

LOG: Revert "Following up on PR48517, fix handling of template arguments that 
refer"

This reverts commit 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See 
bug for repro.

Added: 
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/OpenMP/distribute_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_parallel_for_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/distribute_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_collapse_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_ordered_messages.cpp
clang/test/OpenMP/target_simd_collapse_messages.cpp
clang/test/OpenMP/target_teams_distribute_dist_schedule_messages.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_messages.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_messages.cpp
clang/test/OpenMP/target_update_from_messages.cpp
clang/test/OpenMP/target_update_to_messages.cpp
clang/test/OpenMP/task_messages.cpp
clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_messages.cpp

clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_messages.cpp
clang/test/OpenMP/teams_distribute_simd_dist_schedule_messages.cpp
clang/test/SemaCXX/warn-unused-lambda-capture.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Removed: 
clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp



diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index e1c3b6944142..c8d87ec48a3f 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -578,12 +578,12 @@ class Expr : public ValueStmt {
   struct EvalStatus {
 /// Whether the evaluated expression has side effects.
 /// For example, (f() && 0) can be folded, but it still has side effects.
-bool HasSideEffects = false;
+bool HasSideEffects;
 
 /// Whether the evaluation hit undefined behavior.
 /// For example, 1.0 / 0.0 can be folded to Inf, but has undefined 
behavior.
 /// Likewise, INT_MAX + 1 can be folded to INT_MIN, but has UB.
-bool HasUndefinedBehavior = false;
+bool HasUndefinedBehavior;
 
 /// Diag - If this is non-null, it will be filled in with a stack of notes
 /// indicating why evaluation failed (or why it failed to produce a 
constant
@@ -592,7 +592,10 @@ class Expr : public ValueStmt {
 /// foldable. If the expression is foldable, but not a constant expression,
 /// the notes will describes why it isn't a constant expression. If the
 /// expression *is* a constant expression, no notes will be produced.
-SmallVectorImpl *Diag = nullptr;
+SmallVectorImpl *Diag;
+
+EvalStatus()
+: HasSideEffects(false), HasUndefinedBehavior(false), Diag(nullptr) {}
 
 // hasSideEffects - Return true if the evaluated expression has
 // side effects.
@@ -603,11 +606,8 @@ class Expr : public ValueStmt {
 
   /// EvalResult is a struct with detailed info about an evaluated expression.
   struct EvalResult : EvalStatus {
-/// This is the value the expression can be folded to.
+/// Val - This is the value the expression can be folded to.
 APValue Val;
-/// Indicates whether Val contains a pointer or reference or pointer to
-/// member naming a templated entity, and thus the value is dependent.
-bool Dependent = false;
 
 // isGlobalLValue - Return true if the evaluated lvalue expression
 // is global.

diff  --git a/clang/include/clang/AST/TemplateBase.h 
b/clang/include/clang/AST/TemplateBase.h
index abf873a7ee40..7967f8a91214 100644
--- a/clang/include/clang/AST/TemplateBase.h
+++ b/clang/include/clang/AST/TemplateBase.h
@@ -252,12 +252,6 @@ class TemplateArgument {
   /// Whether this template argument is dependent on a template
   /// parameter such that its result can change from one instantiation to
   /// anot

[llvm-branch-commits] [clang] 2080232 - Revert "[c++20] P1907R1: Support for generalized non-type template arguments of scalar type."

2020-12-22 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-22T10:18:08-08:00
New Revision: 208023233398a677cc0aacb8153be9801db03af6

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

LOG: Revert "[c++20] P1907R1: Support for generalized non-type template 
arguments of scalar type."

This reverts commit 9e08e51a20d0d2b1c5724bb17e969d036fced4cd.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See 
bug for repro.

Added: 


Modified: 
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/TemplateArgumentVisitor.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTRecordWriter.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CodeGenCXX/mangle-ms-templates.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp

Removed: 
clang/test/CodeGenCXX/template-arguments.cpp



diff  --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index dbe75ab9de19..ba0f237a3bc3 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -72,7 +72,6 @@ class CountPropertyType : 
PropertyType {
 
 def APInt : PropertyType<"llvm::APInt"> { let PassByReference = 1; }
 def APSInt : PropertyType<"llvm::APSInt"> { let PassByReference = 1; }
-def APValue : PropertyType { let PassByReference = 1; }
 def ArraySizeModifier : EnumPropertyType<"ArrayType::ArraySizeModifier">;
 def AttrKind : EnumPropertyType<"attr::Kind">;
 def AutoTypeKeyword : EnumPropertyType;
@@ -451,17 +450,6 @@ let Class = PropertyTypeCase 
in {
 return TemplateArgument(ctx, value, type);
   }]>;
 }
-let Class = PropertyTypeCase in {
-  def : Property<"value", APValue> {
-let Read = [{ node.getAsUncommonValue() }];
-  }
-  def : Property<"type", QualType> {
-let Read = [{ node.getUncommonValueType() }];
-  }
-  def : Creator<[{
-return TemplateArgument(ctx, type, value);
-  }]>;
-}
 let Class = PropertyTypeCase in {
   def : Property<"name", TemplateName> {
 let Read = [{ node.getAsTemplateOrTemplatePattern() }];

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 1426e569eabe..505ea700fd0e 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -768,7 +768,6 @@ bool RecursiveASTVisitor::TraverseTemplateArgument(
   case TemplateArgument::Declaration:
   case TemplateArgument::Integral:
   case TemplateArgument::NullPtr:
-  case TemplateArgument::UncommonValue:
 return true;
 
   case TemplateArgument::Type:
@@ -802,7 +801,6 @@ bool 
RecursiveASTVisitor::TraverseTemplateArgumentLoc(
   case TemplateArgument::Declaration:
   case TemplateArgument::Integral:
   case TemplateArgument::NullPtr:
-  case TemplateArgument::UncommonValue:
 return true;
 
   case TemplateArgument::Type: {

diff  --git a/clang/include/clang/AST/TemplateArgumentVisitor.h 
b/clang/include/clang/AST/TemplateArgumentVisitor.h
index 8c0da70b25eb..190aa97adf45 100644
--- a/clang/include/clang/AST/TemplateArgumentVisitor.h
+++ b/clang/include/clang/AST/TemplateArgumentVisitor.h
@@ -37,7 +37,6 @@ class Base {
   DISPATCH(Declaration);
   DISPATCH(NullPtr);
   DISPATCH(Integral);
-  DISPATCH(UncommonValue);
   DISPATCH(Template);
   DISPATCH(TemplateExpansion);
   DISPATCH(Expression);
@@ -60,7 +59,6 @@ class Base {
   VISIT_METHOD(Declaration);
   VISIT_METHOD(NullPtr);
   VISIT_METHOD(Integral);
-  VISIT_METHOD(UncommonValue);
   VISIT_METHOD(Template);
   VISIT_METHOD(TemplateExpansion);
   VISIT_METHOD(Expression);

diff  --git a/clang/include/clang/AST/TemplateBase.h 
b/cl

[llvm-branch-commits] [clang] 34e72a1 - Revert "DR2064: decltype(E) is only a dependent type if E is type-dependent, not"

2020-12-22 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-22T10:18:08-08:00
New Revision: 34e72a146111dd986889a0f0ec8767b2ca6b2913

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

LOG: Revert "DR2064: decltype(E) is only a dependent type if E is 
type-dependent, not"

This reverts commit 638867afd4bce4a2c56dea041299428af3727d61.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See 
bug for repro.

Added: 


Modified: 
clang/include/clang/AST/DependenceFlags.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Type.cpp
clang/test/CXX/drs/dr20xx.cpp
clang/test/Sema/invalid-bitwidth-expr.mm
clang/test/SemaCXX/invalid-template-base-specifier.cpp
clang/test/SemaTemplate/dependent-expr.cpp
clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 8c47047a7526..ca96b65574bd 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -255,12 +255,6 @@ inline TypeDependence 
toTypeDependence(TemplateNameDependence D) {
 inline TypeDependence toTypeDependence(TemplateArgumentDependence D) {
   return Dependence(D).type();
 }
-/// Compute the dependence of a type that depends on the type of an expression,
-/// given the dependence of that expression and of its type.
-inline TypeDependence typeToTypeDependence(ExprDependence ED, TypeDependence 
TD) {
-  return Dependence(ED & ~ExprDependence::Value).type() |
- (TD & TypeDependence::VariablyModified);
-}
 
 inline NestedNameSpecifierDependence
 toNestedNameSpecifierDependendence(TypeDependence D) {

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 0190573fe36e..44545f00b146 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5383,10 +5383,10 @@ QualType ASTContext::getDecltypeType(Expr *e, QualType 
UnderlyingType) const {
   DecltypeType *dt;
 
   // C++11 [temp.type]p2:
-  //   If an expression e is type-dependent, decltype(e) denotes a unique
-  //   dependent type. Two such decltype-specifiers refer to the same type only
-  //   if their expressions are equivalent (14.5.6.1).
-  if (e->isTypeDependent()) {
+  //   If an expression e involves a template parameter, decltype(e) denotes a
+  //   unique dependent type. Two such decltype-specifiers refer to the same
+  //   type only if their expressions are equivalent (14.5.6.1).
+  if (e->isInstantiationDependent()) {
 llvm::FoldingSetNodeID ID;
 DependentDecltypeType::Profile(ID, *this, e);
 

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 01deb598a078..6c8d5687c64a 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2582,11 +2582,6 @@ void CXXNameMangler::mangleType(QualType T) {
   // instantation-dependent qualifiers. See
   // https://github.com/itanium-cxx-abi/cxx-abi/issues/114.
 
-  // Don't desugar instantiation-dependent decltype / typeof types. We need
-  // to mangle the expression as written.
-  if (isa(T))
-break;
-
   QualType Desugared
 = T.getSingleStepDesugaredType(Context.getASTContext());
   if (Desugared == T)

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 5dec80be9ccb..034e175f1352 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -125,7 +125,8 @@ ArrayType::ArrayType(TypeClass tc, QualType et, QualType 
can,
 //   template int arr[] = {N...};
 : Type(tc, can,
et->getDependence() |
-   (sz ? toTypeDependence(sz->getDependence())
+   (sz ? toTypeDependence(
+ turnValueToTypeDependence(sz->getDependence()))
: TypeDependence::None) |
(tc == VariableArray ? TypeDependence::VariablyModified
 : TypeDependence::None) |
@@ -3395,8 +3396,9 @@ QualType MacroQualifiedType::getModifiedType() const {
 
 TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
 : Type(TypeOfExpr, can,
-   typeToTypeDependence(E->getDependence(),
-E->getType()->getDependence())),
+   toTypeDependence(E->getDependence()) |
+   (E->getType()->getDependence() &
+TypeDependence::VariablyModified)),
   TOExpr(E) {}
 
 bool TypeOfExprType::isSugared() const {
@@ -3416,12 +3418,18 @@ void 
DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID,
 }
 
 DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can)
+// C++11 [temp.type]p2: "If an expression e involves a template parameter,

[llvm-branch-commits] [llvm] 1aa10ab - Revert "[Flang][openmp][5.0] Add task_reduction clause."

2020-12-22 Thread Sameeran joshi via llvm-branch-commits

Author: sameeran joshi
Date: 2020-12-22T23:53:51+05:30
New Revision: 1aa10ab2e1ddc863a944fb181b2b8ed633864bab

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

LOG: Revert "[Flang][openmp][5.0] Add task_reduction clause."

This reverts commit 9a7895dc20852b662a66976d06871ec2a0b968c8.
Reverting due to missing Co-author attribution.

https://reviews.llvm.org/D93105

Added: 


Modified: 
flang/include/flang/Parser/parse-tree.h
flang/lib/Parser/openmp-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.cpp
flang/lib/Semantics/check-omp-structure.h
flang/test/Semantics/omp-clause-validity01.f90
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index 119a92bee211..7e258b668576 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3415,7 +3415,7 @@ struct OmpReductionOperator {
 // variable-name-list)
 struct OmpReductionClause {
   TUPLE_CLASS_BOILERPLATE(OmpReductionClause);
-  std::tuple t;
+  std::tuple> t;
 };
 
 // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)

diff  --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 3a0d28cd9c12..1386b2b16a78 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -102,7 +102,7 @@ 
TYPE_PARSER(construct(Parser{}) ||
 construct(Parser{}))
 
 TYPE_PARSER(construct(
-Parser{} / ":", Parser{}))
+Parser{} / ":", nonemptyList(designator)))
 
 // OMP 5.0 2.11.4  ALLOCATE ([allocator:] variable-name-list)
 TYPE_PARSER(construct(
@@ -220,9 +220,6 @@ TYPE_PARSER(
parenthesized(Parser{}))) ||
 "REDUCTION" >>
 construct(parenthesized(Parser{})) ||
-"TASK_REDUCTION" >>
-construct(construct(
-parenthesized(Parser{}))) ||
 "RELAXED" >> construct(construct()) ||
 "RELEASE" >> construct(construct()) ||
 "SAFELEN" >> construct(construct(

diff  --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index ba54a0a84fa7..fdb694f3d26f 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2016,7 +2016,7 @@ class UnparseVisitor {
 Word("REDUCTION(");
 Walk(std::get(x.t));
 Put(":");
-Walk(std::get(x.t));
+Walk(std::get>(x.t), ",");
 Put(")");
   }
   void Unparse(const OmpAllocateClause &x) {

diff  --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index a144c7a2b57b..e2c8333ce7ee 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -419,7 +419,6 @@ CHECK_SIMPLE_CLAUSE(Mergeable, OMPC_mergeable)
 CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
 CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
 CHECK_SIMPLE_CLAUSE(Nowait, OMPC_nowait)
-CHECK_SIMPLE_CLAUSE(TaskReduction, OMPC_task_reduction)
 CHECK_SIMPLE_CLAUSE(To, OMPC_to)
 CHECK_SIMPLE_CLAUSE(Uniform, OMPC_uniform)
 CHECK_SIMPLE_CLAUSE(Untied, OMPC_untied)

diff  --git a/flang/lib/Semantics/check-omp-structure.h 
b/flang/lib/Semantics/check-omp-structure.h
index ccd0e08a8c08..a966eaf8c4a7 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -155,7 +155,6 @@ class OmpStructureChecker
   void Enter(const parser::OmpClause::Safelen &);
   void Enter(const parser::OmpClause::Shared &);
   void Enter(const parser::OmpClause::Simdlen &);
-  void Enter(const parser::OmpClause::TaskReduction &);
   void Enter(const parser::OmpClause::ThreadLimit &);
   void Enter(const parser::OmpClause::To &);
   void Enter(const parser::OmpClause::Link &);

diff  --git a/flang/test/Semantics/omp-clause-validity01.f90 
b/flang/test/Semantics/omp-clause-validity01.f90
index 1d689ea91699..3f5345137866 100644
--- a/flang/test/Semantics/omp-clause-validity01.f90
+++ b/flang/test/Semantics/omp-clause-validity01.f90
@@ -349,8 +349,7 @@
 !  collapse-clause
 
   a = 0.0
-  !ERROR: TASK_REDUCTION clause is not allowed on the SIMD directive
-  !$omp simd private(b) reduction(+:a) task_reduction(+:a)
+  !$omp simd private(b) reduction(+:a)
   do i = 1, N
  a = a + b + 3.14
   enddo
@@ -450,8 +449,7 @@
   enddo
 
   !ERROR: At most one NUM_TASKS clause can appear on the TASKLOOP directive
-  !ERROR: TASK_REDUCTION clause is not allowed on the TASKLOOP directive
-  !$omp taskloop num_tasks(3) num_tasks(2) task_reduction(*:a)
+  !$omp taskloop num_tasks(3) num_tasks(2)
   do i = 1,N
 a = 3.14
   enddo

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td 
b/llvm/include/llvm/Fronte

[llvm-branch-commits] [clang-tools-extra] b2e734d - Revert "[clangd] zap a few warnings"

2020-12-22 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-22T10:34:03-08:00
New Revision: b2e734d5f46d70c5a73dd16b0619c58eff6b8052

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

LOG: Revert "[clangd] zap a few warnings"

This reverts commit 95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc.

Depends on a reverted change.

Added: 


Modified: 
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/index/remote/Client.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 8f1b3f3a1aae..12698b42ef3e 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -143,7 +143,6 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_ARGUMENT_KIND(Declaration);
   TEMPLATE_ARGUMENT_KIND(Template);
   TEMPLATE_ARGUMENT_KIND(TemplateExpansion);
-  TEMPLATE_ARGUMENT_KIND(UncommonValue);
 #undef TEMPLATE_ARGUMENT_KIND
 }
 llvm_unreachable("Unhandled ArgKind enum");

diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index c5c7d71be661..3afd65522680 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -1069,7 +1069,6 @@ class ExplicitReferenceCollector
 case TemplateArgument::Pack:
 case TemplateArgument::Type:
 case TemplateArgument::Expression:
-case TemplateArgument::UncommonValue:
   break; // Handled by VisitType and VisitExpression.
 };
 return RecursiveASTVisitor::TraverseTemplateArgumentLoc(A);

diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index a153a8812baf..b09dbf915e46 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -152,8 +152,7 @@ class IndexClient : public clangd::SymbolIndex {
   });
   }
 
-  llvm::unique_function
-  indexedFiles() const override {
+  llvm::unique_function indexedFiles() const {
 // FIXME: For now we always return "false" regardless of whether the file
 //was indexed or not. A possible implementation could be based on
 //the idea that we do not want to send a request at every



___
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] [lldb] 6283d2a - Revert "[LLDB] Unbreak the build after recent clang changes"

2020-12-22 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-22T10:34:04-08:00
New Revision: 6283d2aa51985d6e6f3404f4b0a3b38b5b05ee6e

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

LOG: Revert "[LLDB] Unbreak the build after recent clang changes"

This reverts commit 430d5d8429473c2b10b109991d7577a3cea41140.

Depends on a reverted change.

Added: 


Modified: 
lldb/include/lldb/lldb-enumerations.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index ff4e15e7e070..2679ee52136d 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -816,7 +816,6 @@ enum TemplateArgumentKind {
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
-  eTemplateArgumentKindUncommonValue,
 };
 
 /// Options that can be set for a formatter to alter its behavior. Not

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4f55cf7cfa79..c15b15e736fb 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7002,9 +7002,6 @@ 
TypeSystemClang::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type,
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
-
-  case clang::TemplateArgument::UncommonValue:
-return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }



___
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] a5311d7 - [clang-tidy] Handle template instantiations in container size check

2020-12-22 Thread Stephen Kelly via llvm-branch-commits

Author: Stephen Kelly
Date: 2020-12-22T18:44:45Z
New Revision: a5311d731e1b95e93b35b1e9183a4a531df386e7

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

LOG: [clang-tidy] Handle template instantiations in container size check

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

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

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp

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

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
index 14a38c09ad9b..e7c5f0ab05be 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -16,6 +16,77 @@
 using namespace clang::ast_matchers;
 
 namespace clang {
+namespace ast_matchers {
+AST_POLYMORPHIC_MATCHER_P2(hasAnyArgumentWithParam,
+   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
+   CXXConstructExpr),
+   internal::Matcher, ArgMatcher,
+   internal::Matcher, ParamMatcher) {
+  BoundNodesTreeBuilder Result;
+  // The first argument of an overloaded member operator is the implicit object
+  // argument of the method which should not be matched against a parameter, so
+  // we skip over it here.
+  BoundNodesTreeBuilder Matches;
+  unsigned ArgIndex = cxxOperatorCallExpr(callee(cxxMethodDecl()))
+  .matches(Node, Finder, &Matches)
+  ? 1
+  : 0;
+  int ParamIndex = 0;
+  for (; ArgIndex < Node.getNumArgs(); ++ArgIndex) {
+BoundNodesTreeBuilder ArgMatches(*Builder);
+if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), 
Finder,
+   &ArgMatches)) {
+  BoundNodesTreeBuilder ParamMatches(ArgMatches);
+  if (expr(anyOf(cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
+ hasParameter(ParamIndex, ParamMatcher,
+ callExpr(callee(functionDecl(
+ hasParameter(ParamIndex, ParamMatcher))
+  .matches(Node, Finder, &ParamMatches)) {
+Result.addMatch(ParamMatches);
+*Builder = std::move(Result);
+return true;
+  }
+}
+++ParamIndex;
+  }
+  return false;
+}
+
+AST_MATCHER(Expr, usedInBooleanContext) {
+  const char *ExprName = "__booleanContextExpr";
+  auto Result =
+  expr(expr().bind(ExprName),
+   anyOf(hasParent(varDecl(hasType(booleanType(,
+ hasParent(cxxConstructorDecl(
+ hasAnyConstructorInitializer(cxxCtorInitializer(
+ withInitializer(expr(equalsBoundNode(ExprName))),
+ forField(hasType(booleanType())),
+ hasParent(fieldDecl(hasType(booleanType(,
+ hasParent(stmt(anyOf(
+ explicitCastExpr(hasDestinationType(booleanType())),
+ ifStmt(hasCondition(expr(equalsBoundNode(ExprName,
+ doStmt(hasCondition(expr(equalsBoundNode(ExprName,
+ whileStmt(hasCondition(expr(equalsBoundNode(ExprName,
+ forStmt(hasCondition(expr(equalsBoundNode(ExprName,
+ conditionalOperator(
+ hasCondition(expr(equalsBoundNode(ExprName,
+ parenListExpr(hasParent(varDecl(hasType(booleanType(),
+ parenExpr(hasParent(
+ explicitCastExpr(hasDestinationType(booleanType(),
+ returnStmt(forFunction(returns(booleanType(,
+ cxxUnresolvedConstructExpr(hasType(booleanType())),
+ callExpr(hasAnyArgumentWithParam(
+ expr(equalsBoundNode(ExprName)),
+ parmVarDecl(hasType(booleanType(),
+ binaryOperator(hasAnyOperatorName("&&", "||")),
+ unaryOperator(hasOperatorName("!")).bind("NegOnSize"))
+  .matches(Node, Finder, Builder);
+  Builder->removeBindings([ExprName](const BoundNodesMap &Nodes) {
+r

[llvm-branch-commits] [llvm] ae8f4b2 - [AMDGPU] Folding of FI operand with flat scratch

2020-12-22 Thread Stanislav Mekhanoshin via llvm-branch-commits

Author: Stanislav Mekhanoshin
Date: 2020-12-22T10:48:04-08:00
New Revision: ae8f4b2178c46da1f10eb9279c9b44fab8b85417

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

LOG: [AMDGPU] Folding of FI operand with flat scratch

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

Added: 
llvm/test/CodeGen/AMDGPU/flat-scratch-fold-fi.mir

Modified: 
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.h
llvm/lib/Target/AMDGPU/SIInstrInfo.td
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
llvm/test/CodeGen/AMDGPU/frame-index-elimination.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp 
b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index bfba432848d4..06cce54e540c 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -172,9 +172,23 @@ static bool frameIndexMayFold(const SIInstrInfo *TII,
   const MachineInstr &UseMI,
   int OpNo,
   const MachineOperand &OpToFold) {
-  return OpToFold.isFI() &&
-TII->isMUBUF(UseMI) &&
-OpNo == AMDGPU::getNamedOperandIdx(UseMI.getOpcode(), 
AMDGPU::OpName::vaddr);
+  if (!OpToFold.isFI())
+return false;
+
+  if (TII->isMUBUF(UseMI))
+return OpNo == AMDGPU::getNamedOperandIdx(UseMI.getOpcode(),
+  AMDGPU::OpName::vaddr);
+  if (!TII->isFLATScratch(UseMI))
+return false;
+
+  int SIdx = AMDGPU::getNamedOperandIdx(UseMI.getOpcode(),
+AMDGPU::OpName::saddr);
+  if (OpNo == SIdx)
+return true;
+
+  int VIdx = AMDGPU::getNamedOperandIdx(UseMI.getOpcode(),
+AMDGPU::OpName::vaddr);
+  return OpNo == VIdx && SIdx == -1;
 }
 
 FunctionPass *llvm::createSIFoldOperandsPass() {
@@ -631,25 +645,36 @@ void SIFoldOperands::foldOperand(
 // Sanity check that this is a stack access.
 // FIXME: Should probably use stack pseudos before frame lowering.
 
-if (TII->getNamedOperand(*UseMI, AMDGPU::OpName::srsrc)->getReg() !=
-MFI->getScratchRSrcReg())
-  return;
+if (TII->isMUBUF(*UseMI)) {
+  if (TII->getNamedOperand(*UseMI, AMDGPU::OpName::srsrc)->getReg() !=
+  MFI->getScratchRSrcReg())
+return;
 
-// Ensure this is either relative to the current frame or the current wave.
-MachineOperand &SOff =
-*TII->getNamedOperand(*UseMI, AMDGPU::OpName::soffset);
-if ((!SOff.isReg() || SOff.getReg() != MFI->getStackPtrOffsetReg()) &&
-(!SOff.isImm() || SOff.getImm() != 0))
-  return;
+  // Ensure this is either relative to the current frame or the current
+  // wave.
+  MachineOperand &SOff =
+  *TII->getNamedOperand(*UseMI, AMDGPU::OpName::soffset);
+  if ((!SOff.isReg() || SOff.getReg() != MFI->getStackPtrOffsetReg()) &&
+  (!SOff.isImm() || SOff.getImm() != 0))
+return;
+
+  // If this is relative to the current wave, update it to be relative to
+  // the current frame.
+  if (SOff.isImm())
+SOff.ChangeToRegister(MFI->getStackPtrOffsetReg(), false);
+}
 
 // A frame index will resolve to a positive constant, so it should always 
be
 // safe to fold the addressing mode, even pre-GFX9.
 UseMI->getOperand(UseOpIdx).ChangeToFrameIndex(OpToFold.getIndex());
 
-// If this is relative to the current wave, update it to be relative to the
-// current frame.
-if (SOff.isImm())
-  SOff.ChangeToRegister(MFI->getStackPtrOffsetReg(), false);
+if (TII->isFLATScratch(*UseMI) &&
+AMDGPU::getNamedOperandIdx(UseMI->getOpcode(),
+   AMDGPU::OpName::vaddr) != -1) {
+  unsigned NewOpc = AMDGPU::getFlatScratchInstSSfromSV(UseMI->getOpcode());
+  UseMI->setDesc(TII->get(NewOpc));
+}
+
 return;
   }
 

diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.h 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
index 4625cefa1e3e..75aedee1ec6b 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -1184,6 +1184,9 @@ namespace AMDGPU {
   LLVM_READONLY
   int getFlatScratchInstSTfromSS(uint16_t Opcode);
 
+  LLVM_READONLY
+  int getFlatScratchInstSSfromSV(uint16_t Opcode);
+
   const uint64_t RSRC_DATA_FORMAT = 0xf000LL;
   const uint64_t RSRC_ELEMENT_SIZE_SHIFT = (32 + 19);
   const uint64_t RSRC_INDEX_STRIDE_SHIFT = (32 + 21);

diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
index 746d08b8ce0e..e48138e56d71 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -2524,6 +2524,13 @@ def getFlatScratchInstSTfromSS : InstrMapping

[llvm-branch-commits] [llvm] 333108e - Add a llvm.coro.end.async intrinsic

2020-12-22 Thread Arnold Schwaighofer via llvm-branch-commits

Author: Arnold Schwaighofer
Date: 2020-12-22T10:52:28-08:00
New Revision: 333108e8bef8966520defe8602521d0d4e2ef789

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

LOG: Add a llvm.coro.end.async intrinsic

The llvm.coro.end.async intrinsic allows to specify a function that is
to be called as the last action before returning. This function will be
inlined after coroutine splitting.

This function can contain a 'musttail' call to allow for guaranteed tail
calling as the last action.

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

Added: 


Modified: 
llvm/docs/Coroutines.rst
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/Transforms/Coroutines/CoroEarly.cpp
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/lib/Transforms/Coroutines/CoroInstr.h
llvm/lib/Transforms/Coroutines/CoroInternal.h
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/lib/Transforms/Coroutines/Coroutines.cpp
llvm/test/Transforms/Coroutines/coro-async.ll

Removed: 




diff  --git a/llvm/docs/Coroutines.rst b/llvm/docs/Coroutines.rst
index 77fb77d9a967..268e9c79ac8f 100644
--- a/llvm/docs/Coroutines.rst
+++ b/llvm/docs/Coroutines.rst
@@ -1389,6 +1389,48 @@ The following table summarizes the handling of 
`coro.end`_ intrinsic.
 || Landingpad  | nothing   | nothing   
|
 
++-+---+---+
 
+
+'llvm.coro.end.async' Intrinsic
+^
+::
+
+  declare i1 @llvm.coro.end.async(i8* , i1 , ...)
+
+Overview:
+"
+
+The '``llvm.coro.end.async``' marks the point where execution of the resume 
part
+of the coroutine should end and control should return to the caller. As part of
+its variable tail arguments this instruction allows to specify a function and
+the function's arguments that are to be tail called as the last action before
+returning.
+
+
+Arguments:
+""
+
+The first argument should refer to the coroutine handle of the enclosing
+coroutine. A frontend is allowed to supply null as the first parameter, in this
+case `coro-early` pass will replace the null with an appropriate coroutine
+handle value.
+
+The second argument should be `true` if this coro.end is in the block that is
+part of the unwind sequence leaving the coroutine body due to an exception and
+`false` otherwise.
+
+The third argument if present should specify a function to be called.
+
+If the third argument is present, the remaining arguments are the arguments to
+the function call.
+
+.. code-block:: llvm
+
+  call i1 (i8*, i1, ...) @llvm.coro.end.async(
+   i8* %hdl, i1 0,
+   void (i8*, %async.task*, %async.actor*)* 
@must_tail_call_return,
+   i8* %ctxt, %async.task* %task, %async.actor* %actor)
+  unreachable
+
 .. _coro.suspend:
 .. _suspend points:
 

diff  --git a/llvm/include/llvm/IR/Intrinsics.td 
b/llvm/include/llvm/IR/Intrinsics.td
index f71dc147416b..aed498d80b02 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1213,6 +1213,8 @@ def int_coro_free : Intrinsic<[llvm_ptr_ty], 
[llvm_token_ty, llvm_ptr_ty],
ReadOnly>,
NoCapture>]>;
 def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty], []>;
+def int_coro_end_async
+: Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_vararg_ty], []>;
 
 def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
 def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;

diff  --git a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp 
b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
index 07c571a962b0..e134ff7f45c6 100644
--- a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
@@ -164,10 +164,11 @@ bool Lowerer::lowerEarlyIntrinsics(Function &F) {
 if (cast(&I)->isFinal())
   CB->setCannotDuplicate();
 break;
+  case Intrinsic::coro_end_async:
   case Intrinsic::coro_end:
 // Make sure that fallthrough coro.end is not duplicated as CoroSplit
 // pass expects that there is at most one fallthrough coro.end.
-if (cast(&I)->isFallthrough())
+if (cast(&I)->isFallthrough())
   CB->setCannotDuplicate();
 break;
   case Intrinsic::coro_noop:
@@ -219,8 +220,8 @@ static bool declaresCoroEarlyIntrinsics(const Module &M) {
   return coro::declaresIntrinsics(
   M, {"llvm.coro.id", "llvm.coro.id.retcon", "llvm.coro.id.retcon.once",
   "llvm.coro.destroy", "llvm.coro.done", "llvm.coro.end",
-  "llvm.coro.noop", "llvm.coro.free", "llvm.coro.promise",
-  "llvm.coro.resume",

[llvm-branch-commits] [openmp] 1eb082c - [OpenMP][Docs] Fixed a typo in the doc that can mislead users to a CMake error

2020-12-22 Thread Shilei Tian via llvm-branch-commits

Author: Shilei Tian
Date: 2020-12-22T14:05:58-05:00
New Revision: 1eb082c2ea426f1dab4d1b3541b37c883b3a6b4f

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

LOG: [OpenMP][Docs] Fixed a typo in the doc that can mislead users to a CMake 
error

When setting `LLVM_ENABLE_RUNTIMES`, lower case word should be used;
otherwise, it can cause a CMake error that specific path is not found.

Reviewed By: ye-luo

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

Added: 


Modified: 
openmp/docs/SupportAndFAQ.rst

Removed: 




diff  --git a/openmp/docs/SupportAndFAQ.rst b/openmp/docs/SupportAndFAQ.rst
index 489b66d5b4a6..647fa57a9e76 100644
--- a/openmp/docs/SupportAndFAQ.rst
+++ b/openmp/docs/SupportAndFAQ.rst
@@ -53,7 +53,7 @@ Q: How to build an OpenMP offload capable compiler?
 ^^^
 
 To build an *effective* OpenMP offload capable compiler, only one extra CMake
-option, `LLVM_ENABLE_RUNTIMES="OPENMP"`, is needed when building LLVM (Generic
+option, `LLVM_ENABLE_RUNTIMES="openmp"`, is needed when building LLVM (Generic
 information about building LLVM is available `here 
`__.).
 Make sure all backends that are targeted by OpenMP to be enabled. By default,
 Clang will be build with all backends enabled.



___
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] [openmp] 9cb7487 - [OpenMP][Docs] Add FAQ entry about math and complex on GPUs

2020-12-22 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2020-12-22T13:05:04-06:00
New Revision: 9cb748724ef5d7d0f7d662d849423404267d532a

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

LOG: [OpenMP][Docs] Add FAQ entry about math and complex on GPUs

Reviewed By: tianshilei1992

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

Added: 


Modified: 
openmp/docs/SupportAndFAQ.rst

Removed: 




diff  --git a/openmp/docs/SupportAndFAQ.rst b/openmp/docs/SupportAndFAQ.rst
index 37c5bcecfccc..489b66d5b4a6 100644
--- a/openmp/docs/SupportAndFAQ.rst
+++ b/openmp/docs/SupportAndFAQ.rst
@@ -80,3 +80,32 @@ For now, the answer is most likely *no*. Please see 
:ref:`build_offload_capable_
 Q: Does OpenMP offloading support work in packages distributed as part of my 
OS?
 

 For now, the answer is most likely *no*. Please see 
:ref:`build_offload_capable_compiler`.
+
+
+.. _math_and_complex_in_target_regions:
+
+Q: Does Clang support `` and `` operations in OpenMP target 
on GPUs?
+^^^
+
+Yes, LLVM/Clang allows math functions and complex arithmetic inside of OpenMP 
target regions
+that are compiled for GPUs.
+
+Clang provides a set of wrapper headers that are found first when `math.h` and
+`complex.h`, for C, `cmath` and `complex`, foc C++, or similar headers are
+included by the application. These wrappers will eventually include the system
+version of the corresponding header file after setting up a target device
+specific environment. The fact that the system header is included is important
+because they 
diff er based on the architecture and operating system and may
+contain preprocessor, variable, and function definitions that need to be
+available in the target region regardless of the targeted device architecture.
+However, various functions may require specialized device versions, e.g.,
+`sin`, and others are only available on certain devices, e.g., `__umul64hi`. To
+provide "native" support for math and complex on the respective architecture,
+Clang will wrap the "native" math functions, e.g., as provided by the device
+vendor, in an OpenMP begin/end declare variant. These functions will then be
+picked up instead of the host versions while host only variables and function
+definitions are still available. Complex arithmetic and functions are support
+through a similar mechanism. It is worth noting that this support requires
+`extensions to the OpenMP begin/end declare variant context selector
+`__
+that are exposed through LLVM/Clang to the user as well.



___
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] [openmp] 7b0f9dd - [OpenMP][Docs] Fix Typo

2020-12-22 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2020-12-22T13:06:23-06:00
New Revision: 7b0f9dd79a3c1799866a7b08e172598df90c649f

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

LOG: [OpenMP][Docs] Fix Typo

Added: 


Modified: 
openmp/docs/SupportAndFAQ.rst

Removed: 




diff  --git a/openmp/docs/SupportAndFAQ.rst b/openmp/docs/SupportAndFAQ.rst
index 647fa57a9e76..ef209aed17a0 100644
--- a/openmp/docs/SupportAndFAQ.rst
+++ b/openmp/docs/SupportAndFAQ.rst
@@ -91,7 +91,7 @@ Yes, LLVM/Clang allows math functions and complex arithmetic 
inside of OpenMP ta
 that are compiled for GPUs.
 
 Clang provides a set of wrapper headers that are found first when `math.h` and
-`complex.h`, for C, `cmath` and `complex`, foc C++, or similar headers are
+`complex.h`, for C, `cmath` and `complex`, for C++, or similar headers are
 included by the application. These wrappers will eventually include the system
 version of the corresponding header file after setting up a target device
 specific environment. The fact that the system header is included is important



___
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] 53deef9 - [RISCV] Remove unneeded !eq comparing a single bit value to 0/1 in RISCVInstrInfoVPseudos.td. NFC

2020-12-22 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-22T11:57:16-08:00
New Revision: 53deef9e0b8ffa1a4a9c0f88b5fc0621978f9ea6

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

LOG: [RISCV] Remove unneeded !eq comparing a single bit value to 0/1 in 
RISCVInstrInfoVPseudos.td. NFC

Instead we can either use the bit directly. If it was checking for
0 we need to swap the operands or use !not.

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index 67bdfa80e8c4..c28bd3093643 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -543,7 +543,7 @@ class VPseudoBinaryCarryIn :
 Pseudo<(outs RetClass:$rd),
-   !if(!eq(CarryIn, 1),
+   !if(CarryIn,
   (ins Op1Class:$rs2, Op2Class:$rs1, VMV0:$carry, GPR:$vl,
ixlenimm:$sew),
   (ins Op1Class:$rs2, Op2Class:$rs1, GPR:$vl, ixlenimm:$sew)), 
[]>,
@@ -554,8 +554,8 @@ class VPseudoBinaryCarryIn(PseudoToVInst.VInst);
   let VLMul = MInfo.value;
@@ -675,8 +675,8 @@ multiclass VPseudoBinaryV_VV {
 
 multiclass VPseudoBinaryV_VX {
   foreach m = MxList.m in
-defm !if(!eq(IsFloat, 0), "_VX", "_VF") : VPseudoBinary;
+defm !if(IsFloat, "_VF", "_VX") : VPseudoBinary;
 }
 
 multiclass VPseudoBinaryV_VI {
@@ -699,8 +699,8 @@ multiclass VPseudoBinaryW_VV {
 
 multiclass VPseudoBinaryW_VX {
   foreach m = MxList.m[0-5] in
-defm !if(!eq(IsFloat, 0), "_VX", "_VF") : VPseudoBinary;
 }
 
@@ -712,8 +712,8 @@ multiclass VPseudoBinaryW_WV {
 
 multiclass VPseudoBinaryW_WX {
   foreach m = MxList.m[0-5] in
-defm !if(!eq(IsFloat, 0), "_WX", "_WF") : VPseudoBinary;
 }
 
@@ -741,9 +741,9 @@ multiclass VPseudoBinaryV_WI {
 multiclass VPseudoBinaryV_VM {
   foreach m = MxList.m in
-def "_VV" # !if(!eq(CarryIn, 1), "M", "") # "_" # m.MX :
-  VPseudoBinaryCarryIn.R, m.vrclass)),
m.vrclass, m.vrclass, m, CarryIn, Constraint>;
 }
@@ -751,9 +751,9 @@ multiclass VPseudoBinaryV_VM {
   foreach m = MxList.m in
-def "_VX" # !if(!eq(CarryIn, 1), "M", "") # "_" # m.MX :
-  VPseudoBinaryCarryIn.R, m.vrclass)),
m.vrclass, GPR, m, CarryIn, Constraint>;
 }
@@ -761,9 +761,9 @@ multiclass VPseudoBinaryV_XM {
   foreach m = MxList.m in
-def "_VI" # !if(!eq(CarryIn, 1), "M", "") # "_" # m.MX :
-  VPseudoBinaryCarryIn.R, m.vrclass)),
m.vrclass, simm5, m, CarryIn, Constraint>;
 }
@@ -789,8 +789,8 @@ multiclass VPseudoBinaryM_VV {
 
 multiclass VPseudoBinaryM_VX {
   foreach m = MxList.m in
-defm !if(!eq(IsFloat, 0), "_VX", "_VF") :
-  VPseudoBinary;
 }
 
@@ -1374,7 +1374,7 @@ multiclass VPatBinaryV_VM {
   foreach vti = AllIntegerVectors in
 defm : VPatBinaryCarryIn;
@@ -1384,7 +1384,7 @@ multiclass VPatBinaryV_XM {
   foreach vti = AllIntegerVectors in
 defm : VPatBinaryCarryIn;
@@ -1394,7 +1394,7 @@ multiclass VPatBinaryV_IM {
   foreach vti = AllIntegerVectors in
 defm : VPatBinaryCarryIn;



___
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] 7ec7788 - Try to fix build on Windows

2020-12-22 Thread Stephen Kelly via llvm-branch-commits

Author: Stephen Kelly
Date: 2020-12-22T20:25:58Z
New Revision: 7ec7788ac175f3ccb7083de0e786438ad8610771

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

LOG: Try to fix build on Windows

Added: 


Modified: 

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

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
index e730b1b22130..4fe75f46932d 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-container-size-empty %t
+// RUN: %check_clang_tidy %s readability-container-size-empty %t -- -- 
-fno-delayed-template-parsing
 
 namespace std {
 template  struct vector {



___
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] [lld] 57ffbe0 - glld/mac] Don't add names of unreferenced symbols to string table

2020-12-22 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-22T15:52:33-05:00
New Revision: 57ffbe020af6469b7c2fdb599f2f7e5e5d0322f0

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

LOG: glld/mac] Don't add names of unreferenced symbols to string table

Before this, a hello world program would contain many many unnecessary
entries in its string table.

No behavior change, just makes the string table in the output smaller
and more like ld64's.

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

Added: 


Modified: 
lld/MachO/SyntheticSections.cpp
lld/test/MachO/symtab.s

Removed: 




diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 8b2ebd36e1ae..2ed1f2eb34fb 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -694,6 +694,11 @@ void SymtabSection::emitStabs() {
 }
 
 void SymtabSection::finalizeContents() {
+  auto addSymbol = [&](std::vector &symbols, Symbol *sym) {
+uint32_t strx = stringTableSection.addString(sym->getName());
+symbols.push_back({sym, strx});
+  };
+
   // Local symbols aren't in the SymbolTable, so we walk the list of object
   // files to gather them.
   for (InputFile *file : inputFiles) {
@@ -702,10 +707,8 @@ void SymtabSection::finalizeContents() {
 // TODO: when we implement -dead_strip, we should filter out symbols
 // that belong to dead sections.
 if (auto *defined = dyn_cast(sym)) {
-  if (!defined->isExternal()) {
-uint32_t strx = stringTableSection.addString(sym->getName());
-localSymbols.push_back({sym, strx});
-  }
+  if (!defined->isExternal())
+addSymbol(localSymbols, sym);
 }
   }
 }
@@ -713,19 +716,16 @@ void SymtabSection::finalizeContents() {
 
   // __dyld_private is a local symbol too. It's linker-created and doesn't
   // exist in any object file.
-  if (Defined* dyldPrivate = in.stubHelper->dyldPrivate) {
-uint32_t strx = stringTableSection.addString(dyldPrivate->getName());
-localSymbols.push_back({dyldPrivate, strx});
-  }
+  if (Defined* dyldPrivate = in.stubHelper->dyldPrivate)
+addSymbol(localSymbols, dyldPrivate);
 
   for (Symbol *sym : symtab->getSymbols()) {
-uint32_t strx = stringTableSection.addString(sym->getName());
 if (auto *defined = dyn_cast(sym)) {
   assert(defined->isExternal());
-  externalSymbols.push_back({sym, strx});
+  addSymbol(externalSymbols, sym);
 } else if (auto *dysym = dyn_cast(sym)) {
   if (dysym->isReferenced())
-undefinedSymbols.push_back({sym, strx});
+addSymbol(undefinedSymbols, sym);
 }
   }
 

diff  --git a/lld/test/MachO/symtab.s b/lld/test/MachO/symtab.s
index d18986c9d91c..fa784a34e16a 100644
--- a/lld/test/MachO/symtab.s
+++ b/lld/test/MachO/symtab.s
@@ -86,17 +86,19 @@
 # CHECK-NEXT:   iundefsym: 5
 # CHECK-NEXT:   nundefsym: 2
 
-## Verify that the first entry in the StringTable is a space.
+## Verify that the first entry in the StringTable is a space, and that
+## unreferenced symbols aren't emitted.
 # RUN: obj2yaml %t/test | FileCheck %s --check-prefix=YAML
 # YAML:  StringTable:
 # YAML-NEXT: ' '
+# YAML-NOT: _unreferenced
 
 #--- libfoo.s
 .globl _dynamic
 _dynamic:
 
 #--- test.s
-.globl _main, _external, _external_weak
+.globl _main, _external, _external_weak, _unreferenced
 
 .data
 _external:



___
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] 0d15d4b - [SLP] use operand index abstraction for number of operands

2020-12-22 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-22T16:05:39-05:00
New Revision: 0d15d4b6f43a3355c1d618766c8e550cfe1481d0

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

LOG: [SLP] use operand index abstraction for number of operands

I think this is NFC currently, but the bug would be exposed
when we allow binary intrinsics (maxnum, etc) as candidates
for reductions.

The code in matchAssociativeReduction() is using
OperationData::getNumberOfOperands() when comparing whether
the "EdgeToVisit" iterator is in-bounds, so this code must
use the same (potentially offset) operand value to set
the "EdgeToVisit".

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 b03fb203c6d7..baa8ce2638a0 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6772,7 +6772,8 @@ class HorizontalReduction {
   // in this case.
   // Do not perform analysis of remaining operands of ParentStackElem.first
   // instruction, this whole instruction is an extra argument.
-  ParentStackElem.second = ParentStackElem.first->getNumOperands();
+  OperationData OpData = getOperationData(ParentStackElem.first);
+  ParentStackElem.second = OpData.getNumberOfOperands();
 } else {
   // We ran into something like:
   // ParentStackElem.first += ... + ExtraArg + ...



___
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] f6929c0 - [SLP] add reduction tests for maxnum/minnum intrinsics; NFC

2020-12-22 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-22T16:05:39-05:00
New Revision: f6929c01952b3f144df620544ed937e801b9c945

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

LOG: [SLP] add reduction tests for maxnum/minnum intrinsics; NFC

Added: 


Modified: 
llvm/test/Transforms/SLPVectorizer/X86/fmaxnum.ll
llvm/test/Transforms/SLPVectorizer/X86/fminnum.ll

Removed: 




diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/fmaxnum.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/fmaxnum.ll
index e03f3f808a4f..23f2196b2425 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/fmaxnum.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/fmaxnum.ll
@@ -338,4 +338,151 @@ define void @fmaxnum_16f32() #0 {
   ret void
 }
 
+define float @reduction_v4f32_fast(float* %p) {
+; CHECK-LABEL: @reduction_v4f32_fast(
+; CHECK-NEXT:[[G1:%.*]] = getelementptr inbounds float, float* [[P:%.*]], 
i64 1
+; CHECK-NEXT:[[G2:%.*]] = getelementptr inbounds float, float* [[P]], i64 2
+; CHECK-NEXT:[[G3:%.*]] = getelementptr inbounds float, float* [[P]], i64 3
+; CHECK-NEXT:[[T0:%.*]] = load float, float* [[P]], align 4
+; CHECK-NEXT:[[T1:%.*]] = load float, float* [[G1]], align 4
+; CHECK-NEXT:[[T2:%.*]] = load float, float* [[G2]], align 4
+; CHECK-NEXT:[[T3:%.*]] = load float, float* [[G3]], align 4
+; CHECK-NEXT:[[M1:%.*]] = tail call fast float @llvm.maxnum.f32(float 
[[T1]], float [[T0]])
+; CHECK-NEXT:[[M2:%.*]] = tail call fast float @llvm.maxnum.f32(float 
[[T2]], float [[M1]])
+; CHECK-NEXT:[[M3:%.*]] = tail call fast float @llvm.maxnum.f32(float 
[[T3]], float [[M2]])
+; CHECK-NEXT:ret float [[M3]]
+;
+  %g1 = getelementptr inbounds float, float* %p, i64 1
+  %g2 = getelementptr inbounds float, float* %p, i64 2
+  %g3 = getelementptr inbounds float, float* %p, i64 3
+  %t0 = load float, float* %p, align 4
+  %t1 = load float, float* %g1, align 4
+  %t2 = load float, float* %g2, align 4
+  %t3 = load float, float* %g3, align 4
+  %m1 = tail call fast float @llvm.maxnum.f32(float %t1, float %t0)
+  %m2 = tail call fast float @llvm.maxnum.f32(float %t2, float %m1)
+  %m3 = tail call fast float @llvm.maxnum.f32(float %t3, float %m2)
+  ret float %m3
+}
+
+define float @reduction_v4f32_nnan(float* %p) {
+; CHECK-LABEL: @reduction_v4f32_nnan(
+; CHECK-NEXT:[[G1:%.*]] = getelementptr inbounds float, float* [[P:%.*]], 
i64 1
+; CHECK-NEXT:[[G2:%.*]] = getelementptr inbounds float, float* [[P]], i64 2
+; CHECK-NEXT:[[G3:%.*]] = getelementptr inbounds float, float* [[P]], i64 3
+; CHECK-NEXT:[[T0:%.*]] = load float, float* [[P]], align 4
+; CHECK-NEXT:[[T1:%.*]] = load float, float* [[G1]], align 4
+; CHECK-NEXT:[[T2:%.*]] = load float, float* [[G2]], align 4
+; CHECK-NEXT:[[T3:%.*]] = load float, float* [[G3]], align 4
+; CHECK-NEXT:[[M1:%.*]] = tail call nnan float @llvm.maxnum.f32(float 
[[T1]], float [[T0]])
+; CHECK-NEXT:[[M2:%.*]] = tail call nnan float @llvm.maxnum.f32(float 
[[T2]], float [[M1]])
+; CHECK-NEXT:[[M3:%.*]] = tail call nnan float @llvm.maxnum.f32(float 
[[T3]], float [[M2]])
+; CHECK-NEXT:ret float [[M3]]
+;
+  %g1 = getelementptr inbounds float, float* %p, i64 1
+  %g2 = getelementptr inbounds float, float* %p, i64 2
+  %g3 = getelementptr inbounds float, float* %p, i64 3
+  %t0 = load float, float* %p, align 4
+  %t1 = load float, float* %g1, align 4
+  %t2 = load float, float* %g2, align 4
+  %t3 = load float, float* %g3, align 4
+  %m1 = tail call nnan float @llvm.maxnum.f32(float %t1, float %t0)
+  %m2 = tail call nnan float @llvm.maxnum.f32(float %t2, float %m1)
+  %m3 = tail call nnan float @llvm.maxnum.f32(float %t3, float %m2)
+  ret float %m3
+}
+
+define float @reduction_v8f32_fast(float* %p) {
+; CHECK-LABEL: @reduction_v8f32_fast(
+; CHECK-NEXT:[[G1:%.*]] = getelementptr inbounds float, float* [[P:%.*]], 
i64 1
+; CHECK-NEXT:[[G2:%.*]] = getelementptr inbounds float, float* [[P]], i64 2
+; CHECK-NEXT:[[G3:%.*]] = getelementptr inbounds float, float* [[P]], i64 3
+; CHECK-NEXT:[[G4:%.*]] = getelementptr inbounds float, float* [[P]], i64 4
+; CHECK-NEXT:[[G5:%.*]] = getelementptr inbounds float, float* [[P]], i64 5
+; CHECK-NEXT:[[G6:%.*]] = getelementptr inbounds float, float* [[P]], i64 6
+; CHECK-NEXT:[[G7:%.*]] = getelementptr inbounds float, float* [[P]], i64 7
+; CHECK-NEXT:[[T0:%.*]] = load float, float* [[P]], align 4
+; CHECK-NEXT:[[T1:%.*]] = load float, float* [[G1]], align 4
+; CHECK-NEXT:[[T2:%.*]] = load float, float* [[G2]], align 4
+; CHECK-NEXT:[[T3:%.*]] = load float, float* [[G3]], align 4
+; CHECK-NEXT:[[T4:%.*]] = load float, float* [[G4]], align 4
+; CHECK-NEXT:[[T5:%.*]] = load float, float* [[G5]], align 4
+; CHECK-NEXT:[[T6:

[llvm-branch-commits] [clang-tools-extra] 3dbe471 - [clangd] Use atomics instead of locks to track periodic memory trimming

2020-12-22 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-12-22T22:32:22+01:00
New Revision: 3dbe471a260392ec63dda8deb2709160afc56dde

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

LOG: [clangd] Use atomics instead of locks to track periodic memory trimming

Instead of always locking/unlocking a contended mutex, we now do one atomic read
in the common case, and one read + one exchange if the timer has expried.

Also use this for memory profiling which has similar/compatible requirements.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/support/Threading.cpp
clang-tools-extra/clangd/support/Threading.h
clang-tools-extra/clangd/unittests/support/ThreadingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 0c42f95fb594..c606ccae4fdc 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1285,13 +1285,7 @@ void ClangdLSPServer::publishDiagnostics(
 }
 
 void ClangdLSPServer::maybeExportMemoryProfile() {
-  if (!trace::enabled())
-return;
-  // Profiling might be expensive, so we throttle it to happen once every 5
-  // minutes.
-  static constexpr auto ProfileInterval = std::chrono::minutes(5);
-  auto Now = std::chrono::steady_clock::now();
-  if (Now < NextProfileTime)
+  if (!trace::enabled() || !ShouldProfile())
 return;
 
   static constexpr trace::Metric MemoryUsage(
@@ -1300,27 +1294,11 @@ void ClangdLSPServer::maybeExportMemoryProfile() {
   MemoryTree MT;
   profile(MT);
   record(MT, "clangd_lsp_server", MemoryUsage);
-  NextProfileTime = Now + ProfileInterval;
 }
 
 void ClangdLSPServer::maybeCleanupMemory() {
-  // Memory cleanup is probably expensive, throttle it
-  static constexpr auto MemoryCleanupInterval = std::chrono::minutes(1);
-
-  if (!Opts.MemoryCleanup)
+  if (!Opts.MemoryCleanup || !ShouldCleanupMemory())
 return;
-
-  // FIXME: this can probably be done without a mutex
-  // and the logic could be shared with maybeExportMemoryProfile
-  {
-auto Now = std::chrono::steady_clock::now();
-std::lock_guard Lock(NextMemoryCleanupTimeMutex);
-if (Now < NextMemoryCleanupTime)
-  return;
-NextMemoryCleanupTime = Now + MemoryCleanupInterval;
-  }
-
-  vlog("Calling memory cleanup callback");
   Opts.MemoryCleanup();
 }
 
@@ -1481,10 +1459,15 @@ void ClangdLSPServer::onAST(const ASTParams &Params,
 ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
  const ThreadsafeFS &TFS,
  const ClangdLSPServer::Options &Opts)
-: BackgroundContext(Context::current().clone()), Transp(Transp),
+: ShouldProfile(/*Period=*/std::chrono::minutes(5),
+/*Delay=*/std::chrono::minutes(1)),
+  ShouldCleanupMemory(/*Period=*/std::chrono::minutes(1),
+  /*Delay=*/std::chrono::minutes(1)),
+  BackgroundContext(Context::current().clone()), Transp(Transp),
   MsgHandler(new MessageHandler(*this)), TFS(TFS),
   SupportedSymbolKinds(defaultSymbolKinds()),
   SupportedCompletionItemKinds(defaultCompletionItemKinds()), Opts(Opts) {
+
   // clang-format off
   MsgHandler->bind("initialize", &ClangdLSPServer::onInitialize);
   MsgHandler->bind("initialized", &ClangdLSPServer::onInitialized);
@@ -1529,10 +1512,6 @@ ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
   if (Opts.FoldingRanges)
 MsgHandler->bind("textDocument/foldingRange", 
&ClangdLSPServer::onFoldingRange);
   // clang-format on
-
-  // Delay first profile and memory cleanup until we've finished warming up.
-  NextMemoryCleanupTime = NextProfileTime =
-  std::chrono::steady_clock::now() + std::chrono::minutes(1);
 }
 
 ClangdLSPServer::~ClangdLSPServer() {

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index b5f9d2c9d766..a41bc5666af3 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -19,6 +19,7 @@
 #include "support/Context.h"
 #include "support/MemoryTree.h"
 #include "support/Path.h"
+#include "support/Threading.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSet.h"
@@ -186,18 +187,12 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
   /// Runs profiling and exports memory usage metrics if tracing is enabled and
   /// profiling hasn't happened recently.
   void maybeExportMemoryProfile();
+  PeriodicThrottler ShouldProfile;
 
   /// Run the MemoryCleanup callback if it's time.
   /// This meth

[llvm-branch-commits] [mlir] df6cbd3 - [mlir] Lower gpu.memcpy to GPU runtime calls.

2020-12-22 Thread Christian Sigg via llvm-branch-commits

Author: Christian Sigg
Date: 2020-12-22T22:49:19+01:00
New Revision: df6cbd37f57fd330e413c394a4653ea55393fcef

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

LOG: [mlir] Lower gpu.memcpy to GPU runtime calls.

Reviewed By: herhut

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

Added: 
mlir/test/Conversion/GPUCommon/lower-memcpy-to-gpu-runtime-calls.mlir

Modified: 
mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp
mlir/tools/mlir-rocm-runner/rocm-runtime-wrappers.cpp

Removed: 




diff  --git a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp 
b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
index 3b4b39e57d55..41a079c44eea 100644
--- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
+++ b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
@@ -151,6 +151,12 @@ class ConvertOpToGpuRuntimeCallPattern : public 
ConvertOpToLLVMPattern {
   "mgpuMemFree",
   llvmVoidType,
   {llvmPointerType /* void *ptr */, llvmPointerType /* void *stream */}};
+  FunctionCallBuilder memcpyCallBuilder = {
+  "mgpuMemcpy",
+  llvmVoidType,
+  {llvmPointerType /* void *dst */, llvmPointerType /* void *src */,
+   llvmIntPtrType /* intptr_t sizeBytes */,
+   llvmPointerType /* void *stream */}};
 };
 
 /// A rewrite pattern to convert gpu.host_register operations into a GPU 
runtime
@@ -268,6 +274,20 @@ class EraseGpuModuleOpPattern : public 
OpRewritePattern {
 return success();
   }
 };
+
+/// A rewrite pattern to convert gpu.memcpy operations into a GPU runtime
+/// call. Currently it supports CUDA and ROCm (HIP).
+class ConvertMemcpyOpToGpuRuntimeCallPattern
+: public ConvertOpToGpuRuntimeCallPattern {
+public:
+  ConvertMemcpyOpToGpuRuntimeCallPattern(LLVMTypeConverter &typeConverter)
+  : ConvertOpToGpuRuntimeCallPattern(typeConverter) {}
+
+private:
+  LogicalResult
+  matchAndRewrite(gpu::MemcpyOp memcpyOp, ArrayRef operands,
+  ConversionPatternRewriter &rewriter) const override;
+};
 } // namespace
 
 void GpuToLLVMConversionPass::runOnOperation() {
@@ -643,6 +663,50 @@ LogicalResult 
ConvertLaunchFuncOpToGpuRuntimeCallPattern::matchAndRewrite(
   return success();
 }
 
+LogicalResult ConvertMemcpyOpToGpuRuntimeCallPattern::matchAndRewrite(
+gpu::MemcpyOp memcpyOp, ArrayRef operands,
+ConversionPatternRewriter &rewriter) const {
+  auto memRefType = memcpyOp.src().getType().cast();
+
+  if (failed(areAllLLVMTypes(memcpyOp, operands, rewriter)) ||
+  !isSupportedMemRefType(memRefType) ||
+  failed(isAsyncWithOneDependency(rewriter, memcpyOp)))
+return failure();
+
+  auto loc = memcpyOp.getLoc();
+  auto adaptor = gpu::MemcpyOpAdaptor(operands, memcpyOp->getAttrDictionary());
+
+  MemRefDescriptor srcDesc(adaptor.src());
+
+  Value numElements =
+  memRefType.hasStaticShape()
+  ? createIndexConstant(rewriter, loc, memRefType.getNumElements())
+  // For identity layouts (verified above), the number of elements is
+  // stride[0] * size[0].
+  : rewriter.create(loc, srcDesc.stride(rewriter, loc, 0),
+ srcDesc.size(rewriter, loc, 0));
+
+  Type elementPtrType = getElementPtrType(memRefType);
+  Value nullPtr = rewriter.create(loc, elementPtrType);
+  Value gepPtr = rewriter.create(
+  loc, elementPtrType, ArrayRef{nullPtr, numElements});
+  auto sizeBytes =
+  rewriter.create(loc, getIndexType(), gepPtr);
+
+  auto src = rewriter.create(
+  loc, llvmPointerType, srcDesc.alignedPtr(rewriter, loc));
+  auto dst = rewriter.create(
+  loc, llvmPointerType,
+  MemRefDescriptor(adaptor.dst()).alignedPtr(rewriter, loc));
+
+  auto stream = adaptor.asyncDependencies().front();
+  memcpyCallBuilder.create(loc, rewriter, {dst, src, sizeBytes, stream});
+
+  rewriter.replaceOp(memcpyOp, {stream});
+
+  return success();
+}
+
 std::unique_ptr>
 mlir::createGpuToLLVMConversionPass(StringRef gpuBinaryAnnotation) {
   return std::make_unique(gpuBinaryAnnotation);
@@ -658,6 +722,7 @@ void mlir::populateGpuToLLVMConversionPatterns(
   patterns.insert(converter);
   patterns.insert(

diff  --git 
a/mlir/test/Conversion/GPUCommon/lower-memcpy-to-gpu-runtime-calls.mlir 
b/mlir/test/Conversion/GPUCommon/lower-memcpy-to-gpu-runtime-calls.mlir
new file mode 100644
index ..790c92f92ec9
--- /dev/null
+++ b/mlir/test/Conversion/GPUCommon/lower-memcpy-to-gpu-runtime-calls.mlir
@@ -0,0 +1,19 @@
+// RUN: mlir-opt -allow-unregistered-dialect %s --gpu-to-llvm | FileCheck %s
+
+module attributes {gpu.container_module} {
+
+  // CHECK: func @foo
+  func @foo(%dst : memref<7xf32, 1>, %sr

[llvm-branch-commits] [clang-tools-extra] f7a2612 - [clangd] Release notes for b8c37153d5393aad96

2020-12-22 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-12-22T22:58:45+01:00
New Revision: f7a26127f21fb1ca8252879ca647835ea7c5903d

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

LOG: [clangd] Release notes for b8c37153d5393aad96

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 450b80fd4581..2960aad5a556 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -47,7 +47,17 @@ Major New Features
 Improvements to clangd
 --
 
-The improvements are...
+- clangd's memory usage is significantly reduced on most Linux systems.
+  In particular, memory usage should not increase dramatically over time.
+
+  The standard allocator on most systems is glibc's ptmalloc2, and it creates
+  disproportionately large heaps when handling clangd's allocation patterns.
+  By default, clangd will now periodically call ``malloc_trim`` to release free
+  pages on glibc systems.
+
+  Users of other allocators (such as ``jemalloc`` or ``tcmalloc``) on glibc
+  systems can disable this using ``--malloc_trim=0`` or the CMake flag
+  ``-DCLANGD_MALLOC_TRIM=0``.
 
 Improvements to clang-doc
 -



___
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] a781a70 - [WebAssembly][SIMD] Rename shuffle, swizzle, and load_splats

2020-12-22 Thread Thomas Lively via llvm-branch-commits

Author: Thomas Lively
Date: 2020-12-22T14:29:06-08:00
New Revision: a781a706b961a348006b604cdff8b555e62a2fcb

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

LOG: [WebAssembly][SIMD] Rename shuffle, swizzle, and load_splats

These instructions previously used prefixes like v8x16 to signify that they were
agnostic between float and int interpretations. We renamed these instructions to
remove this form of prefix in https://github.com/WebAssembly/simd/issues/297 and
https://github.com/WebAssembly/simd/issues/316 and this commit brings the names
in LLVM up to date.

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

Added: 


Modified: 
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/CodeGen/WebAssembly/simd-load-splat.ll
llvm/test/CodeGen/WebAssembly/simd-load-store-alignment.ll
llvm/test/CodeGen/WebAssembly/simd-nested-shuffles.ll
llvm/test/CodeGen/WebAssembly/simd-offset.ll
llvm/test/CodeGen/WebAssembly/simd-shift-complex-splats.ll
llvm/test/CodeGen/WebAssembly/simd-shuffle-bitcast.ll
llvm/test/CodeGen/WebAssembly/simd.ll
llvm/test/MC/Disassembler/WebAssembly/wasm.txt
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git 
a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h 
b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
index fccee4b96ed5..4bc77aa68668 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
@@ -194,7 +194,7 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
   WASM_LOAD_STORE(ATOMIC_RMW8_U_XCHG_I64)
   WASM_LOAD_STORE(ATOMIC_RMW8_U_CMPXCHG_I32)
   WASM_LOAD_STORE(ATOMIC_RMW8_U_CMPXCHG_I64)
-  WASM_LOAD_STORE(LOAD_SPLAT_v8x16)
+  WASM_LOAD_STORE(LOAD8_SPLAT)
   WASM_LOAD_STORE(LOAD_LANE_v16i8)
   WASM_LOAD_STORE(STORE_LANE_v16i8)
   return 0;
@@ -222,7 +222,7 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
   WASM_LOAD_STORE(ATOMIC_RMW16_U_XCHG_I64)
   WASM_LOAD_STORE(ATOMIC_RMW16_U_CMPXCHG_I32)
   WASM_LOAD_STORE(ATOMIC_RMW16_U_CMPXCHG_I64)
-  WASM_LOAD_STORE(LOAD_SPLAT_v16x8)
+  WASM_LOAD_STORE(LOAD16_SPLAT)
   WASM_LOAD_STORE(LOAD_LANE_v8i16)
   WASM_LOAD_STORE(STORE_LANE_v8i16)
   return 1;
@@ -253,7 +253,7 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
   WASM_LOAD_STORE(ATOMIC_RMW32_U_CMPXCHG_I64)
   WASM_LOAD_STORE(MEMORY_ATOMIC_NOTIFY)
   WASM_LOAD_STORE(MEMORY_ATOMIC_WAIT32)
-  WASM_LOAD_STORE(LOAD_SPLAT_v32x4)
+  WASM_LOAD_STORE(LOAD32_SPLAT)
   WASM_LOAD_STORE(LOAD_ZERO_v4i32)
   WASM_LOAD_STORE(LOAD_LANE_v4i32)
   WASM_LOAD_STORE(STORE_LANE_v4i32)
@@ -272,7 +272,7 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
   WASM_LOAD_STORE(ATOMIC_RMW_XCHG_I64)
   WASM_LOAD_STORE(ATOMIC_RMW_CMPXCHG_I64)
   WASM_LOAD_STORE(MEMORY_ATOMIC_WAIT64)
-  WASM_LOAD_STORE(LOAD_SPLAT_v64x2)
+  WASM_LOAD_STORE(LOAD64_SPLAT)
   WASM_LOAD_STORE(LOAD_EXTEND_S_v8i16)
   WASM_LOAD_STORE(LOAD_EXTEND_U_v8i16)
   WASM_LOAD_STORE(LOAD_EXTEND_S_v4i32)

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td 
b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index 191cdea0c0ae..e48bbaebd47e 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -64,55 +64,55 @@ defm : LoadPatOffsetOnly;
 defm : LoadPatGlobalAddrOffOnly;
 }
 
-// vNxM.load_splat
-multiclass SIMDLoadSplat simdop> {
+// v128.loadX_splat
+multiclass SIMDLoadSplat simdop> {
   let mayLoad = 1, UseNamedOperandTable = 1 in {
-  defm LOAD_SPLAT_#vec#_A32 :
+  defm LOAD#size#_SPLAT_A32 :
 SIMD_I<(outs V128:$dst),
(ins P2Align:$p2align, offset32_op:$off, I32:$addr),
(outs),
(ins P2Align:$p2align, offset32_op:$off), [],
-   vec#".load_splat\t$dst, ${off}(${addr})$p2align",
-   vec#".load_splat\t$off$p2align", simdop>;
-  defm LOAD_SPLAT_#vec#_A64 :
+   "v128.load"#size#"_splat\t$dst, ${off}(${addr})$p2align",
+   "v128.load"#size#"_splat\t$off$p2align", simdop>;
+  defm LOAD#size#_SPLAT_A64 :
 SIMD_I<(outs V128:$dst),
(ins P2Align:$p2align, offset64_op:$off, I64:$addr),
(outs),
(ins P2Align:$p2align, offset64_op:$off), [],
-   vec#".load_splat\t$dst, ${off}(${addr})$p2align",
-   vec#".load_splat\t$off$p2align", simdop>;
+   "v128.load"#size#"_splat\t$dst, ${off}(${addr})$p2align",
+   "v128.load"#size#"_splat\t$off$p2align", simdop>;
   }
 }
 
-defm "" : SIMDLoadSplat<"v8x16", 7>;
-defm "" : SIM

[llvm-branch-commits] [mlir] 8de43b9 - [mlir] Remove instance methods from LLVMType

2020-12-22 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-12-22T23:34:54+01:00
New Revision: 8de43b926f0e960bbc5b6a53d1b613c46b7c774b

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

LOG: [mlir] Remove instance methods from LLVMType

LLVMType contains multiple instance methods that were introduced initially for
compatibility with LLVM API. These methods boil down to `cast` followed by
type-specific call. Arguably, they are mostly used in an LLVM cast-follows-isa
anti-pattern. This doesn't connect nicely to the rest of the MLIR
infrastructure and actively prevents it from making the LLVM dialect type
system more open, e.g., reusing built-in types when appropriate. Remove such
instance methods and replaces their uses with apporpriate casts and methods on
derived classes. In some cases, the result may look slightly more verbose, but
most cases should actually use a stricter subtype of LLVMType anyway and avoid
the isa/cast.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h
mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
mlir/lib/ExecutionEngine/JitRunner.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Dialect/LLVMIR/invalid.mlir

Removed: 




diff  --git 
a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h 
b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index 7c069c9cd556..63ff16a84ab8 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -446,7 +446,8 @@ class UnrankedMemRefDescriptor : public StructBuilder {
   /// Builds IR extracting the pointer to the first element of the size array.
   static Value sizeBasePtr(OpBuilder &builder, Location loc,
LLVMTypeConverter &typeConverter,
-   Value memRefDescPtr, LLVM::LLVMType elemPtrPtrType);
+   Value memRefDescPtr,
+   LLVM::LLVMPointerType elemPtrPtrType);
   /// Builds IR extracting the size[index] from the descriptor.
   static Value size(OpBuilder &builder, Location loc,
 LLVMTypeConverter typeConverter, Value sizeBasePtr,

diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index df022ef47b33..552fe15e6899 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -51,7 +51,7 @@ def LLVM_VoidResultTypeOpBuilder :
   [{
 auto llvmType = resultType.dyn_cast(); (void)llvmType;
 assert(llvmType && "result must be an LLVM type");
-assert(llvmType.isVoidTy() &&
+assert(llvmType.isa() &&
"for zero-result operands, only 'void' is accepted as result type");
 build($_builder, $_state, operands, attributes);
   }]>;
@@ -288,7 +288,7 @@ def LLVM_LoadOp : LLVM_Op<"load">, 
MemoryOpWithAlignmentAndAttributes {
 OpBuilderDAG<(ins "Value":$addr, CArg<"unsigned", "0">:$alignment,
   CArg<"bool", "false">:$isVolatile, CArg<"bool", "false">:$isNonTemporal),
 [{
-  auto type = addr.getType().cast().getPointerElementTy();
+  auto type = addr.getType().cast().getElementType();
   build($_builder, $_state, type, addr, alignment, isVolatile, 
isNonTemporal);
 }]>,
 OpBuilderDAG<(ins "Type":$t, "Value":$addr,
@@ -443,8 +443,8 @@ def LLVM_CallOp : LLVM_Op<"call"> {
 OpBuilderDAG<(ins "LLVMFuncOp":$func, "ValueRange":$operands,
   CArg<"ArrayRef", "{}">:$attributes),
 [{
-  LLVMType resultType = func.getType().getFunctionResultType();
-  if (!resultType.isVoidTy())
+  LLVMType resultType = func.getType().getReturnType();
+  if (!resultType.isa())
 $_state.addTypes(resultType);
   $_state.addAttribute("callee", $_builder.getSymbolRefAttr(func));
   $_state.addAttri

[llvm-branch-commits] [openmp] 1c19804 - [OpenMP] Add OpenMP Documentation for Libomptarget environment variables

2020-12-22 Thread Joseph Huber via llvm-branch-commits

Author: Joseph Huber
Date: 2020-12-22T17:41:27-05:00
New Revision: 1c19804ebf4c97666a5c7de86ca7432c6b020205

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

LOG: [OpenMP] Add OpenMP Documentation for Libomptarget environment variables

Add support to the OpenMP web pages for environment variables supported
by Libomptarget and their usage.

Reviewed By: jdoerfert

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

Added: 


Modified: 
openmp/docs/design/Runtimes.rst

Removed: 




diff  --git a/openmp/docs/design/Runtimes.rst b/openmp/docs/design/Runtimes.rst
index 61491060ea04..39ed256c4856 100644
--- a/openmp/docs/design/Runtimes.rst
+++ b/openmp/docs/design/Runtimes.rst
@@ -16,6 +16,88 @@ the LLVM/OpenMP host runtime, aka.  `libomp.so`, is 
available as a `pdf
 LLVM/OpenMP Target Host Runtime (``libomptarget``)
 --
 
+Environment Variables
+^
+
+``libomptarget`` uses environment variables to control 
diff erent features of the
+library at runtime. This allows the user to obtain useful runtime information 
as
+well as enable or disable certain features. A full list of supported 
environment
+variables is defined below.
+
+* ``LIBOMPTARGET_DEBUG=``
+* ``LIBOMPTARGET_PROFILE=``
+* ``LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD=``
+* ``LIBOMPTARGET_INFO=``
+
+LIBOMPTARGET_DEBUG
+""
+
+``LIBOMPTARGET_DEBUG`` controls whether or not debugging information will be
+displayed. This feature is only availible if ``libomptarget`` was built with
+``-DOMPTARGET_DEBUG``. The debugging output provided is intended for use by
+``libomptarget`` developers. More user-friendly output is presented when using
+``LIBOMPTARGET_INFO``.
+
+LIBOMPTARGET_PROFILE
+
+``LIBOMPTARGET_PROFILE`` allows ``libomptarget`` to generate time profile 
output
+similar to Clang's ``-ftime-trace`` option. This generates a JSON file based on
+`Chrome Tracing`_ that can be viewed with ``chrome://tracing`` or the
+`Speedscope App`_. Building this feature depends on the `LLVM Support Library`_
+for time trace output. Using this library is enabled by default when building
+using the CMake option ``OPENMP_ENABLE_LIBOMPTARGET_PROFILING``. The output 
will
+be saved to the filename specified by the environment variable.
+
+.. _`Chrome Tracing`: 
https://www.chromium.org/developers/how-tos/trace-event-profiling-tool
+
+.. _`Speedscope App`: https://www.speedscope.app/
+
+.. _`LLVM Support Library`: https://llvm.org/docs/SupportLibrary.html
+
+LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD
+"
+
+``LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD`` sets the threshold size for which the
+``libomptarget`` memory manager will handle the allocation. Any allocations
+larger than this threshold will not use the memory manager and be freed after
+the device kernel exits The default threshold value is ``8Kb``. If
+``LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD`` is set to ``0`` the memory manager
+will be completely disabled.
+
+LIBOMPTARGET_INFO
+"
+
+``LIBOMPTARGET_INFO`` allows the user to request 
diff erent types runtime
+information from ``libomptarget``. ``LIBOMPTARGET_INFO`` uses a 32-bit field to
+enable or disable 
diff erent types of information. This includes information
+about data-mappings and kernel execution. It is recommended to build your
+application with debugging information enabled, this will enable filenames and
+variable declarations in the information messages. OpenMP Debugging information
+is enabled at any level of debugging so a full debug runtime is not required.
+For minimal debugging information compile with `-gline-tables-only`, or compile
+with `-g` for full debug information. A full list of flags supported by
+``LIBOMPTARGET_INFO`` is given below. 
+
+* Print all data arguments upon entering an OpenMP device kernel: ``0x01``
+* Indicate when a mapped address already exists in the device mapping 
table:
+  ``0x02``
+* Dump the contents of the device pointer map at kernel exit: ``0x04``
+* Print OpenMP kernel information from device plugins: ``0x10``
+
+Any combination of these flags can be used by setting the appropriate bits. For
+example, to enable printing all data active in an OpenMP target region along
+with ``CUDA`` information, run the following ``bash`` command.
+
+.. code-block:: console
+
+   $ env LIBOMPTARGET_INFO=$((1 << 0x1 | 1 << 0x10)) ./your-application
+
+Or, to enable every flag run with every bit set.
+
+.. code-block:: console
+
+   $ env LIBOMPTARGET_INFO=-1 ./your-application
+
 LLVM/OpenMP Target Host Runtime Plugins (``libomptarget.rtl.``)
 ---
 


 

[llvm-branch-commits] [mlir] 75a3f32 - [IR] Add an ImplicitLocOpBuilder helper class for building IR with the same loc.

2020-12-22 Thread Chris Lattner via llvm-branch-commits

Author: Chris Lattner
Date: 2020-12-22T14:47:33-08:00
New Revision: 75a3f326c3d874853031d8bedd1d00127c835103

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

LOG: [IR] Add an ImplicitLocOpBuilder helper class for building IR with the 
same loc.

One common situation is to create a lot of IR at a well known location,
e.g. when doing a big rewrite from one dialect to another where you're expanding
ops out into lots of other ops.

For these sorts of situations, it is annoying to pass the location into
every create call.  As we discused in a few threads on the forum, a way to help
with this is to produce a new sort of builder that holds a location and provides
it to each of the create<> calls automatically.

This patch implements an ImplicitLocOpBuilder class that does this.  We've had
good experience with this in the CIRCT project, and it makes sense to upstream 
to
MLIR.

I picked a random pass to adopt it to show the impact, but I don't think there 
is
any particular need to force adopt it in the codebase.

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

Added: 
mlir/include/mlir/IR/ImplicitLocOpBuilder.h

Modified: 
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp

Removed: 




diff  --git a/mlir/include/mlir/IR/ImplicitLocOpBuilder.h 
b/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
new file mode 100644
index ..2dc7c34f4e85
--- /dev/null
+++ b/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
@@ -0,0 +1,123 @@
+//===- ImplicitLocOpBuilder.h - Convenience OpBuilder ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Helper class to create ops with a modally set location.
+//
+//===--===//
+
+#ifndef MLIR_IR_IMPLICITLOCOPBUILDER_H
+#define MLIR_IR_IMPLICITLOCOPBUILDER_H
+
+#include "mlir/IR/Builders.h"
+
+namespace mlir {
+
+/// ImplictLocOpBuilder maintains a 'current location', allowing use of the
+/// create<> method without specifying the location.  It is otherwise the same
+/// as OpBuilder.
+class ImplicitLocOpBuilder : public mlir::OpBuilder {
+public:
+  /// Create an ImplicitLocOpBuilder using the insertion point and listener 
from
+  /// an existing OpBuilder.
+  ImplicitLocOpBuilder(Location loc, const OpBuilder &builder)
+  : OpBuilder(builder), curLoc(loc) {}
+
+  /// OpBuilder has a bunch of convenience constructors - we support them all
+  /// with the additional Location.
+  template 
+  ImplicitLocOpBuilder(Location loc, T &&operand, Listener *listener = nullptr)
+  : OpBuilder(std::forward(operand), listener), curLoc(loc) {}
+
+  ImplicitLocOpBuilder(Location loc, Block *block, Block::iterator insertPoint,
+   Listener *listener = nullptr)
+  : OpBuilder(block, insertPoint, listener), curLoc(loc) {}
+
+  /// Create a builder and set the insertion point to before the first 
operation
+  /// in the block but still inside the block.
+  static ImplicitLocOpBuilder atBlockBegin(Location loc, Block *block,
+   Listener *listener = nullptr) {
+return ImplicitLocOpBuilder(loc, block, block->begin(), listener);
+  }
+
+  /// Create a builder and set the insertion point to after the last operation
+  /// in the block but still inside the block.
+  static ImplicitLocOpBuilder atBlockEnd(Location loc, Block *block,
+ Listener *listener = nullptr) {
+return ImplicitLocOpBuilder(loc, block, block->end(), listener);
+  }
+
+  /// Create a builder and set the insertion point to before the block
+  /// terminator.
+  static ImplicitLocOpBuilder atBlockTerminator(Location loc, Block *block,
+Listener *listener = nullptr) {
+auto *terminator = block->getTerminator();
+assert(terminator != nullptr && "the block has no terminator");
+return ImplicitLocOpBuilder(loc, block, Block::iterator(terminator),
+listener);
+  }
+
+  /// Accessors for the implied location.
+  Location getLoc() const { return curLoc; }
+  void setLoc(Location loc) { curLoc = loc; }
+
+  // We allow clients to use the explicit-loc version of create as well.
+  using OpBuilder::create;
+  using OpBuilder::createOrFold;
+
+  /// Create an operation of specific op type at the current insertion point 
and
+  /// location.
+  template 
+  OpTy create(Args &&... args) {
+return OpBuilder::create(curLoc, std::forward(args)...);
+  }
+
+  /// Create an op

[llvm-branch-commits] [compiler-rt] 6dfe580 - scudo: Move the configuration for the primary allocator to Config. NFCI.

2020-12-22 Thread Peter Collingbourne via llvm-branch-commits

Author: Peter Collingbourne
Date: 2020-12-22T14:54:40-08:00
New Revision: 6dfe5801e01d259d00198147b27438ffea39e59f

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

LOG: scudo: Move the configuration for the primary allocator to Config. NFCI.

This will allow the primary and secondary allocators to share
the MaySupportMemoryTagging bool.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/allocator_config.h
compiler-rt/lib/scudo/standalone/memtag.h
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h
compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
compiler-rt/lib/scudo/standalone/tests/primary_test.cpp

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/allocator_config.h 
b/compiler-rt/lib/scudo/standalone/allocator_config.h
index 8f1757dab322..12daaa2f6b44 100644
--- a/compiler-rt/lib/scudo/standalone/allocator_config.h
+++ b/compiler-rt/lib/scudo/standalone/allocator_config.h
@@ -25,13 +25,18 @@ namespace scudo {
 
 struct DefaultConfig {
   using SizeClassMap = DefaultSizeClassMap;
+  static const bool MaySupportMemoryTagging = false;
+
 #if SCUDO_CAN_USE_PRIMARY64
-  // 1GB Regions
-  typedef SizeClassAllocator64 Primary;
+  typedef SizeClassAllocator64 Primary;
+  static const uptr PrimaryRegionSizeLog = 30U;
 #else
-  // 512KB regions
-  typedef SizeClassAllocator32 Primary;
+  typedef SizeClassAllocator32 Primary;
+  static const uptr PrimaryRegionSizeLog = 19U;
 #endif
+  static const s32 PrimaryMinReleaseToOsIntervalMs = INT32_MIN;
+  static const s32 PrimaryMaxReleaseToOsIntervalMs = INT32_MAX;
+
   typedef MapAllocatorCache SecondaryCache;
   static const u32 SecondaryCacheEntriesArraySize = 32U;
   static const u32 SecondaryCacheDefaultMaxEntriesCount = 32U;
@@ -44,15 +49,18 @@ struct DefaultConfig {
 
 struct AndroidConfig {
   using SizeClassMap = AndroidSizeClassMap;
+  static const bool MaySupportMemoryTagging = true;
+
 #if SCUDO_CAN_USE_PRIMARY64
-  // 256MB regions
-  typedef SizeClassAllocator64
-  Primary;
+  typedef SizeClassAllocator64 Primary;
+  static const uptr PrimaryRegionSizeLog = 28U;
 #else
-  // 256KB regions
-  typedef SizeClassAllocator32 Primary;
+  typedef SizeClassAllocator32 Primary;
+  static const uptr PrimaryRegionSizeLog = 18U;
 #endif
+  static const s32 PrimaryMinReleaseToOsIntervalMs = 1000;
+  static const s32 PrimaryMaxReleaseToOsIntervalMs = 1000;
+
   typedef MapAllocatorCache SecondaryCache;
   static const u32 SecondaryCacheEntriesArraySize = 256U;
   static const u32 SecondaryCacheDefaultMaxEntriesCount = 32U;
@@ -66,13 +74,18 @@ struct AndroidConfig {
 
 struct AndroidSvelteConfig {
   using SizeClassMap = SvelteSizeClassMap;
+  static const bool MaySupportMemoryTagging = false;
+
 #if SCUDO_CAN_USE_PRIMARY64
-  // 128MB regions
-  typedef SizeClassAllocator64 Primary;
+  typedef SizeClassAllocator64 Primary;
+  static const uptr PrimaryRegionSizeLog = 27U;
 #else
-  // 64KB regions
-  typedef SizeClassAllocator32 Primary;
+  typedef SizeClassAllocator32 Primary;
+  static const uptr PrimaryRegionSizeLog = 16U;
 #endif
+  static const s32 PrimaryMinReleaseToOsIntervalMs = 1000;
+  static const s32 PrimaryMaxReleaseToOsIntervalMs = 1000;
+
   typedef MapAllocatorCache SecondaryCache;
   static const u32 SecondaryCacheEntriesArraySize = 16U;
   static const u32 SecondaryCacheDefaultMaxEntriesCount = 4U;
@@ -86,8 +99,14 @@ struct AndroidSvelteConfig {
 
 #if SCUDO_CAN_USE_PRIMARY64
 struct FuchsiaConfig {
-  // 1GB Regions
-  typedef SizeClassAllocator64 Primary;
+  using SizeClassMap = DefaultSizeClassMap;
+  static const bool MaySupportMemoryTagging = false;
+
+  typedef SizeClassAllocator64 Primary;
+  static const uptr PrimaryRegionSizeLog = 30U;
+  static const s32 PrimaryMinReleaseToOsIntervalMs = INT32_MIN;
+  static const s32 PrimaryMaxReleaseToOsIntervalMs = INT32_MAX;
+
   typedef MapAllocatorNoCache SecondaryCache;
   template 
   using TSDRegistryT = TSDRegistrySharedT; // Shared, max 8 TSDs.

diff  --git a/compiler-rt/lib/scudo/standalone/memtag.h 
b/compiler-rt/lib/scudo/standalone/memtag.h
index c3c4f574b4fc..d848e3a0b6c9 100644
--- a/compiler-rt/lib/scudo/standalone/memtag.h
+++ b/compiler-rt/lib/scudo/standalone/memtag.h
@@ -268,6 +268,11 @@ inline void setRandomTag(void *Ptr, uptr Size, uptr 
ExcludeMask,
   *TaggedEnd = storeTags(*TaggedBegin, *TaggedBegin + Size);
 }
 
+template 
+inline constexpr bool allocatorSupportsMemoryTagging() {
+  return archSupportsMemoryTagging() && Config::MaySupportMemoryTagging;
+}
+
 } // namespace scudo
 
 #endif

diff  --git a/compiler-rt/lib/scudo/standalone/primary32.h 
b/compiler-rt/lib/scudo/standalone/primary32.h
index 0db95d2e1f11.

[llvm-branch-commits] [llvm] ca4bf58 - [AMDGPU] Support unaligned flat scratch in TLI

2020-12-22 Thread Stanislav Mekhanoshin via llvm-branch-commits

Author: Stanislav Mekhanoshin
Date: 2020-12-22T16:12:31-08:00
New Revision: ca4bf58e4ee5951473a861716193063c5ef83e9a

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

LOG: [AMDGPU] Support unaligned flat scratch in TLI

Adjust SITargetLowering::allowsMisalignedMemoryAccessesImpl for
unaligned flat scratch support. Mostly needed for global isel.

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/test/CodeGen/AMDGPU/chain-hi-to-lo.ll
llvm/test/CodeGen/AMDGPU/unaligned-load-store.ll
llvm/test/Transforms/LoadStoreVectorizer/AMDGPU/adjust-alloca-alignment.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 5fb1924bdd9f..81fdfa0343b3 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -1470,12 +1470,21 @@ bool 
SITargetLowering::allowsMisalignedMemoryAccessesImpl(
 }
   }
 
+  if (AddrSpace == AMDGPUAS::PRIVATE_ADDRESS) {
+bool AlignedBy4 = Alignment >= Align(4);
+if (IsFast)
+  *IsFast = AlignedBy4;
+
+return AlignedBy4 ||
+   Subtarget->enableFlatScratch() ||
+   Subtarget->hasUnalignedScratchAccess();
+  }
+
   // FIXME: We have to be conservative here and assume that flat operations
   // will access scratch.  If we had access to the IR function, then we
   // could determine if any private memory was used in the function.
-  if (!Subtarget->hasUnalignedScratchAccess() &&
-  (AddrSpace == AMDGPUAS::PRIVATE_ADDRESS ||
-   AddrSpace == AMDGPUAS::FLAT_ADDRESS)) {
+  if (AddrSpace == AMDGPUAS::FLAT_ADDRESS &&
+  !Subtarget->hasUnalignedScratchAccess()) {
 bool AlignedBy4 = Alignment >= Align(4);
 if (IsFast)
   *IsFast = AlignedBy4;

diff  --git a/llvm/test/CodeGen/AMDGPU/chain-hi-to-lo.ll 
b/llvm/test/CodeGen/AMDGPU/chain-hi-to-lo.ll
index 271f6c703980..8e37b413ddf5 100644
--- a/llvm/test/CodeGen/AMDGPU/chain-hi-to-lo.ll
+++ b/llvm/test/CodeGen/AMDGPU/chain-hi-to-lo.ll
@@ -271,16 +271,9 @@ define amdgpu_kernel void @vload2_private(i16 
addrspace(1)* nocapture readonly %
 ; FLATSCR-NEXT:s_waitcnt vmcnt(0)
 ; FLATSCR-NEXT:scratch_store_short off, v0, vcc_hi offset:8
 ; FLATSCR-NEXT:s_mov_b32 vcc_hi, 0
-; FLATSCR-NEXT:scratch_load_ushort v0, off, vcc_hi offset:4
+; FLATSCR-NEXT:scratch_load_dword v0, off, vcc_hi offset:4
 ; FLATSCR-NEXT:s_mov_b32 vcc_hi, 0
-; FLATSCR-NEXT:scratch_load_ushort v3, off, vcc_hi offset:6
-; FLATSCR-NEXT:s_mov_b32 vcc_hi, 0
-; FLATSCR-NEXT:s_waitcnt vmcnt(1)
-; FLATSCR-NEXT:v_and_b32_e32 v0, 0x, v0
-; FLATSCR-NEXT:s_waitcnt vmcnt(0)
-; FLATSCR-NEXT:v_mov_b32_e32 v1, v3
-; FLATSCR-NEXT:scratch_load_short_d16_hi v1, off, vcc_hi offset:8
-; FLATSCR-NEXT:v_lshl_or_b32 v0, v3, 16, v0
+; FLATSCR-NEXT:scratch_load_dword v1, off, vcc_hi offset:6
 ; FLATSCR-NEXT:s_waitcnt vmcnt(0)
 ; FLATSCR-NEXT:global_store_dwordx2 v2, v[0:1], s[2:3]
 ; FLATSCR-NEXT:s_endpgm

diff  --git a/llvm/test/CodeGen/AMDGPU/unaligned-load-store.ll 
b/llvm/test/CodeGen/AMDGPU/unaligned-load-store.ll
index 5d5cfd318edf..645eead8c297 100644
--- a/llvm/test/CodeGen/AMDGPU/unaligned-load-store.ll
+++ b/llvm/test/CodeGen/AMDGPU/unaligned-load-store.ll
@@ -1,6 +1,7 @@
-; RUN: llc -march=amdgcn -verify-machineinstrs< %s | FileCheck 
-check-prefix=SI -check-prefix=ALIGNED %s
-; RUN: llc -march=amdgcn -mcpu=bonaire -mattr=+unaligned-access-mode 
-verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=UNALIGNED 
%s
-; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global 
-verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=ALIGNED %s
+; RUN: llc -march=amdgcn -verify-machineinstrs< %s | FileCheck 
-check-prefixes=SI,MUBUF,ALIGNED %s
+; RUN: llc -march=amdgcn -mcpu=bonaire -mattr=+unaligned-access-mode 
-verify-machineinstrs< %s | FileCheck -check-prefixes=SI,MUBUF,UNALIGNED %s
+; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global 
-verify-machineinstrs< %s | FileCheck -check-prefixes=SI,MUBUF,ALIGNED %s
+; RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=-flat-for-global 
-amdgpu-enable-flat-scratch -verify-machineinstrs < %s | FileCheck 
-check-prefixes=SI,FLATSCR,ALIGNED %s
 
 ; SI-LABEL: {{^}}local_unaligned_load_store_i16:
 ; SI: ds_read_u8
@@ -602,64 +603,70 @@ define amdgpu_kernel void @local_store_align1_v16i8(<16 x 
i8> addrspace(3)* %out
 }
 
 ; SI-LABEL: {{^}}private_load_align1_f64:
-; SI: buffer_load_ubyte
-; SI: buffer_load_ubyte
-; SI: buffer_load_ubyte
-; SI: buffer_load_ubyte
-; SI: buffer_load_ubyte
-; SI: buffer_load_ubyte
-; SI: buffer_load_ubyte
-; SI: buffer_load_ubyte
+; MUBUF: buffer_load_ubyte
+; MUB

[llvm-branch-commits] [llvm] d15119a - [AMDGPU][GlobalISel] GlobalISel for flat scratch

2020-12-22 Thread Stanislav Mekhanoshin via llvm-branch-commits

Author: Stanislav Mekhanoshin
Date: 2020-12-22T16:33:06-08:00
New Revision: d15119a02d92274cd7f779f4bb8485b1020110e0

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

LOG: [AMDGPU][GlobalISel] GlobalISel for flat scratch

It does not seem to fold offsets but this is not specific
to the flat scratch as getPtrBaseWithConstantOffset() does
not return the split for these tests unlike its SDag
counterpart.

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

Added: 
llvm/test/CodeGen/AMDGPU/GlobalISel/flat-scratch.ll

Modified: 
llvm/lib/Target/AMDGPU/AMDGPUGISel.td
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUGISel.td 
b/llvm/lib/Target/AMDGPU/AMDGPUGISel.td
index 661b96a6a98e..bba03736d01a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUGISel.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPUGISel.td
@@ -85,6 +85,14 @@ def gi_mubuf_scratch_offen :
 GIComplexOperandMatcher,
 GIComplexPatternEquiv;
 
+def gi_flat_scratch_offset :
+GIComplexOperandMatcher,
+GIComplexPatternEquiv;
+
+def gi_flat_scratch_saddr :
+GIComplexOperandMatcher,
+GIComplexPatternEquiv;
+
 def gi_ds_1addr_1offset :
 GIComplexOperandMatcher,
 GIComplexPatternEquiv;

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index b157c03672d1..6c2ff0972ae5 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -3589,6 +3589,67 @@ 
AMDGPUInstructionSelector::selectGlobalSAddr(MachineOperand &Root) const {
}}};
 }
 
+InstructionSelector::ComplexRendererFns
+AMDGPUInstructionSelector::selectScratchSAddr(MachineOperand &Root) const {
+  Register Addr = Root.getReg();
+  Register PtrBase;
+  int64_t ConstOffset;
+  int64_t ImmOffset = 0;
+
+  // Match the immediate offset first, which canonically is moved as low as
+  // possible.
+  std::tie(PtrBase, ConstOffset) = getPtrBaseWithConstantOffset(Addr, *MRI);
+
+  if (ConstOffset != 0 &&
+  TII.isLegalFLATOffset(ConstOffset, AMDGPUAS::PRIVATE_ADDRESS, true)) {
+Addr = PtrBase;
+ImmOffset = ConstOffset;
+  }
+
+  auto AddrDef = getDefSrcRegIgnoringCopies(Addr, *MRI);
+  if (!AddrDef)
+return None;
+
+  if (AddrDef->MI->getOpcode() == AMDGPU::G_FRAME_INDEX) {
+int FI = AddrDef->MI->getOperand(1).getIndex();
+return {{
+[=](MachineInstrBuilder &MIB) { MIB.addFrameIndex(FI); }, // saddr
+[=](MachineInstrBuilder &MIB) { MIB.addImm(ImmOffset); } // offset
+}};
+  }
+
+  Register SAddr = AddrDef->Reg;
+
+  if (AddrDef->MI->getOpcode() == AMDGPU::G_PTR_ADD) {
+Register LHS = AddrDef->MI->getOperand(1).getReg();
+Register RHS = AddrDef->MI->getOperand(2).getReg();
+auto LHSDef = getDefSrcRegIgnoringCopies(LHS, *MRI);
+auto RHSDef = getDefSrcRegIgnoringCopies(RHS, *MRI);
+
+if (LHSDef && RHSDef &&
+LHSDef->MI->getOpcode() == AMDGPU::G_FRAME_INDEX &&
+isSGPR(RHSDef->Reg)) {
+  int FI = LHSDef->MI->getOperand(1).getIndex();
+  MachineInstr &I = *Root.getParent();
+  MachineBasicBlock *BB = I.getParent();
+  const DebugLoc &DL = I.getDebugLoc();
+  SAddr = MRI->createVirtualRegister(&AMDGPU::SReg_32RegClass);
+
+  BuildMI(*BB, &I, DL, TII.get(AMDGPU::S_ADD_U32), SAddr)
+.addFrameIndex(FI)
+.addReg(RHSDef->Reg);
+}
+  }
+
+  if (!isSGPR(SAddr))
+return None;
+
+  return {{
+  [=](MachineInstrBuilder &MIB) { MIB.addReg(SAddr); }, // saddr
+  [=](MachineInstrBuilder &MIB) { MIB.addImm(ImmOffset); } // offset
+  }};
+}
+
 static bool isStackPtrRelative(const MachinePointerInfo &PtrInfo) {
   auto PSV = PtrInfo.V.dyn_cast();
   return PSV && PSV->isStack();

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h 
b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
index c575e7e9c8a5..c6b26ea70659 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
@@ -200,6 +200,9 @@ class AMDGPUInstructionSelector final : public 
InstructionSelector {
   InstructionSelector::ComplexRendererFns
   selectGlobalSAddr(MachineOperand &Root) const;
 
+  InstructionSelector::ComplexRendererFns
+  selectScratchSAddr(MachineOperand &Root) const;
+
   InstructionSelector::ComplexRendererFns
   selectMUBUFScratchOffen(MachineOperand &Root) const;
   InstructionSelector::ComplexRendererFns

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
index 9b39b86ae28f..28cd867d40be 100644
--- a/llvm/lib/Target/AMDGP

[llvm-branch-commits] [compiler-rt] e6b3db6 - scudo: Replace the Cache argument on MapAllocator with a Config argument. NFCI.

2020-12-22 Thread Peter Collingbourne via llvm-branch-commits

Author: Peter Collingbourne
Date: 2020-12-22T16:52:48-08:00
New Revision: e6b3db6309f201075dd97fdfb89297f481bcee6e

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

LOG: scudo: Replace the Cache argument on MapAllocator with a Config argument. 
NFCI.

This will allow the secondary allocator to access the
MaySupportMemoryTagging bool.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/combined.h
compiler-rt/lib/scudo/standalone/secondary.h
compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/combined.h 
b/compiler-rt/lib/scudo/standalone/combined.h
index 7bf108e0b5e0..fae71ba1b84f 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -930,7 +930,7 @@ class Allocator {
   }
 
 private:
-  using SecondaryT = MapAllocator;
+  using SecondaryT = MapAllocator;
   typedef typename PrimaryT::SizeClassMap SizeClassMap;
 
   static const uptr MinAlignmentLog = SCUDO_MIN_ALIGNMENT_LOG;

diff  --git a/compiler-rt/lib/scudo/standalone/secondary.h 
b/compiler-rt/lib/scudo/standalone/secondary.h
index cccbeb239dae..063640106abb 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -245,7 +245,7 @@ template  class MapAllocatorCache {
   atomic_s32 ReleaseToOsIntervalMs;
 };
 
-template  class MapAllocator {
+template  class MapAllocator {
 public:
   void initLinkerInitialized(GlobalStats *S, s32 ReleaseToOsInterval = -1) {
 Cache.initLinkerInitialized(ReleaseToOsInterval);
@@ -295,7 +295,7 @@ template  class MapAllocator {
   void releaseToOS() { Cache.releaseToOS(); }
 
 private:
-  CacheT Cache;
+  typename Config::SecondaryCache Cache;
 
   HybridMutex Mutex;
   DoublyLinkedList InUseBlocks;
@@ -318,8 +318,8 @@ template  class MapAllocator {
 // For allocations requested with an alignment greater than or equal to a page,
 // the committed memory will amount to something close to Size - AlignmentHint
 // (pending rounding and headers).
-template 
-void *MapAllocator::allocate(uptr Size, uptr AlignmentHint,
+template 
+void *MapAllocator::allocate(uptr Size, uptr AlignmentHint,
  uptr *BlockEnd,
  FillContentsMode FillContents) {
   DCHECK_GE(Size, AlignmentHint);
@@ -410,7 +410,7 @@ void *MapAllocator::allocate(uptr Size, uptr 
AlignmentHint,
   return reinterpret_cast(Ptr + LargeBlock::getHeaderSize());
 }
 
-template  void MapAllocator::deallocate(void *Ptr) {
+template  void MapAllocator::deallocate(void *Ptr) {
   LargeBlock::Header *H = LargeBlock::getHeader(Ptr);
   const uptr Block = reinterpret_cast(H);
   const uptr CommitSize = H->BlockEnd - Block;
@@ -430,8 +430,8 @@ template  void 
MapAllocator::deallocate(void *Ptr) {
   unmap(Addr, Size, UNMAP_ALL, &Data);
 }
 
-template 
-void MapAllocator::getStats(ScopedString *Str) const {
+template 
+void MapAllocator::getStats(ScopedString *Str) const {
   Str->append(
   "Stats: MapAllocator: allocated %zu times (%zuK), freed %zu times "
   "(%zuK), remains %zu (%zuK) max %zuM\n",

diff  --git a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp 
b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
index 3c1e77987ec4..846ec8f6d6fa 100644
--- a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
@@ -19,7 +19,9 @@
 #include 
 #include 
 
-template  static void testSecondaryBasic(void) {
+template  static void testSecondaryBasic(void) {
+  using SecondaryT = scudo::MapAllocator;
+
   scudo::GlobalStats S;
   S.init();
   std::unique_ptr L(new SecondaryT);
@@ -55,7 +57,12 @@ template  static void 
testSecondaryBasic(void) {
   Str.output();
 }
 
+struct NoCacheConfig {
+  typedef scudo::MapAllocatorNoCache SecondaryCache;
+};
+
 struct TestConfig {
+  typedef scudo::MapAllocatorCache SecondaryCache;
   static const scudo::u32 SecondaryCacheEntriesArraySize = 128U;
   static const scudo::u32 SecondaryCacheDefaultMaxEntriesCount = 64U;
   static const scudo::uptr SecondaryCacheDefaultMaxEntrySize = 1UL << 20;
@@ -64,15 +71,12 @@ struct TestConfig {
 };
 
 TEST(ScudoSecondaryTest, SecondaryBasic) {
-  testSecondaryBasic>();
-  testSecondaryBasic<
-  scudo::MapAllocator>>();
-  testSecondaryBasic<
-  scudo::MapAllocator>>();
+  testSecondaryBasic();
+  testSecondaryBasic();
+  testSecondaryBasic();
 }
 
-using LargeAllocator =
-scudo::MapAllocator>;
+using LargeAllocator = scudo::MapAllocator;
 
 // This exercises a variety of combinations of size and alignment for the
 // MapAllocator. The size computation done here mimic 

[llvm-branch-commits] [compiler-rt] faac1c0 - scudo: Move the management of the UseMemoryTagging bit out of the Primary. NFCI.

2020-12-22 Thread Peter Collingbourne via llvm-branch-commits

Author: Peter Collingbourne
Date: 2020-12-22T16:52:54-08:00
New Revision: faac1c02c802048efa17f8f6cda8f39b5584f0c6

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

LOG: scudo: Move the management of the UseMemoryTagging bit out of the Primary. 
NFCI.

The primary and secondary allocators will need to share this bit,
so move the management of the bit to the combined allocator and
make useMemoryTagging() a free function.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/combined.h
compiler-rt/lib/scudo/standalone/options.h
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h
compiler-rt/lib/scudo/standalone/tests/combined_test.cpp

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/combined.h 
b/compiler-rt/lib/scudo/standalone/combined.h
index fae71ba1b84f..911c49dcc3fd 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -100,7 +100,7 @@ class Allocator {
 
   // Reset tag to 0 as this chunk may have been previously used for a 
tagged
   // user allocation.
-  if (UNLIKELY(Allocator.useMemoryTagging()))
+  if (UNLIKELY(useMemoryTagging(Allocator.Primary.Options.load(
 storeTags(reinterpret_cast(Ptr),
   reinterpret_cast(Ptr) + sizeof(QuarantineBatch));
 
@@ -161,6 +161,9 @@ class Allocator {
   Primary.Options.set(OptionBit::DeallocTypeMismatch);
 if (getFlags()->delete_size_mismatch)
   Primary.Options.set(OptionBit::DeleteSizeMismatch);
+if (allocatorSupportsMemoryTagging() &&
+systemSupportsMemoryTagging())
+  Primary.Options.set(OptionBit::UseMemoryTagging);
 Primary.Options.set(OptionBit::UseOddEvenTags);
 
 QuarantineMaxChunkSize =
@@ -240,7 +243,7 @@ class Allocator {
   }
 
   ALWAYS_INLINE void *untagPointerMaybe(void *Ptr) {
-if (Primary.SupportsMemoryTagging)
+if (allocatorSupportsMemoryTagging())
   return reinterpret_cast(
   untagPointer(reinterpret_cast(Ptr)));
 return Ptr;
@@ -367,7 +370,7 @@ class Allocator {
   //
   // When memory tagging is enabled, zeroing the contents is done as part 
of
   // setting the tag.
-  if (UNLIKELY(useMemoryTagging(Options))) {
+  if (UNLIKELY(useMemoryTagging(Options))) {
 uptr PrevUserPtr;
 Chunk::UnpackedHeader Header;
 const uptr BlockSize = PrimaryT::getSizeByClassId(ClassId);
@@ -594,7 +597,7 @@ class Allocator {
  : BlockEnd - (reinterpret_cast(OldPtr) + NewSize)) &
 Chunk::SizeOrUnusedBytesMask;
 Chunk::compareExchangeHeader(Cookie, OldPtr, &NewHeader, &OldHeader);
-if (UNLIKELY(ClassId && useMemoryTagging(Options))) {
+if (UNLIKELY(ClassId && useMemoryTagging(Options))) {
   resizeTaggedChunk(reinterpret_cast(OldTaggedPtr) + OldSize,
 reinterpret_cast(OldTaggedPtr) + NewSize,
 BlockEnd);
@@ -692,7 +695,7 @@ class Allocator {
   if (getChunkFromBlock(Block, &Chunk, &Header) &&
   Header.State == Chunk::State::Allocated) {
 uptr TaggedChunk = Chunk;
-if (useMemoryTagging(Primary.Options.load()))
+if (useMemoryTagging(Primary.Options.load()))
   TaggedChunk = loadTag(Chunk);
 Callback(TaggedChunk, getSize(reinterpret_cast(Chunk), 
&Header),
  Arg);
@@ -783,15 +786,14 @@ class Allocator {
Header.State == Chunk::State::Allocated;
   }
 
-  bool useMemoryTagging() const {
-return useMemoryTagging(Primary.Options.load());
+  bool useMemoryTaggingTestOnly() const {
+return useMemoryTagging(Primary.Options.load());
   }
-  static bool useMemoryTagging(Options Options) {
-return PrimaryT::useMemoryTagging(Options);
+  void disableMemoryTagging() {
+if (allocatorSupportsMemoryTagging())
+  Primary.Options.clear(OptionBit::UseMemoryTagging);
   }
 
-  void disableMemoryTagging() { Primary.disableMemoryTagging(); }
-
   void setTrackAllocationStacks(bool Track) {
 initThreadMaybe();
 if (Track)
@@ -823,7 +825,7 @@ class Allocator {
const char *MemoryTags, uintptr_t MemoryAddr,
size_t MemorySize) {
 *ErrorInfo = {};
-if (!PrimaryT::SupportsMemoryTagging ||
+if (!allocatorSupportsMemoryTagging() ||
 MemoryAddr + MemorySize < MemoryAddr)
   return;
 
@@ -942,7 +944,7 @@ class Allocator {
 
   static_assert(MinAlignment >= sizeof(Chunk::PackedHeader),
 "Minimal alignment must at least cover a chunk header.");
-  static_assert(!PrimaryT::SupportsMemoryTagging ||
+  static_assert(!allocatorSupport

[llvm-branch-commits] [clang] 22cf54a - Replace `T(x)` with `reinterpret_cast(x)` everywhere it means reinterpret_cast. NFC.

2020-12-22 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2020-12-22T19:54:29-05:00
New Revision: 22cf54a7fba670642c121684ac3c7ff7e35dfa5c

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

LOG: Replace `T(x)` with `reinterpret_cast(x)` everywhere it means 
reinterpret_cast. NFC.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.h
llvm/include/llvm/IR/SymbolTableListTraits.h
llvm/include/llvm/Object/Binary.h
llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
llvm/lib/Object/COFFObjectFile.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/Object/XCOFFObjectFile.cpp
llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h
index 509ca43a9784..e3d9fec6d363 100644
--- a/clang/lib/CodeGen/CGCall.h
+++ b/clang/lib/CodeGen/CGCall.h
@@ -110,7 +110,8 @@ class CGCallee {
   /// Construct a callee.  Call this constructor directly when this
   /// isn't a direct call.
   CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr)
-  : KindOrFunctionPointer(SpecialKind(uintptr_t(functionPtr))) {
+  : KindOrFunctionPointer(
+SpecialKind(reinterpret_cast(functionPtr))) {
 AbstractInfo = abstractInfo;
 assert(functionPtr && "configuring callee without function pointer");
 assert(functionPtr->getType()->isPointerTy());
@@ -186,7 +187,8 @@ class CGCallee {
   }
   void setFunctionPointer(llvm::Value *functionPtr) {
 assert(isOrdinary());
-KindOrFunctionPointer = SpecialKind(uintptr_t(functionPtr));
+KindOrFunctionPointer =
+SpecialKind(reinterpret_cast(functionPtr));
   }
 
   bool isVirtual() const {

diff  --git a/llvm/include/llvm/IR/SymbolTableListTraits.h 
b/llvm/include/llvm/IR/SymbolTableListTraits.h
index 5b793e5dbf28..8af712374bfa 100644
--- a/llvm/include/llvm/IR/SymbolTableListTraits.h
+++ b/llvm/include/llvm/IR/SymbolTableListTraits.h
@@ -76,9 +76,11 @@ class SymbolTableListTraits : public 
ilist_alloc_traits {
   /// getListOwner - Return the object that owns this list.  If this is a list
   /// of instructions, it returns the BasicBlock that owns them.
   ItemParentClass *getListOwner() {
-size_t Offset(size_t(&((ItemParentClass*)nullptr->*ItemParentClass::
-   
getSublistAccess(static_cast(nullptr);
-ListTy *Anchor(static_cast(this));
+size_t Offset = reinterpret_cast(
+&((ItemParentClass *)nullptr->*ItemParentClass::getSublistAccess(
+   static_cast(
+   nullptr;
+ListTy *Anchor = static_cast(this);
 return reinterpret_cast(reinterpret_cast(Anchor)-
   Offset);
   }

diff  --git a/llvm/include/llvm/Object/Binary.h 
b/llvm/include/llvm/Object/Binary.h
index e12e512d68b8..dd98e1143e25 100644
--- a/llvm/include/llvm/Object/Binary.h
+++ b/llvm/include/llvm/Object/Binary.h
@@ -165,8 +165,8 @@ class Binary {
   static Error checkOffset(MemoryBufferRef M, uintptr_t Addr,
const uint64_t Size) {
 if (Addr + Size < Addr || Addr + Size < Size ||
-Addr + Size > uintptr_t(M.getBufferEnd()) ||
-Addr < uintptr_t(M.getBufferStart())) {
+Addr + Size > reinterpret_cast(M.getBufferEnd()) ||
+Addr < reinterpret_cast(M.getBufferStart())) {
   return errorCodeToError(object_error::unexpected_eof);
 }
 return Error::success();

diff  --git a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
index 8fa83f515910..354b638b47a2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
@@ -145,9 +145,10 @@ void OcamlGCMetadataPrinter::finishAssembly(Module &M, 
GCModuleInfo &Info,
   report_fatal_error("Function '" + FI.getFunction().getName() +
  "' is too large for the ocaml GC! "
  "Frame size " +
- Twine(FrameSize) + ">= 65536.\n"
-"(" +
- Twine(uintptr_t(&FI)) + ")");
+ Twine(FrameSize) +
+ ">= 65536.\n"
+ "(" +
+ Twine(reinterpret_cast(&FI)) + ")");
 }
 
 AP.OutStreamer->AddComment("live roots for " +

diff  --git a/llvm/lib/Object/COFFObjectFile.cpp 
b/llvm/lib/Object/COFFObjectFile.cpp
index c0902597fadf..2e44a38ccdaa 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -57,7 +57,7 @@ static bool checkSize(MemoryBufferRef M, std::error_code &EC,

[llvm-branch-commits] [llvm] 5bec082 - VirtRegMap: Use Register

2020-12-22 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-22T20:56:14-05:00
New Revision: 5bec0828347893544ab863ddf4caa2f0b5ef79dd

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

LOG: VirtRegMap: Use Register

Added: 


Modified: 
llvm/include/llvm/CodeGen/VirtRegMap.h
llvm/lib/CodeGen/LiveRangeEdit.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/VirtRegMap.h 
b/llvm/include/llvm/CodeGen/VirtRegMap.h
index 1775afb51bdf..deef4b90279a 100644
--- a/llvm/include/llvm/CodeGen/VirtRegMap.h
+++ b/llvm/include/llvm/CodeGen/VirtRegMap.h
@@ -151,7 +151,7 @@ class TargetInstrInfo;
 bool hasKnownPreference(Register VirtReg);
 
 /// records virtReg is a split live interval from SReg.
-void setIsSplitFromReg(Register virtReg, unsigned SReg) {
+void setIsSplitFromReg(Register virtReg, Register SReg) {
   Virt2SplitMap[virtReg.id()] = SReg;
   if (hasShape(SReg)) {
 Virt2ShapeMap[virtReg.id()] = getShape(SReg);
@@ -159,7 +159,7 @@ class TargetInstrInfo;
 }
 
 /// returns the live interval virtReg is split from.
-unsigned getPreSplitReg(Register virtReg) const {
+Register getPreSplitReg(Register virtReg) const {
   return Virt2SplitMap[virtReg.id()];
 }
 
@@ -167,8 +167,8 @@ class TargetInstrInfo;
 /// from through splitting.
 /// A register that was not created by splitting is its own original.
 /// This operation is idempotent.
-unsigned getOriginal(unsigned VirtReg) const {
-  unsigned Orig = getPreSplitReg(VirtReg);
+Register getOriginal(Register VirtReg) const {
+  Register Orig = getPreSplitReg(VirtReg);
   return Orig ? Orig : VirtReg;
 }
 

diff  --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp 
b/llvm/lib/CodeGen/LiveRangeEdit.cpp
index dbf02802d473..037cb5426235 100644
--- a/llvm/lib/CodeGen/LiveRangeEdit.cpp
+++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp
@@ -435,7 +435,7 @@ void 
LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl &Dead,
 if (!SplitLIs.empty())
   ++NumFracRanges;
 
-unsigned Original = VRM ? VRM->getOriginal(VReg) : 0;
+Register Original = VRM ? VRM->getOriginal(VReg) : Register();
 for (const LiveInterval *SplitLI : SplitLIs) {
   // If LI is an original interval that hasn't been split yet, make the new
   // intervals their own originals instead of referring to LI. The original



___
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] 29ed846 - AMDGPU: Fix assert when checking for implicit operand legality

2020-12-22 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-22T20:56:24-05:00
New Revision: 29ed846d671117b9a635767dac43cb19fb5ce11f

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

LOG: AMDGPU: Fix assert when checking for implicit operand legality

Added: 


Modified: 
llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
llvm/test/CodeGen/AMDGPU/si-fix-sgpr-copies.mir

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp 
b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
index 75a54c0a412e..d6c151d3d2cc 100644
--- a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
@@ -213,8 +213,12 @@ static bool tryChangeVGPRtoSGPRinCopy(MachineInstr &MI,
 if (UseMI == &MI)
   continue;
 if (MO.isDef() || UseMI->getParent() != MI.getParent() ||
-UseMI->getOpcode() <= TargetOpcode::GENERIC_OP_END ||
-!TII->isOperandLegal(*UseMI, UseMI->getOperandNo(&MO), &Src))
+UseMI->getOpcode() <= TargetOpcode::GENERIC_OP_END)
+  return false;
+
+unsigned OpIdx = UseMI->getOperandNo(&MO);
+if (OpIdx >= UseMI->getDesc().getNumOperands() ||
+!TII->isOperandLegal(*UseMI, OpIdx, &Src))
   return false;
   }
   // Change VGPR to SGPR destination.

diff  --git a/llvm/test/CodeGen/AMDGPU/si-fix-sgpr-copies.mir 
b/llvm/test/CodeGen/AMDGPU/si-fix-sgpr-copies.mir
index e96f2839ab02..6c438d80e532 100644
--- a/llvm/test/CodeGen/AMDGPU/si-fix-sgpr-copies.mir
+++ b/llvm/test/CodeGen/AMDGPU/si-fix-sgpr-copies.mir
@@ -72,3 +72,19 @@ body: |
 %1:sreg_32_xm0 = COPY %0
 S_ENDPGM 0, implicit %1
 ...
+
+# Make sure there's no assert when looking at the implicit use on S_ENDPGM
+# GCN-LABEL: name: s_to_v_copy_implicit_use
+# GCN: %0:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM undef %1:sreg_64, 0, 0, 0 :: 
(load 4, addrspace 4)
+# GCN-NEXT: %2:vgpr_32 = COPY %0
+# GCN-NEXT: S_ENDPGM 0, implicit %2
+---
+name: s_to_v_copy_implicit_use
+tracksRegLiveness: true
+body:   |
+  bb.0:
+%0:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM undef %2:sreg_64, 0, 0, 0 :: (load 
4, addrspace 4)
+%1:vgpr_32 = COPY %0
+S_ENDPGM 0, implicit %1
+
+...



___
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] bac5463 - AMDGPU: Add spilled CSR SGPRs to entry block live ins

2020-12-22 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-22T21:55:59-05:00
New Revision: bac54639c7be602cabffcc3b801316f784f1c4b1

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

LOG: AMDGPU: Add spilled CSR SGPRs to entry block live ins

Added: 
llvm/test/CodeGen/AMDGPU/csr-sgpr-spill-live-ins.mir

Modified: 
llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp 
b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp
index 130edd83bef6..65c7f49b646c 100644
--- a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp
+++ b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp
@@ -185,6 +185,16 @@ void 
SILowerSGPRSpills::calculateSaveRestoreBlocks(MachineFunction &MF) {
   }
 }
 
+// TODO: To support shrink wrapping, this would need to copy
+// PrologEpilogInserter's updateLiveness.
+static void updateLiveness(MachineFunction &MF, ArrayRef CSI) 
{
+  MachineBasicBlock &EntryBB = MF.front();
+
+  for (const CalleeSavedInfo &CSIReg : CSI)
+EntryBB.addLiveIn(CSIReg.getReg());
+  EntryBB.sortUniqueLiveIns();
+}
+
 bool SILowerSGPRSpills::spillCalleeSavedRegs(MachineFunction &MF) {
   MachineRegisterInfo &MRI = MF.getRegInfo();
   const Function &F = MF.getFunction();
@@ -222,6 +232,10 @@ bool 
SILowerSGPRSpills::spillCalleeSavedRegs(MachineFunction &MF) {
   for (MachineBasicBlock *SaveBlock : SaveBlocks)
 insertCSRSaves(*SaveBlock, CSI, LIS);
 
+  // Add live ins to save blocks.
+  assert(SaveBlocks.size() == 1 && "shrink wrapping not fully 
implemented");
+  updateLiveness(MF, CSI);
+
   for (MachineBasicBlock *RestoreBlock : RestoreBlocks)
 insertCSRRestores(*RestoreBlock, CSI, LIS);
   return true;

diff  --git a/llvm/test/CodeGen/AMDGPU/csr-sgpr-spill-live-ins.mir 
b/llvm/test/CodeGen/AMDGPU/csr-sgpr-spill-live-ins.mir
new file mode 100644
index ..6bc94455e0a8
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/csr-sgpr-spill-live-ins.mir
@@ -0,0 +1,35 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=amdgcn -mcpu=gfx906 
-run-pass=si-lower-sgpr-spills,prologepilog -o - %s | FileCheck %s
+
+# Make sure the modified CSR VGPRs are added as live-in to the entry
+# block.
+
+---
+name: def_csr_sgpr
+tracksRegLiveness: true
+machineFunctionInfo:
+  scratchRSrcReg: $sgpr0_sgpr1_sgpr2_sgpr3
+  stackPtrOffsetReg: $sgpr32
+body: |
+  ; CHECK-LABEL: name: def_csr_sgpr
+  ; CHECK: bb.0:
+  ; CHECK:   successors: %bb.1(0x8000)
+  ; CHECK:   liveins: $sgpr42, $sgpr43, $sgpr46, $sgpr47, $vgpr0
+  ; CHECK:   $vgpr0 = V_WRITELANE_B32 killed $sgpr42, 0, $vgpr0
+  ; CHECK:   $vgpr0 = V_WRITELANE_B32 killed $sgpr43, 1, $vgpr0
+  ; CHECK:   $vgpr0 = V_WRITELANE_B32 killed $sgpr46, 2, $vgpr0
+  ; CHECK:   $vgpr0 = V_WRITELANE_B32 killed $sgpr47, 3, $vgpr0
+  ; CHECK:   S_NOP 0
+  ; CHECK: bb.1:
+  ; CHECK:   liveins: $vgpr0
+  ; CHECK:   $sgpr42 = S_MOV_B32 0
+  ; CHECK:   $sgpr43 = S_MOV_B32 1
+  ; CHECK:   $sgpr46_sgpr47 = S_MOV_B64 2
+  bb.0:
+S_NOP 0
+
+  bb.1:
+$sgpr42 = S_MOV_B32 0
+$sgpr43 = S_MOV_B32 1
+$sgpr46_sgpr47 = S_MOV_B64 2
+...



___
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] 8bf9cde - AMDGPU: Use Register

2020-12-22 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-22T21:55:59-05:00
New Revision: 8bf9cdeaee4834bcba35322f1d84c57c691d2244

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

LOG: AMDGPU: Use Register

Added: 


Modified: 
llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp 
b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp
index 65c7f49b646c..939a9676ad3b 100644
--- a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp
+++ b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp
@@ -98,7 +98,7 @@ static void insertCSRSaves(MachineBasicBlock &SaveBlock,
   if (!TFI->spillCalleeSavedRegisters(SaveBlock, I, CSI, TRI)) {
 for (const CalleeSavedInfo &CS : CSI) {
   // Insert the spill to the stack frame.
-  unsigned Reg = CS.getReg();
+  MCRegister Reg = CS.getReg();
 
   MachineInstrSpan MIS(I, &SaveBlock);
   const TargetRegisterClass *RC =
@@ -217,7 +217,8 @@ bool 
SILowerSGPRSpills::spillCalleeSavedRegs(MachineFunction &MF) {
 const MCPhysReg *CSRegs = MRI.getCalleeSavedRegs();
 
 for (unsigned I = 0; CSRegs[I]; ++I) {
-  unsigned Reg = CSRegs[I];
+  MCRegister Reg = CSRegs[I];
+
   if (SavedRegs.test(Reg)) {
 const TargetRegisterClass *RC =
   TRI->getMinimalPhysRegClass(Reg, MVT::i32);



___
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] [lld] 77fb45e - [lld/mac] Add --version flag

2020-12-22 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-22T22:06:39-05:00
New Revision: 77fb45e59e49d25fbc57854b62599ae24aa2c4c9

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

LOG: [lld/mac] Add --version flag

It's an extension to ld64, but all the other ports have it, and
someone asked for it in PR43721.

While here, change the COFF help text to match the other ports.

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

Added: 


Modified: 
lld/COFF/Options.td
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/driver.test

Removed: 




diff  --git a/lld/COFF/Options.td b/lld/COFF/Options.td
index 2b8e65587ad7..5447c8312128 100644
--- a/lld/COFF/Options.td
+++ b/lld/COFF/Options.td
@@ -240,7 +240,7 @@ def lto_obj_path : P<
 "lto-obj-path",
 "output native object for merged LTO unit to this path">;
 def dash_dash_version : Flag<["--"], "version">,
-  HelpText<"Print version information">;
+  HelpText<"Display the version number and exit">;
 def threads
 : P<"threads", "Number of threads. '1' disables multi-threading. By "
"default all available hardware threads are used">;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 82ddcf084dc0..edc9fe001ab5 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -690,10 +690,15 @@ bool macho::link(llvm::ArrayRef argsArr, 
bool canExitEarly,
   if (args.hasArg(OPT_help_hidden)) {
 parser.printHelp(argsArr[0], /*showHidden=*/true);
 return true;
-  } else if (args.hasArg(OPT_help)) {
+  }
+  if (args.hasArg(OPT_help)) {
 parser.printHelp(argsArr[0], /*showHidden=*/false);
 return true;
   }
+  if (args.hasArg(OPT_version)) {
+message(getLLDVersion());
+return true;
+  }
 
   if (const char *path = getReproduceOption(args)) {
 // Note that --reproduce is a debug option so you can ignore it

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 52a351836a15..8e88c74efc0e 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -18,6 +18,8 @@ def reproduce: Separate<["--"], "reproduce">;
 def reproduce_eq: Joined<["--"], "reproduce=">,
 Alias(reproduce)>,
 HelpText<"Write tar file containing inputs and command to reproduce link">;
+def version: Flag<["--"], "version">,
+HelpText<"Display the version number and exit">;
 
 
 // This is a complete Options.td compiled from Apple's ld(1) manpage
@@ -508,7 +510,7 @@ def bitcode_symbol_map : Separate<["-"], 
"bitcode_symbol_map">,
 def grp_rare : OptionGroup<"rare">, HelpText<"RARELY USED">;
 
 def v : Flag<["-"], "v">,
- HelpText<"Print the linker version">,
+ HelpText<"Print the linker version and search paths and exit">,
  Group;
 def version_details : Flag<["-"], "version_details">,
  HelpText<"Print the linker version in JSON form">,

diff  --git a/lld/test/MachO/driver.test b/lld/test/MachO/driver.test
index 229ec3ef6963..417c71eac561 100644
--- a/lld/test/MachO/driver.test
+++ b/lld/test/MachO/driver.test
@@ -1,5 +1,7 @@
-# RUN: not %lld ---help 2>&1 | FileCheck -check-prefix=SPELLHELP %s
+# RUN: %lld --version | FileCheck -check-prefix=VERSION %s
+VERSION: {{LLD [0-9]+\.[0-9]+}}
 
+# RUN: not %lld ---help 2>&1 | FileCheck -check-prefix=SPELLHELP %s
 SPELLHELP: error: unknown argument '---help', did you mean '--help'
 # FIXME: This should say "no input files" instead
 SPELLHELP: error: undefined symbol: _main



___
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] 581d13f - GlobalISel: Return APInt from getConstantVRegVal

2020-12-22 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2020-12-22T22:23:58-05:00
New Revision: 581d13f8aeb66c040d5ea69ad4385f766e1f97c9

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

LOG: GlobalISel: Return APInt from getConstantVRegVal

Returning int64_t was arbitrarily limiting for wide integer types, and
the functions should handle the full generality of the IR.

Also changes the full form which returns the originally defined
vreg. Add another wrapper for the common case of just immediately
converting to int64_t (arguably this would be useful for the full
return value case as well).

One possible issue with this change is some of the existing uses did
break without conversion to getConstantVRegSExtVal, and it's possible
some without adequate test coverage are now broken.

Added: 


Modified: 
llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
llvm/include/llvm/CodeGen/GlobalISel/Utils.h
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/lib/CodeGen/GlobalISel/InstructionSelector.cpp
llvm/lib/CodeGen/GlobalISel/Utils.cpp
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp
llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/lib/Target/X86/X86InstructionSelector.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h 
b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
index 3357b0e1a6eb..427906db6696 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
@@ -43,7 +43,7 @@ struct ConstantMatch {
   int64_t &CR;
   ConstantMatch(int64_t &C) : CR(C) {}
   bool match(const MachineRegisterInfo &MRI, Register Reg) {
-if (auto MaybeCst = getConstantVRegVal(Reg, MRI)) {
+if (auto MaybeCst = getConstantVRegSExtVal(Reg, MRI)) {
   CR = *MaybeCst;
   return true;
 }

diff  --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h 
b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
index 9fad903ea16b..446aaf8c3551 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
@@ -121,14 +121,19 @@ void reportGISelWarning(MachineFunction &MF, const 
TargetPassConfig &TPC,
 MachineOptimizationRemarkEmitter &MORE,
 MachineOptimizationRemarkMissed &R);
 
+/// If \p VReg is defined by a G_CONSTANT, return the corresponding value.
+Optional getConstantVRegVal(Register VReg,
+   const MachineRegisterInfo &MRI);
+
 /// If \p VReg is defined by a G_CONSTANT fits in int64_t
 /// returns it.
-Optional getConstantVRegVal(Register VReg,
- const MachineRegisterInfo &MRI);
+Optional getConstantVRegSExtVal(Register VReg,
+ const MachineRegisterInfo &MRI);
+
 /// Simple struct used to hold a constant integer value and a virtual
 /// register.
 struct ValueAndVReg {
-  int64_t Value;
+  APInt Value;
   Register VReg;
 };
 /// If \p VReg is defined by a statically evaluable chain of

diff  --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp 
b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 79f74a47d83c..90b1dcea2648 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -1029,8 +1029,7 @@ static Register getMemsetValue(Register Val, LLT Ty, 
MachineIRBuilder &MIB) {
   unsigned NumBits = Ty.getScalarSizeInBits();
   auto ValVRegAndVal = getConstantVRegValWithLookThrough(Val, MRI);
   if (!Ty.isVector() && ValVRegAndVal) {
-unsigned KnownVal = ValVRegAndVal->Value;
-APInt Scalar = APInt(8, KnownVal);
+APInt Scalar = ValVRegAndVal->Value.truncOrSelf(8);
 APInt SplatVal = APInt::getSplat(NumBits, Scalar);
 return MIB.buildConstant(Ty, SplatVal).getReg(0);
   }
@@ -1411,7 +1410,7 @@ bool CombinerHelper::tryCombineMemCpyFamily(MachineInstr 
&MI, unsigned MaxLen) {
   auto LenVRegAndVal = getConstantVRegValWithLookThrough(Len, MRI);
   if (!LenVRegAndVal)
 return false; // Leave it to the legalizer to lower it to a libcall.
-  unsigned KnownLen = LenVRegAndVal->Value;
+  unsigned KnownLen = LenVRegAndVal->Value.getZExtValue();
 
   if (KnownLen == 0) {
 MI.eraseFromParent();
@@ -1521,7 +1520,7 @@ bool CombinerHelper::matchPtrAddImmedChain(MachineInstr 
&MI,
 return false;
 
   // Pass the combined immediate to the apply function.
-  MatchInfo.Imm = MaybeImmVal->Value + MaybeImm2Val->

[llvm-branch-commits] [llvm] e6fde1a - [MemorySSA] Use is_contained (NFC)

2020-12-22 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-12-22T19:58:54-08:00
New Revision: e6fde1ae7df0b019392352b61d898c9b83b775fa

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

LOG: [MemorySSA] Use is_contained (NFC)

Added: 


Modified: 
llvm/lib/Analysis/MemorySSA.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index 00b4d42892c9..c9ad9ffab16e 100644
--- a/llvm/lib/Analysis/MemorySSA.cpp
+++ b/llvm/lib/Analysis/MemorySSA.cpp
@@ -2017,8 +2017,7 @@ void 
MemorySSA::verifyOrderingDominationAndDefUses(Function &F) const {
  "Incomplete MemoryPhi Node");
   for (unsigned I = 0, E = Phi->getNumIncomingValues(); I != E; ++I) {
 verifyUseInDefs(Phi->getIncomingValue(I), Phi);
-assert(find(predecessors(&B), Phi->getIncomingBlock(I)) !=
-   pred_end(&B) &&
+assert(is_contained(predecessors(&B), Phi->getIncomingBlock(I)) &&
"Incoming phi block not a block predecessor");
   }
 #endif



___
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] efe7f5e - [WebAssembly][NFC] Refactor SIMD load/store tablegen defs

2020-12-22 Thread Thomas Lively via llvm-branch-commits

Author: Thomas Lively
Date: 2020-12-22T20:06:12-08:00
New Revision: efe7f5ede0b3276f3f43daca46410bb7978221fb

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

LOG: [WebAssembly][NFC] Refactor SIMD load/store tablegen defs

Introduce `Vec` records, each bundling all information related to a single SIMD
lane interpretation. This lets TableGen definitions take a single Vec parameter
from which they can extract information rather than taking multiple redundant
parameters. This commit refactors all of the SIMD load and store instruction
definitions to use the new `Vec`s. Subsequent commits will similarly refactor
additional instruction definitions.

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

Added: 


Modified: 
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td

Removed: 




diff  --git 
a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h 
b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
index 4bc77aa68668..6c819f396ddc 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
@@ -195,8 +195,8 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
   WASM_LOAD_STORE(ATOMIC_RMW8_U_CMPXCHG_I32)
   WASM_LOAD_STORE(ATOMIC_RMW8_U_CMPXCHG_I64)
   WASM_LOAD_STORE(LOAD8_SPLAT)
-  WASM_LOAD_STORE(LOAD_LANE_v16i8)
-  WASM_LOAD_STORE(STORE_LANE_v16i8)
+  WASM_LOAD_STORE(LOAD_LANE_I8x16)
+  WASM_LOAD_STORE(STORE_LANE_I8x16)
   return 0;
   WASM_LOAD_STORE(LOAD16_S_I32)
   WASM_LOAD_STORE(LOAD16_U_I32)
@@ -223,8 +223,8 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
   WASM_LOAD_STORE(ATOMIC_RMW16_U_CMPXCHG_I32)
   WASM_LOAD_STORE(ATOMIC_RMW16_U_CMPXCHG_I64)
   WASM_LOAD_STORE(LOAD16_SPLAT)
-  WASM_LOAD_STORE(LOAD_LANE_v8i16)
-  WASM_LOAD_STORE(STORE_LANE_v8i16)
+  WASM_LOAD_STORE(LOAD_LANE_I16x8)
+  WASM_LOAD_STORE(STORE_LANE_I16x8)
   return 1;
   WASM_LOAD_STORE(LOAD_I32)
   WASM_LOAD_STORE(LOAD_F32)
@@ -254,9 +254,9 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
   WASM_LOAD_STORE(MEMORY_ATOMIC_NOTIFY)
   WASM_LOAD_STORE(MEMORY_ATOMIC_WAIT32)
   WASM_LOAD_STORE(LOAD32_SPLAT)
-  WASM_LOAD_STORE(LOAD_ZERO_v4i32)
-  WASM_LOAD_STORE(LOAD_LANE_v4i32)
-  WASM_LOAD_STORE(STORE_LANE_v4i32)
+  WASM_LOAD_STORE(LOAD_ZERO_I32x4)
+  WASM_LOAD_STORE(LOAD_LANE_I32x4)
+  WASM_LOAD_STORE(STORE_LANE_I32x4)
   return 2;
   WASM_LOAD_STORE(LOAD_I64)
   WASM_LOAD_STORE(LOAD_F64)
@@ -273,15 +273,15 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
   WASM_LOAD_STORE(ATOMIC_RMW_CMPXCHG_I64)
   WASM_LOAD_STORE(MEMORY_ATOMIC_WAIT64)
   WASM_LOAD_STORE(LOAD64_SPLAT)
-  WASM_LOAD_STORE(LOAD_EXTEND_S_v8i16)
-  WASM_LOAD_STORE(LOAD_EXTEND_U_v8i16)
-  WASM_LOAD_STORE(LOAD_EXTEND_S_v4i32)
-  WASM_LOAD_STORE(LOAD_EXTEND_U_v4i32)
-  WASM_LOAD_STORE(LOAD_EXTEND_S_v2i64)
-  WASM_LOAD_STORE(LOAD_EXTEND_U_v2i64)
-  WASM_LOAD_STORE(LOAD_ZERO_v2i64)
-  WASM_LOAD_STORE(LOAD_LANE_v2i64)
-  WASM_LOAD_STORE(STORE_LANE_v2i64)
+  WASM_LOAD_STORE(LOAD_EXTEND_S_I16x8)
+  WASM_LOAD_STORE(LOAD_EXTEND_U_I16x8)
+  WASM_LOAD_STORE(LOAD_EXTEND_S_I32x4)
+  WASM_LOAD_STORE(LOAD_EXTEND_U_I32x4)
+  WASM_LOAD_STORE(LOAD_EXTEND_S_I64x2)
+  WASM_LOAD_STORE(LOAD_EXTEND_U_I64x2)
+  WASM_LOAD_STORE(LOAD_ZERO_I64x2)
+  WASM_LOAD_STORE(LOAD_LANE_I64x2)
+  WASM_LOAD_STORE(STORE_LANE_I64x2)
   return 3;
   WASM_LOAD_STORE(LOAD_V128)
   WASM_LOAD_STORE(STORE_V128)

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td 
b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index e48bbaebd47e..df4de49ee4c8 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -37,6 +37,75 @@ def ImmI#SIZE : ImmLeaf;
 
+class Vec {
+  ValueType vt;
+  ValueType lane_vt;
+  WebAssemblyRegClass lane_rc;
+  int lane_bits;
+  ImmLeaf lane_idx;
+  string prefix;
+  Vec split;
+}
+
+def I8x16 : Vec {
+  let vt = v16i8;
+  let lane_vt = i32;
+  let lane_rc = I32;
+  let lane_bits = 8;
+  let lane_idx = LaneIdx16;
+  let prefix = "i8x16";
+}
+
+def I16x8 : Vec {
+  let vt = v8i16;
+  let lane_vt = i32;
+  let lane_rc = I32;
+  let lane_bits = 16;
+  let lane_idx = LaneIdx8;
+  let prefix = "i16x8";
+  let split = I8x16;
+}
+
+def I32x4 : Vec {
+  let vt = v4i32;
+  let lane_vt = i32;
+  let lane_rc = I32;
+  let lane_bits = 32;
+  let lane_idx = LaneIdx4;
+  let prefix = "i32x4";
+  let split = I16x8;
+}
+
+def I64x2 : Vec {
+  let vt = v2i64;
+  let lane_vt = i64;
+  let lane_rc = I64;
+  let lane_bits = 64;
+  let lane_idx = LaneIdx2;
+  let prefix = "i64x2";
+  let split = I32x4;
+}
+
+def F32x4 : Vec {
+  let vt = v4f32;
+  let lane_vt = f32;
+  let lane_rc = F

[llvm-branch-commits] [llvm] 3c707d7 - [NewGVN] Remove for_each_found (NFC)

2020-12-22 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-12-22T20:13:27-08:00
New Revision: 3c707d73f26f4189a21e610210d01c0059f4fd01

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

LOG: [NewGVN] Remove for_each_found (NFC)

The last use of the function was removed on Sep 30, 2017 in commit
9b926e90d33e0f71c16618365333fc7b330b6bb5.

Added: 


Modified: 
llvm/lib/Transforms/Scalar/NewGVN.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp 
b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 958014fcb1ed..ee26c299c88c 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -802,8 +802,6 @@ class NewGVN {
 const BasicBlock *) const;
 
   // Various instruction touch utilities
-  template 
-  void for_each_found(Map &, const KeyType &, Func);
   template 
   void touchAndErase(Map &, const KeyType &);
   void markUsersTouched(Value *);
@@ -1991,16 +1989,6 @@ NewGVN::performSymbolicEvaluation(Value *V,
   return E;
 }
 
-// Look up a container in a map, and then call a function for each thing in the
-// found container.
-template 
-void NewGVN::for_each_found(Map &M, const KeyType &Key, Func F) {
-  const auto Result = M.find_as(Key);
-  if (Result != M.end())
-for (typename Map::mapped_type::value_type Mapped : Result->second)
-  F(Mapped);
-}
-
 // Look up a container of values/instructions in a map, and touch all the
 // instructions in the container.  Then erase value from the map.
 template 



___
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] 0219cf7 - [NewPM] Fix objc-arc-apelim pass typo

2020-12-22 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-22T21:40:43-08:00
New Revision: 0219cf7dfafa45ef82fcd92f48e4b614da866d51

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

LOG: [NewPM] Fix objc-arc-apelim pass typo

Added: 


Modified: 
llvm/lib/Passes/PassRegistry.def

Removed: 




diff  --git a/llvm/lib/Passes/PassRegistry.def 
b/llvm/lib/Passes/PassRegistry.def
index 977bd46b0633..b00a7bd14b4f 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -81,7 +81,7 @@ MODULE_PASS("mergefunc", MergeFunctionsPass())
 MODULE_PASS("name-anon-globals", NameAnonGlobalPass())
 MODULE_PASS("no-op-module", NoOpModulePass())
 MODULE_PASS("objc-arc", ObjCARCOptPass())
-MODULE_PASS("objc-arc-apelim", ObjCARCOptPass())
+MODULE_PASS("objc-arc-apelim", ObjCARCAPElimPass())
 MODULE_PASS("objc-arc-contract", ObjCARCContractPass())
 MODULE_PASS("partial-inliner", PartialInlinerPass())
 MODULE_PASS("pgo-icall-prom", PGOIndirectCallPromotion())



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