[llvm-branch-commits] [llvm] 84b8222 - [RISCV] Use separate Lo and Hi MemOperands when expanding BuildPairF64Pseudo and SplitF64Pseudo.

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

Author: Craig Topper
Date: 2020-11-22T00:46:12-08:00
New Revision: 84b8222705c32c15818a9093b8217027f129f218

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

LOG: [RISCV] Use separate Lo and Hi MemOperands when expanding 
BuildPairF64Pseudo and SplitF64Pseudo.

We generate two 4 byte loads or two stores as part of the expansion.
Previously the MemOperand was set the same for both to cover the
full 8 bytes. Now we set a separate 4 byte mem operand for each
with a 4 byte offset for the high part.

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index bbb76d39ab7a..0ae3c7b768a5 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1520,17 +1520,19 @@ static MachineBasicBlock 
*emitSplitF64Pseudo(MachineInstr &MI,
 
   TII.storeRegToStackSlot(*BB, MI, SrcReg, MI.getOperand(2).isKill(), FI, 
SrcRC,
   RI);
-  MachineMemOperand *MMO =
-  MF.getMachineMemOperand(MachinePointerInfo::getFixedStack(MF, FI),
-  MachineMemOperand::MOLoad, 8, Align(8));
+  MachinePointerInfo MPI = MachinePointerInfo::getFixedStack(MF, FI);
+  MachineMemOperand *MMOLo =
+  MF.getMachineMemOperand(MPI, MachineMemOperand::MOLoad, 4, Align(8));
+  MachineMemOperand *MMOHi = MF.getMachineMemOperand(
+  MPI.getWithOffset(4), MachineMemOperand::MOLoad, 4, Align(8));
   BuildMI(*BB, MI, DL, TII.get(RISCV::LW), LoReg)
   .addFrameIndex(FI)
   .addImm(0)
-  .addMemOperand(MMO);
+  .addMemOperand(MMOLo);
   BuildMI(*BB, MI, DL, TII.get(RISCV::LW), HiReg)
   .addFrameIndex(FI)
   .addImm(4)
-  .addMemOperand(MMO);
+  .addMemOperand(MMOHi);
   MI.eraseFromParent(); // The pseudo instruction is gone now.
   return BB;
 }
@@ -1550,19 +1552,21 @@ static MachineBasicBlock 
*emitBuildPairF64Pseudo(MachineInstr &MI,
   const TargetRegisterClass *DstRC = &RISCV::FPR64RegClass;
   int FI = MF.getInfo()->getMoveF64FrameIndex(MF);
 
-  MachineMemOperand *MMO =
-  MF.getMachineMemOperand(MachinePointerInfo::getFixedStack(MF, FI),
-  MachineMemOperand::MOStore, 8, Align(8));
+  MachinePointerInfo MPI = MachinePointerInfo::getFixedStack(MF, FI);
+  MachineMemOperand *MMOLo =
+  MF.getMachineMemOperand(MPI, MachineMemOperand::MOStore, 4, Align(8));
+  MachineMemOperand *MMOHi = MF.getMachineMemOperand(
+  MPI.getWithOffset(4), MachineMemOperand::MOStore, 4, Align(8));
   BuildMI(*BB, MI, DL, TII.get(RISCV::SW))
   .addReg(LoReg, getKillRegState(MI.getOperand(1).isKill()))
   .addFrameIndex(FI)
   .addImm(0)
-  .addMemOperand(MMO);
+  .addMemOperand(MMOLo);
   BuildMI(*BB, MI, DL, TII.get(RISCV::SW))
   .addReg(HiReg, getKillRegState(MI.getOperand(2).isKill()))
   .addFrameIndex(FI)
   .addImm(4)
-  .addMemOperand(MMO);
+  .addMemOperand(MMOHi);
   TII.loadRegFromStackSlot(*BB, MI, DstReg, FI, DstRC, RI);
   MI.eraseFromParent(); // The pseudo instruction is gone now.
   return BB;



___
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] 20b69af - [clangd] Add clang-tidy options to config

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

Author: Nathan James
Date: 2020-11-22T10:04:01Z
New Revision: 20b69af7c9c8bd9a621b05203f944bf94a3a4c26

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

LOG: [clangd] Add clang-tidy options to config

First step of implementing clang-tidy configuration into clangd config.
This is just adding support for reading and verifying the clang tidy options 
from the config fragments.
No support is added for actually using the options within clang-tidy yet.

That will be added in a follow up as its a little more involved.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 087dc4fb805d..ff285d34633b 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -26,6 +26,7 @@
 
 #include "support/Context.h"
 #include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ADT/StringMap.h"
 #include 
 #include 
 
@@ -70,6 +71,14 @@ struct Config {
 // ::). All nested namespaces are affected as well.
 std::vector FullyQualifiedNamespaces;
   } Style;
+
+  /// Configures what clang-tidy checks to run and options to use with them.
+  struct {
+// A comma-seperated list of globs to specify which clang-tidy checks to
+// run.
+std::string Checks;
+llvm::StringMap CheckOptions;
+  } ClangTidy;
 };
 
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index e2823894dd11..ff031238418d 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -157,6 +157,7 @@ struct FragmentCompiler {
 compile(std::move(F.If));
 compile(std::move(F.CompileFlags));
 compile(std::move(F.Index));
+compile(std::move(F.ClangTidy));
   }
 
   void compile(Fragment::IfBlock &&F) {
@@ -264,6 +265,49 @@ struct FragmentCompiler {
 }
   }
 
+  void appendTidyCheckSpec(std::string &CurSpec,
+   const Located &Arg, bool IsPositive) {
+StringRef Str = *Arg;
+// Don't support negating here, its handled if the item is in the Add or
+// Remove list.
+if (Str.startswith("-") || Str.contains(',')) {
+  diag(Error, "Invalid clang-tidy check name", Arg.Range);
+  return;
+}
+CurSpec += ',';
+if (!IsPositive)
+  CurSpec += '-';
+CurSpec += Str;
+  }
+
+  void compile(Fragment::ClangTidyBlock &&F) {
+std::string Checks;
+for (auto &CheckGlob : F.Add)
+  appendTidyCheckSpec(Checks, CheckGlob, true);
+
+for (auto &CheckGlob : F.Remove)
+  appendTidyCheckSpec(Checks, CheckGlob, false);
+
+if (!Checks.empty())
+  Out.Apply.push_back(
+  [Checks = std::move(Checks)](const Params &, Config &C) {
+C.ClangTidy.Checks.append(
+Checks, C.ClangTidy.Checks.empty() ? /*skip comma*/ 1 : 0);
+  });
+if (!F.CheckOptions.empty()) {
+  std::vector> CheckOptions;
+  for (auto &Opt : F.CheckOptions)
+CheckOptions.emplace_back(std::move(*Opt.first),
+  std::move(*Opt.second));
+  Out.Apply.push_back(
+  [CheckOptions = std::move(CheckOptions)](const Params &, Config &C) {
+for (auto &StringPair : CheckOptions)
+  C.ClangTidy.CheckOptions.insert_or_assign(StringPair.first,
+StringPair.second);
+  });
+}
+  }
+
   constexpr static llvm::SourceMgr::DiagKind Error = llvm::SourceMgr::DK_Error;
   constexpr static llvm::SourceMgr::DiagKind Warning =
   llvm::SourceMgr::DK_Warning;

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index 65772715095f..766463e11e25 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -174,6 +174,29 @@ struct Fragment {
 std::vector> FullyQualifiedNamespaces;
   };
   StyleBlock Style;
+
+  /// Controls how clang-tidy will run over the code base.
+  ///
+  /// The settings are merged with any settings found in .clang-tidy
+  /// configiration files with these ones taking precedence.
+  struct ClangTidyBlock {
+std::vector> Add;
+/// List of checks to disable.
+/// Takes precedence over Add. To enable all llvm checks except include
+/// order:
+///   Add: llvm-*
+///   Remove: llvm-include-

[llvm-branch-commits] [llvm] 24d6e60 - [Analysis] Remove unused system header includes

2020-11-22 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-22T10:32:37Z
New Revision: 24d6e60488a2f447df27a4f67a960925deceeb6b

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

LOG: [Analysis] Remove unused system header includes

Cleanup unused system headers and fix an implicit dependency

Added: 


Modified: 
llvm/lib/Analysis/DivergenceAnalysis.cpp
llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/DivergenceAnalysis.cpp 
b/llvm/lib/Analysis/DivergenceAnalysis.cpp
index d01a0b95612c..c10971dab95c 100644
--- a/llvm/lib/Analysis/DivergenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DivergenceAnalysis.cpp
@@ -84,7 +84,6 @@
 #include "llvm/IR/Value.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
-#include 
 
 using namespace llvm;
 

diff  --git a/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp 
b/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp
index c32aa0340ceb..b112ed2e4439 100644
--- a/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp
+++ b/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp
@@ -22,9 +22,7 @@
 #include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
-#include 
-#include 
-#include 
+#include 
 
 using namespace llvm;
 



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


[llvm-branch-commits] [clang-tools-extra] 82c22f1 - [clangd] Fix compile error after 20b69af7

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

Author: Nathan James
Date: 2020-11-22T10:48:48Z
New Revision: 82c22f124816d1f260dc8f0626d56b459d1358b8

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

LOG: [clangd] Fix compile error after 20b69af7

Some of the buildbots were failing due to what seems to be them using a non 
c++14 compilant std::string implementation.
Since c++14 std::basic_string::append(const basic_string, size_t, size_t) has a 
defaulted 3rd paramater, but some of the build bots were reporting that it 
wasn't defaulted in their implementation.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index ff031238418d..3f4dcd3c036d 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -292,7 +292,8 @@ struct FragmentCompiler {
   Out.Apply.push_back(
   [Checks = std::move(Checks)](const Params &, Config &C) {
 C.ClangTidy.Checks.append(
-Checks, C.ClangTidy.Checks.empty() ? /*skip comma*/ 1 : 0);
+Checks, C.ClangTidy.Checks.empty() ? /*skip comma*/ 1 : 0,
+std::string::npos);
   });
 if (!F.CheckOptions.empty()) {
   std::vector> CheckOptions;



___
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] 791040c - [DAG] LowerMINMAX - move default expansion to generic TargetLowering::expandIntMINMAX

2020-11-22 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-11-22T13:02:27Z
New Revision: 791040cd8b37414e86757577f480ba3c0a0884f6

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

LOG: [DAG] LowerMINMAX - move default expansion to generic 
TargetLowering::expandIntMINMAX

This is part of the discussion on D91876 about trying to reduce custom lowering 
of MIN/MAX ops on older SSE targets - if we can improve generic vector 
expansion we should be able to relax the limitations in SelectionDAGBuilder 
when it will let MIN/MAX ops be generated, and avoid having to flag so many ops 
as 'custom'.

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 30d1623d80c2..164cbd710713 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -4418,6 +4418,10 @@ class TargetLowering : public TargetLoweringBase {
   SDValue getVectorElementPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT,
   SDValue Index) const;
 
+  /// Method for building the DAG expansion of ISD::[US][MIN|MAX]. This
+  /// method accepts integers as its arguments.
+  SDValue expandIntMINMAX(SDNode *Node, SelectionDAG &DAG) const;
+
   /// Method for building the DAG expansion of ISD::[US][ADD|SUB]SAT. This
   /// method accepts integers as its arguments.
   SDValue expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const;

diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
index d3e95818af97..db44ea2553ce 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
@@ -812,6 +812,15 @@ void VectorLegalizer::Expand(SDNode *Node, 
SmallVectorImpl &Results) {
   return;
 }
 break;
+  case ISD::SMIN:
+  case ISD::SMAX:
+  case ISD::UMIN:
+  case ISD::UMAX:
+if (SDValue Expanded = TLI.expandIntMINMAX(Node, DAG)) {
+  Results.push_back(Expanded);
+  return;
+}
+break;
   case ISD::UADDO:
   case ISD::USUBO:
 ExpandUADDSUBO(Node, Results);

diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 875a429253ca..1d51773dc2d8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -7458,6 +7458,31 @@ TargetLowering::getCanonicalIndexType(ISD::MemIndexType 
IndexType, EVT MemVT,
   return IndexType;
 }
 
+SDValue TargetLowering::expandIntMINMAX(SDNode *Node, SelectionDAG &DAG) const 
{
+  SDValue Op0 = Node->getOperand(0);
+  SDValue Op1 = Node->getOperand(1);
+  EVT VT = Op0.getValueType();
+
+  // Expand Y = MAX(A, B) -> Y = (A > B) ? A : B
+  ISD::CondCode CC;
+  switch (Node->getOpcode()) {
+  default: llvm_unreachable("How did we get here?");
+  case ISD::SMAX: CC = ISD::SETGT; break;
+  case ISD::SMIN: CC = ISD::SETLT; break;
+  case ISD::UMAX: CC = ISD::SETUGT; break;
+  case ISD::UMIN: CC = ISD::SETULT; break;
+  }
+
+  // FIXME: Should really try to split the vector in case it's legal on a
+  // subvector.
+  if (VT.isVector() && !isOperationLegalOrCustom(ISD::VSELECT, VT))
+return DAG.UnrollVectorOp(Node);
+
+  SDLoc DL(Node);
+  SDValue Cond = DAG.getSetCC(DL, VT, Op0, Op1, CC);
+  return DAG.getSelect(DL, VT, Cond, Op0, Op1);
+}
+
 SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const 
{
   unsigned Opcode = Node->getOpcode();
   SDValue LHS = Node->getOperand(0);

diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 3587e0eb294c..fcbe1330b546 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -26975,18 +26975,8 @@ static SDValue LowerMINMAX(SDValue Op, SelectionDAG 
&DAG) {
DAG.getNode(ISD::USUBSAT, DL, VT, N1, N0), N0);
   }
 
-  // Else, expand to a compare/select.
-  ISD::CondCode CC;
-  switch (Opcode) {
-  case ISD::SMIN: CC = ISD::CondCode::SETLT;  break;
-  case ISD::SMAX: CC = ISD::CondCode::SETGT;  break;
-  case ISD::UMIN: CC = ISD::CondCode::SETULT; break;
-  case ISD::UMAX: CC = ISD::CondCode::SETUGT; break;
-  default: llvm_unreachable("Unknown MINMAX opcode");
-  }
-
-  SDValue Cond = DAG.getSetCC(DL, VT, N0, N1, CC);
-  return DAG.getSelect(DL, VT, Cond, N0, N1);
+  // Default to expand.
+  return SDValue();
 }
 
 static SDValue LowerMUL(SDValue Op, const X86Subtarget &Subtarget,



_

[llvm-branch-commits] [flang] 29dffb0 - Add Semantic check for Flang OpenMP 4.5 - 2.7.1 ordered and collapse clause

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

Author: Yashaswini
Date: 2020-11-22T18:38:57+05:30
New Revision: 29dffb0c8a5dbe8bdcc1abe38aafb3f5ea7d57f4

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

LOG: Add Semantic check for Flang OpenMP 4.5 - 2.7.1 ordered and collapse clause

Semantic check added to check and restrict the value of the parameter in the 
COLLAPSE or ORDERED clause
if it is larger than the number of nested loops following the construct.

Test Cases:
omp-do-collapse-positivecases.f90
omp-do-collapse.f90
omp-do-ordered-positivecases.f90
omp-do-ordered.f90

Reviewed by: Kiran Chandramohan @kiranchandramohan , Valentin Clement 
@clementval

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

Added: 
flang/test/Semantics/omp-do-collapse-positivecases.f90
flang/test/Semantics/omp-do-collapse.f90
flang/test/Semantics/omp-do-ordered-positivecases.f90
flang/test/Semantics/omp-do-ordered.f90

Modified: 
flang/lib/Semantics/resolve-directives.cpp

Removed: 




diff  --git a/flang/lib/Semantics/resolve-directives.cpp 
b/flang/lib/Semantics/resolve-directives.cpp
index 2c0a4c730a98..65606d119dc4 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -305,6 +305,12 @@ class OmpAttributeVisitor : 
DirectiveAttributeVisitor {
   }
   void Post(const parser::Name &);
 
+  const parser::OmpClause *associatedClause{nullptr};
+  void SetAssociatedClause(const parser::OmpClause &c) {
+associatedClause = &c;
+  }
+  const parser::OmpClause *GetAssociatedClause() { return associatedClause; }
+
 private:
   std::int64_t GetAssociatedLoopLevelFromClauses(const parser::OmpClauseList 
&);
 
@@ -344,7 +350,8 @@ class OmpAttributeVisitor : 
DirectiveAttributeVisitor {
   }
 
   // Predetermined DSA rules
-  void PrivatizeAssociatedLoopIndex(const parser::OpenMPLoopConstruct &);
+  void PrivatizeAssociatedLoopIndexAndCheckLoopLevel(
+  const parser::OpenMPLoopConstruct &);
   void ResolveSeqLoopIndexInParallelOrTaskConstruct(const parser::Name &);
 
   void ResolveOmpObjectList(const parser::OmpObjectList &, Symbol::Flag);
@@ -362,6 +369,8 @@ class OmpAttributeVisitor : 
DirectiveAttributeVisitor {
 
   void CheckDataCopyingClause(
   const parser::Name &, const Symbol &, Symbol::Flag);
+
+  void CheckAssocLoopLevel(std::int64_t level, const parser::OmpClause 
*clause);
 };
 
 template 
@@ -777,7 +786,7 @@ bool OmpAttributeVisitor::Pre(const 
parser::OpenMPLoopConstruct &x) {
   }
   ClearDataSharingAttributeObjects();
   SetContextAssociatedLoopLevel(GetAssociatedLoopLevelFromClauses(clauseList));
-  PrivatizeAssociatedLoopIndex(x);
+  PrivatizeAssociatedLoopIndexAndCheckLoopLevel(x);
   return true;
 }
 
@@ -824,24 +833,32 @@ std::int64_t 
OmpAttributeVisitor::GetAssociatedLoopLevelFromClauses(
 const parser::OmpClauseList &x) {
   std::int64_t orderedLevel{0};
   std::int64_t collapseLevel{0};
+
+  const parser::OmpClause *ordClause{nullptr};
+  const parser::OmpClause *collClause{nullptr};
+
   for (const auto &clause : x.v) {
 if (const auto *orderedClause{
 std::get_if(&clause.u)}) {
   if (const auto v{EvaluateInt64(context_, orderedClause->v)}) {
 orderedLevel = *v;
   }
+  ordClause = &clause;
 }
 if (const auto *collapseClause{
 std::get_if(&clause.u)}) {
   if (const auto v{EvaluateInt64(context_, collapseClause->v)}) {
 collapseLevel = *v;
   }
+  collClause = &clause;
 }
   }
 
   if (orderedLevel && (!collapseLevel || orderedLevel >= collapseLevel)) {
+SetAssociatedClause(*ordClause);
 return orderedLevel;
   } else if (!orderedLevel && collapseLevel) {
+SetAssociatedClause(*collClause);
 return collapseLevel;
   } // orderedLevel < collapseLevel is an error handled in structural checks
   return 1; // default is outermost loop
@@ -855,10 +872,7 @@ std::int64_t 
OmpAttributeVisitor::GetAssociatedLoopLevelFromClauses(
 // increment of the associated do-loop.
 //   - The loop iteration variables in the associated do-loops of a simd
 // construct with multiple associated do-loops are lastprivate.
-//
-// TODO: revisit after semantics checks are completed for do-loop association 
of
-//   collapse and ordered
-void OmpAttributeVisitor::PrivatizeAssociatedLoopIndex(
+void OmpAttributeVisitor::PrivatizeAssociatedLoopIndexAndCheckLoopLevel(
 const parser::OpenMPLoopConstruct &x) {
   std::int64_t level{GetContext().associatedLoopLevel};
   if (level <= 0) {
@@ -887,7 +901,16 @@ void OmpAttributeVisitor::PrivatizeAssociatedLoopIndex(
 const auto it{block.begin()};
 loop = it != block.end() ? GetDoConstructIf(*it) : nullptr;
   }
-  CHECK(level == 0);
+  CheckAssocLoopLevel(level, GetAssociatedClause());
+}
+void OmpAttribut

[llvm-branch-commits] [libcxxabi] 3b62506 - [libc++] [libc++abi] Use C++20 standard.

2020-11-22 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-11-22T15:57:25+01:00
New Revision: 3b625060fc91598d28196e559196bfc7b9a929f9

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

LOG: [libc++] [libc++abi] Use C++20 standard.

This change is needed to use char8_t when building libc++.
Using the same standard in libc++abi for coherence.

See https://reviews.llvm.org/D91517.

Reviewed By: ldionne, #libc, #libc_abi

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

Added: 


Modified: 
libcxx/CMakeLists.txt
libcxxabi/src/CMakeLists.txt

Removed: 




diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index dd4c93b59d33..f4c7e9992f71 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -514,11 +514,11 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
 # Required flags ==
 function(cxx_add_basic_build_flags target)
 
-  # Require C++17 for all targets. C++17 is needed to use aligned allocation
-  # in the dylib.
+  # Require C++20 for all targets. C++17 is needed to use aligned allocation
+  # in the dylib. C++20 is needed to use char8_t.
   set_target_properties(${target} PROPERTIES
-CXX_STANDARD 17
-CXX_STANDARD_REQUIRED YES
+CXX_STANDARD 20
+CXX_STANDARD_REQUIRED NO
 CXX_EXTENSIONS NO)
 
   # When building the dylib, don't warn for unavailable aligned allocation

diff  --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 7353c2086b94..a8e12aa36e64 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -174,9 +174,9 @@ if (LIBCXXABI_ENABLE_SHARED)
   CXX_EXTENSIONS
 OFF
   CXX_STANDARD
-17
+20
   CXX_STANDARD_REQUIRED
-ON
+OFF
   COMPILE_FLAGS
 "${LIBCXXABI_COMPILE_FLAGS}"
   LINK_FLAGS
@@ -241,9 +241,9 @@ if (LIBCXXABI_ENABLE_STATIC)
   CXX_EXTENSIONS
 OFF
   CXX_STANDARD
-17
+20
   CXX_STANDARD_REQUIRED
-ON
+OFF
   COMPILE_FLAGS
 "${LIBCXXABI_COMPILE_FLAGS}"
   LINK_FLAGS



___
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] 221c2b8 - [BasicAA] Add more phi-phi tests (NFC)

2020-11-22 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-11-22T16:53:06+01:00
New Revision: 221c2b8862b1e507a6e79ca2731c2f839a2fd482

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

LOG: [BasicAA] Add more phi-phi tests (NFC)

Test a few more variations:
 * NoAlias with different strides
 * MustAlias without loop
 * MustAlias with same stride
 * MustAlias base pointers with different stride

Added: 


Modified: 
llvm/test/Analysis/BasicAA/phi-speculation.ll

Removed: 




diff  --git a/llvm/test/Analysis/BasicAA/phi-speculation.ll 
b/llvm/test/Analysis/BasicAA/phi-speculation.ll
index 198c5340488e..12b2310f4c45 100644
--- a/llvm/test/Analysis/BasicAA/phi-speculation.ll
+++ b/llvm/test/Analysis/BasicAA/phi-speculation.ll
@@ -92,3 +92,85 @@ while.body:
 the_exit:
   ret i32 1
 }
+
+; CHECK-LABEL: test_
diff erent_stride_noalias
+; CHECK: NoAlias: i16* %y.base, i8* %x.base
+; CHECK: NoAlias: i16* %y, i8* %x
+; CHECK: NoAlias: i16* %y.next, i8* %x.next
+define void @test_
diff erent_stride_noalias(i1 %c, i8* noalias %x.base, i16* noalias %y.base) {
+entry:
+  br label %loop
+
+loop:
+  %x = phi i8* [ %x.base, %entry ], [ %x.next, %loop ]
+  %y = phi i16* [ %y.base, %entry ], [ %y.next, %loop ]
+  %x.next = getelementptr i8, i8* %x, i64 1
+  %y.next = getelementptr i16, i16* %y, i64 1
+  br i1 %c, label %loop, label %exit
+
+exit:
+  ret void
+}
+
+; CHECK-LABEL: test_no_loop_mustalias
+; CHECK: MayAlias: i16* %z16, i8* %z8
+; TODO: (z8, z16) could be MustAlias
+define void @test_no_loop_mustalias(i1 %c, i8* noalias %x8, i8* noalias %y8) {
+  br i1 %c, label %if, label %else
+
+if:
+  %x16 = bitcast i8* %x8 to i16*
+  br label %end
+
+else:
+  %y16 = bitcast i8* %y8 to i16*
+  br label %end
+
+end:
+  %z8 = phi i8* [ %x8, %if ], [ %y8, %else ]
+  %z16 = phi i16* [ %x16, %if ], [ %y16, %else ]
+  ret void
+}
+
+; CHECK-LABEL: test_same_stride_mustalias
+; CHECK: MustAlias: i4* %y.base, i8* %x.base
+; CHECK: MayAlias: i4* %y, i8* %x
+; CHECK: MayAlias: i4* %y.next, i8* %x.next
+; TODO: (x, y) could be MustAlias
+define void @test_same_stride_mustalias(i1 %c, i8* noalias %x.base) {
+entry:
+  %y.base = bitcast i8* %x.base to i4*
+  br label %loop
+
+loop:
+  %x = phi i8* [ %x.base, %entry ], [ %x.next, %loop ]
+  %y = phi i4* [ %y.base, %entry ], [ %y.next, %loop ]
+  %x.next = getelementptr i8, i8* %x, i64 1
+  %y.next = getelementptr i4, i4* %y, i64 1
+  br i1 %c, label %loop, label %exit
+
+exit:
+  ret void
+}
+
+; CHECK-LABEL: test_
diff erent_stride_mustalias
+; CHECK: MustAlias: i16* %y.base, i8* %x.base
+; CHECK: MayAlias: i16* %y, i8* %x
+; CHECK: MayAlias: i16* %y.next, i8* %x.next
+; Even though the base pointers MustAlias, the 
diff erent strides don't preserve
+; this property across iterations.
+define void @test_
diff erent_stride_mustalias(i1 %c, i8* noalias %x.base) {
+entry:
+  %y.base = bitcast i8* %x.base to i16*
+  br label %loop
+
+loop:
+  %x = phi i8* [ %x.base, %entry ], [ %x.next, %loop ]
+  %y = phi i16* [ %y.base, %entry ], [ %y.next, %loop ]
+  %x.next = getelementptr i8, i8* %x, i64 1
+  %y.next = getelementptr i16, i16* %y, i64 1
+  br i1 %c, label %loop, label %exit
+
+exit:
+  ret void
+}



___
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] c5a4d80 - [ValueTracking][MemCpyOpt] avoid crash on inttoptr with vector pointer type (PR48075)

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

Author: Sanjay Patel
Date: 2020-11-22T12:54:18-05:00
New Revision: c5a4d80fd47cfdae1995df46d0c407f78d8666e8

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

LOG: [ValueTracking][MemCpyOpt] avoid crash on inttoptr with vector pointer 
type (PR48075)

Added: 


Modified: 
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/MemCpyOpt/crash.ll

Removed: 




diff  --git a/llvm/lib/Analysis/ValueTracking.cpp 
b/llvm/lib/Analysis/ValueTracking.cpp
index bcf35111502e..90f8dff87472 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3610,12 +3610,13 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout 
&DL) {
 
   if (auto *CE = dyn_cast(C)) {
 if (CE->getOpcode() == Instruction::IntToPtr) {
-  auto PS = DL.getPointerSizeInBits(
-  cast(CE->getType())->getAddressSpace());
-  return isBytewiseValue(
-  ConstantExpr::getIntegerCast(CE->getOperand(0),
-   Type::getIntNTy(Ctx, PS), false),
-  DL);
+  if (auto *PtrTy = dyn_cast(CE->getType())) {
+unsigned BitWidth = DL.getPointerSizeInBits(PtrTy->getAddressSpace());
+return isBytewiseValue(
+ConstantExpr::getIntegerCast(CE->getOperand(0),
+ Type::getIntNTy(Ctx, BitWidth), 
false),
+DL);
+  }
 }
   }
 

diff  --git a/llvm/test/Transforms/MemCpyOpt/crash.ll 
b/llvm/test/Transforms/MemCpyOpt/crash.ll
index f70f10429f84..73635891c683 100644
--- a/llvm/test/Transforms/MemCpyOpt/crash.ll
+++ b/llvm/test/Transforms/MemCpyOpt/crash.ll
@@ -83,3 +83,16 @@ define void @test2(i32 %cmd) nounwind {
   call void @llvm.memcpy.p0i8.p0i8.i64(i8* null, i8* undef, i64 20, i1 false) 
nounwind
   ret void
 }
+
+; https://llvm.org/PR48075
+
+@g = external global i16, align 1
+
+define void @inttoptr_constexpr_crash(<1 x i16*>* %p) {
+; CHECK-LABEL: @inttoptr_constexpr_crash(
+; CHECK-NEXT:store <1 x i16*> inttoptr (<1 x i16> bitcast (<2 x i8>  to <1 x i16>) to <1 x 
i16*>), <1 x i16*>* [[P:%.*]], align 1
+; CHECK-NEXT:ret void
+;
+  store <1 x i16*> inttoptr (<1 x i16> bitcast (<2 x i8>  to <1 x i16>) to <1 x i16*>), <1 x i16*>* 
%p, align 1
+  ret void
+}



___
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] 3a18f26 - [CostModel] add tests for FP maximum; NFC

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

Author: Sanjay Patel
Date: 2020-11-22T13:33:42-05:00
New Revision: 3a18f267236351873a4c7821735c70b0790e4919

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

LOG: [CostModel] add tests for FP maximum; NFC

These min/max intrinsics are not handled in the basic
implementation and probably not handled in target-specific
overrides either.

Added: 


Modified: 
llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll

Removed: 




diff  --git a/llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll 
b/llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
index e472e0424d8a..805bd810e950 100644
--- a/llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
+++ b/llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
@@ -22,6 +22,9 @@ declare <16 x float> @llvm.log2.v16f32(<16 x float>)
 declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, 
metadata)
 declare <16 x float> @llvm.experimental.constrained.fadd.v16f32(<16 x float>, 
<16 x float>, metadata, metadata)
 
+declare float @llvm.maximum.f32(float, float)
+declare <16 x float> @llvm.maximum.v16f32(<16 x float>, <16 x float>)
+
 declare i32 @llvm.cttz.i32(i32, i1)
 declare <16 x i32> @llvm.cttz.v16i32(<16 x i32>, i1)
 
@@ -141,6 +144,32 @@ define void @constrained_fadd(float %a, <16 x float> %va) {
   ret void
 }
 
+define void @fmaximum(float %a, float %b, <16 x float> %va, <16 x float> %vb) {
+; THRU-LABEL: 'fmaximum'
+; THRU-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %s = 
call float @llvm.maximum.f32(float %a, float %b)
+; THRU-NEXT:  Cost Model: Found an estimated cost of 784 for instruction: %v = 
call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
+; THRU-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret 
void
+;
+; LATE-LABEL: 'fmaximum'
+; LATE-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %s = 
call float @llvm.maximum.f32(float %a, float %b)
+; LATE-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %v = 
call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
+; LATE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret 
void
+;
+; SIZE-LABEL: 'fmaximum'
+; SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %s = 
call float @llvm.maximum.f32(float %a, float %b)
+; SIZE-NEXT:  Cost Model: Found an estimated cost of 784 for instruction: %v = 
call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
+; SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret 
void
+;
+; SIZE_LATE-LABEL: 'fmaximum'
+; SIZE_LATE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: 
%s = call float @llvm.maximum.f32(float %a, float %b)
+; SIZE_LATE-NEXT:  Cost Model: Found an estimated cost of 784 for instruction: 
%v = call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
+; SIZE_LATE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: 
ret void
+;
+  %s = call float @llvm.maximum.f32(float %a, float %b)
+  %v = call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> 
%vb)
+  ret void
+}
+
 define void @cttz(i32 %a, <16 x i32> %va) {
 ; THRU-LABEL: 'cttz'
 ; THRU-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %s = 
call i32 @llvm.cttz.i32(i32 %a, i1 false)

diff  --git a/llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll 
b/llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll
index 2e53c836676f..f7f0a24af363 100644
--- a/llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll
+++ b/llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll
@@ -25,6 +25,9 @@ declare <16 x float> @llvm.log2.v16f32(<16 x float>)
 declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, 
metadata)
 declare <16 x float> @llvm.experimental.constrained.fadd.v16f32(<16 x float>, 
<16 x float>, metadata, metadata)
 
+declare float @llvm.maximum.f32(float, float)
+declare <16 x float> @llvm.maximum.v16f32(<16 x float>, <16 x float>)
+
 declare i32 @llvm.cttz.i32(i32, i1)
 declare <16 x i32> @llvm.cttz.v16i32(<16 x i32>, i1)
 
@@ -172,6 +175,32 @@ define void @constrained_fadd(float %a, <16 x float> %va) {
   ret void
 }
 
+define void @fmaximum(float %a, float %b, <16 x float> %va, <16 x float> %vb) {
+; THRU-LABEL: 'fmaximum'
+; THRU-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %s = 
call float @llvm.maximum.f32(float %a, float %b)
+; THRU-NEXT:  Cost Model: Found an estimated cost of 52 for instruction: %v = 
call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
+; THRU-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret 
void
+

[llvm-branch-commits] [llvm] 2717252 - [CostModel] add basic handling for FP maximum/minimum intrinsics

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

Author: Sanjay Patel
Date: 2020-11-22T13:43:53-05:00
New Revision: 2717252c929be7b1f14c36dda9686a4aa8726de3

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

LOG: [CostModel] add basic handling for FP maximum/minimum intrinsics

This might be a regression for some ARM targets, but that should
be changed in the target-specific overrides.

There is apparently still no default lowering for these nodes,
so I am assuming these intrinsics are not in common use.
X86, PowerPC, and RISC-V for example, just crash given the most
basic IR.

Added: 


Modified: 
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h 
b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 91c426fb6730..fce025aa75f8 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1396,6 +1396,12 @@ class BasicTTIImplBase : public 
TargetTransformInfoImplCRTPBase {
 case Intrinsic::maxnum:
   ISDs.push_back(ISD::FMAXNUM);
   break;
+case Intrinsic::minimum:
+  ISDs.push_back(ISD::FMINIMUM);
+  break;
+case Intrinsic::maximum:
+  ISDs.push_back(ISD::FMAXIMUM);
+  break;
 case Intrinsic::copysign:
   ISDs.push_back(ISD::FCOPYSIGN);
   break;

diff  --git a/llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll 
b/llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
index 805bd810e950..2ed26243733b 100644
--- a/llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
+++ b/llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll
@@ -146,8 +146,8 @@ define void @constrained_fadd(float %a, <16 x float> %va) {
 
 define void @fmaximum(float %a, float %b, <16 x float> %va, <16 x float> %vb) {
 ; THRU-LABEL: 'fmaximum'
-; THRU-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %s = 
call float @llvm.maximum.f32(float %a, float %b)
-; THRU-NEXT:  Cost Model: Found an estimated cost of 784 for instruction: %v = 
call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
+; THRU-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: %s = 
call float @llvm.maximum.f32(float %a, float %b)
+; THRU-NEXT:  Cost Model: Found an estimated cost of 928 for instruction: %v = 
call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
 ; THRU-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret 
void
 ;
 ; LATE-LABEL: 'fmaximum'
@@ -161,8 +161,8 @@ define void @fmaximum(float %a, float %b, <16 x float> %va, 
<16 x float> %vb) {
 ; SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret 
void
 ;
 ; SIZE_LATE-LABEL: 'fmaximum'
-; SIZE_LATE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: 
%s = call float @llvm.maximum.f32(float %a, float %b)
-; SIZE_LATE-NEXT:  Cost Model: Found an estimated cost of 784 for instruction: 
%v = call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
+; SIZE_LATE-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: 
%s = call float @llvm.maximum.f32(float %a, float %b)
+; SIZE_LATE-NEXT:  Cost Model: Found an estimated cost of 928 for instruction: 
%v = call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
 ; SIZE_LATE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: 
ret void
 ;
   %s = call float @llvm.maximum.f32(float %a, float %b)

diff  --git a/llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll 
b/llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll
index f7f0a24af363..4d0dbe544fb5 100644
--- a/llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll
+++ b/llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll
@@ -177,8 +177,8 @@ define void @constrained_fadd(float %a, <16 x float> %va) {
 
 define void @fmaximum(float %a, float %b, <16 x float> %va, <16 x float> %vb) {
 ; THRU-LABEL: 'fmaximum'
-; THRU-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %s = 
call float @llvm.maximum.f32(float %a, float %b)
-; THRU-NEXT:  Cost Model: Found an estimated cost of 52 for instruction: %v = 
call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
+; THRU-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: %s = 
call float @llvm.maximum.f32(float %a, float %b)
+; THRU-NEXT:  Cost Model: Found an estimated cost of 196 for instruction: %v = 
call <16 x float> @llvm.maximum.v16f32(<16 x float> %va, <16 x float> %vb)
 ; THRU-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret 
void
 ;
 ; LATE-LABEL: 'fmaximum'
@@ -192,8 +192,8 @@ define void @fmaximum(float %a, float %b, <16 x float> %va, 
<16 x floa

[llvm-branch-commits] [llvm] 6f5ef64 - [BasicAA] Avoid unnecessary cache update (NFC)

2020-11-22 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-11-22T20:10:45+01:00
New Revision: 6f5ef648a57aed3274118dcbd6467e8ac4f6ed1f

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

LOG: [BasicAA] Avoid unnecessary cache update (NFC)

If the final recursive query returns MayAlias as well, there is
no need to update the cache (which already stores MayAlias).

Added: 


Modified: 
llvm/lib/Analysis/BasicAliasAnalysis.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp 
b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index cfc1c59c15d9..16043da339c3 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1785,7 +1785,11 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, 
LocationSize V1Size,
   // memory locations. We have already ensured that BasicAA has a MayAlias
   // cache result for these, so any recursion back into BasicAA won't loop.
   AliasResult Result = getBestAAResults().alias(Locs.first, Locs.second, AAQI);
-  return AAQI.updateResult(Locs, Result);
+  if (Result != MayAlias)
+return AAQI.updateResult(Locs, Result);
+
+  // MayAlias is already in the cache.
+  return MayAlias;
 }
 
 /// Check whether two Values can be considered equivalent.



___
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] 825f80e - [Sema] Introduce function reference conversion, NFC

2020-11-22 Thread Aaron Puchert via llvm-branch-commits

Author: Aaron Puchert
Date: 2020-11-22T20:51:57+01:00
New Revision: 825f80e111f2815a009084f65267be3b5bf0897a

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

LOG: [Sema] Introduce function reference conversion, NFC

Technically 'noexcept' isn't a qualifier, so this should be a separate 
conversion.

Also make the test a pure frontend test.

Reviewed By: rsmith

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

Added: 
clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp

Modified: 
clang/include/clang/AST/OperationKinds.def
clang/include/clang/Sema/Initialization.h
clang/lib/Sema/SemaInit.cpp

Removed: 
clang/test/CodeGenCXX/implicit-function-conversion.cpp



diff  --git a/clang/include/clang/AST/OperationKinds.def 
b/clang/include/clang/AST/OperationKinds.def
index 6daab1ffcb0a..7c82ab6e57ef 100644
--- a/clang/include/clang/AST/OperationKinds.def
+++ b/clang/include/clang/AST/OperationKinds.def
@@ -77,9 +77,10 @@ CAST_OPERATION(LValueToRValueBitCast)
 CAST_OPERATION(LValueToRValue)
 
 /// CK_NoOp - A conversion which does not affect the type other than
-/// (possibly) adding qualifiers.
+/// (possibly) adding qualifiers or removing noexcept.
 ///   int-> int
 ///   char** -> const char * const *
+///   void () noexcept -> void ()
 CAST_OPERATION(NoOp)
 
 /// CK_BaseToDerived - A conversion from a C++ class pointer/reference

diff  --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 6976e7c95c8b..2245c1505001 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -840,6 +840,9 @@ class InitializationSequence {
 /// Perform a qualification conversion, producing an lvalue.
 SK_QualificationConversionLValue,
 
+/// Perform a function reference conversion, see [dcl.init.ref]p4.
+SK_FunctionReferenceConversion,
+
 /// Perform a conversion adding _Atomic to a type.
 SK_AtomicConversion,
 
@@ -1288,6 +1291,10 @@ class InitializationSequence {
   void AddQualificationConversionStep(QualType Ty,
  ExprValueKind Category);
 
+  /// Add a new step that performs a function reference conversion to the
+  /// given type.
+  void AddFunctionReferenceConversionStep(QualType Ty);
+
   /// Add a new step that performs conversion from non-atomic to atomic
   /// type.
   void AddAtomicConversionStep(QualType Ty);

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 5131ce446d04..6d2e6094e79c 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -3442,6 +3442,7 @@ void InitializationSequence::Step::Destroy() {
   case SK_QualificationConversionRValue:
   case SK_QualificationConversionXValue:
   case SK_QualificationConversionLValue:
+  case SK_FunctionReferenceConversion:
   case SK_AtomicConversion:
   case SK_ListInitialization:
   case SK_UnwrapInitList:
@@ -3620,6 +3621,13 @@ void 
InitializationSequence::AddQualificationConversionStep(QualType Ty,
   Steps.push_back(S);
 }
 
+void InitializationSequence::AddFunctionReferenceConversionStep(QualType Ty) {
+  Step S;
+  S.Kind = SK_FunctionReferenceConversion;
+  S.Type = Ty;
+  Steps.push_back(S);
+}
+
 void InitializationSequence::AddAtomicConversionStep(QualType Ty) {
   Step S;
   S.Kind = SK_AtomicConversion;
@@ -4653,7 +4661,7 @@ static OverloadingResult TryRefInitWithConversionFunction(
   else if (RefConv & Sema::ReferenceConversions::ObjC)
 Sequence.AddObjCObjectConversionStep(cv1T1);
   else if (RefConv & Sema::ReferenceConversions::Function)
-Sequence.AddQualificationConversionStep(cv1T1, VK);
+Sequence.AddFunctionReferenceConversionStep(cv1T1);
   else if (RefConv & Sema::ReferenceConversions::Qualification) {
 if (!S.Context.hasSameType(cv1T4, cv1T1))
   Sequence.AddQualificationConversionStep(cv1T1, VK);
@@ -4755,12 +4763,12 @@ static void TryReferenceInitializationCore(Sema &S,
   Sequence.AddDerivedToBaseCastStep(cv1T1, VK_LValue);
 else
   Sequence.AddObjCObjectConversionStep(cv1T1);
-  } else if (RefConv & (Sema::ReferenceConversions::Qualification |
-Sema::ReferenceConversions::Function)) {
+  } else if (RefConv & Sema::ReferenceConversions::Qualification) {
 // Perform a (possibly multi-level) qualification conversion.
-// FIXME: Should we use a 
diff erent step kind for function conversions?
 Sequence.AddQualificationConversionStep(cv1T1,
 Initializer->getValueKind());
+  } else if (RefConv & Sema::ReferenceConversions::Function) {
+Sequence.AddFunctionReferenceConversionStep(cv1T1);
   }
 
   // We only create a temporary he

[llvm-branch-commits] [llvm] 1a00929 - Build reproducible tarballs for releases

2020-11-22 Thread Aaron Puchert via llvm-branch-commits

Author: Aaron Puchert
Date: 2020-11-22T20:51:58+01:00
New Revision: 1a009296a4e9a50e85908f9141c3c1ea860d73e4

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

LOG: Build reproducible tarballs for releases

Currently the tarballs contain superfluous metadata, like the user name
of the packager and via Pax headers even the PID of the tar process that
packaged the files. We build the monorepo projects directly from the git
repo using "git archive" and for the test-suite we add some flags as
recommended by https://reproducible-builds.org/docs/archives/. We don't
use numeric owners though to be compatible with "git archive".

The advantage of "git archive" is that the releaser doesn't have to
download the tar ball and extract it, rather the archive is built
directly from the repository. This is probably what GitHub uses
internally to produce the tarballs, so I wouldn't expect a difference.

Reviewed By: tstellar

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

Added: 


Modified: 
llvm/utils/release/export.sh

Removed: 




diff  --git a/llvm/utils/release/export.sh b/llvm/utils/release/export.sh
index 3ffd7e78dd63..0c76ed047081 100755
--- a/llvm/utils/release/export.sh
+++ b/llvm/utils/release/export.sh
@@ -13,7 +13,7 @@
 
 set -e
 
-projects="llvm clang test-suite compiler-rt libcxx libcxxabi libclc 
clang-tools-extra polly lldb lld openmp libunwind flang"
+projects="llvm clang compiler-rt libcxx libcxxabi libclc clang-tools-extra 
polly lldb lld openmp libunwind flang"
 
 release=""
 rc=""
@@ -37,26 +37,34 @@ export_sources() {
 tag="$tag-$rc"
 fi
 
-llvm_src_dir=llvm-project-$release$rc
-mkdir -p $llvm_src_dir
+llvm_src_dir=$(readlink -f $(dirname "$(readlink -f "$0")")/../../..)
+[ -d $llvm_src_dir/.git ] || ( echo "No git repository at $llvm_src_dir" ; 
exit 1 )
 
 echo $tag
-echo "Fetching LLVM project source ..."
-curl -L https://github.com/llvm/llvm-project/archive/$tag.tar.gz | \
-tar -C $llvm_src_dir --strip-components=1 -xzf -
+target_dir=$(pwd)
 
 echo "Creating tarball for llvm-project ..."
-tar -cJf llvm-project-$release$rc.tar.xz $llvm_src_dir
+pushd $llvm_src_dir/
+git archive --prefix=llvm-project-$release$rc.src/ $tag . | xz 
>$target_dir/llvm-project-$release$rc.src.tar.xz
+popd
 
-echo "Fetching LLVM test-suite source ..."
-mkdir -p $llvm_src_dir/test-suite
-curl -L https://github.com/llvm/test-suite/archive/$tag.tar.gz | \
-tar -C $llvm_src_dir/test-suite --strip-components=1 -xzf -
+if [ ! -d test-suite-$release$rc.src ]
+then
+  echo "Fetching LLVM test-suite source ..."
+  mkdir -p test-suite-$release$rc.src
+  curl -L https://github.com/llvm/test-suite/archive/$tag.tar.gz | \
+  tar -C test-suite-$release$rc.src --strip-components=1 -xzf -
+fi
+echo "Creating tarball for test-suite ..."
+tar --sort=name --owner=0 --group=0 \
+--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
+-cJf test-suite-$release$rc.src.tar.xz test-suite-$release$rc.src
 
 for proj in $projects; do
 echo "Creating tarball for $proj ..."
-mv $llvm_src_dir/$proj $llvm_src_dir/$proj-$release$rc.src
-tar -C $llvm_src_dir -cJf $proj-$release$rc.src.tar.xz 
$proj-$release$rc.src
+pushd $llvm_src_dir/$proj
+git archive --prefix=$proj-$release$rc.src/ $tag . | xz 
>$target_dir/$proj-$release$rc.src.tar.xz
+popd
 done
 }
 



___
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] 359e2f9 - [clangd] Introduce config parsing for External blocks

2020-11-22 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-22T20:59:37+01:00
New Revision: 359e2f988dc560d519c91d3ee96a2ea99983f5d4

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

LOG: [clangd] Introduce config parsing for External blocks

Enable configuration of remote and static indexes through config files
in addition to command line arguments.

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

Added: 


Modified: 
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index 766463e11e25..0e4ce638fc72 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -162,6 +162,22 @@ struct Fragment {
 /// This is checked for translation units only, not headers they include.
 /// Legal values are "Build" or "Skip".
 llvm::Optional> Background;
+/// An external index uses data source outside of clangd itself. This is
+/// usually prepared using clangd-indexer.
+/// Exactly one source (File/Server) should be configured.
+struct ExternalBlock {
+  /// Path to an index file generated by clangd-indexer. Relative paths may
+  /// be used, if config fragment is associated with a directory.
+  llvm::Optional> File;
+  /// Address and port number for a clangd-index-server. e.g.
+  /// `123.1.1.1:13337`.
+  llvm::Optional> Server;
+  /// Source root governed by this index. Default is the directory
+  /// associated with the config fragment. Absolute in case of user config
+  /// and relative otherwise. Should always use forward-slashes.
+  llvm::Optional> MountPoint;
+};
+llvm::Optional> External;
   };
   IndexBlock Index;
 

diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index 742abb42670f..a3bb1eb29adb 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -5,7 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===--===//
-
 #include "ConfigFragment.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallSet.h"
@@ -111,6 +110,22 @@ class Parser {
 DictParser Dict("Index", this);
 Dict.handle("Background",
 [&](Node &N) { F.Background = scalarValue(N, "Background"); });
+Dict.handle("External", [&](Node &N) {
+  Fragment::IndexBlock::ExternalBlock External;
+  parse(External, N);
+  F.External.emplace(std::move(External));
+  F.External->Range = N.getSourceRange();
+});
+Dict.parse(N);
+  }
+
+  void parse(Fragment::IndexBlock::ExternalBlock &F, Node &N) {
+DictParser Dict("External", this);
+Dict.handle("File", [&](Node &N) { F.File = scalarValue(N, "File"); });
+Dict.handle("Server",
+[&](Node &N) { F.Server = scalarValue(N, "Server"); });
+Dict.handle("MountPoint",
+[&](Node &N) { F.MountPoint = scalarValue(N, "MountPoint"); });
 Dict.parse(N);
   }
 

diff  --git a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
index 9cdfdf9657d3..1da0f3a1cc71 100644
--- a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -10,6 +10,7 @@
 #include "ConfigFragment.h"
 #include "ConfigTesting.h"
 #include "Protocol.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/SourceMgr.h"
@@ -142,6 +143,25 @@ horrible
   ASSERT_THAT(Results, IsEmpty());
 }
 
+TEST(ParseYAML, ExternalBlock) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+Index:
+  External:
+File: "foo"
+Server: ^"bar"
+MountPoint: "baz"
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  ASSERT_EQ(Results.size(), 1u);
+  ASSERT_TRUE(Results[0].Index.External);
+  EXPECT_THAT(*Results[0].Index.External.getValue()->File, Val("foo"));
+  EXPECT_THAT(*Results[0].Index.External.getValue()->MountPoint, Val("baz"));
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(*Results[0].Index.External.getValue()->Server, Val("bar"));
+}
+
 } // namespace
 } // namespace config
 } // namespace clangd



___
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] c9776c8 - [clangd] Introduce config compilation for External blocks

2020-11-22 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-22T20:59:37+01:00
New Revision: c9776c8d4ef7c1d69b6d74b81627c4028396e7c1

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

LOG: [clangd] Introduce config compilation for External blocks

Compilation logic for External blocks. A few of the high level points:
- Requires exactly one-of File/Server at a time:
  - Server is ignored in case of both, with a warning.
  - Having none is an error, would render ExternalBlock void.
- Ensures mountpoint is an absolute path:
  - Interprets it as relative to FragmentDirectory.
  - Defaults to FragmentDirectory when empty.
- Marks Background as Skip.

Depends on D90748.

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

Added: 


Modified: 
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index ff285d34633b..318220364e6e 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -26,6 +26,7 @@
 
 #include "support/Context.h"
 #include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
 #include 
 #include 
@@ -58,10 +59,22 @@ struct Config {
   } CompileFlags;
 
   enum class BackgroundPolicy { Build, Skip };
+  /// Describes an external index configuration.
+  struct ExternalIndexSpec {
+enum { File, Server } Kind;
+/// This is one of:
+/// - Address of a clangd-index-server, in the form of "ip:port".
+/// - Absolute path to an index produced by clangd-indexer.
+std::string Location;
+/// Absolute path to source root this index is associated with, uses
+/// forward-slashes.
+std::string MountPoint;
+  };
   /// Controls background-index behavior.
   struct {
 /// Whether this TU should be indexed.
 BackgroundPolicy Background = BackgroundPolicy::Build;
+llvm::Optional External;
   } Index;
 
   /// Style of the codebase.

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 3f4dcd3c036d..846c6a170b38 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -27,11 +27,19 @@
 #include "Config.h"
 #include "ConfigFragment.h"
 #include "ConfigProvider.h"
+#include "Features.inc"
 #include "support/Logger.h"
 #include "support/Trace.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/SMLoc.h"
@@ -102,6 +110,27 @@ struct FragmentCompiler {
 return Result;
   }
 
+  llvm::Optional makeAbsolute(Located Path,
+   llvm::StringLiteral Description,
+   llvm::sys::path::Style Style) {
+if (llvm::sys::path::is_absolute(*Path))
+  return *Path;
+if (FragmentDirectory.empty()) {
+  diag(Error,
+   llvm::formatv(
+   "{0} must be an absolute path, because this fragment is not "
+   "associated with any directory.",
+   Description)
+   .str(),
+   Path.Range);
+  return llvm::None;
+}
+llvm::SmallString<256> AbsPath = llvm::StringRef(*Path);
+llvm::sys::fs::make_absolute(FragmentDirectory, AbsPath);
+llvm::sys::path::native(AbsPath, Style);
+return AbsPath.str().str();
+  }
+
   // Helper with similar API to StringSwitch, for parsing enum values.
   template  class EnumSwitch {
 FragmentCompiler &Outer;
@@ -243,6 +272,59 @@ struct FragmentCompiler {
 Out.Apply.push_back(
 [Val](const Params &, Config &C) { C.Index.Background = *Val; });
 }
+if (F.External)
+  compile(std::move(**F.External), F.External->Range);
+  }
+
+  void compile(Fragment::IndexBlock::ExternalBlock &&External,
+   llvm::SMRange BlockRange) {
+#ifndef CLANGD_ENABLE_REMOTE
+if (External.Server) {
+  diag(Error, "Clangd isn't compiled with remote index support, ignoring "
+  "Server." External.Server->Range);
+  External.Server.reset();
+}
+#endif
+// Make sure exactly one of the Sources is set.
+unsigned SourceCount =
+External.File.hasValue() + External.Server.hasValue();
+if (SourceCount != 1) {
+  diag(Error, "Exactly one of File or Server must be set.", BlockRange);
+   

[llvm-branch-commits] [clang-tools-extra] 067ffbf - [clangd] Introduce ProjectAwareIndex

2020-11-22 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-22T20:59:37+01:00
New Revision: 067ffbfe60180aa7b1fdd87b2b6e8ccc67a43a76

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

LOG: [clangd] Introduce ProjectAwareIndex

An index implementation that can dispatch to a variety of indexes
depending on the file path. Enables clangd to work with multiple indexes in the
same instance, configured via config files.

Depends on D90749, D90746

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

Added: 
clang-tools-extra/clangd/index/ProjectAware.cpp
clang-tools-extra/clangd/index/ProjectAware.h
clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 3fd110e9e135..d02a5cf3f2ec 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -97,6 +97,7 @@ add_clang_library(clangDaemon
   index/IndexAction.cpp
   index/MemIndex.cpp
   index/Merge.cpp
+  index/ProjectAware.cpp
   index/Ref.cpp
   index/Relation.cpp
   index/Serialization.cpp
@@ -150,6 +151,7 @@ target_link_libraries(clangDaemon
   clangTidy
   ${ALL_CLANG_TIDY_CHECKS}
 
+  clangdRemoteIndex
   clangdSupport
   )
 

diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 318220364e6e..79e94ef6fe37 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -97,4 +97,24 @@ struct Config {
 } // namespace clangd
 } // namespace clang
 
+namespace llvm {
+template <> struct DenseMapInfo {
+  using ExternalIndexSpec = clang::clangd::Config::ExternalIndexSpec;
+  static inline ExternalIndexSpec getEmptyKey() {
+return {ExternalIndexSpec::File, "", ""};
+  }
+  static inline ExternalIndexSpec getTombstoneKey() {
+return {ExternalIndexSpec::File, "TOMB", "STONE"};
+  }
+  static unsigned getHashValue(const ExternalIndexSpec &Val) {
+return llvm::hash_combine(Val.Kind, Val.Location, Val.MountPoint);
+  }
+  static bool isEqual(const ExternalIndexSpec &LHS,
+  const ExternalIndexSpec &RHS) {
+return std::tie(LHS.Kind, LHS.Location, LHS.MountPoint) ==
+   std::tie(RHS.Kind, RHS.Location, RHS.MountPoint);
+  }
+};
+} // namespace llvm
+
 #endif

diff  --git a/clang-tools-extra/clangd/index/ProjectAware.cpp 
b/clang-tools-extra/clangd/index/ProjectAware.cpp
new file mode 100644
index ..58685fd14bf5
--- /dev/null
+++ b/clang-tools-extra/clangd/index/ProjectAware.cpp
@@ -0,0 +1,156 @@
+//===--- ProjectAware.h --*- 
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
+//
+//===--===//
+
+#include "ProjectAware.h"
+#include "Config.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "index/Merge.h"
+#include "index/Ref.h"
+#include "index/Serialization.h"
+#include "index/Symbol.h"
+#include "index/SymbolID.h"
+#include "index/remote/Client.h"
+#include "support/Logger.h"
+#include "support/Threading.h"
+#include "support/Trace.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+class ProjectAwareIndex : public SymbolIndex {
+public:
+  size_t estimateMemoryUsage() const override;
+
+  /// Only queries the associated index with the current context.
+  void lookup(const LookupRequest &Req,
+  llvm::function_ref Callback) const 
override;
+
+  /// Query all indexes while prioritizing the associated one (if any).
+  bool refs(const RefsRequest &Req,
+llvm::function_ref Callback) const override;
+
+  /// Queries only the associates index when Req.RestrictForCodeCompletion is
+  /// set, otherwise queries all.
+  bool
+  fuzzyFind(const FuzzyFindRequest &Req,
+llvm::function_ref Callback) const override;
+
+  /// Query all indexes while prioritizing the associated one (if any).
+  void relations(const RelationsRequest &Req,
+ llvm::function_ref
+ Callback) const override;
+
+  ProjectAwareIndex(IndexFactory Gen) : Gen(std::move(Gen)) {}
+
+private:
+  // Returns the index associated with current context, if any.
+  SymbolIndex *getIndex() const;
+
+  // Sto

[llvm-branch-commits] [clang-tools-extra] cab3136 - [clangd] Use ProjectAwareIndex in ClangdMain

2020-11-22 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-22T20:59:38+01:00
New Revision: cab313680703097f5f4642b348c43018f55a5a4f

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

LOG: [clangd] Use ProjectAwareIndex in ClangdMain

Put project-aware-index between command-line specified static index and
ClangdServer indexes.

This also moves remote-index dependency from clangDaemon to ClangdMain
in an attempt to prevent cyclic dependency between clangDaemon and
remote-index-marshalling.

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

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/index/ProjectAware.cpp
clang-tools-extra/clangd/index/ProjectAware.h
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index d02a5cf3f2ec..72b232b92c08 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -151,7 +151,6 @@ target_link_libraries(clangDaemon
   clangTidy
   ${ALL_CLANG_TIDY_CHECKS}
 
-  clangdRemoteIndex
   clangdSupport
   )
 

diff  --git a/clang-tools-extra/clangd/index/ProjectAware.cpp 
b/clang-tools-extra/clangd/index/ProjectAware.cpp
index 58685fd14bf5..63f8f823f3a7 100644
--- a/clang-tools-extra/clangd/index/ProjectAware.cpp
+++ b/clang-tools-extra/clangd/index/ProjectAware.cpp
@@ -15,7 +15,6 @@
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
-#include "index/remote/Client.h"
 #include "support/Logger.h"
 #include "support/Threading.h"
 #include "support/Trace.h"
@@ -124,33 +123,11 @@ SymbolIndex *ProjectAwareIndex::getIndex() const {
 Entry.first->getSecond() = Gen(External, Tasks);
   return Entry.first->second.get();
 }
-
-std::unique_ptr
-defaultFactory(const Config::ExternalIndexSpec &External,
-   AsyncTaskRunner &Tasks) {
-  switch (External.Kind) {
-  case Config::ExternalIndexSpec::Server:
-log("Associating {0} with remote index at {1}.", External.MountPoint,
-External.Location);
-return remote::getClient(External.Location, External.MountPoint);
-  case Config::ExternalIndexSpec::File:
-log("Associating {0} with monolithic index at {1}.", External.MountPoint,
-External.Location);
-auto NewIndex = std::make_unique(std::make_unique());
-Tasks.runAsync("Load-index:" + External.Location,
-   [File = External.Location, PlaceHolder = NewIndex.get()] {
- if (auto Idx = loadIndex(File, /*UseDex=*/true))
-   PlaceHolder->reset(std::move(Idx));
-   });
-return std::move(NewIndex);
-  }
-  llvm_unreachable("Invalid ExternalIndexKind.");
-}
 } // namespace
 
 std::unique_ptr createProjectAwareIndex(IndexFactory Gen) {
-  return std::make_unique(Gen ? std::move(Gen)
- : defaultFactory);
+  assert(Gen);
+  return std::make_unique(std::move(Gen));
 }
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/index/ProjectAware.h 
b/clang-tools-extra/clangd/index/ProjectAware.h
index 2d7c6ba3ad88..af98ba612751 100644
--- a/clang-tools-extra/clangd/index/ProjectAware.h
+++ b/clang-tools-extra/clangd/index/ProjectAware.h
@@ -23,11 +23,11 @@ namespace clangd {
 using IndexFactory = std::function(
 const Config::ExternalIndexSpec &, AsyncTaskRunner &)>;
 
-/// Returns an index that answers queries using external indices. 
IndexGenerator
-/// can be used to customize how to generate an index from an external source.
-/// The default implementation loads the index asynchronously on the
-/// AsyncTaskRunner. The index will appear empty until loaded.
-std::unique_ptr createProjectAwareIndex(IndexFactory = nullptr);
+/// Returns an index that answers queries using external indices. IndexFactory
+/// specifies how to generate an index from an external source.
+/// IndexFactory must be injected because this code cannot depend on the remote
+/// index client.
+std::unique_ptr createProjectAwareIndex(IndexFactory);
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 08d498f30873..1a70058cd8ab 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -13,6 +13,9 @@
 #include "Protocol.h"
 #include "Transport.h"
 #include "index/Background.h"
+#include "index/Index.h"
+#include "index/Merge.h"
+#include "index/ProjectAware.h"
 #include "index/Serialization.h"
 #include "index/remote/Client.h"
 #include "refactor/Rename.h"
@@ -40,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef _WIN32
 #includ

[llvm-branch-commits] [clang-tools-extra] 6553600 - [clangd] Fix use-after-free in ProjectAwareIndex tests

2020-11-22 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-22T21:29:45+01:00
New Revision: 655360096f27f25a0e2f71729c1c879f1fd8d8a2

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

LOG: [clangd] Fix use-after-free in ProjectAwareIndex tests

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp 
b/clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
index 8adac296ee60..0d14d2ed5d54 100644
--- a/clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
@@ -27,9 +27,9 @@ using testing::ElementsAre;
 using testing::IsEmpty;
 
 std::unique_ptr createIndex() {
-  std::vector Symbols = {symbol("1")};
-  return std::make_unique(std::move(Symbols), RefSlab(),
-RelationSlab());
+  SymbolSlab::Builder Builder;
+  Builder.insert(symbol("1"));
+  return MemIndex::build(std::move(Builder).build(), RefSlab(), 
RelationSlab());
 }
 
 TEST(ProjectAware, Test) {



___
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] [mlir] f4f8a67 - [mlir][Python] Support finding pybind11 from the python environment.

2020-11-22 Thread Stella Laurenzo via llvm-branch-commits

Author: Stella Laurenzo
Date: 2020-11-22T12:52:01-08:00
New Revision: f4f8a67aaf13bc66a2b7d55561b14a3724a5e0de

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

LOG: [mlir][Python] Support finding pybind11 from the python environment.

* Makes `pip install pybind11` do the right thing with no further config.
* Since we now require a version of pybind11 greater than many LTS OS installs 
(>=2.6), a more convenient way to get a recent version is preferable.
* Also adds the version spec to find_package so it will skip older versions 
that may be lying around.
* Tested the full matrix of old system install, no system install, pip install 
and no pip install.

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

Added: 
mlir/cmake/modules/MLIRDetectPythonEnv.cmake

Modified: 
mlir/CMakeLists.txt
mlir/docs/Bindings/Python.md

Removed: 




diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 09ab67ff73dc..c10a169640ee 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -78,14 +78,12 @@ set(MLIR_PYTHON_BINDINGS_VERSION_LOCKED 1 CACHE BOOL
"Links to specific python libraries, resolving all symbols.")
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
+  include(MLIRDetectPythonEnv)
   find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
-  find_package(pybind11 CONFIG REQUIRED)
-  # TODO: pybind11 v2.6 switched from pybind11_INCLUDE_DIRS (plural) to
-  # pybind11_INCLUDE_DIR (singular). A lot has changed in this area since this
-  # was written and overall python config and pybind11 should be modernized.
-  set(pybind11_INCLUDE_DIR ${pybind11_INCLUDE_DIR} ${pybind11_INCLUDE_DIRS})
+  mlir_detect_pybind11_install()
+  find_package(pybind11 2.6 CONFIG REQUIRED)
   message(STATUS "Found pybind11 v${pybind11_VERSION}: 
${pybind11_INCLUDE_DIR}")
   message(STATUS "Python prefix = '${PYTHON_MODULE_PREFIX}', "
  "suffix = '${PYTHON_MODULE_SUFFIX}', "

diff  --git a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake 
b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
new file mode 100644
index ..e3572c37f99e
--- /dev/null
+++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
@@ -0,0 +1,26 @@
+# Macros and functions related to detecting details of the Python environment.
+
+# Detects a pybind11 package installed in the current python environment
+# and sets variables to allow it to be found. This allows pybind11 to be
+# installed via pip, which typically yields a much more recent version than
+# the OS install, which will be available otherwise.
+function(mlir_detect_pybind11_install)
+  if(pybind11_DIR)
+message(STATUS "Using explicit pybind11 cmake directory: ${pybind11_DIR} 
(-Dpybind11_DIR to change)")
+  else()
+message(CHECK_START "Checking for pybind11 in python path...")
+execute_process(
+  COMMAND "${PYTHON_EXECUTABLE}"
+  -c "import pybind11;print(pybind11.get_cmake_dir(), end='')"
+  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+  RESULT_VARIABLE STATUS
+  OUTPUT_VARIABLE PACKAGE_DIR
+  ERROR_QUIET)
+if(NOT STATUS EQUAL "0")
+  message(CHECK_FAIL "not found (install via 'pip install pybind11' or set 
pybind11_DIR)")
+  return()
+endif()
+message(CHECK_PASS "found (${PACKAGE_DIR})")
+set(pybind11_DIR "${PACKAGE_DIR}" PARENT_SCOPE)
+  endif()
+endfunction()

diff  --git a/mlir/docs/Bindings/Python.md b/mlir/docs/Bindings/Python.md
index a1626ea4505e..89f2742e2fad 100644
--- a/mlir/docs/Bindings/Python.md
+++ b/mlir/docs/Bindings/Python.md
@@ -6,9 +6,10 @@ Current status: Under development and not enabled by default
 
 ### Pre-requisites
 
-* [`pybind11`](https://github.com/pybind/pybind11) must be installed and able 
to
-  be located by CMake. Note: minimum version required: :2.6.0
 * A relatively recent Python3 installation
+* [`pybind11`](https://github.com/pybind/pybind11) must be installed and able 
to
+  be located by CMake (auto-detected if installed via
+  `python -m pip install pybind11`). Note: minimum version required: :2.6.0.
 
 ### CMake variables
 



___
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] 6a9d05a - [gn build] sort of merge 37ac559fccd4

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

Author: Nico Weber
Date: 2020-11-22T16:07:35-05:00
New Revision: 6a9d05a0a2e9c52799df60409a86fdb1b7ee6b9c

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

LOG: [gn build] sort of merge 37ac559fccd4

It'd be nicer if there was a group target that forwarded either to
//clang-tools-extra/clangd/index/remote or
//clangd/index/remote/unimplemented based on if remote index is enabled,
but for now it's never enabled in the gn build.

Added: 


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

Removed: 




diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/clangd/tool/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/tool/BUILD.gn
index 870f1072956e..856e46eaf6eb 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/tool/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/tool/BUILD.gn
@@ -6,6 +6,7 @@ executable("clangd") {
 "//clang-tools-extra/clang-tidy",
 "//clang-tools-extra/clangd",
 "//clang-tools-extra/clangd:features",
+"//clang-tools-extra/clangd/index/remote/unimplemented",
 "//clang-tools-extra/clangd/refactor/tweaks",
 "//clang/lib/AST",
 "//clang/lib/Basic",



___
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] 8c5d751 - [gn build] Port 067ffbfe601

2020-11-22 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-11-22T21:09:32Z
New Revision: 8c5d751b723a52c124fc49ee30bf4a0cbe01d835

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

LOG: [gn build] Port 067ffbfe601

Added: 


Modified: 
llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/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 e99207b51c15..8ca0b9460b46 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
@@ -117,6 +117,7 @@ static_library("clangd") {
 "index/IndexAction.cpp",
 "index/MemIndex.cpp",
 "index/Merge.cpp",
+"index/ProjectAware.cpp",
 "index/Ref.cpp",
 "index/Relation.cpp",
 "index/Serialization.cpp",

diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
index a7e997539643..d9715d8a26db 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
@@ -82,6 +82,7 @@ unittest("ClangdTests") {
 "PathMappingTests.cpp",
 "PreambleTests.cpp",
 "PrintASTTests.cpp",
+"ProjectAwareIndexTests.cpp",
 "QualityTests.cpp",
 "RIFFTests.cpp",
 "RenameTests.cpp",



___
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] f3339b9 - [ARM] MVE VABD tests. NFC

2020-11-22 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-11-22T21:16:49Z
New Revision: f3339b9f988cb86e32179982266cccf8962f7e45

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

LOG: [ARM] MVE VABD tests. NFC

Added: 
llvm/test/CodeGen/Thumb2/mve-vabdus.ll

Modified: 


Removed: 




diff  --git a/llvm/test/CodeGen/Thumb2/mve-vabdus.ll 
b/llvm/test/CodeGen/Thumb2/mve-vabdus.ll
new file mode 100644
index ..cb82f9020d34
--- /dev/null
+++ b/llvm/test/CodeGen/Thumb2/mve-vabdus.ll
@@ -0,0 +1,942 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve %s -o - | 
FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @vabd_s8(<16 x i8> %src1, <16 x i8> %src2) {
+; CHECK-LABEL: vabd_s8:
+; CHECK:   @ %bb.0:
+; CHECK-NEXT:vmov.u8 r0, q1[0]
+; CHECK-NEXT:vmov.16 q2[0], r0
+; CHECK-NEXT:vmov.u8 r0, q1[1]
+; CHECK-NEXT:vmov.16 q2[1], r0
+; CHECK-NEXT:vmov.u8 r0, q1[2]
+; CHECK-NEXT:vmov.16 q2[2], r0
+; CHECK-NEXT:vmov.u8 r0, q1[3]
+; CHECK-NEXT:vmov.16 q2[3], r0
+; CHECK-NEXT:vmov.u8 r0, q1[4]
+; CHECK-NEXT:vmov.16 q2[4], r0
+; CHECK-NEXT:vmov.u8 r0, q1[5]
+; CHECK-NEXT:vmov.16 q2[5], r0
+; CHECK-NEXT:vmov.u8 r0, q1[6]
+; CHECK-NEXT:vmov.16 q2[6], r0
+; CHECK-NEXT:vmov.u8 r0, q1[7]
+; CHECK-NEXT:vmov.16 q2[7], r0
+; CHECK-NEXT:vmov.u8 r0, q0[0]
+; CHECK-NEXT:vmov.16 q3[0], r0
+; CHECK-NEXT:vmov.u8 r0, q0[1]
+; CHECK-NEXT:vmov.16 q3[1], r0
+; CHECK-NEXT:vmov.u8 r0, q0[2]
+; CHECK-NEXT:vmov.16 q3[2], r0
+; CHECK-NEXT:vmov.u8 r0, q0[3]
+; CHECK-NEXT:vmov.16 q3[3], r0
+; CHECK-NEXT:vmov.u8 r0, q0[4]
+; CHECK-NEXT:vmov.16 q3[4], r0
+; CHECK-NEXT:vmov.u8 r0, q0[5]
+; CHECK-NEXT:vmov.16 q3[5], r0
+; CHECK-NEXT:vmov.u8 r0, q0[6]
+; CHECK-NEXT:vmov.16 q3[6], r0
+; CHECK-NEXT:vmov.u8 r0, q0[7]
+; CHECK-NEXT:vmov.16 q3[7], r0
+; CHECK-NEXT:vmovlb.s8 q2, q2
+; CHECK-NEXT:vmovlb.s8 q3, q3
+; CHECK-NEXT:vsub.i16 q2, q3, q2
+; CHECK-NEXT:vabs.s16 q3, q2
+; CHECK-NEXT:vmov.u16 r0, q3[0]
+; CHECK-NEXT:vmov.8 q2[0], r0
+; CHECK-NEXT:vmov.u16 r0, q3[1]
+; CHECK-NEXT:vmov.8 q2[1], r0
+; CHECK-NEXT:vmov.u16 r0, q3[2]
+; CHECK-NEXT:vmov.8 q2[2], r0
+; CHECK-NEXT:vmov.u16 r0, q3[3]
+; CHECK-NEXT:vmov.8 q2[3], r0
+; CHECK-NEXT:vmov.u16 r0, q3[4]
+; CHECK-NEXT:vmov.8 q2[4], r0
+; CHECK-NEXT:vmov.u16 r0, q3[5]
+; CHECK-NEXT:vmov.8 q2[5], r0
+; CHECK-NEXT:vmov.u16 r0, q3[6]
+; CHECK-NEXT:vmov.8 q2[6], r0
+; CHECK-NEXT:vmov.u16 r0, q3[7]
+; CHECK-NEXT:vmov.8 q2[7], r0
+; CHECK-NEXT:vmov.u8 r0, q1[8]
+; CHECK-NEXT:vmov.16 q3[0], r0
+; CHECK-NEXT:vmov.u8 r0, q1[9]
+; CHECK-NEXT:vmov.16 q3[1], r0
+; CHECK-NEXT:vmov.u8 r0, q1[10]
+; CHECK-NEXT:vmov.16 q3[2], r0
+; CHECK-NEXT:vmov.u8 r0, q1[11]
+; CHECK-NEXT:vmov.16 q3[3], r0
+; CHECK-NEXT:vmov.u8 r0, q1[12]
+; CHECK-NEXT:vmov.16 q3[4], r0
+; CHECK-NEXT:vmov.u8 r0, q1[13]
+; CHECK-NEXT:vmov.16 q3[5], r0
+; CHECK-NEXT:vmov.u8 r0, q1[14]
+; CHECK-NEXT:vmov.16 q3[6], r0
+; CHECK-NEXT:vmov.u8 r0, q1[15]
+; CHECK-NEXT:vmov.16 q3[7], r0
+; CHECK-NEXT:vmov.u8 r0, q0[8]
+; CHECK-NEXT:vmovlb.s8 q1, q3
+; CHECK-NEXT:vmov.16 q3[0], r0
+; CHECK-NEXT:vmov.u8 r0, q0[9]
+; CHECK-NEXT:vmov.16 q3[1], r0
+; CHECK-NEXT:vmov.u8 r0, q0[10]
+; CHECK-NEXT:vmov.16 q3[2], r0
+; CHECK-NEXT:vmov.u8 r0, q0[11]
+; CHECK-NEXT:vmov.16 q3[3], r0
+; CHECK-NEXT:vmov.u8 r0, q0[12]
+; CHECK-NEXT:vmov.16 q3[4], r0
+; CHECK-NEXT:vmov.u8 r0, q0[13]
+; CHECK-NEXT:vmov.16 q3[5], r0
+; CHECK-NEXT:vmov.u8 r0, q0[14]
+; CHECK-NEXT:vmov.16 q3[6], r0
+; CHECK-NEXT:vmov.u8 r0, q0[15]
+; CHECK-NEXT:vmov.16 q3[7], r0
+; CHECK-NEXT:vmovlb.s8 q0, q3
+; CHECK-NEXT:vsub.i16 q0, q0, q1
+; CHECK-NEXT:vabs.s16 q0, q0
+; CHECK-NEXT:vmov.u16 r0, q0[0]
+; CHECK-NEXT:vmov.8 q2[8], r0
+; CHECK-NEXT:vmov.u16 r0, q0[1]
+; CHECK-NEXT:vmov.8 q2[9], r0
+; CHECK-NEXT:vmov.u16 r0, q0[2]
+; CHECK-NEXT:vmov.8 q2[10], r0
+; CHECK-NEXT:vmov.u16 r0, q0[3]
+; CHECK-NEXT:vmov.8 q2[11], r0
+; CHECK-NEXT:vmov.u16 r0, q0[4]
+; CHECK-NEXT:vmov.8 q2[12], r0
+; CHECK-NEXT:vmov.u16 r0, q0[5]
+; CHECK-NEXT:vmov.8 q2[13], r0
+; CHECK-NEXT:vmov.u16 r0, q0[6]
+; CHECK-NEXT:vmov.8 q2[14], r0
+; CHECK-NEXT:vmov.u16 r0, q0[7]
+; CHECK-NEXT:vmov.8 q2[15], r0
+; CHECK-NEXT:vmov q0, q2
+; CHECK-NEXT:bx lr
+  %sextsrc1 = sext <16 x i8> %src1 to <16 x i16>
+  %sextsrc2 = sext <16 x i8> %src2 to <16 x i16>
+  %add1 = sub <16 x i16> %sextsrc1, %sextsrc2
+  %add2 = sub <16 x i16

[llvm-branch-commits] [llvm] 191117c - [gn build] (manually) port ed424b428

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

Author: Nico Weber
Date: 2020-11-22T16:19:59-05:00
New Revision: 191117cec5cdffb46fc3b889bd0627b77b798864

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

LOG: [gn build] (manually) port ed424b428

Added: 


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

llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/unimplemented/BUILD.gn

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/BUILD.gn
index 6bb246d894ee..522bec5f5bfe 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/BUILD.gn
@@ -1,7 +1,6 @@
 source_set("remote") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
-"//clang-tools-extra/clangd",
 "//clang-tools-extra/clangd/support",
 "//llvm/lib/Support",
   ]

diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/unimplemented/BUILD.gn
 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/unimplemented/BUILD.gn
index 708e0f54a086..b4efca109fdc 100644
--- 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/unimplemented/BUILD.gn
+++ 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/index/remote/unimplemented/BUILD.gn
@@ -1,7 +1,6 @@
 source_set("unimplemented") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
-"//clang-tools-extra/clangd",
 "//clang-tools-extra/clangd/support",
 "//llvm/lib/Support",
   ]



___
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] c8c3a41 - [ARM] Ensure MVE_TwoOpPattern is used inside Predicate's

2020-11-22 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-11-22T21:38:00Z
New Revision: c8c3a411c50f541ce5362bd60ee3f8fe43ac2722

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

LOG: [ARM] Ensure MVE_TwoOpPattern is used inside Predicate's

Added: 


Modified: 
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARMInstrMVE.td 
b/llvm/lib/Target/ARM/ARMInstrMVE.td
index 66a6d4bd6de0..0f197d57a1f7 100644
--- a/llvm/lib/Target/ARM/ARMInstrMVE.td
+++ b/llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -1962,9 +1962,10 @@ multiclass MVE_VQxDMULH_m {
   def "" : MVE_VQxDMULH_Base;
   defvar Inst = !cast(NAME);
-  defm : MVE_TwoOpPattern;
 
   let Predicates = [HasMVEInt] in {
+defm : MVE_TwoOpPattern;
+
 // Extra unpredicated multiply intrinsic patterns
 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
   (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
@@ -5492,7 +5493,10 @@ class MVE_VxxMUL_qr {
   def "" : MVE_VxxMUL_qr;
-  defm : MVE_TwoOpPatternDup(NAME)>;
+
+  let Predicates = [HasMVEInt] in {
+defm : MVE_TwoOpPatternDup(NAME)>;
+  }
   defm : MVE_vec_scalar_int_pat_m(NAME), VTI, int_unpred, 
int_pred>;
 }
 



___
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] 15a3ae1 - [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-22 Thread Zequan Wu via llvm-branch-commits

Author: Zequan Wu
Date: 2020-11-22T16:05:53-08:00
New Revision: 15a3ae1ab1a64cc62041c32ba54914a9dd7b8361

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

LOG: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

According to https://eel.is/c++draft/cpp.predefined#2.6, `__STDCPP_THREADS__` 
is a predefined macro.

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

Added: 
clang/test/CXX/cpp/cpp.predefined/p2.cpp

Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Preprocessor/init-aarch64.c

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 6452d2bb25f6..e710c5792d76 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -211,9 +211,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// The name of the relocation model to use.
   llvm::Reloc::Model RelocationModel;
 
-  /// The thread model to use
-  std::string ThreadModel;
-
   /// If not an empty string, trap intrinsics are lowered to calls to this
   /// function instead of to trap instructions.
   std::string TrapFuncName;

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 3788ae87f6b9..9c573b43049c 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -330,6 +330,7 @@ VALUE_LANGOPT(TrivialAutoVarInitStopAfter, 32, 0,
  "stop trivial automatic variable initialization after the 
specified number of instances. Must be greater than 0.")
 ENUM_LANGOPT(SignedOverflowBehavior, SignedOverflowBehaviorTy, 2, 
SOB_Undefined,
  "signed integer overflow handling")
+ENUM_LANGOPT(ThreadModel  , ThreadModelKind, 2, ThreadModelKind::POSIX, 
"Thread Model")
 
 BENIGN_LANGOPT(ArrowDepth, 32, 256,
"maximum number of operator->s to follow")

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index dea9d217cf0c..7806483ec5b5 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -232,6 +232,13 @@ class LangOptions : public LangOptionsBase {
 BKey
   };
 
+  enum class ThreadModelKind {
+/// POSIX Threads.
+POSIX,
+/// Single Threaded Environment.
+Single
+  };
+
 public:
   /// Set of enabled sanitizers.
   SanitizerSet Sanitize;

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 816eaf3bf27e..243468598928 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -453,10 +453,14 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   const clang::TargetOptions &TargetOpts,
   const LangOptions &LangOpts,
   const HeaderSearchOptions &HSOpts) {
-  Options.ThreadModel =
-  llvm::StringSwitch(CodeGenOpts.ThreadModel)
-  .Case("posix", llvm::ThreadModel::POSIX)
-  .Case("single", llvm::ThreadModel::Single);
+  switch (LangOpts.getThreadModel()) {
+  case LangOptions::ThreadModelKind::POSIX:
+Options.ThreadModel = llvm::ThreadModel::POSIX;
+break;
+  case LangOptions::ThreadModelKind::Single:
+Options.ThreadModel = llvm::ThreadModel::Single;
+break;
+  }
 
   // Set float ABI type.
   assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" ||

diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 04bd6680e31c..de5c1a4c8f02 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -49,7 +49,7 @@ class PCHContainerGenerator : public ASTConsumer {
   const PreprocessorOptions &PreprocessorOpts;
   CodeGenOptions CodeGenOpts;
   const TargetOptions TargetOpts;
-  const LangOptions LangOpts;
+  LangOptions LangOpts;
   std::unique_ptr VMContext;
   std::unique_ptr M;
   std::unique_ptr Builder;
@@ -147,7 +147,7 @@ class PCHContainerGenerator : public ASTConsumer {
 // The debug info output isn't affected by CodeModel and
 // ThreadModel, but the backend expects them to be nonempty.
 CodeGenOpts.CodeModel = "default";
-CodeGenOpts.ThreadModel = "single";
+LangOpts.setThreadModel(LangOptions::ThreadModelKind::Single);
 CodeGenOpts.DebugTypeExtRefs = true;
 // When building 

[llvm-branch-commits] [mlir] 95956c1 - [MLIR] ODS typedef gen fixes & improvements

2020-11-22 Thread John Demme via llvm-branch-commits

Author: John Demme
Date: 2020-11-22T16:06:14-08:00
New Revision: 95956c1c9aae7ea21c2b2f7a21e0901d549bd190

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

LOG: [MLIR] ODS typedef gen fixes & improvements

- Fixes bug 48242 point 3 crash.
- Makes the improvments from points 1 & 2.

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

```
   def RTLValueType : Type, "Type"> {
 string cppType = "::mlir::Type";
   }
```
Works now, but merely by happenstance. Parameters expects a `TypeParameter` 
class def or a string representing a c++ type but doesn't enforce it.

Reviewed By: lattner

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

Added: 


Modified: 
mlir/lib/TableGen/TypeDef.cpp
mlir/test/mlir-tblgen/typedefs.td
mlir/tools/mlir-tblgen/TypeDefGen.cpp

Removed: 




diff  --git a/mlir/lib/TableGen/TypeDef.cpp b/mlir/lib/TableGen/TypeDef.cpp
index 86373a481239..aa7f36a3626b 100644
--- a/mlir/lib/TableGen/TypeDef.cpp
+++ b/mlir/lib/TableGen/TypeDef.cpp
@@ -112,6 +112,8 @@ llvm::Optional TypeParameter::getAllocator() 
const {
 
   if (auto *typeParameter = dyn_cast(parameterType)) {
 llvm::RecordVal *code = typeParameter->getDef()->getValue("allocator");
+if (!code)
+  return llvm::Optional();
 if (llvm::CodeInit *ci = dyn_cast(code->getValue()))
   return ci->getValue();
 if (isa(code->getValue()))

diff  --git a/mlir/test/mlir-tblgen/typedefs.td 
b/mlir/test/mlir-tblgen/typedefs.td
index ae459df4934d..6db866a10c8d 100644
--- a/mlir/test/mlir-tblgen/typedefs.td
+++ b/mlir/test/mlir-tblgen/typedefs.td
@@ -6,6 +6,11 @@ include "mlir/IR/OpBase.td"
 // DECL: #ifdef GET_TYPEDEF_CLASSES
 // DECL: #undef GET_TYPEDEF_CLASSES
 
+// DECL: namespace mlir {
+// DECL: class DialectAsmParser;
+// DECL: class DialectAsmPrinter;
+// DECL: } // namespace mlir
+
 // DECL: ::mlir::Type generatedTypeParser(::mlir::MLIRContext* ctxt, 
::mlir::DialectAsmParser& parser, ::llvm::StringRef mnenomic);
 // DECL: ::mlir::LogicalResult generatedTypePrinter(::mlir::Type type, 
::mlir::DialectAsmPrinter& printer);
 
@@ -34,6 +39,10 @@ def A_SimpleTypeA : TestType<"SimpleA"> {
 // DECL: class SimpleAType: public ::mlir::Type
 }
 
+def RTLValueType : Type, "Type"> {
+  string cppType = "::mlir::Type";
+}
+
 // A more complex parameterized type
 def B_CompoundTypeA : TestType<"CompoundA"> {
   let summary = "A more complex parameterized type";
@@ -44,14 +53,15 @@ def B_CompoundTypeA : TestType<"CompoundA"> {
   "int":$widthOfSomething,
   "::mlir::test::SimpleTypeA": $exampleTdType,
   "SomeCppStruct": $exampleCppType,
-  ArrayRefParameter<"int", "Matrix dimensions">:$dims
+  ArrayRefParameter<"int", "Matrix dimensions">:$dims,
+  RTLValueType:$inner
   );
 
   let genVerifyInvariantsDecl = 1;
 
 // DECL-LABEL: class CompoundAType: public ::mlir::Type
-// DECL: static ::mlir::LogicalResult verifyConstructionInvariants(Location 
loc, int widthOfSomething, ::mlir::test::SimpleTypeA exampleTdType, 
SomeCppStruct exampleCppType, ::llvm::ArrayRef dims);
-// DECL: static ::mlir::Type getChecked(Location loc, int widthOfSomething, 
::mlir::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, 
::llvm::ArrayRef dims);
+// DECL: static ::mlir::LogicalResult 
verifyConstructionInvariants(::mlir::Location loc, int widthOfSomething, 
::mlir::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, 
::llvm::ArrayRef dims, ::mlir::Type inner);
+// DECL: static ::mlir::Type getChecked(::mlir::Location loc, int 
widthOfSomething, ::mlir::test::SimpleTypeA exampleTdType, SomeCppStruct 
exampleCppType, ::llvm::ArrayRef dims, ::mlir::Type inner);
 // DECL: static ::llvm::StringRef getMnemonic() { return "cmpnd_a"; }
 // DECL: static ::mlir::Type parse(::mlir::MLIRContext* ctxt, 
::mlir::DialectAsmParser& parser);
 // DECL: void print(::mlir::DialectAsmPrinter& printer) const;

diff  --git a/mlir/tools/mlir-tblgen/TypeDefGen.cpp 
b/mlir/tools/mlir-tblgen/TypeDefGen.cpp
index 4473f629f3f1..0990a5afb884 100644
--- a/mlir/tools/mlir-tblgen/TypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/TypeDefGen.cpp
@@ -133,6 +133,15 @@ class TypeParamCommaFormatter : public 
llvm::detail::format_adapter {
 // GEN: TypeDef declarations
 
//===--===//
 
+/// Print this above all the other declarations. Contains type declarations 
used
+/// later on.
+static const char *const typeDefDeclHeader = R"(
+namespace mlir {
+class DialectAsmParser;
+class DialectAsmPrinter;
+} // namespace mlir
+)";
+
 /// The code block for the start of a typeDef class declaration -- singleton
 /// case.
 ///
@@ -174,8 +183,8 @@ static const char *const typeDefParsePrint = R"(
 ///
 /// {0}: List of parameters, parameters style.
 static c

[llvm-branch-commits] [llvm] 186d129 - [hwasan] Remove unused declaration shadowBase (NFC)

2020-11-22 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-11-22T20:08:51-08:00
New Revision: 186d129320c85dd3b1a108acf96046d811a6f8cf

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

LOG: [hwasan] Remove unused declaration shadowBase (NFC)

The function was introduced on Jan 23, 2019 in commit
73078ecd381b5ce95638c7a8e41fcabb6c27703a.

Its definition was removed on Oct 27, 2020 in commit
0930763b4baf926a39dd2d0571fd9e2102ec3831, leaving the declaration
unused.

Added: 


Modified: 
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 385795812df4..25b70f7ea68c 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -213,7 +213,6 @@ class HWAddressSanitizer {
   Value *getShadowNonTls(IRBuilder<> &IRB);
 
   void untagPointerOperand(Instruction *I, Value *Addr);
-  Value *shadowBase();
   Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
   void instrumentMemAccessInline(Value *Ptr, bool IsWrite,
  unsigned AccessSizeIndex,



___
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] df73b8c - [ValueMapper] Remove unused declaration remapFunction (NFC)

2020-11-22 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-11-22T21:52:03-08:00
New Revision: df73b8c174820557608bf364dcf4dfb2bdc1811e

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

LOG: [ValueMapper] Remove unused declaration remapFunction (NFC)

The function declaration with two parameters was introduced on Apr 16
2016 in commit f0d73f95c15f909c6034f1735632695248bb75a8 without a
corresponding definition.

Added: 


Modified: 
llvm/lib/Transforms/Utils/ValueMapper.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp 
b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index ec5769309f86..fac7b555e975 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -172,7 +172,6 @@ class Mapper {
 bool IsOldCtorDtor,
 ArrayRef NewMembers);
   void mapGlobalIndirectSymbol(GlobalIndirectSymbol &GIS, Constant &Target);
-  void remapFunction(Function &F, ValueToValueMapTy &VM);
 
   ValueToValueMapTy &getVM() { return *MCs[CurrentMCID].VM; }
   ValueMaterializer *getMaterializer() { return MCs[CurrentMCID].Materializer; 
}



___
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] 85d6af3 - [CodeGen] Use pred_empty (NFC)

2020-11-22 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-11-22T22:16:13-08:00
New Revision: 85d6af393c6e9ff8437e567dbf9e40d2026b7bc8

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

LOG: [CodeGen] Use pred_empty (NFC)

Added: 


Modified: 
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/WasmEHPrepare.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp 
b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 825d3ee520fc..4ddfe0ad48c7 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -559,7 +559,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
 
   for (SmallVectorImpl::iterator
  II = Successors.begin(), IE = Successors.end(); II != IE; ++II)
-if (pred_begin(*II) == pred_end(*II))
+if (pred_empty(*II))
   WorkList.insert(*II);
 }
 
@@ -573,7 +573,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
 
   for (SmallVectorImpl::iterator
  II = Successors.begin(), IE = Successors.end(); II != IE; ++II)
-if (pred_begin(*II) == pred_end(*II))
+if (pred_empty(*II))
   WorkList.insert(*II);
 }
 
@@ -2300,7 +2300,7 @@ bool 
CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB, bool &ModifiedDT
   }
 
   // If we eliminated all predecessors of the block, delete the block now.
-  if (Changed && !BB->hasAddressTaken() && pred_begin(BB) == pred_end(BB))
+  if (Changed && !BB->hasAddressTaken() && pred_empty(BB))
 BB->eraseFromParent();
 
   return Changed;

diff  --git a/llvm/lib/CodeGen/WasmEHPrepare.cpp 
b/llvm/lib/CodeGen/WasmEHPrepare.cpp
index 44f4fe2ff9b1..171ba78203ec 100644
--- a/llvm/lib/CodeGen/WasmEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WasmEHPrepare.cpp
@@ -169,7 +169,7 @@ static void eraseDeadBBsAndChildren(const Container &BBs, 
DomTreeUpdater *DTU) {
   SmallVector WL(BBs.begin(), BBs.end());
   while (!WL.empty()) {
 auto *BB = WL.pop_back_val();
-if (pred_begin(BB) != pred_end(BB))
+if (!pred_empty(BB))
   continue;
 WL.append(succ_begin(BB), succ_end(BB));
 DeleteDeadBlock(BB, DTU);



___
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] 47e31d1 - [NFC] Reduce code duplication in binop processing in computeExitLimitFromCondCached

2020-11-22 Thread Max Kazantsev via llvm-branch-commits

Author: Max Kazantsev
Date: 2020-11-23T13:18:12+07:00
New Revision: 47e31d1b5eac6a7b69a50404ecdc35daf18c01f9

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

LOG: [NFC] Reduce code duplication in binop processing in 
computeExitLimitFromCondCached

Handling of `and` and `or` vastly uses copy-paste. Factored out into
a helper function as preparation step for further fix (see PR48225).

Differential Revision: https://reviews.llvm.org/D91864
Reviewed By: nikic

Added: 


Modified: 
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/ScalarEvolution.h 
b/llvm/include/llvm/Analysis/ScalarEvolution.h
index a45034fb5494..677433c32556 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1669,7 +1669,14 @@ class ScalarEvolution {
  Value *ExitCond, bool ExitIfTrue,
  bool ControlsExit,
  bool AllowPredicates);
-
+  Optional
+  computeExitLimitFromCondFromBinOp(ExitLimitCacheTy &Cache, const Loop *L,
+Value *ExitCond, bool ExitIfTrue,
+bool ControlsExit, bool AllowPredicates);
+  ExitLimit computeExitLimitFromCondFromBinOpHelper(
+  ExitLimitCacheTy &Cache, const Loop *L, BinaryOperator *BO,
+  bool EitherMayExit, bool ExitIfTrue, bool ControlsExit,
+  bool AllowPredicates, const Constant *NeutralElement);
   /// Compute the number of times the backedge of the specified loop will
   /// execute if its exit condition were a conditional branch of the ICmpInst
   /// ExitCond and ExitIfTrue. If AllowPredicates is set, this call will try

diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp 
b/llvm/lib/Analysis/ScalarEvolution.cpp
index 3176f8fc12f5..496b0da8853a 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7521,114 +7521,10 @@ ScalarEvolution::ExitLimit 
ScalarEvolution::computeExitLimitFromCondCached(
 ScalarEvolution::ExitLimit ScalarEvolution::computeExitLimitFromCondImpl(
 ExitLimitCacheTy &Cache, const Loop *L, Value *ExitCond, bool ExitIfTrue,
 bool ControlsExit, bool AllowPredicates) {
-  // Check if the controlling expression for this loop is an And or Or.
-  if (BinaryOperator *BO = dyn_cast(ExitCond)) {
-if (BO->getOpcode() == Instruction::And) {
-  // Recurse on the operands of the and.
-  bool EitherMayExit = !ExitIfTrue;
-  ExitLimit EL0 = computeExitLimitFromCondCached(
-  Cache, L, BO->getOperand(0), ExitIfTrue,
-  ControlsExit && !EitherMayExit, AllowPredicates);
-  ExitLimit EL1 = computeExitLimitFromCondCached(
-  Cache, L, BO->getOperand(1), ExitIfTrue,
-  ControlsExit && !EitherMayExit, AllowPredicates);
-  // Be robust against unsimplified IR for the form "and i1 X, true"
-  if (ConstantInt *CI = dyn_cast(BO->getOperand(1)))
-return CI->isOne() ? EL0 : EL1;
-  if (ConstantInt *CI = dyn_cast(BO->getOperand(0)))
-return CI->isOne() ? EL1 : EL0;
-  const SCEV *BECount = getCouldNotCompute();
-  const SCEV *MaxBECount = getCouldNotCompute();
-  if (EitherMayExit) {
-// Both conditions must be true for the loop to continue executing.
-// Choose the less conservative count.
-if (EL0.ExactNotTaken == getCouldNotCompute() ||
-EL1.ExactNotTaken == getCouldNotCompute())
-  BECount = getCouldNotCompute();
-else
-  BECount =
-  getUMinFromMismatchedTypes(EL0.ExactNotTaken, EL1.ExactNotTaken);
-if (EL0.MaxNotTaken == getCouldNotCompute())
-  MaxBECount = EL1.MaxNotTaken;
-else if (EL1.MaxNotTaken == getCouldNotCompute())
-  MaxBECount = EL0.MaxNotTaken;
-else
-  MaxBECount =
-  getUMinFromMismatchedTypes(EL0.MaxNotTaken, EL1.MaxNotTaken);
-  } else {
-// Both conditions must be true at the same time for the loop to exit.
-// For now, be conservative.
-if (EL0.MaxNotTaken == EL1.MaxNotTaken)
-  MaxBECount = EL0.MaxNotTaken;
-if (EL0.ExactNotTaken == EL1.ExactNotTaken)
-  BECount = EL0.ExactNotTaken;
-  }
-
-  // There are cases (e.g. PR26207) where computeExitLimitFromCond is able
-  // to be more aggressive when computing BECount than when computing
-  // MaxBECount.  In these cases it is possible for EL0.ExactNotTaken and
-  // EL1.ExactNotTaken to match, but for EL0.MaxNotTaken and 
EL1.MaxNotTaken
-  // to not.
-  if (isa(MaxBECount) &&
-  !isa(BECount))
-M

[llvm-branch-commits] [llvm] 2584e1e - [llvm-readobj] - Don't crash when relocation table goes past the EOF.

2020-11-22 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-23T10:31:04+03:00
New Revision: 2584e1e324c97eeeacc1e421e5f3191a708c3d2d

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

LOG: [llvm-readobj] - Don't crash when relocation table goes past the EOF.

It is possible to trigger reading past the EOF by breaking fields like
DT_PLTRELSZ, DT_RELSZ or DT_RELASZ

This patch adds a validation in `DynRegionInfo` helper class.

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

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test 
b/llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
index bd7916a91fc1..741eaec90d13 100644
--- a/llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
+++ b/llvm/test/tools/llvm-readobj/ELF/broken-dynamic-reloc.test
@@ -49,11 +49,16 @@ ProgramHeaders:
 LastSec:  .dynamic
 
 ## Show we print a warning for an invalid relocation table size stored in a 
DT_RELASZ entry.
-# RUN: yaml2obj --docnum=2 -DRELTYPE=RELA -DTAG1=DT_RELASZ -DTAG1VAL=0xFF 
-DTAG2=DT_RELAENT %s -o %t2
-# RUN: llvm-readobj --dyn-relocations %t2 2>&1 | FileCheck %s -DFILE=%t2 
--check-prefix=INVALID-DT-RELASZ
-# RUN: llvm-readelf --dyn-relocations %t2 2>&1 | FileCheck %s -DFILE=%t2 
--check-prefix=INVALID-DT-RELASZ
 
-# INVALID-DT-RELASZ: warning: '[[FILE]]': invalid DT_RELASZ value (0xff) or 
DT_RELAENT value (0x18)
+## Case A: the size of a single relocation entry is 0x18. In this case 0xFF % 
0x18 != 0 and we report a warning
+
+# RUN: yaml2obj --docnum=2 -DRELTYPE=RELA -DTAG1=DT_RELASZ -DTAG1VAL=0xFF 
-DTAG2=DT_RELAENT %s -o %t2a
+# RUN: llvm-readobj --dyn-relocations %t2a 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t2a --check-prefix=INVALID-DT-RELASZ1 
--implicit-check-not=warning:
+# RUN: llvm-readelf --dyn-relocations %t2a 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t2a --check-prefix=INVALID-DT-RELASZ1 
--implicit-check-not=warning:
+
+# INVALID-DT-RELASZ1: warning: '[[FILE]]': invalid DT_RELASZ value (0xff) or 
DT_RELAENT value (0x18)
 
 --- !ELF
 FileHeader:
@@ -80,19 +85,42 @@ ProgramHeaders:
 FirstSec: .relx.dyn
 LastSec:  .dynamic
 
+## Case B: the DT_RELASZ has value of 0x251, what is too large, because the 
relocation table goes past the EOF.
+
+# RUN: yaml2obj --docnum=2 -DRELTYPE=RELA -DTAG1=DT_RELASZ -DTAG1VAL=0x251 
-DTAG2=DT_RELAENT %s -o %t2b
+# RUN: llvm-readobj --dyn-relocations %t2b 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t2b --check-prefix=INVALID-DT-RELASZ2 
--implicit-check-not=warning:
+# RUN: llvm-readelf --dyn-relocations %t2b 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t2b --check-prefix=INVALID-DT-RELASZ2 
--implicit-check-not=warning:
+
+# INVALID-DT-RELASZ2: warning: '[[FILE]]': unable to read data at 0x78 of size 
0x251 (DT_RELASZ value): it goes past the end of the file of size 0x2c8
+
 ## Show we print a warning for an invalid relocation table entry size stored 
in a DT_RELAENT entry.
 # RUN: yaml2obj --docnum=2 -DRELTYPE=RELA -DTAG1=DT_RELASZ -DTAG2=DT_RELAENT 
-DTAG2VAL=0xFF %s -o %t3
-# RUN: llvm-readobj --dyn-relocations %t3 2>&1 | FileCheck %s -DFILE=%t3 
--check-prefix=INVALID-DT-RELAENT
-# RUN: llvm-readelf --dyn-relocations %t3 2>&1 | FileCheck %s -DFILE=%t3 
--check-prefix=INVALID-DT-RELAENT
+# RUN: llvm-readobj --dyn-relocations %t3 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t3 --check-prefix=INVALID-DT-RELAENT 
--implicit-check-not=warning:
+# RUN: llvm-readelf --dyn-relocations %t3 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t3 --check-prefix=INVALID-DT-RELAENT 
--implicit-check-not=warning:
 
 ## INVALID-DT-RELAENT: warning: '[[FILE]]': invalid DT_RELASZ value (0x18) or 
DT_RELAENT value (0xff)
 
 ## Show we print a warning for an invalid relocation table size stored in a 
DT_RELSZ entry.
-# RUN: yaml2obj --docnum=2 -DRELTYPE=REL -DTAG1=DT_RELSZ -DTAG1VAL=0xFF 
-DTAG2=DT_RELENT %s -o %t4
-# RUN: llvm-readobj --dyn-relocations %t4 2>&1 | FileCheck %s -DFILE=%t4 
--check-prefix=INVALID-DT-RELSZ
-# RUN: llvm-readelf --dyn-relocations %t4 2>&1 | FileCheck %s -DFILE=%t4 
--check-prefix=INVALID-DT-RELSZ
 
-## INVALID-DT-RELSZ: warning: '[[FILE]]': invalid DT_RELSZ value (0xff) or 
DT_RELENT value (0x18)
+## Case A: the size of a single relocation entry is 0x18. In this case 0xFF % 
0x18 != 0 and we report a warning.
+
+# RUN: yaml2obj --docnum=2 -DRELTYPE=REL -DTAG1=DT_RELSZ -DTAG1VAL=0xFF 
-DTAG2=DT_RELENT %s -o %t4a
+# RUN: llvm-readobj --dyn-relocations %t4a 2>&1 | FileCheck %s -DFILE=%t4a 
--check-prefix=INVALID-DT-RELSZ1
+# RUN: llvm-readelf --dyn-relocations %t4a 2>&1 | FileCheck %s -DFILE=%t4a 
--check-prefix=INVALID-DT-RELSZ1
+
+## INVALID-DT-RELSZ1: warning: '[[FILE]]': invalid DT_RELSZ value