[llvm-branch-commits] [libcxx] da97d12 - [libc++] Remove invalid use of `#if _LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11.

2020-12-10 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-12-11T08:31:59+01:00
New Revision: da97d12cc05a2474cd893b996c0d789f766d97b8

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

LOG: [libc++] Remove invalid use of `#if _LIBCPP_STD_VER >= 11`, as 
`_LIBCPP_STD_VER` can never be less than 11.

The relevant part of `__config` is:
```
#ifndef _LIBCPP_STD_VER
#  if  __cplusplus <= 201103L
#define _LIBCPP_STD_VER 11
```

Reviewed By: ldionne, #libc

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

Added: 


Modified: 
libcxx/include/atomic

Removed: 




diff  --git a/libcxx/include/atomic b/libcxx/include/atomic
index 5994b0c5..0fc799a24319 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -1503,8 +1503,6 @@ struct __cxx_atomic_impl : public _Base {
 using __cxx_contention_t = int64_t;
 #endif //__linux__
 
-#if _LIBCPP_STD_VER >= 11
-
 using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
 
 #ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT
@@ -1582,8 +1580,6 @@ _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* 
__a, _Tp const __val, mem
 return __cxx_atomic_wait(__a, __test_fn);
 }
 
-#endif //_LIBCPP_STD_VER >= 11
-
 // general atomic
 
 template ::value && !is_same<_Tp, 
bool>::value>



___
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] 86abc9a - [OpenMPIRBuilder] Fix typo. NFC.

2020-12-10 Thread Michael Kruse via llvm-branch-commits

Author: Michael Kruse
Date: 2020-12-11T00:15:23-06:00
New Revision: 86abc9a1192ba0e8fc9b0756d673a78a6fc13001

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

LOG: [OpenMPIRBuilder] Fix typo. NFC.

Added: 


Modified: 
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Removed: 




diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 2e4bb20c7998..fe06c502489d 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -233,7 +233,7 @@ class OpenMPIRBuilder {
   ///  for (uint8_t i = 100u; i > 0; i += 127u)
   ///
   ///
-  /// TODO: May need to add addtional parameters to represent:
+  /// TODO: May need to add additional parameters to represent:
   ///
   ///  * Allow representing downcounting with unsigned integers.
   ///



___
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] c80e193 - [NFC] Inline maxDevirtIterationsReached()

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

Author: Arthur Eubanks
Date: 2020-12-10T22:12:29-08:00
New Revision: c80e1935876424f9025238750a073092c24cbd44

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

LOG: [NFC] Inline maxDevirtIterationsReached()

This was separated in the past because the cl::opt was in the .cpp file
but DevirtSCCRepeatedPass::run() was in the .h file. Now that
DevirtSCCRepeatedPass::run() is in the .cpp file, get rid of the tiny
maxDevirtIterationsReached(), it's bad for readability.

Added: 


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

Removed: 




diff  --git a/llvm/include/llvm/Analysis/CGSCCPassManager.h 
b/llvm/include/llvm/Analysis/CGSCCPassManager.h
index 99ad0f2dc938..985424a74054 100644
--- a/llvm/include/llvm/Analysis/CGSCCPassManager.h
+++ b/llvm/include/llvm/Analysis/CGSCCPassManager.h
@@ -499,10 +499,6 @@ createCGSCCToFunctionPassAdaptor(FunctionPassT Pass) {
   std::make_unique(std::move(Pass)));
 }
 
-/// Checks -abort-on-max-devirt-iterations-reached to see if we should report 
an
-/// error.
-void maxDevirtIterationsReached();
-
 /// A helper that repeats an SCC pass each time an indirect call is refined to
 /// a direct call by that pass.
 ///

diff  --git a/llvm/lib/Analysis/CGSCCPassManager.cpp 
b/llvm/lib/Analysis/CGSCCPassManager.cpp
index fae78273fb96..59df6059dcf6 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -489,7 +489,8 @@ PreservedAnalyses 
DevirtSCCRepeatedPass::run(LazyCallGraph::SCC ,
 
 // Otherwise, if we've already hit our max, we're done.
 if (Iteration >= MaxIterations) {
-  maxDevirtIterationsReached();
+  if (AbortOnMaxDevirtIterationsReached)
+report_fatal_error("Max devirtualization iterations reached");
   LLVM_DEBUG(
   dbgs() << "Found another devirtualization after hitting the max "
 "number of repetitions ("
@@ -815,11 +816,6 @@ static void 
updateNewSCCFunctionAnalyses(LazyCallGraph::SCC ,
   }
 }
 
-void llvm::maxDevirtIterationsReached() {
-  if (AbortOnMaxDevirtIterationsReached)
-report_fatal_error("Max devirtualization iterations reached");
-}
-
 /// Helper function to update both the \c CGSCCAnalysisManager \p AM and the \c
 /// CGSCCPassManager's \c CGSCCUpdateResult \p UR based on a range of newly
 /// added SCCs.



___
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] 5aa584e - [RISCV] Separate masked and unmasked definitions for pseudo instructions.

2020-12-10 Thread Hsiangkai Wang via llvm-branch-commits

Author: Hsiangkai Wang
Date: 2020-12-11T14:02:56+08:00
New Revision: 5aa584ec713c6aefc34ecc997d98c5f05210fa07

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

LOG: [RISCV] Separate masked and unmasked definitions for pseudo instructions.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir
llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index a0bcea883118..32762fd2803e 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -126,36 +126,88 @@ def RISCVVPseudosTable : GenericTable {
 // Helpers to define the 
diff erent pseudo instructions.
 
//===--===//
 
-multiclass pseudo_binary {
-  let Constraints = "$rd = $merge",
-  Uses = [VL, VTYPE], VLIndex = 5, SEWIndex = 6, MergeOpIndex = 1,
-  BaseInstr = !cast(!subst("Pseudo", "", NAME)) in
-def "_"# vlmul.MX : Pseudo<(outs result_reg_class:$rd),
-(ins result_reg_class:$merge,
- op1_reg_class:$rs2, op2_kind:$rs1,
- VMaskOp:$vm, GPR:$vl, ixlenimm:$sew),
-[]>,
- RISCVVPseudo;
+class PseudoToVInst {
+  string VInst = !subst("_M8", "",
+ !subst("_M4", "",
+ !subst("_M2", "",
+ !subst("_M1", "",
+ !subst("_MF2", "",
+ !subst("_MF4", "",
+ !subst("_MF8", "",
+ !subst("_MASK", "",
+ !subst("Pseudo", "", PseudoInst);
 }
 
-multiclass pseudo_binary_v_vv_vx_vi {
+class VPseudoBinary :
+Pseudo<(outs RetClass:$rd),
+   (ins Op1Class:$rs2, Op2Class:$rs1, GPR:$vl, ixlenimm:$sew), []>,
+RISCVVPseudo {
+  let Uses = [VL, VTYPE];
+  let VLIndex = 3;
+  let SEWIndex = 4;
+  let MergeOpIndex = -1;
+  let BaseInstr = !cast(PseudoToVInst.VInst);
+}
+
+class VPseudoBinaryMask :
+Pseudo<(outs RetClass:$rd),
+(ins RetClass:$merge,
+ Op1Class:$rs2, Op2Class:$rs1,
+ VMaskOp:$vm, GPR:$vl, ixlenimm:$sew), []>,
+RISCVVPseudo {
+  let Constraints = "$rd = $merge";
+  let Uses = [VL, VTYPE];
+  let VLIndex = 5;
+  let SEWIndex = 6;
+  let MergeOpIndex = 1;
+  let BaseInstr = !cast(PseudoToVInst.VInst);
+}
+
+multiclass VPseudoBinary {
+  def "_" # MInfo.MX : VPseudoBinary;
+  def "_" # MInfo.MX # "_MASK" : VPseudoBinaryMask;
+}
+
+multiclass VPseudoBinaryV_VV {
   let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1 in
   foreach m = MxList.m in
   {
 let VLMul = m.value in
-{
-  defvar evr = m.vrclass;
-  defm _VV : pseudo_binary;
-  defm _VX : pseudo_binary;
-  defm _VI : pseudo_binary;
-}
+defm _VV : VPseudoBinary;
+  }
+}
+
+multiclass VPseudoBinaryV_VX {
+  let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1 in
+  foreach m = MxList.m in
+  {
+let VLMul = m.value in
+defm _VX : VPseudoBinary;
+  }
+}
+
+multiclass VPseudoBinaryV_VI {
+  let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1 in
+  foreach m = MxList.m in
+  {
+let VLMul = m.value in
+defm _VI : VPseudoBinary;
   }
 }
 
+multiclass VPseudoBinary_VV_VX_VI {
+  defm "" : VPseudoBinaryV_VV;
+  defm "" : VPseudoBinaryV_VX;
+  defm "" : VPseudoBinaryV_VI;
+}
+
 
//===--===//
 // Helpers to define the 
diff erent patterns.
 
//===--===//
@@ -167,7 +219,7 @@ multiclass pat_vop_binary
 {
@@ -175,10 +227,8 @@ multiclass pat_vop_binary;
 }
 
@@ -300,7 +350,7 @@ foreach vti = AllVectors in
 
//===--===//
 
 // Pseudo instructions.
-defm PseudoVADD: pseudo_binary_v_vv_vx_vi;
+defm PseudoVADD: VPseudoBinary_VV_VX_VI;
 
 // Whole-register vector patterns.
 defm "" : pat_vop_binary_common;

diff  --git a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp 
b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
index 876d557ec79d..b1aacfe878b9 100644
--- a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
+++ b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -176,6 +176,12 @@ static bool lowerRISCVVMachineInstrToMCInst(const 
MachineInstr *MI,
 }
 OutMI.addOperand(MCOp);
   }
+
+  // Unmasked 

[llvm-branch-commits] [llvm] fd78012 - [MemorySSA] Remove unused declaration optimizeUses (NFC)

2020-12-10 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-12-10T20:54:37-08:00
New Revision: fd78012b9e592d1d5e1904cf2dbfdb1a17b803a4

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

LOG: [MemorySSA] Remove unused declaration optimizeUses (NFC)

The declaration was introduced on Aug 2, 2016 in commit
c43aa5a5b62b21c1d38cd3d2ece7d0d5124d5180 without a corresponding
definition.

Note that we do have a definition for
MmeorySSA::OptimizeUses::optimizeUses but not for
MmeorySSA::optimizeUses.

Added: 


Modified: 
llvm/include/llvm/Analysis/MemorySSA.h

Removed: 




diff  --git a/llvm/include/llvm/Analysis/MemorySSA.h 
b/llvm/include/llvm/Analysis/MemorySSA.h
index fc9d6d730635..759024c22f80 100644
--- a/llvm/include/llvm/Analysis/MemorySSA.h
+++ b/llvm/include/llvm/Analysis/MemorySSA.h
@@ -841,7 +841,6 @@ class MemorySSA {
 
   CachingWalker *getWalkerImpl();
   void buildMemorySSA(BatchAAResults );
-  void optimizeUses();
 
   void prepareForMoveTo(MemoryAccess *, BasicBlock *);
   void verifyUseInDefs(MemoryAccess *, MemoryAccess *) const;



___
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] ef1cf34 - [Support] Use is_contained (NFC)

2020-12-10 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2020-12-10T20:40:37-08:00
New Revision: ef1cf345bbc56501f775330ec4a010d22443f6b7

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

LOG: [Support] Use is_contained (NFC)

Added: 


Modified: 
llvm/lib/Support/CommandLine.cpp

Removed: 




diff  --git a/llvm/lib/Support/CommandLine.cpp 
b/llvm/lib/Support/CommandLine.cpp
index a185863fddb9..1b9436d56fdb 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -464,7 +464,7 @@ void Option::addCategory(OptionCategory ) {
   // must be explicitly added if you want multiple categories that include it.
   if ( !=  && Categories[0] == )
 Categories[0] = 
-  else if (find(Categories, ) == Categories.end())
+  else if (!is_contained(Categories, ))
 Categories.push_back();
 }
 
@@ -2590,7 +2590,7 @@ void cl::HideUnrelatedOptions(ArrayRef Categories,
   SubCommand ) {
   for (auto  : Sub.OptionsMap) {
 for (auto  : I.second->Categories) {
-  if (find(Categories, Cat) == Categories.end() && Cat != )
+  if (!is_contained(Categories, Cat) && Cat != )
 I.second->setHiddenFlag(cl::ReallyHidden);
 }
   }



___
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] [polly] bc633fe - [Polly] Consider InvalidContext to determine partial READ.

2020-12-10 Thread Michael Kruse via llvm-branch-commits

Author: Michael Kruse
Date: 2020-12-10T22:25:19-06:00
New Revision: bc633fe46bbec1cf70d4a3f740da43888979d8c6

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

LOG: [Polly] Consider InvalidContext to determine partial READ.

MemoryAccess::setNewAccessRelation() in assert-builds checks whether the
access relation for a READ has a memory location for every instance of
the domain. Otherwise, we would not have value to load from. That check
already considered that instances outside the Scop's context do not
matter since they are never executed (or would be undefined behavior).
In this patch also take instances of the InvalidContext into account,
as these can also be assumed to never occur. InvalidContext was
introduced to avoid the computational complexity of subtracting
restrictions from the AssumedContext. However, this additional check in
setNewAccessRelation is only done in assert-builds.

The assertion case with an InvalidContext may occur with DeLICM on a
conditionally infinite loops, as it is the case in the following code:

for (int i = 0; i < n; i+=b)
  vreg = ...;
*Dest = vreg;

The loop is infinite when b=0, and [b] -> { : b = 0 }  is part of the
InvalidContext. When DeLICM tries to map the memory for %vreg to *Dest,
there is no store instance that uses the value of vreg when b = 0, hence
no location to map it to. However, the case is irrelevant since Polly's
runtime condition check ensures that this is never case.

Fixes llvm.org/PR48445

Added: 
polly/test/DeLICM/load-in-cond-inf-loop.ll

Modified: 
polly/include/polly/Support/ISLTools.h
polly/lib/Analysis/ScopInfo.cpp
polly/lib/Support/ISLTools.cpp

Removed: 




diff  --git a/polly/include/polly/Support/ISLTools.h 
b/polly/include/polly/Support/ISLTools.h
index 41a9021896bc..1e028313153b 100644
--- a/polly/include/polly/Support/ISLTools.h
+++ b/polly/include/polly/Support/ISLTools.h
@@ -478,6 +478,9 @@ isl::map intersectRange(isl::map Map, isl::union_set Range);
 /// @param The map with the parameter conditions removed.
 isl::map subtractParams(isl::map Map, isl::set Params);
 
+/// Subtract the parameter space @p Params from @p Set.
+isl::set subtractParams(isl::set Set, isl::set Params);
+
 /// If @p PwAff maps to a constant, return said constant. If @p Max/@p Min, it
 /// can also be a piecewise constant and it would return the minimum/maximum
 /// value. Otherwise, return NaN.

diff  --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index ba462351af57..97321c018a12 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1079,6 +1079,8 @@ void MemoryAccess::setNewAccessRelation(isl::map 
NewAccess) {
 isl::set StmtDomain = getStatement()->getDomain();
 StmtDomain =
 StmtDomain.intersect_params(getStatement()->getParent()->getContext());
+StmtDomain = subtractParams(
+StmtDomain, getStatement()->getParent()->getInvalidContext());
 isl::set NewDomain = NewAccess.domain();
 assert(StmtDomain.is_subset(NewDomain) &&
"Partial READ accesses not supported");

diff  --git a/polly/lib/Support/ISLTools.cpp b/polly/lib/Support/ISLTools.cpp
index a7c10314c084..9d8278ac669f 100644
--- a/polly/lib/Support/ISLTools.cpp
+++ b/polly/lib/Support/ISLTools.cpp
@@ -524,6 +524,12 @@ isl::map polly::subtractParams(isl::map Map, isl::set 
Params) {
   return Map.subtract(ParamsMap);
 }
 
+isl::set polly::subtractParams(isl::set Set, isl::set Params) {
+  isl::space SetSpace = Set.get_space();
+  isl::set ParamsSet = isl::set::universe(SetSpace).intersect_params(Params);
+  return Set.subtract(ParamsSet);
+}
+
 isl::val polly::getConstant(isl::pw_aff PwAff, bool Max, bool Min) {
   assert(!Max || !Min); // Cannot return min and max at the same time.
   isl::val Result;

diff  --git a/polly/test/DeLICM/load-in-cond-inf-loop.ll 
b/polly/test/DeLICM/load-in-cond-inf-loop.ll
new file mode 100644
index ..d32d975b3262
--- /dev/null
+++ b/polly/test/DeLICM/load-in-cond-inf-loop.ll
@@ -0,0 +1,71 @@
+; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
+
+; When %b is 0, %for.body13 is an infite loop. In this case the loaded
+; value %1 is not used anywhere.
+; This is a problem when DeLICM tries to map %1 to %arrayidx16 because
+; %1 has no corresponding when %b == 0 and therefore hat no location
+; where it can be mapped to. However, since %b == 0 results in an
+; infinite loop, it should not in the Context, or in this case, in the
+; InvalidContext.
+;
+; Test case reduced from llvm.org/PR48445.
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+@arr_18 = external dso_local local_unnamed_addr global [0 x i16], align 2
+
+define void @func(i64 %b, i8* 

[llvm-branch-commits] [llvm] b90e2d8 - [RISCV] Use tail agnostic policy for vsetvli instruction emitted in the custom inserter

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

Author: Craig Topper
Date: 2020-12-10T19:48:03-08:00
New Revision: b90e2d850e780d290b554963db1cd264625a73a4

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

LOG: [RISCV] Use tail agnostic policy for vsetvli instruction emitted in the 
custom inserter

The compiler is making no effort to preserve upper elements. To do so would 
require another source operand tied with the destination and a different 
intrinsic interface to give control of this source to the programmer.

This patch changes the tail policy to agnostic so that the CPU doesn't need to 
make an effort to preserve them.

This is consistent with the RVV intrinsic spec here 
https://github.com/riscv/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#configuration-setting

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir
llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll
llvm/test/CodeGen/RISCV/rvv/load-add-store-16.ll
llvm/test/CodeGen/RISCV/rvv/load-add-store-32.ll
llvm/test/CodeGen/RISCV/rvv/load-add-store-64.ll
llvm/test/CodeGen/RISCV/rvv/load-add-store-8.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 78909b2f4039..d7496b3ac7c9 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1952,7 +1952,7 @@ static MachineBasicBlock *addVSetVL(MachineInstr , 
MachineBasicBlock *BB,
 
   // For simplicity we reuse the vtype representation here.
   MIB.addImm(RISCVVType::encodeVTYPE(Multiplier, ElementWidth,
- /*TailAgnostic*/ false,
+ /*TailAgnostic*/ true,
  /*MaskAgnostic*/ false));
 
   // Remove (now) redundant operands from pseudo

diff  --git a/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir 
b/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir
index bb7228871fc9..b2b07343be2f 100644
--- a/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-gpr.mir
@@ -40,23 +40,23 @@ body: |
 
 # POST-INSERTER: %0:gpr = COPY $x13
 # POST-INSERTER: %4:vr = IMPLICIT_DEF
-# POST-INSERTER: dead %10:gpr = PseudoVSETVLI %0, 12, implicit-def $vl, 
implicit-def $vtype
+# POST-INSERTER: dead %10:gpr = PseudoVSETVLI %0, 76, implicit-def $vl, 
implicit-def $vtype
 # POST-INSERTER: %5:vr = PseudoVLE64_V_M1 %4, %2, $noreg, $noreg, -1, implicit 
$vl, implicit $vtype :: (load unknown-size from %ir.pa, align 8)
 # POST-INSERTER: %6:vr = IMPLICIT_DEF
-# POST-INSERTER: dead %11:gpr = PseudoVSETVLI %0, 12, implicit-def $vl, 
implicit-def $vtype
+# POST-INSERTER: dead %11:gpr = PseudoVSETVLI %0, 76, implicit-def $vl, 
implicit-def $vtype
 # POST-INSERTER: %7:vr = PseudoVLE64_V_M1 %6, %1, $noreg, $noreg, -1, implicit 
$vl, implicit $vtype :: (load unknown-size from %ir.pb, align 8)
 # POST-INSERTER: %8:vr = IMPLICIT_DEF
-# POST-INSERTER: dead %12:gpr = PseudoVSETVLI %0, 12, implicit-def $vl, 
implicit-def $vtype
+# POST-INSERTER: dead %12:gpr = PseudoVSETVLI %0, 76, implicit-def $vl, 
implicit-def $vtype
 # POST-INSERTER: %9:vr = PseudoVADD_VV_M1 %8, killed %5, killed %7, $noreg, 
$noreg, -1, implicit $vl, implicit $vtype
-# POST-INSERTER: dead %13:gpr = PseudoVSETVLI %0, 12, implicit-def $vl, 
implicit-def $vtype
+# POST-INSERTER: dead %13:gpr = PseudoVSETVLI %0, 76, implicit-def $vl, 
implicit-def $vtype
 # POST-INSERTER: PseudoVSE64_V_M1 killed %9, %3, $noreg, $noreg, -1, implicit 
$vl, implicit $vtype :: (store unknown-size into %ir.pc, align 8)
 
-# CODEGEN: vsetvli a4, a3, e64,m1,tu,mu
+# CODEGEN: vsetvli a4, a3, e64,m1,ta,mu
 # CODEGEN-NEXT: vle64.vv25, (a1)
-# CODEGEN-NEXT: vsetvlia1, a3, e64,m1,tu,mu
+# CODEGEN-NEXT: vsetvlia1, a3, e64,m1,ta,mu
 # CODEGEN-NEXT: vle64.vv26, (a2)
-# CODEGEN-NEXT: vsetvlia1, a3, e64,m1,tu,mu
+# CODEGEN-NEXT: vsetvlia1, a3, e64,m1,ta,mu
 # CODEGEN-NEXT: vadd.vvv25, v25, v26
-# CODEGEN-NEXT: vsetvlia1, a3, e64,m1,tu,mu
+# CODEGEN-NEXT: vsetvlia1, a3, e64,m1,ta,mu
 # CODEGEN-NEXT: vse64.vv25, (a0)
 # CODEGEN-NEXT: ret

diff  --git a/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll 
b/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll
index 1ac50da0858c..d88d354f6302 100644
--- a/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/add-vsetvli-vlmax.ll
@@ -29,13 +29,13 @@ define void @vadd_vint64m1(
 ; PRE-INSERTER: PseudoVSE64_V_M1 killed %7, %0, $noreg, $x0, 64, implicit $vl, 
implicit $vtype :: (store unknown-size into %ir.pc, align 8)
 
 ; POST-INSERTER: %4:vr = 

[llvm-branch-commits] [clang] 8c5ca7c - [analyzer] OSObjectCStyleCast: Improve warning message.

2020-12-10 Thread Artem Dergachev via llvm-branch-commits

Author: Artem Dergachev
Date: 2020-12-10T19:46:33-08:00
New Revision: 8c5ca7c6e62c203b9642dca2a1d9118c36777ad5

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

LOG: [analyzer] OSObjectCStyleCast: Improve warning message.

Suggest OSRequiredCast as a closer alternative to C-style cast.
Explain how to decide.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
clang/test/Analysis/osobjectcstylecastchecker_test.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp 
b/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
index 53ed0e187a4c..270b66dab020 100644
--- a/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
@@ -24,32 +24,36 @@ using namespace ento;
 using namespace ast_matchers;
 
 namespace {
-
-const char *WarnAtNode = "OSObjCast";
+static constexpr const char *const WarnAtNode = "WarnAtNode";
+static constexpr const char *const WarnRecordDecl = "WarnRecordDecl";
 
 class OSObjectCStyleCastChecker : public Checker {
 public:
-  void checkASTCodeBody(const Decl *D,
-AnalysisManager ,
+  void checkASTCodeBody(const Decl *D, AnalysisManager ,
 BugReporter ) const;
 };
+}
 
 static void emitDiagnostics(const BoundNodes ,
 BugReporter ,
 AnalysisDeclContext *ADC,
 const OSObjectCStyleCastChecker *Checker) {
   const auto *CE = Nodes.getNodeAs(WarnAtNode);
-  assert(CE);
+  const CXXRecordDecl *RD = Nodes.getNodeAs(WarnRecordDecl);
+  assert(CE && RD);
 
   std::string Diagnostics;
   llvm::raw_string_ostream OS(Diagnostics);
-  OS << "C-style cast of OSObject. Use OSDynamicCast instead.";
+  OS << "C-style cast of an OSObject is prone to type confusion attacks; "
+ << "use 'OSRequiredCast' if the object is definitely of type '"
+ << RD->getNameAsString() << "', or 'OSDynamicCast' followed by "
+ << "a null check if unsure",
 
   BR.EmitBasicReport(
 ADC->getDecl(),
 Checker,
 /*Name=*/"OSObject C-Style Cast",
-/*BugCategory=*/"Security",
+categories::SecurityError,
 OS.str(),
 PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), ADC),
 CE->getSourceRange());
@@ -68,7 +72,7 @@ void OSObjectCStyleCastChecker::checkASTCodeBody(const Decl 
*D, AnalysisManager
 
   auto OSObjTypeM = 
hasTypePointingTo(cxxRecordDecl(isDerivedFrom("OSMetaClassBase")));
   auto OSObjSubclassM = hasTypePointingTo(
-cxxRecordDecl(isDerivedFrom("OSObject")));
+cxxRecordDecl(isDerivedFrom("OSObject")).bind(WarnRecordDecl));
 
   auto CastM = cStyleCastExpr(
   allOf(hasSourceExpression(allOf(OSObjTypeM, unless(DynamicCastM))),
@@ -78,7 +82,6 @@ void OSObjectCStyleCastChecker::checkASTCodeBody(const Decl 
*D, AnalysisManager
   for (BoundNodes Match : Matches)
 emitDiagnostics(Match, BR, ADC, this);
 }
-}
 
 void ento::registerOSObjectCStyleCast(CheckerManager ) {
   Mgr.registerChecker();

diff  --git a/clang/test/Analysis/osobjectcstylecastchecker_test.cpp 
b/clang/test/Analysis/osobjectcstylecastchecker_test.cpp
index fabed7ee34b1..a5ebb2823a92 100644
--- a/clang/test/Analysis/osobjectcstylecastchecker_test.cpp
+++ b/clang/test/Analysis/osobjectcstylecastchecker_test.cpp
@@ -13,7 +13,7 @@ struct B : public A {
 };
 
 unsigned warn_on_explicit_downcast(OSObject * obj) {
-  OSArray *a = (OSArray *) obj; // expected-warning{{C-style cast of OSObject. 
Use OSDynamicCast instead}}
+  OSArray *a = (OSArray *) obj; // expected-warning{{C-style cast of an 
OSObject is prone to type confusion attacks; use 'OSRequiredCast' if the object 
is definitely of type 'OSArray', or 'OSDynamicCast' followed by a null check if 
unsure}}
   return a->getCount();
 }
 



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


[llvm-branch-commits] [libcxx] 3696227 - [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.

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

Author: Arthur O'Dwyer
Date: 2020-12-10T22:03:12-05:00
New Revision: 3696227c10f5e5841223c2a2fb63fdd1d50a7930

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

LOG: [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.

Generally these calls aren't vulnerable to ADL because they involve only
primitive types. The ones in  and  drag in namespace std
but that's OK; the ones in  and  are vulnerable
iff `CharT` is an enum type, which seems far-fetched.
But absolutely zero of them *need* ADL to happen; so in my opinion
they should all be consistently qualified, just like calls to any
other (non-user-customizable) functions in namespace std.

Also: Include  and  in <__string>.
We seemed to be getting lucky that  included 
included  included . That gave us the
global-namespace `wmemmove`, but not `_VSTD::wmemmove`.
This is now fixed.

I didn't touch these headers:
 uses strlen, safely
 uses memcpy, safely
 uses memchr and strchr, safely
 uses wcschr, safely
<__bsd_locale_fallbacks.h> uses wcsnrtombs, safely

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

Added: 


Modified: 
libcxx/include/__hash_table
libcxx/include/__locale
libcxx/include/__string
libcxx/include/atomic
libcxx/include/fstream
libcxx/include/list
libcxx/include/locale
libcxx/include/string
libcxx/include/strstream
libcxx/include/vector

Removed: 




diff  --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 96845cbd466f..ab45277e20c8 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -1571,7 +1571,7 @@ __hash_table<_Tp, _Hash, _Equal, 
_Alloc>::__deallocate_node(__next_pointer __np)
 {
 (*__p)->__c_ = nullptr;
 if (--__c->end_ != __p)
-memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+_VSTD::memmove(__p, __p+1, (__c->end_ - 
__p)*sizeof(__i_node*));
 }
 }
 __get_db()->unlock();
@@ -2599,7 +2599,7 @@ __hash_table<_Tp, _Hash, _Equal, 
_Alloc>::remove(const_iterator __p) _NOEXCEPT
 {
 (*__dp)->__c_ = nullptr;
 if (--__c->end_ != __dp)
-memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));
+_VSTD::memmove(__dp, __dp+1, (__c->end_ - 
__dp)*sizeof(__i_node*));
 }
 }
 __get_db()->unlock();

diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index dda8a75d9046..f32bd59ae585 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -79,7 +79,7 @@ struct __libcpp_locale_guard {
   // locale name, otherwise it will be a semicolon-separated string listing
   // each category.  In the second case, we know at least one category 
won't
   // be what we want, so we only have to check the first case.
-  if (strcmp(__l.__get_locale(), __lc) != 0) {
+  if (_VSTD::strcmp(__l.__get_locale(), __lc) != 0) {
 __locale_all = _strdup(__lc);
 if (__locale_all == nullptr)
   __throw_bad_alloc();

diff  --git a/libcxx/include/__string b/libcxx/include/__string
index 2473e1f1718e..d8b672e4c1be 100644
--- a/libcxx/include/__string
+++ b/libcxx/include/__string
@@ -55,7 +55,9 @@ template <> struct char_traits;  // c++20
 
 #include <__config>
 #include   // for search and min
-#include  // For EOF.
+#include  // for EOF
+#include // for memcpy
+#include  // for wmemcpy
 #include  // for __murmur2_or_cityhash
 
 #include <__debug>
@@ -375,7 +377,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 {
 return __libcpp_is_constant_evaluated()
? _VSTD::__move_constexpr(__s1, __s2, __n)
-   : __n == 0 ? __s1 : (char_type*)memmove(__s1, __s2, 
__n);
+   : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, 
__s2, __n);
 }
 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) 
_NOEXCEPT
@@ -383,14 +385,14 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __libcpp_is_constant_evaluated()
? _VSTD::__copy_constexpr(__s1, __s2, __n)
-   : __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
+   : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, 
__s2, __n);
 }
 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
 {
 return __libcpp_is_constant_evaluated()
? _VSTD::__assign_constexpr(__s, __n, __a)
-

[llvm-branch-commits] [libcxx] b12ea06 - [libc++] Include C++ headers, not C headers, in .

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

Author: Arthur O'Dwyer
Date: 2020-12-10T22:03:12-05:00
New Revision: b12ea0652129da3b42642a0b76adbfab8833db53

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

LOG: [libc++] Include C++ headers, not C headers, in .

This matches how libc++ does it in all other C++ headers
(that is, headers not ending in ".h").
We need to include  if we want to use `_VSTD::memmove`
instead of unqualified ADL `memmove`. Even though ADL doesn't
physically matter in 's specific case, I'm trying
to migrate libc++ to using `_VSTD::memmove` for all cases
(because some of them do matter, and this way it's easier to
grep for outliers).

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

Added: 


Modified: 
libcxx/include/charconv

Removed: 




diff  --git a/libcxx/include/charconv b/libcxx/include/charconv
index 4664f5b1d034..4666c5c51db6 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -76,11 +76,11 @@ namespace std {
 #include <__config>
 #include <__availability>
 #include <__errc>
-#include 
+#include  // for log2f
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
+#include 
 
 #include <__debug>
 
@@ -333,7 +333,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, 
false_type)
 auto __len = __p - __buf;
 if (__len <= __
diff )
 {
-memcpy(__first, __buf, __len);
+_VSTD::memcpy(__first, __buf, __len);
 return {__first + __len, {}};
 }
 else
@@ -382,7 +382,7 @@ __to_chars_integral(char* __first, char* __last, _Tp 
__value, int __base,
 return {__last, errc::value_too_large};
 else
 {
-memmove(__first, __p, __len);
+_VSTD::memmove(__first, __p, __len);
 return {__first + __len, {}};
 }
 }
@@ -429,7 +429,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, 
_Fn __f, _Ts... __args)
 if (__x <= __complement(__to_unsigned(__tl::min(
 {
 __x = __complement(__x);
-memcpy(&__value, &__x, sizeof(__x));
+_VSTD::memcpy(&__value, &__x, sizeof(__x));
 return __r;
 }
 }



___
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] 0f1f13f - Re-land: [lit] Support running tests on Windows without GnuWin32

2020-12-10 Thread Alexandre Ganea via llvm-branch-commits

Author: Alexandre Ganea
Date: 2020-12-10T21:41:54-05:00
New Revision: 0f1f13fcb17fbc8c93d505da989a04ab5cbd9ed3

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

LOG: Re-land: [lit] Support running tests on Windows without GnuWin32

Historically, we have told contributors that GnuWin32 is a pre-requisite
because our tests depend on utilities such as sed, grep, diff, and more.
However, Git on Windows includes versions of these utilities in its
installation. Furthermore, GnuWin32 has not been updated in many years.
For these reasons, it makes sense to have the ability to run llvm tests
in a way that is both:

a) Easier on the user (less stuff to install)
b) More up-to-date (The verions that ship with git are at least as
   new, if not newer, than the versions in GnuWin32.
We add support for this here by attempting to detect where Git is
installed using the Windows registry, confirming the existence of
several common Unix tools, and then adding this location to lit's PATH
environment.

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

Added: 


Modified: 
llvm/utils/lit/lit/llvm/config.py

Removed: 




diff  --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index 498e34cae3a5..949c5e694db7 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -1,3 +1,4 @@
+import itertools
 import os
 import platform
 import re
@@ -8,6 +9,7 @@
 from lit.llvm.subst import FindTool
 from lit.llvm.subst import ToolSubst
 
+lit_path_displayed = False
 
 class LLVMConfig(object):
 
@@ -20,19 +22,26 @@ def __init__(self, lit_config, config):
 self.use_lit_shell = False
 # Tweak PATH for Win32 to decide to use bash.exe or not.
 if sys.platform == 'win32':
-# For tests that require Windows to run.
-features.add('system-windows')
-
-# Seek sane tools in directories and set to $PATH.
-path = self.lit_config.getToolsPath(config.lit_tools_dir,
+# Seek necessary tools in directories and set to $PATH.
+path = None
+lit_tools_dir = getattr(config, 'lit_tools_dir', None)
+required_tools = ['cmp.exe', 'grep.exe', 'sed.exe', '
diff .exe', 'echo.exe']
+path = self.lit_config.getToolsPath(lit_tools_dir,
 config.environment['PATH'],
-['cmp.exe', 'grep.exe', 
'sed.exe'])
+required_tools)
+if path is None:
+path = self._find_git_windows_unix_tools(required_tools)
 if path is not None:
 self.with_environment('PATH', path, append_path=True)
 # Many tools behave strangely if these environment variables 
aren't set.
 self.with_system_environment(['SystemDrive', 'SystemRoot', 'TEMP', 
'TMP'])
 self.use_lit_shell = True
 
+global lit_path_displayed
+if not self.lit_config.quiet and lit_path_displayed is False:
+self.lit_config.note("using lit tools: {}".format(path))
+lit_path_displayed = True
+
 # Choose between lit's internal shell pipeline runner and a real 
shell.  If
 # LIT_USE_INTERNAL_SHELL is in the environment, we use that as an 
override.
 lit_shell_env = os.environ.get('LIT_USE_INTERNAL_SHELL')
@@ -117,6 +126,35 @@ def __init__(self, lit_config, config):
 self.with_environment(
 'DYLD_INSERT_LIBRARIES', gmalloc_path_str)
 
+def _find_git_windows_unix_tools(self, tools_needed):
+assert(sys.platform == 'win32')
+if sys.version_info.major >= 3:
+import winreg
+else:
+import _winreg as winreg
+
+# Search both the 64 and 32-bit hives, as well as HKLM + HKCU
+masks = [0, winreg.KEY_WOW64_64KEY]
+hives = [winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER]
+for mask, hive in itertools.product(masks, hives):
+try:
+with winreg.OpenKey(hive, r"SOFTWARE\GitForWindows", 0,
+winreg.KEY_READ | mask) as key:
+install_root, _ = winreg.QueryValueEx(key, 'InstallPath')
+
+if not install_root:
+continue
+candidate_path = os.path.join(install_root, 'usr', 'bin')
+if not lit.util.checkToolsPath(candidate_path, 
tools_needed):
+continue
+
+# We found it, stop enumerating.
+return lit.util.to_string(candidate_path)
+except:
+continue
+
+return 

[llvm-branch-commits] [openmp] ce93de3 - [libomptarget][nfc] Remove data_sharing type aliasing

2020-12-10 Thread Jon Chesterfield via llvm-branch-commits

Author: Jon Chesterfield
Date: 2020-12-11T02:13:34Z
New Revision: ce93de3bb284c944676c7b81890156d9d80b1db9

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

LOG: [libomptarget][nfc] Remove data_sharing type aliasing

[libomptarget][nfc] Remove data_sharing type aliasing

Libomptarget previous used __kmpc_data_sharing_slot to access values of type
__kmpc_data_sharing_{worker,master}_slot_static. This aliasing violation was
benign in practice. The master type has since been removed, so a single type
can be used instead.

This is particularly helpful for the transition to an openmp deviceRTL, as the
c++/openmp compiler for amdgcn currently rejects the flexible array member for
being an incomplete type. Serves the same purpose as abandoned D86324.

Reviewed By: jdoerfert

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

Added: 


Modified: 
openmp/libomptarget/deviceRTLs/common/omptarget.h
openmp/libomptarget/deviceRTLs/interface.h

Removed: 




diff  --git a/openmp/libomptarget/deviceRTLs/common/omptarget.h 
b/openmp/libomptarget/deviceRTLs/common/omptarget.h
index 0ccd71c3b55f..fc4eb6bfbcfa 100644
--- a/openmp/libomptarget/deviceRTLs/common/omptarget.h
+++ b/openmp/libomptarget/deviceRTLs/common/omptarget.h
@@ -74,6 +74,16 @@ class omptarget_nvptx_SharedArgs {
 extern DEVICE SHARED omptarget_nvptx_SharedArgs
 omptarget_nvptx_globalArgs;
 
+// Worker slot type which is initialized with the default worker slot
+// size of 4*32 bytes.
+struct __kmpc_data_sharing_slot {
+  __kmpc_data_sharing_slot *Next;
+  __kmpc_data_sharing_slot *Prev;
+  void *PrevSlotStackPtr;
+  void *DataEnd;
+  char Data[DS_Worker_Warp_Slot_Size];
+};
+
 // Data structure to keep in shared memory that traces the current slot, stack,
 // and frame pointer as well as the active threads that didn't exit the current
 // environment.
@@ -83,15 +93,6 @@ struct DataSharingStateTy {
   void * volatile FramePtr[DS_Max_Warp_Number];
   __kmpc_impl_lanemask_t ActiveThreads[DS_Max_Warp_Number];
 };
-// Additional worker slot type which is initialized with the default worker 
slot
-// size of 4*32 bytes.
-struct __kmpc_data_sharing_worker_slot_static {
-  __kmpc_data_sharing_slot *Next;
-  __kmpc_data_sharing_slot *Prev;
-  void *PrevSlotStackPtr;
-  void *DataEnd;
-  char Data[DS_Worker_Warp_Slot_Size];
-};
 
 extern DEVICE SHARED DataSharingStateTy DataSharingState;
 
@@ -213,7 +214,7 @@ class omptarget_nvptx_TeamDescr {
   workDescrForActiveParallel; // one, ONLY for the active par
 
   ALIGN(16)
-  __kmpc_data_sharing_worker_slot_static worker_rootS[DS_Max_Warp_Number];
+  __kmpc_data_sharing_slot worker_rootS[DS_Max_Warp_Number];
 };
 
 


diff  --git a/openmp/libomptarget/deviceRTLs/interface.h 
b/openmp/libomptarget/deviceRTLs/interface.h
index 330880556293..5f539bc3fd66 100644
--- a/openmp/libomptarget/deviceRTLs/interface.h
+++ b/openmp/libomptarget/deviceRTLs/interface.h
@@ -438,17 +438,6 @@ EXTERN void __kmpc_begin_sharing_variables(void 
***GlobalArgs, size_t nArgs);
 EXTERN void __kmpc_end_sharing_variables();
 EXTERN void __kmpc_get_shared_variables(void ***GlobalArgs);
 
-// The slot used for data sharing by the master and worker threads. We use a
-// complete (default size version and an incomplete one so that we allow sizes
-// greater than the default).
-struct __kmpc_data_sharing_slot {
-  __kmpc_data_sharing_slot *Next;
-  __kmpc_data_sharing_slot *Prev;
-  void *PrevSlotStackPtr;
-  void *DataEnd;
-  char Data[];
-};
-
 // SPMD execution mode interrogation function.
 EXTERN int8_t __kmpc_is_spmd_exec_mode();
 



___
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] 494aacd - Tooling: Migrate some tests to FileEntryRef, NFC

2020-12-10 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-10T18:05:03-08:00
New Revision: 494aacd72c6a85a6d586fa58a8481e13b68acf24

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

LOG: Tooling: Migrate some tests to FileEntryRef, NFC

Migrate to the `FileEntryRef` overload of `SourceManager::createFileID`
(using `FileManager::getOptionalFileRef`) in RefactoringTest.cpp and
RewriterTestContext.h.

No functionality change.

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

Added: 


Modified: 
clang/unittests/Tooling/RefactoringTest.cpp
clang/unittests/Tooling/RewriterTestContext.h

Removed: 




diff  --git a/clang/unittests/Tooling/RefactoringTest.cpp 
b/clang/unittests/Tooling/RefactoringTest.cpp
index 97a26a71deec..d239aba31d1d 100644
--- a/clang/unittests/Tooling/RefactoringTest.cpp
+++ b/clang/unittests/Tooling/RefactoringTest.cpp
@@ -608,7 +608,7 @@ class FlushRewrittenFilesTest : public ::testing::Test {
 llvm::raw_fd_ostream OutStream(FD, true);
 OutStream << Content;
 OutStream.close();
-auto File = Context.Files.getFile(Path);
+auto File = Context.Files.getOptionalFileRef(Path);
 assert(File);
 
 StringRef Found =

diff  --git a/clang/unittests/Tooling/RewriterTestContext.h 
b/clang/unittests/Tooling/RewriterTestContext.h
index ae2d2baa0fdc..a618ebd3a865 100644
--- a/clang/unittests/Tooling/RewriterTestContext.h
+++ b/clang/unittests/Tooling/RewriterTestContext.h
@@ -70,7 +70,7 @@ class RewriterTestContext {
 llvm::MemoryBuffer::getMemBuffer(Content);
 InMemoryFileSystem->addFile(Name, 0, std::move(Source));
 
-auto Entry = Files.getFile(Name);
+auto Entry = Files.getOptionalFileRef(Name);
 assert(Entry);
 return Sources.createFileID(*Entry, SourceLocation(), SrcMgr::C_User);
   }
@@ -87,7 +87,7 @@ class RewriterTestContext {
 llvm::raw_fd_ostream OutStream(FD, true);
 OutStream << Content;
 OutStream.close();
-auto File = Files.getFile(Path);
+auto File = Files.getOptionalFileRef(Path);
 assert(File);
 
 StringRef Found =



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


[llvm-branch-commits] [lld] 349d5c9 - [lld-macho] Disable some tests that are failing on Windows

2020-12-10 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-10T17:54:23-08:00
New Revision: 349d5c9cf79803187a2e1e2a080a8e460d03cf76

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

LOG: [lld-macho] Disable some tests that are failing on Windows

lto-object-path.ll, like stabs.s, is disabled on Windows as the path
separators make it difficult to write a test that works across
platforms.

This diff also disables implicit-dylibs.s on Windows as we seem to emit
LC_LOAD_DYLIBs in a different order on that platform. This seems like a
bug in LLD that needs to be addressed (in a future diff).

Added: 


Modified: 
lld/test/MachO/implicit-dylibs.s
lld/test/MachO/lto-object-path.ll

Removed: 




diff  --git a/lld/test/MachO/implicit-dylibs.s 
b/lld/test/MachO/implicit-dylibs.s
index 2030da423020..21084b50006b 100644
--- a/lld/test/MachO/implicit-dylibs.s
+++ b/lld/test/MachO/implicit-dylibs.s
@@ -1,4 +1,6 @@
 # REQUIRES: x86
+## FIXME: We appear to emit LC_LOAD_DYLIBs in a 
diff erent order on Windows.
+# UNSUPPORTED: system-windows
 # RUN: rm -rf %t; split-file %s %t
 # RUN: mkdir -p %t/usr/lib/system
 

diff  --git a/lld/test/MachO/lto-object-path.ll 
b/lld/test/MachO/lto-object-path.ll
index b362bf45b133..b21b38f23527 100644
--- a/lld/test/MachO/lto-object-path.ll
+++ b/lld/test/MachO/lto-object-path.ll
@@ -1,4 +1,5 @@
 ; REQUIRES: x86
+; UNSUPPORTED: system-windows
 
 ; RUN: rm -rf %t; mkdir %t
 ; RUN: llvm-as %s -o %t/test.o



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


[llvm-branch-commits] [lld] 553284b - [lld-macho] Don't include absolute address value in expected test output

2020-12-10 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-10T17:54:23-08:00
New Revision: 553284be2dded5b1d1106b380525e0b1e3b609cd

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

LOG: [lld-macho] Don't include absolute address value in expected test output

Should fix the mattrs.ll failure introduced by rG29d3b0e47113.

Added: 


Modified: 
lld/test/MachO/mattrs.ll

Removed: 




diff  --git a/lld/test/MachO/mattrs.ll b/lld/test/MachO/mattrs.ll
index 66415013093b..8771f02e0c50 100644
--- a/lld/test/MachO/mattrs.ll
+++ b/lld/test/MachO/mattrs.ll
@@ -11,14 +11,14 @@
 
 ; FMA:  <_foo>:
 ; FMA-NEXT:vrcpss  %xmm0, %xmm0, %xmm1
-; FMA-NEXT:vfmsub213ss 7(%rip), %xmm1, %xmm0  # 2d4
+; FMA-NEXT:vfmsub213ss 7(%rip), %xmm1, %xmm0
 ; FMA-NEXT:vfnmadd132ss%xmm1, %xmm1, %xmm0
 ; FMA-NEXT:retq
 
 ; NO-FMA:  <_foo>:
 ; NO-FMA-NEXT: vrcpss  %xmm0, %xmm0, %xmm1
 ; NO-FMA-NEXT: vmulss  %xmm1, %xmm0, %xmm0
-; NO-FMA-NEXT: vmovss  16(%rip), %xmm2  # 2e0
+; NO-FMA-NEXT: vmovss  16(%rip), %xmm2
 ; NO-FMA-NEXT: vsubss  %xmm0, %xmm2, %xmm0
 ; NO-FMA-NEXT: vmulss  %xmm0, %xmm1, %xmm0
 ; NO-FMA-NEXT: vaddss  %xmm0, %xmm1, %xmm0



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


[llvm-branch-commits] [lld] dd6412c - [WebAssembly][lld] Exclude COMDAT sections

2020-12-10 Thread Derek Schuff via llvm-branch-commits

Author: Derek Schuff
Date: 2020-12-10T17:47:41-08:00
New Revision: dd6412c05c1039e582a970da1aee62cdde75c892

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

LOG: [WebAssembly][lld] Exclude COMDAT sections

Allow exclusion/discarding of custom sections with COMDAT groups.
It piggybacks on the existing COMDAT-handling code, but applies to custom 
sections as well.

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

Added: 
lld/test/wasm/Inputs/comdat1.s
lld/test/wasm/Inputs/comdat2.s
lld/test/wasm/comdat-sections.s

Modified: 
lld/wasm/InputChunks.h
lld/wasm/InputFiles.cpp
lld/wasm/OutputSections.cpp
lld/wasm/Writer.cpp

Removed: 




diff  --git a/lld/test/wasm/Inputs/comdat1.s b/lld/test/wasm/Inputs/comdat1.s
new file mode 100644
index ..ff988ccef20f
--- /dev/null
+++ b/lld/test/wasm/Inputs/comdat1.s
@@ -0,0 +1,13 @@
+.text
+.section .text.foo,"G",@,foo,comdat
+.globl foo
+.type foo,@function
+foo:
+.functype foo () -> ()
+return
+end_function
+
+.section .debug_foo,"G",@,foo,comdat
+.int32 1
+.section .debug_foo,"G",@,duplicate,comdat
+.int64 123

diff  --git a/lld/test/wasm/Inputs/comdat2.s b/lld/test/wasm/Inputs/comdat2.s
new file mode 100644
index ..f498fdd105d6
--- /dev/null
+++ b/lld/test/wasm/Inputs/comdat2.s
@@ -0,0 +1,13 @@
+.text
+.section .text.foo,"G",@,foo,comdat
+.globl foo
+.type foo,@function
+foo:
+.functype foo () -> ()
+return
+end_function
+
+.section .debug_foo,"G",@,foo,comdat
+.int32 2
+.section .debug_foo,"G",@,duplicate,comdat
+.int64 234

diff  --git a/lld/test/wasm/comdat-sections.s b/lld/test/wasm/comdat-sections.s
new file mode 100644
index ..fc8d2ded1980
--- /dev/null
+++ b/lld/test/wasm/comdat-sections.s
@@ -0,0 +1,22 @@
+# RUN: llvm-mc -triple=wasm32 -filetype=obj %p/Inputs/comdat1.s -o %t1.o
+# RUN: llvm-mc -triple=wasm32 -filetype=obj %p/Inputs/comdat2.s -o %t2.o
+# RUN: llvm-mc -triple=wasm32 -filetype=obj %s -o %t.o
+# RUN: wasm-ld  -o %t.wasm %t.o %t1.o %t2.o
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+
+.globl  _start
+.type  _start,@function
+_start:
+.functype _start () -> ()
+call foo
+end_function
+
+.functype foo () -> ()
+
+
+# Check that we got 1 copy of each of the .debug_foo sections from the 2 object
+# files, and that they came from the same object.
+# CHECK:  - Type:CUSTOM
+# CHECK-NEXT:Name:.debug_foo
+# CHECK-NEXT:Payload: 01007B00

diff  --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h
index ba4e2a591074..9082d1dada5f 100644
--- a/lld/wasm/InputChunks.h
+++ b/lld/wasm/InputChunks.h
@@ -221,7 +221,7 @@ class InputSection : public InputChunk {
 
   StringRef getName() const override { return section.Name; }
   StringRef getDebugName() const override { return StringRef(); }
-  uint32_t getComdat() const override { return UINT32_MAX; }
+  uint32_t getComdat() const override { return section.Comdat; }
 
 protected:
   ArrayRef data() const override { return section.Content; }

diff  --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index 2b3c2591058c..68a9472819e4 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -341,6 +341,12 @@ void ObjFile::parse(bool ignoreComdats) {
 }
   }
 
+  ArrayRef comdats = wasmObj->linkingData().Comdats;
+  for (StringRef comdat : comdats) {
+bool isNew = ignoreComdats || symtab->addComdat(comdat);
+keptComdats.push_back(isNew);
+  }
+
   uint32_t sectionIndex = 0;
 
   // Bool for each symbol, true if called directly.  This allows us to 
implement
@@ -360,7 +366,9 @@ void ObjFile::parse(bool ignoreComdats) {
   assert(!dataSection);
   dataSection = 
 } else if (section.Type == WASM_SEC_CUSTOM) {
-  customSections.emplace_back(make(section, this));
+  auto *customSec = make(section, this);
+  customSec->discarded = isExcludedByComdat(customSec);
+  customSections.emplace_back(customSec);
   customSections.back()->setRelocations(section.Relocations);
   customSectionsByIndex[sectionIndex] = customSections.back();
 }
@@ -374,11 +382,6 @@ void ObjFile::parse(bool ignoreComdats) {
   typeMap.resize(getWasmObj()->types().size());
   typeIsUsed.resize(getWasmObj()->types().size(), false);
 
-  ArrayRef comdats = wasmObj->linkingData().Comdats;
-  for (StringRef comdat : comdats) {
-bool isNew = ignoreComdats || symtab->addComdat(comdat);
-keptComdats.push_back(isNew);
-  }
 
   // Populate `Segments`.
   for (const WasmSegment  : wasmObj->dataSegments()) {
@@ -487,6 +490,10 @@ 

[llvm-branch-commits] [llvm] 6b1bf90 - [gn build] Port 705a4c149d8

2020-12-10 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-11T01:40:59Z
New Revision: 6b1bf905d01e6b459d6afde424c8fe76741d865c

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

LOG: [gn build] Port 705a4c149d8

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
index 5bd7ec8f5818..e26d0bd01521 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
@@ -38,6 +38,7 @@ static_library("AsmPrinter") {
 "EHStreamer.cpp",
 "ErlangGCPrinter.cpp",
 "OcamlGCPrinter.cpp",
+"PseudoProbePrinter.cpp",
 "WasmException.cpp",
 "WinCFGuard.cpp",
 "WinException.cpp",

diff  --git a/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
index e0c7701e9896..9aa3f8539ad1 100644
--- a/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
@@ -43,6 +43,7 @@ static_library("MC") {
 "MCObjectFileInfo.cpp",
 "MCObjectStreamer.cpp",
 "MCObjectWriter.cpp",
+"MCPseudoProbe.cpp",
 "MCRegisterInfo.cpp",
 "MCSchedule.cpp",
 "MCSection.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] 705a4c1 - [CSSPGO] Pseudo probe encoding and emission.

2020-12-10 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2020-12-10T17:29:28-08:00
New Revision: 705a4c149d8a3a414c6684a2c01ebbdcb98ccc21

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

LOG: [CSSPGO] Pseudo probe encoding and emission.

This change implements pseudo probe encoding and emission for CSSPGO. Please 
see RFC here for more context: 
https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s

Pseudo probes are in the form of intrinsic calls on IR/MIR but they do not turn 
into any machine instructions. Instead they are emitted into the binary as a 
piece of data in standalone sections.  The probe-specific sections are not 
needed to be loaded into memory at execution time, thus they do not incur a 
runtime overhead. 

**ELF object emission**

The binary data to emit are organized as two ELF sections, i.e, the 
`.pseudo_probe_desc` section and the `.pseudo_probe` section. The 
`.pseudo_probe_desc` section stores a function descriptor for each function and 
the `.pseudo_probe` section stores the actual probes, each fo which corresponds 
to an IR basic block or an IR function callsite. A function descriptor is 
stored as a module-level metadata during the compilation and is serialized into 
the object file during object emission.

Both the probe descriptors and pseudo probes can be emitted into a separate ELF 
section per function to leverage the linker for deduplication.  A 
`.pseudo_probe` section shares the same COMDAT group with the function code so 
that when the function is dead, the probes are dead and disposed too. On the 
contrary, a `.pseudo_probe_desc` section has its own COMDAT group. This is 
because even if a function is dead, its probes may be inlined into other 
functions and its descriptor is still needed by the profile generation tool.

The format of `.pseudo_probe_desc` section looks like:

```
.section   .pseudo_probe_desc,"",@progbits
.quad   6309742469962978389  // Func GUID
.quad   4294967295   // Func Hash
.byte   9// Length of func name
.ascii  "_Z5funcAi"  // Func name
.quad   7102633082150537521
.quad   138828622701
.byte   12
.ascii  "_Z8funcLeafi"
.quad   446061515086924981
.quad   4294967295
.byte   9
.ascii  "_Z5funcBi"
.quad   -2016976694713209516
.quad   72617220756
.byte   7
.ascii  "_Z3fibi"
```

For each `.pseudoprobe` section, the encoded binary data consists of a single 
function record corresponding to an outlined function (i.e, a function with a 
code entry in the `.text` section). A function record has the following format :

```
FUNCTION BODY (one for each outlined function present in the text section)
GUID (uint64)
GUID of the function
NPROBES (ULEB128)
Number of probes originating from this function.
NUM_INLINED_FUNCTIONS (ULEB128)
Number of callees inlined into this function, aka number of
first-level inlinees
PROBE RECORDS
A list of NPROBES entries. Each entry contains:
  INDEX (ULEB128)
  TYPE (uint4)
0 - block probe, 1 - indirect call, 2 - direct call
  ATTRIBUTE (uint3)
reserved
  ADDRESS_TYPE (uint1)
0 - code address, 1 - address delta
  CODE_ADDRESS (uint64 or ULEB128)
code address or address delta, depending on ADDRESS_TYPE
INLINED FUNCTION RECORDS
A list of NUM_INLINED_FUNCTIONS entries describing each of the inlined
callees.  Each record contains:
  INLINE SITE
GUID of the inlinee (uint64)
ID of the callsite probe (ULEB128)
  FUNCTION BODY
A FUNCTION BODY entry describing the inlined function.
```

To support building a context-sensitive profile, probes from inlinees are 
grouped by their inline contexts. An inline context is logically a call path 
through which a callee function lands in a caller function. The probe emitter 
builds an inline tree based on the debug metadata for each outlined function in 
the form of a trie tree. A tree root is the outlined function. Each tree edge 
stands for a callsite where inlining happens. Pseudo probes originating from an 
inlinee function are stored in a tree node and the tree path starting from the 
root all the way down to the tree node is the inline context of the probes. The 
emission happens on the whole tree top-down recursively. Probes of a tree node 
will be emitted altogether with their direct parent edge. Since a pseudo probe 
corresponds to a real code address, for size savings, the address is encoded as 
a delta from the previous probe except for the first probe. Variant-sized 
integer encoding, aka LEB128, is used for address delta and probe index.

**Assembling**

Pseudo probes can be printed as assembly directives alternatively. This allows 
for good assembly code readability and also provides a view of how 
optimizations and pseudo probes 

[llvm-branch-commits] [libc] 1fd32dc - [libc] Add [l|ll]abs implementation.

2020-12-10 Thread Cheng Wang via llvm-branch-commits

Author: Cheng Wang
Date: 2020-12-11T09:25:20+08:00
New Revision: 1fd32dcb294e16781fcfcf1a468180d00cf1e3ca

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

LOG: [libc] Add [l|ll]abs implementation.

Implement abs, labs and llabs with template.

Reviewed By: sivachandra

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

Added: 
libc/src/stdlib/abs.cpp
libc/src/stdlib/abs.h
libc/src/stdlib/abs_utils.h
libc/src/stdlib/labs.cpp
libc/src/stdlib/labs.h
libc/src/stdlib/llabs.cpp
libc/src/stdlib/llabs.h
libc/test/src/stdlib/abs_test.cpp
libc/test/src/stdlib/labs_test.cpp
libc/test/src/stdlib/llabs_test.cpp

Modified: 
libc/config/linux/aarch64/entrypoints.txt
libc/config/linux/x86_64/entrypoints.txt
libc/spec/spec.td
libc/spec/stdc.td
libc/src/stdlib/CMakeLists.txt
libc/test/src/stdlib/CMakeLists.txt

Removed: 




diff  --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index 3a3b050a6e06..534a4bdd6131 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -18,6 +18,11 @@ set(TARGET_LIBC_ENTRYPOINTS
 # errno.h entrypoints
 libc.src.errno.__errno_location
 
+# stdlib.h entrypoints
+libc.src.stdlib.abs
+libc.src.stdlib.labs
+libc.src.stdlib.llabs
+
 # string.h entrypoints
 libc.src.string.bzero
 libc.src.string.memchr

diff  --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 2b461c4eede5..4cae553ac6d4 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -41,6 +41,9 @@ set(TARGET_LIBC_ENTRYPOINTS
 # stdlib.h entrypoints
 libc.src.stdlib._Exit
 libc.src.stdlib.abort
+libc.src.stdlib.abs
+libc.src.stdlib.labs
+libc.src.stdlib.llabs
 
 # string.h entrypoints
 libc.src.string.bzero

diff  --git a/libc/spec/spec.td b/libc/spec/spec.td
index 29c11a9c2199..9a31d85c148c 100644
--- a/libc/spec/spec.td
+++ b/libc/spec/spec.td
@@ -42,6 +42,8 @@ def IntType : NamedType<"int">;
 def FloatType : NamedType<"float">;
 def DoubleType : NamedType<"double">;
 def LongDoubleType : NamedType<"long double">;
+def LongLongType : NamedType<"long long">;
+def LongType : NamedType<"long">;
 def CharType : NamedType<"char">;
 
 // Common types

diff  --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 70cc2600a612..051e0a89eb27 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -400,6 +400,9 @@ def StdC : StandardSpec<"stdc"> {
   [], // Enumerations
   [
   FunctionSpec<"abort", RetValSpec, [ArgSpec]>,
+  FunctionSpec<"abs", RetValSpec, [ArgSpec]>,
+  FunctionSpec<"labs", RetValSpec, [ArgSpec]>,
+  FunctionSpec<"llabs", RetValSpec, 
[ArgSpec]>,
   FunctionSpec<"_Exit", RetValSpec, [ArgSpec]>,
   ]
   >;

diff  --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 50b7421944dd..a599d8a59065 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -2,6 +2,12 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
 endif()
 
+add_header_library(
+  abs_utils
+  HDRS
+abs_utils.h
+)
+
 add_entrypoint_object(
   _Exit
   ALIAS
@@ -20,3 +26,33 @@ add_entrypoint_object(
 libc.src.signal.raise
 ._Exit
 )
+
+add_entrypoint_object(
+  abs
+  SRCS
+abs.cpp
+  HDRS
+abs.h
+  DEPENDS
+.abs_utils
+)
+
+add_entrypoint_object(
+  labs
+  SRCS
+labs.cpp
+  HDRS
+labs.h
+  DEPENDS
+.abs_utils
+)
+
+add_entrypoint_object(
+  llabs
+  SRCS
+llabs.cpp
+  HDRS
+llabs.h
+  DEPENDS
+.abs_utils
+)

diff  --git a/libc/src/stdlib/abs.cpp b/libc/src/stdlib/abs.cpp
new file mode 100644
index ..74c47cdb242d
--- /dev/null
+++ b/libc/src/stdlib/abs.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of abs 
-===//
+//
+// 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 "src/stdlib/abs.h"
+#include "src/__support/common.h"
+#include "src/stdlib/abs_utils.h"
+
+namespace __llvm_libc {
+
+int LLVM_LIBC_ENTRYPOINT(abs)(int n) {
+  // integer_abs from abs_utils.h.
+  return integer_abs(n);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/stdlib/abs.h b/libc/src/stdlib/abs.h
new file mode 100644
index ..42ef7f885ed6
--- /dev/null
+++ b/libc/src/stdlib/abs.h
@@ -0,0 +1,18 @@
+//===-- 

[llvm-branch-commits] [lld] e52881a - [lld][WebAssembly] Split __wasm_apply_relocs function in two

2020-12-10 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2020-12-10T17:07:39-08:00
New Revision: e52881a2870234f0dad6e338a0f084eddeaa9356

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

LOG: [lld][WebAssembly] Split __wasm_apply_relocs function in two

We have two types of relocations that we apply on startup:
1. Relocations that apply to wasm globals
2. Relocations that apply to wasm memory

The first set of relocations use only the `__memory_base` import to
update a set of internal globals.  Because wasm globals are thread local
these need to run on each thread.  Memory relocations, like static
constructors, must only be run once.

To ensure global relocations run on all threads and because the only
depend on the immutable `__memory_base` import we can run them during
the WebAssembly start functions, instead of waiting until the
post-instantiation __wasm_call_ctors.

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

Added: 


Modified: 
lld/test/wasm/bsymbolic.s
lld/test/wasm/data-segments.ll
lld/test/wasm/pie.ll
lld/test/wasm/weak-undefined-pic.s
lld/wasm/Driver.cpp
lld/wasm/MarkLive.cpp
lld/wasm/Symbols.cpp
lld/wasm/Symbols.h
lld/wasm/SyntheticSections.cpp
lld/wasm/SyntheticSections.h
lld/wasm/Writer.cpp

Removed: 




diff  --git a/lld/test/wasm/bsymbolic.s b/lld/test/wasm/bsymbolic.s
index dc0e0ddcc773..07989fc5f437 100644
--- a/lld/test/wasm/bsymbolic.s
+++ b/lld/test/wasm/bsymbolic.s
@@ -1,5 +1,5 @@
 // RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
-// RUN: wasm-ld --no-entry -Bsymbolic %t.o -o %t2.so 2>&1 | FileCheck 
-check-prefix=WARNING %s
+// RUN: wasm-ld --no-entry -Bsymbolic %t.o -o %t.wasm 2>&1 | FileCheck 
-check-prefix=WARNING %s
 // WARNING: warning: -Bsymbolic is only meaningful when combined with -shared
 
 // RUN: wasm-ld --experimental-pic -shared %t.o -o %t0.so

diff  --git a/lld/test/wasm/data-segments.ll b/lld/test/wasm/data-segments.ll
index 6f6d96a30fa5..8c4c4ca79672 100644
--- a/lld/test/wasm/data-segments.ll
+++ b/lld/test/wasm/data-segments.ll
@@ -98,27 +98,27 @@
 ; PASSIVE-NEXT:Name:__wasm_init_memory
 
 ;  PASSIVE-PIC:  - Type:START
-; PASSIVE-PIC-NEXT:StartFunction:   3
+; PASSIVE-PIC-NEXT:StartFunction:   2
 ; PASSIVE-PIC-NEXT:  - Type:DATACOUNT
 ; PASSIVE-PIC-NEXT:Count:   1
 ; PASSIVE-PIC-NEXT:  - Type:CODE
 ; PASSIVE-PIC-NEXT:Functions:
 ; PASSIVE-PIC-NEXT:  - Index:   0
 ; PASSIVE-PIC-NEXT:Locals:  []
-; PASSIVE-PIC-NEXT:Body:10010B
+; PASSIVE-PIC-NEXT:Body:10030B
 ; PASSIVE-PIC-NEXT:  - Index:   1
 ; PASSIVE-PIC-NEXT:Locals:  []
 ; PASSIVE-PIC-NEXT:Body:0B
 ; PASSIVE-PIC-NEXT:  - Index:   2
-; PASSIVE-PIC-NEXT:Locals:  []
-; PASSIVE-PIC-NEXT:Body:0B
-; PASSIVE-PIC-NEXT:  - Index:   3
 ; PASSIVE-PIC-NEXT:Locals:
 ; PASSIVE32-PIC-NEXT:  - Type:I32
 ; PASSIVE64-PIC-NEXT:  - Type:I64
 ; PASSIVE-PIC-NEXT:Count:   1
 ; PASSIVE32-PIC-NEXT:Body:
230141B4CE006A2100200041004101FE480200044020004101427FFE0102001A05410023016A410041B1CE00FC0820004102FE1702002000417FFE0002001A0BFC09000B
 ; PASSIVE64-PIC-NEXT:Body:
230142B4CE006A2100200041004101FE480200044020004101427FFE0102001A05420023016A410041B1CE00FC0820004102FE1702002000417FFE0002001A0BFC09000B
+; PASSIVE-PIC-NEXT:  - Index:   3
+; PASSIVE-PIC-NEXT:Locals:  []
+; PASSIVE-PIC-NEXT:Body:0B
 ; PASSIVE-PIC-NEXT:  - Type:DATA
 ; PASSIVE-PIC-NEXT:Segments:
 ; PASSIVE-PIC-NEXT:  - SectionOffset:   4
@@ -130,8 +130,8 @@
 ; PASSIVE-PIC-NEXT:  - Index:   0
 ; PASSIVE-PIC-NEXT:Name:__wasm_call_ctors
 ; PASSIVE-PIC-NEXT:  - Index:   1
-; PASSIVE-PIC-NEXT:Name:__wasm_apply_relocs
-; PASSIVE-PIC-NEXT:  - Index:   2
 ; PASSIVE-PIC-NEXT:Name:__wasm_init_tls
-; PASSIVE-PIC-NEXT:  - Index:   3
+; PASSIVE-PIC-NEXT:  - Index:   2
 ; PASSIVE-PIC-NEXT:Name:__wasm_init_memory
+; PASSIVE-PIC-NEXT:  - Index:   3
+; PASSIVE-PIC-NEXT:Name:__wasm_apply_data_relocs

diff  --git a/lld/test/wasm/pie.ll b/lld/test/wasm/pie.ll
index 20a6c928b6ee..84555a08f19d 100644
--- a/lld/test/wasm/pie.ll
+++ b/lld/test/wasm/pie.ll
@@ -1,6 +1,5 @@
 ; RUN: llc -relocation-model=pic -mattr=+mutable-globals -filetype=obj %s -o 
%t.o
 ; RUN: wasm-ld --no-gc-sections --allow-undefined --experimental-pic 

[llvm-branch-commits] [clang] a3fe12d - Ensure that we don't leave behind "InstantiatingSpecialization" entries

2020-12-10 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-12-10T17:01:44-08:00
New Revision: a3fe12dc58aa2a0dd7292d748b7c104225f863ba

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

LOG: Ensure that we don't leave behind "InstantiatingSpecialization" entries
after destroying an InstantiatingTemplate object.

This previously caused us to (silently!) bail out of class template
instantiation, thinking we'd produced an error, in some corner cases.

Added: 


Modified: 
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 456daab7e032..829ab2253614 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -390,6 +390,9 @@ void Sema::Initialize() {
 }
 
 Sema::~Sema() {
+  assert(InstantiatingSpecializations.empty() &&
+ "failed to clean up an InstantiatingTemplate?");
+
   if (VisContext) FreeVisContext();
 
   // Kill all the active scopes.

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index e8e34c33e37b..39ea9e06e7b1 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -261,7 +261,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
 
 AlreadyInstantiating = !Inst.Entity ? false :
 !SemaRef.InstantiatingSpecializations
- .insert(std::make_pair(Inst.Entity->getCanonicalDecl(), 
Inst.Kind))
+ .insert({Inst.Entity->getCanonicalDecl(), Inst.Kind})
  .second;
 atTemplateBegin(SemaRef.TemplateInstCallbacks, SemaRef, Inst);
   }
@@ -480,7 +480,7 @@ void Sema::InstantiatingTemplate::Clear() {
   auto  = SemaRef.CodeSynthesisContexts.back();
   if (Active.Entity)
 SemaRef.InstantiatingSpecializations.erase(
-std::make_pair(Active.Entity, Active.Kind));
+{Active.Entity->getCanonicalDecl(), Active.Kind});
 }
 
 atTemplateEnd(SemaRef.TemplateInstCallbacks, SemaRef,
@@ -3037,14 +3037,16 @@ bool Sema::usesPartialOrExplicitSpecialization(
 /// Get the instantiation pattern to use to instantiate the definition of a
 /// given ClassTemplateSpecializationDecl (either the pattern of the primary
 /// template or of a partial specialization).
-static CXXRecordDecl *
+static ActionResult
 getPatternForClassTemplateSpecialization(
 Sema , SourceLocation PointOfInstantiation,
 ClassTemplateSpecializationDecl *ClassTemplateSpec,
-TemplateSpecializationKind TSK, bool Complain) {
+TemplateSpecializationKind TSK) {
   Sema::InstantiatingTemplate Inst(S, PointOfInstantiation, ClassTemplateSpec);
-  if (Inst.isInvalid() || Inst.isAlreadyInstantiating())
-return nullptr;
+  if (Inst.isInvalid())
+return {/*Invalid=*/true};
+  if (Inst.isAlreadyInstantiating())
+return {/*Invalid=*/false};
 
   llvm::PointerUnion
@@ -3141,7 +3143,7 @@ getPatternForClassTemplateSpecialization(
 << S.getTemplateArgumentBindingsText(
P->Partial->getTemplateParameters(), *P->Args);
 
-  return nullptr;
+  return {/*Invalid=*/true};
 }
   }
 
@@ -3192,14 +3194,15 @@ bool Sema::InstantiateClassTemplateSpecialization(
   if (ClassTemplateSpec->isInvalidDecl())
 return true;
 
-  CXXRecordDecl *Pattern = getPatternForClassTemplateSpecialization(
-  *this, PointOfInstantiation, ClassTemplateSpec, TSK, Complain);
-  if (!Pattern)
-return true;
+  ActionResult Pattern =
+  getPatternForClassTemplateSpecialization(*this, PointOfInstantiation,
+   ClassTemplateSpec, TSK);
+  if (!Pattern.isUsable())
+return Pattern.isInvalid();
 
-  return InstantiateClass(PointOfInstantiation, ClassTemplateSpec, Pattern,
-  getTemplateInstantiationArgs(ClassTemplateSpec), TSK,
-  Complain);
+  return InstantiateClass(
+  PointOfInstantiation, ClassTemplateSpec, Pattern.get(),
+  getTemplateInstantiationArgs(ClassTemplateSpec), TSK, Complain);
 }
 
 /// Instantiates the definitions of all of the member

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 9db4f23d7296..d3d6df5e0064 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4521,6 +4521,8 @@ 
TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
   // into a template instantiation for this specific function template
   // specialization, which is not a SFINAE context, so that we diagnose any
   // further errors in the declaration itself.
+  //
+  // FIXME: This is a hack.
   

[llvm-branch-commits] [compiler-rt] f23fae2 - [test] Fix compiler-rt/test/profile/coverage_emptylines.cpp if the build directory is under /tmp

2020-12-10 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2020-12-10T16:57:10-08:00
New Revision: f23fae29eb38b9e9d0c6195fa82a882167bd8abe

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

LOG: [test] Fix compiler-rt/test/profile/coverage_emptylines.cpp if the build 
directory is under /tmp

llvm-cov -path-equivalence=/tmp,... is used by some checked-in coverage mapping
files where the original filename is under /tmp. If the test itself produces the
coverage mapping file, there is no need for /tmp.

For coverage_emptylines.cpp: the source filename is under the build directory.
If the build directory is under /tmp, the path mapping will make
llvm-cov fail to find the file.

Added: 


Modified: 
compiler-rt/test/profile/Linux/coverage_ctors.cpp
compiler-rt/test/profile/Linux/coverage_dtor.cpp
compiler-rt/test/profile/Linux/coverage_test.cpp
compiler-rt/test/profile/coverage_comments.cpp
compiler-rt/test/profile/coverage_emptylines.cpp

Removed: 




diff  --git a/compiler-rt/test/profile/Linux/coverage_ctors.cpp 
b/compiler-rt/test/profile/Linux/coverage_ctors.cpp
index adf078e56305..5c38ecb5d0e3 100644
--- a/compiler-rt/test/profile/Linux/coverage_ctors.cpp
+++ b/compiler-rt/test/profile/Linux/coverage_ctors.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_profgen -std=c++11 -fuse-ld=gold -fcoverage-mapping -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 
2>&1 | FileCheck %s
+// RUN: llvm-cov show %t -instr-profile %t.profdata 2>&1 | FileCheck %s
 
 struct Base {
   int B;

diff  --git a/compiler-rt/test/profile/Linux/coverage_dtor.cpp 
b/compiler-rt/test/profile/Linux/coverage_dtor.cpp
index c91dd42d21d3..499ef01458ae 100644
--- a/compiler-rt/test/profile/Linux/coverage_dtor.cpp
+++ b/compiler-rt/test/profile/Linux/coverage_dtor.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_profgen -x c++ -fno-exceptions  -std=c++11 -fuse-ld=gold 
-fcoverage-mapping -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 
2>&1 | FileCheck %s
+// RUN: llvm-cov show %t -instr-profile %t.profdata 2>&1 | FileCheck %s
 
 int g = 100;
 struct Base {

diff  --git a/compiler-rt/test/profile/Linux/coverage_test.cpp 
b/compiler-rt/test/profile/Linux/coverage_test.cpp
index 67adeb724349..e6370a996c0e 100644
--- a/compiler-rt/test/profile/Linux/coverage_test.cpp
+++ b/compiler-rt/test/profile/Linux/coverage_test.cpp
@@ -1,12 +1,12 @@
 // RUN: %clang_profgen -fuse-ld=gold -O2 -fdata-sections -ffunction-sections 
-fcoverage-mapping -Wl,--gc-sections -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 
2>&1 | FileCheck %s
+// RUN: llvm-cov show %t -instr-profile %t.profdata 2>&1 | FileCheck %s
 // BFD linker older than 2.26 has a bug that per-func profile data will be 
wrongly garbage collected when GC is turned on. We only do end-to-end test here 
without GC:
 // RUN: %clang_profgen -O2  -fcoverage-mapping  -o %t.2 %s
 // RUN: env LLVM_PROFILE_FILE=%t.2.profraw %run %t.2
 // RUN: llvm-profdata merge -o %t.2.profdata %t.2.profraw
-// RUN: llvm-cov show %t.2 -instr-profile %t.2.profdata 
-path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+// RUN: llvm-cov show %t.2 -instr-profile %t.2.profdata 2>&1 | FileCheck %s
 // Check covmap is not garbage collected when GC is turned on with BFD linker. 
Due to the bug mentioned above, we can only
 // do the check with objdump:
 // RUN: %clang_profgen -O2  -fcoverage-mapping -Wl,--gc-sections -o %t.3 %s
@@ -15,7 +15,7 @@
 // RUN: %clang_profgen -fuse-ld=gold -O2 -fdata-sections -ffunction-sections 
-fPIE -pie -fcoverage-mapping -Wl,--gc-sections -o %t.pie %s
 // RUN: env LLVM_PROFILE_FILE=%t.pie.profraw %run %t.pie
 // RUN: llvm-profdata merge -o %t.pie.profdata %t.pie.profraw
-// RUN: llvm-cov show %t.pie -instr-profile %t.pie.profdata 
-path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+// RUN: llvm-cov show %t.pie -instr-profile %t.pie.profdata 2>&1 | FileCheck %s
 
 void foo(bool cond) { // CHECK:  [[@LINE]]| 1|void foo(
   if (cond) { // CHECK:  [[@LINE]]| 1| if (cond) {

diff  --git a/compiler-rt/test/profile/coverage_comments.cpp 
b/compiler-rt/test/profile/coverage_comments.cpp
index 0cf78add7913..d206fb608792 100644
--- a/compiler-rt/test/profile/coverage_comments.cpp
+++ b/compiler-rt/test/profile/coverage_comments.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_profgen -fcoverage-mapping -Wno-comment -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge -o 

[llvm-branch-commits] [llvm] 8d396ac - [WebAssembly] Support COMDAT sections in assembly syntax

2020-12-10 Thread Derek Schuff via llvm-branch-commits

Author: Derek Schuff
Date: 2020-12-10T16:43:59-08:00
New Revision: 8d396acac3bc21f688ac707bb42e4698dbdcab7e

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

LOG: [WebAssembly] Support COMDAT sections in assembly syntax

This CL changes the asm syntax for section flags, making them more like ELF
(previously "passive" was the only option). Now we also allow "G" to designate
COMDAT group sections. In these sections we set the appropriate comdat flag on
function symbols, and also avoid auto-creating a new section for them.

This also adds asm-based tests for the changes D92691 to go along with
the direct-to-object tests.

Differential Revision: https://reviews.llvm.org/D92952
This is a reland of rG4564553b8d8a with a fix to the lit pipeline in
llvm/test/MC/WebAssembly/comdat.ll

Added: 
llvm/test/MC/WebAssembly/comdat-sections.s

Modified: 
llvm/lib/MC/MCParser/WasmAsmParser.cpp
llvm/lib/MC/MCSectionWasm.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/test/MC/WebAssembly/comdat-sections.ll
llvm/test/MC/WebAssembly/comdat.ll

Removed: 




diff  --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp 
b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
index c8f9807d0c54..0c255ef02d2a 100644
--- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
@@ -90,15 +90,40 @@ class WasmAsmParser : public MCAsmParserExtension {
 return false;
   }
 
-  bool parseSectionFlags(StringRef FlagStr, bool ) {
-SmallVector Flags;
-// If there are no flags, keep Flags empty
-FlagStr.split(Flags, ",", -1, false);
-for (auto  : Flags) {
-  if (Flag == "passive")
+  bool parseSectionFlags(StringRef FlagStr, bool , bool ) {
+for (char C : FlagStr) {
+  switch (C) {
+  case 'p':
 Passive = true;
-  else
-return error("Expected section flags, instead got: ", Lexer->getTok());
+break;
+  case 'G':
+Group = true;
+break;
+  default:
+return Parser->Error(getTok().getLoc(),
+ StringRef("Unexepcted section flag: ") + FlagStr);
+  }
+}
+return false;
+  }
+
+  bool parseGroup(StringRef ) {
+if (Lexer->isNot(AsmToken::Comma))
+  return TokError("expected group name");
+Lex();
+if (Lexer->is(AsmToken::Integer)) {
+  GroupName = getTok().getString();
+  Lex();
+} else if (Parser->parseIdentifier(GroupName)) {
+  return TokError("invalid group name");
+}
+if (Lexer->is(AsmToken::Comma)) {
+  Lex();
+  StringRef Linkage;
+  if (Parser->parseIdentifier(Linkage))
+return TokError("invalid linkage");
+  if (Linkage != "comdat")
+return TokError("Linkage must be 'comdat'");
 }
 return false;
   }
@@ -130,27 +155,34 @@ class WasmAsmParser : public MCAsmParserExtension {
 if (!Kind.hasValue())
   return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name);
 
-MCSectionWasm *Section = getContext().getWasmSection(Name, 
Kind.getValue());
 
 // Update section flags if present in this .section directive
 bool Passive = false;
-if (parseSectionFlags(getTok().getStringContents(), Passive))
+bool Group = false;
+if (parseSectionFlags(getTok().getStringContents(), Passive, Group))
   return true;
 
-if (Passive) {
-  if (!Section->isWasmData())
-return Parser->Error(getTok().getLoc(),
- "Only data sections can be passive");
-  Section->setPassive();
-}
-
 Lex();
 
-if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@") ||
-expect(AsmToken::EndOfStatement, "eol"))
+if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@"))
+  return true;
+
+StringRef GroupName;
+if (Group && parseGroup(GroupName))
+  return true;
+
+if (expect(AsmToken::EndOfStatement, "eol"))
   return true;
 
-auto WS = getContext().getWasmSection(Name, Kind.getValue());
+// TODO: Parse UniqueID
+MCSectionWasm *WS = getContext().getWasmSection(
+Name, Kind.getValue(), GroupName, MCContext::GenericSectionID);
+if (Passive) {
+  if (!WS->isWasmData())
+return Parser->Error(getTok().getLoc(),
+ "Only data sections can be passive");
+  WS->setPassive();
+}
 getStreamer().SwitchSection(WS);
 return false;
   }
@@ -189,9 +221,13 @@ class WasmAsmParser : public MCAsmParserExtension {
   Lexer->is(AsmToken::Identifier)))
   return error("Expected label,@type declaration, got: ", Lexer->getTok());
 auto TypeName = Lexer->getTok().getString();
-if (TypeName == "function")
+if (TypeName == "function") {
   

[llvm-branch-commits] [lld] 5dad062 - fix typo to cycle bots

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

Author: Nico Weber
Date: 2020-12-10T19:20:09-05:00
New Revision: 5dad062d7eb4bcae2f5e7fb6504a7be9757700c8

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

LOG: fix typo to cycle bots

Added: 


Modified: 
lld/test/COFF/pdb-tpi-aligned-records.test

Removed: 




diff  --git a/lld/test/COFF/pdb-tpi-aligned-records.test 
b/lld/test/COFF/pdb-tpi-aligned-records.test
index feabe5f0ab5b..264916280916 100644
--- a/lld/test/COFF/pdb-tpi-aligned-records.test
+++ b/lld/test/COFF/pdb-tpi-aligned-records.test
@@ -17,7 +17,7 @@ sections:
 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, 
IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
 Alignment:   1
 # It is important to keep the 'SectionData' since the .OBJ is 
reconstructed from it,
-# and that triggers an alignement bug in the output .PDB.
+# and that triggers an alignment bug in the output .PDB.
 SectionData: 
'04001810030006000112'
 Types:
   - Kind:LF_PROCEDURE



___
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] bc7a61b - Revert "[SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing."

2020-12-10 Thread Jonas Paulsson via llvm-branch-commits

Author: Jonas Paulsson
Date: 2020-12-10T18:05:51-06:00
New Revision: bc7a61b7036044636f9a2c91c916153532a551f8

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

LOG: Revert "[SystemZFrameLowering] Don't overrwrite R1D (backchain) when 
probing."

Temporarily reverted.

This reverts commit ea475c77ff9eab1de7d44684c8fb453b39f70081.

Added: 


Modified: 
llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
llvm/test/CodeGen/SystemZ/stack-clash-dynamic-alloca.ll
llvm/test/CodeGen/SystemZ/stack-clash-protection.ll

Removed: 




diff  --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp 
b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index 0bfab129edb1..57529c8685de 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
@@ -488,6 +488,15 @@ void SystemZFrameLowering::emitPrologue(MachineFunction 
,
   MFFrame.setStackSize(StackSize);
 
   if (StackSize) {
+// Determine if we want to store a backchain.
+bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
+
+// If we need backchain, save current stack pointer.  R1 is free at this
+// point.
+if (StoreBackchain)
+  BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LGR))
+.addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
+
 // Allocate StackSize bytes.
 int64_t Delta = -int64_t(StackSize);
 const unsigned ProbeSize = TLI.getStackProbeSize(MF);
@@ -503,23 +512,18 @@ void SystemZFrameLowering::emitPrologue(MachineFunction 
,
 .addImm(StackSize);
 }
 else {
-  bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
-  // If we need backchain, save current stack pointer.  R1 is free at
-  // this point.
-  if (StoreBackchain)
-BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LGR))
-  .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
   emitIncrement(MBB, MBBI, DL, SystemZ::R15D, Delta, ZII);
   buildCFAOffs(MBB, MBBI, DL, SPOffsetFromCFA + Delta, ZII);
-  if (StoreBackchain) {
-// The back chain is stored topmost with packed-stack.
-int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
-BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG))
-  .addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D)
-  .addImm(Offset).addReg(0);
-  }
 }
 SPOffsetFromCFA += Delta;
+
+if (StoreBackchain) {
+  // The back chain is stored topmost with packed-stack.
+  int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
+  BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG))
+.addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D)
+.addImm(Offset).addReg(0);
+}
   }
 
   if (HasFP) {
@@ -664,11 +668,6 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction ,
   .addMemOperand(MMO);
   };
 
-  bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
-  if (StoreBackchain)
-BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR))
-  .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
-
   if (NumFullBlocks < 3) {
 // Emit unrolled probe statements.
 for (unsigned int i = 0; i < NumFullBlocks; i++)
@@ -678,11 +677,10 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction ,
 uint64_t LoopAlloc = ProbeSize * NumFullBlocks;
 SPOffsetFromCFA -= LoopAlloc;
 
-// Use R0D to hold the exit value.
-BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR), SystemZ::R0D)
+BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR), SystemZ::R1D)
   .addReg(SystemZ::R15D);
-buildDefCFAReg(*MBB, MBBI, DL, SystemZ::R0D, ZII);
-emitIncrement(*MBB, MBBI, DL, SystemZ::R0D, -int64_t(LoopAlloc), ZII);
+buildDefCFAReg(*MBB, MBBI, DL, SystemZ::R1D, ZII);
+emitIncrement(*MBB, MBBI, DL, SystemZ::R1D, -int64_t(LoopAlloc), ZII);
 buildCFAOffs(*MBB, MBBI, DL, -int64_t(SystemZMC::CallFrameSize + 
LoopAlloc),
  ZII);
 
@@ -695,7 +693,7 @@ void SystemZFrameLowering::inlineStackProbe(MachineFunction 
,
 MBB = LoopMBB;
 allocateAndProbe(*MBB, MBB->end(), ProbeSize, false/*EmitCFI*/);
 BuildMI(*MBB, MBB->end(), DL, ZII->get(SystemZ::CLGR))
-  .addReg(SystemZ::R15D).addReg(SystemZ::R0D);
+  .addReg(SystemZ::R15D).addReg(SystemZ::R1D);
 BuildMI(*MBB, MBB->end(), DL, ZII->get(SystemZ::BRC))
   .addImm(SystemZ::CCMASK_ICMP).addImm(SystemZ::CCMASK_CMP_GT).addMBB(MBB);
 
@@ -710,14 +708,6 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction ,
   if (Residual)
 allocateAndProbe(*MBB, MBBI, Residual, true/*EmitCFI*/);
 
-  if (StoreBackchain) {
-// The back chain is stored topmost with packed-stack.
-int Offset = usePackedStack(MF) ? 

[llvm-branch-commits] [llvm] eaa9f6b - [gn build] Port 7ead5f5aa38

2020-12-10 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-10T23:59:49Z
New Revision: eaa9f6b2cca82819dfa2f60fc878ead80c4138b5

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

LOG: [gn build] Port 7ead5f5aa38

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
index e26d0bd01521..5bd7ec8f5818 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
@@ -38,7 +38,6 @@ static_library("AsmPrinter") {
 "EHStreamer.cpp",
 "ErlangGCPrinter.cpp",
 "OcamlGCPrinter.cpp",
-"PseudoProbePrinter.cpp",
 "WasmException.cpp",
 "WinCFGuard.cpp",
 "WinException.cpp",

diff  --git a/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
index 9aa3f8539ad1..e0c7701e9896 100644
--- a/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
@@ -43,7 +43,6 @@ static_library("MC") {
 "MCObjectFileInfo.cpp",
 "MCObjectStreamer.cpp",
 "MCObjectWriter.cpp",
-"MCPseudoProbe.cpp",
 "MCRegisterInfo.cpp",
 "MCSchedule.cpp",
 "MCSection.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] [lld] 76c36c1 - [lld-macho] Don't load dylibs more than once

2020-12-10 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-10T15:57:52-08:00
New Revision: 76c36c11a9c620a5eeced5750b844a1097ab7586

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

LOG: [lld-macho] Don't load dylibs more than once

Also remove `DylibFile::reexported` since it's unused.

Fixes llvm.org/PR48393.

Reviewed By: thakis

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

Added: 


Modified: 
lld/MachO/Driver.cpp
lld/MachO/Driver.h
lld/MachO/DriverUtils.cpp
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/test/MachO/dylink.s
lld/test/MachO/implicit-dylibs.s
lld/test/MachO/lc-linker-option.ll

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 469ab801bfe8..73846d420096 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -309,10 +309,8 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
 break;
   case file_magic::macho_dynamically_linked_shared_lib:
   case file_magic::macho_dynamically_linked_shared_lib_stub:
-newFile = make(mbref);
-break;
   case file_magic::tapi_file: {
-if (Optional dylibFile = makeDylibFromTAPI(mbref))
+if (Optional dylibFile = loadDylib(mbref))
   newFile = *dylibFile;
 break;
   }

diff  --git a/lld/MachO/Driver.h b/lld/MachO/Driver.h
index 9a6a05af0e0d..97b897f0271b 100644
--- a/lld/MachO/Driver.h
+++ b/lld/MachO/Driver.h
@@ -43,8 +43,8 @@ std::string createResponseFile(const llvm::opt::InputArgList 
);
 // Check for both libfoo.dylib and libfoo.tbd (in that order).
 llvm::Optional resolveDylibPath(llvm::StringRef path);
 
-llvm::Optional makeDylibFromTAPI(llvm::MemoryBufferRef mbref,
-  DylibFile *umbrella = nullptr);
+llvm::Optional loadDylib(llvm::MemoryBufferRef mbref,
+  DylibFile *umbrella = nullptr);
 
 uint32_t getModTime(llvm::StringRef path);
 

diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 9f06901d3847..05677a9df78d 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -14,6 +14,8 @@
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Memory.h"
 #include "lld/Common/Reproduce.h"
+#include "llvm/ADT/CachedHashString.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
@@ -166,7 +168,7 @@ Optional macho::resolveDylibPath(StringRef 
path) {
   return {};
 }
 
-Optional macho::makeDylibFromTAPI(MemoryBufferRef mbref,
+static Optional makeDylibFromTapi(MemoryBufferRef mbref,
DylibFile *umbrella) {
   Expected> result = TextAPIReader::get(mbref);
   if (!result) {
@@ -177,6 +179,24 @@ Optional 
macho::makeDylibFromTAPI(MemoryBufferRef mbref,
   return make(**result, umbrella);
 }
 
+static DenseSet loadedDylibs;
+
+Optional macho::loadDylib(MemoryBufferRef mbref,
+   DylibFile *umbrella) {
+  StringRef path = mbref.getBufferIdentifier();
+  if (loadedDylibs.contains(CachedHashStringRef(path)))
+return {};
+  loadedDylibs.insert(CachedHashStringRef(path));
+
+  file_magic magic = identify_magic(mbref.getBuffer());
+  if (magic == file_magic::tapi_file)
+return makeDylibFromTapi(mbref, umbrella);
+
+  assert(magic == file_magic::macho_dynamically_linked_shared_lib ||
+ magic == file_magic::macho_dynamically_linked_shared_lib_stub);
+  return make(mbref, umbrella);
+}
+
 uint32_t macho::getModTime(StringRef path) {
   fs::file_status stat;
   if (!fs::status(path, stat))

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index e9e71e0c6a40..92fc7d10ebb0 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -457,12 +457,7 @@ static Optional loadDylib(StringRef path, 
DylibFile *umbrella) {
 error("could not read dylib file at " + path);
 return {};
   }
-
-  file_magic magic = identify_magic(mbref->getBuffer());
-  if (magic == file_magic::tapi_file)
-return makeDylibFromTAPI(*mbref, umbrella);
-  assert(magic == file_magic::macho_dynamically_linked_shared_lib);
-  return make(*mbref, umbrella);
+  return loadDylib(*mbref, umbrella);
 }
 
 // TBD files are parsed into a series of TAPI documents (InterfaceFiles), with
@@ -518,11 +513,10 @@ static bool isImplicitlyLinked(StringRef path) {
   // -sub_umbrella first to write a test case.
 }
 
-static Optional loadReexport(StringRef path, DylibFile *umbrella) 
{
+void loadReexport(StringRef path, DylibFile *umbrella) {
   Optional reexport = loadReexportHelper(path, umbrella);
   if (reexport && isImplicitlyLinked(path))
 inputFiles.push_back(*reexport);
-  return reexport;
 }
 
 DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella)
@@ 

[llvm-branch-commits] [lld] 6a348f6 - [lld-macho] Implement `-no_implicit_dylibs`

2020-12-10 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-10T15:57:52-08:00
New Revision: 6a348f6158ecdb7a4bcac3f4cd1d3c5b6e80a550

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

LOG: [lld-macho] Implement `-no_implicit_dylibs`

Dylibs that are "public" -- i.e. top-level system libraries -- are considered
implicitly linked when another library re-exports them. That is, we should load
them & bind directly to their symbols instead of via their re-exporting
umbrella library. This diff implements that behavior by default, as well as an
opt-out flag.

In theory, this is just a performance optimization, but in practice it seems
that it's needed for correctness.

Fixes llvm.org/PR48395.

Reviewed By: thakis

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

Added: 
lld/test/MachO/implicit-dylibs.s

Modified: 
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp
lld/MachO/Options.td
lld/test/MachO/reexport-stub.s
lld/test/MachO/stub-link.s

Removed: 




diff  --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index 46ce02fb25e0..2835b5c1546e 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -36,6 +36,7 @@ struct Configuration {
   bool allLoad = false;
   bool forceLoadObjC = false;
   bool staticLink = false;
+  bool implicitDylibs = false;
   bool isPic = false;
   bool headerPadMaxInstallNames = false;
   bool printEachFile = false;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index b8a926279891..469ab801bfe8 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -719,6 +719,7 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
   config->allLoad = args.hasArg(OPT_all_load);
   config->forceLoadObjC = args.hasArg(OPT_ObjC);
   config->demangle = args.hasArg(OPT_demangle);
+  config->implicitDylibs = !args.hasArg(OPT_no_implicit_dylibs);
 
   if (const opt::Arg *arg = args.getLastArg(OPT_static, OPT_dynamic))
 config->staticLink = (arg->getOption().getID() == OPT_static);

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 3e0ad220bff1..e9e71e0c6a40 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -479,7 +479,8 @@ const InterfaceFile *currentTopLevelTapi = nullptr;
 
 // Re-exports can either refer to on-disk files, or to documents within .tbd
 // files.
-static Optional loadReexport(StringRef path, DylibFile *umbrella) 
{
+static Optional loadReexportHelper(StringRef path,
+DylibFile *umbrella) {
   if (path::is_absolute(path, path::Style::posix))
 for (StringRef root : config->systemLibraryRoots)
   if (Optional dylibPath =
@@ -504,6 +505,26 @@ static Optional loadReexport(StringRef path, 
DylibFile *umbrella) {
   return {};
 }
 
+// If a re-exported dylib is public (lives in /usr/lib or
+// /System/Library/Frameworks), then it is considered implicitly linked: we
+// should bind to its symbols directly instead of via the re-exporting umbrella
+// library.
+static bool isImplicitlyLinked(StringRef path) {
+  if (!config->implicitDylibs)
+return false;
+
+  return path::parent_path(path) == "/usr/lib";
+  // TODO: check for public frameworks too. We'll need to implement
+  // -sub_umbrella first to write a test case.
+}
+
+static Optional loadReexport(StringRef path, DylibFile *umbrella) 
{
+  Optional reexport = loadReexportHelper(path, umbrella);
+  if (reexport && isImplicitlyLinked(path))
+inputFiles.push_back(*reexport);
+  return reexport;
+}
+
 DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella)
 : InputFile(DylibKind, mb) {
   if (umbrella == nullptr)
@@ -522,17 +543,15 @@ DylibFile::DylibFile(MemoryBufferRef mb, DylibFile 
*umbrella)
   }
 
   // Initialize symbols.
-  // TODO: if a re-exported dylib is public (lives in /usr/lib or
-  // /System/Library/Frameworks), we should bind to its symbols directly
-  // instead of the re-exporting umbrella library.
+  DylibFile *exportingFile = isImplicitlyLinked(dylibName) ? this : umbrella;
   if (const load_command *cmd = findCommand(hdr, LC_DYLD_INFO_ONLY)) {
 auto *c = reinterpret_cast(cmd);
 parseTrie(buf + c->export_off, c->export_size,
   [&](const Twine , uint64_t flags) {
 bool isWeakDef = flags & EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION;
 bool isTlv = flags & EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL;
-symbols.push_back(symtab->addDylib(saver.save(name), umbrella,
-   isWeakDef, isTlv));
+symbols.push_back(symtab->addDylib(
+saver.save(name), exportingFile, isWeakDef, isTlv));
   });
   } else {
 error("LC_DYLD_INFO_ONLY not found in " + toString(this));
@@ -564,8 +583,9 @@ 

[llvm-branch-commits] [lld] 74d7999 - [lld-macho] Initialize AsmParsers earlier

2020-12-10 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-10T15:57:52-08:00
New Revision: 74d799926e557928352dcd980788cae6487e421c

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

LOG: [lld-macho] Initialize AsmParsers earlier

We need to initialize AsmParsers before any calls to `addFile`, as
bitcode files may require them. Otherwise we trigger `Assertion T &&
T->hasMCAsmParser()' failed`.

Reviewed By: #lld-macho, compnerd

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

Added: 
lld/test/MachO/module-asm.ll

Modified: 
lld/MachO/Driver.cpp

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 432bb81925da..b8a926279891 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -749,6 +749,8 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
 return !errorCount();
   }
 
+  initLLVM(); // must be run before any call to addFile()
+
   for (const auto  : args) {
 const auto  = arg->getOption();
 warnIfDeprecatedOption(opt);
@@ -807,7 +809,6 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
   for (auto *arg : args.filtered(OPT_mllvm))
 parseClangOption(arg->getValue(), arg->getSpelling());
 
-  initLLVM();
   compileBitcodeFiles();
   replaceCommonSymbols();
 

diff  --git a/lld/test/MachO/module-asm.ll b/lld/test/MachO/module-asm.ll
new file mode 100644
index ..01adcc438d2a
--- /dev/null
+++ b/lld/test/MachO/module-asm.ll
@@ -0,0 +1,24 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+; RUN: %lld %t.o -o %t
+; RUN: llvm-objdump -d %t | FileCheck %s
+
+; CHECK:  <_foo>:
+; CHECK-NEXT: retq
+
+; CHECK:  <_main>:
+; CHECK-NEXT: jmp {{.*}} <_foo>
+
+target triple = "x86_64-apple-macosx10.15.0"
+target datalayout = 
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+module asm ".text"
+module asm ".globl _foo"
+module asm "_foo: ret"
+
+declare void @foo()
+
+define void @main() {
+  call void @foo()
+  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] [lld] 95831a5 - [lld-macho] Implement -object_path_lto

2020-12-10 Thread Jez Ng via llvm-branch-commits

Author: Jez Ng
Date: 2020-12-10T15:57:51-08:00
New Revision: 95831a56d092c563b03167ece592be301a2a0081

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

LOG: [lld-macho] Implement -object_path_lto

This makes it possible for STABS entries to reference the debug info
contained in the LTO-compiled output.

I'm not sure how to test the file mtime within llvm-lit -- GNU and BSD
`stat` take different command-line arguments. I've omitted the check for
now.

Reviewed By: clayborg

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

Added: 
lld/test/MachO/lto-object-path.ll

Modified: 
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/LTO.cpp
lld/MachO/Options.td

Removed: 




diff  --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index c13010717bfd..46ce02fb25e0 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -45,6 +45,7 @@ struct Configuration {
   uint32_t headerPad;
   llvm::StringRef installName;
   llvm::StringRef outputFile;
+  llvm::StringRef ltoObjPath;
   bool demangle = false;
   llvm::MachO::Architecture arch;
   PlatformInfo platform;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 72ef1b28ed58..48e7e7e8dc0d 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -703,6 +703,7 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
   config->printEachFile = args.hasArg(OPT_t);
   config->printWhyLoad = args.hasArg(OPT_why_load);
   config->outputType = getOutputType(args);
+  config->ltoObjPath = args.getLastArgValue(OPT_object_path_lto);
   config->runtimePaths = args::getStrings(args, OPT_rpath);
   config->allLoad = args.hasArg(OPT_all_load);
   config->forceLoadObjC = args.hasArg(OPT_ObjC);

diff  --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index 1932cf46661d..f2a0c683052f 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -8,17 +8,21 @@
 
 #include "LTO.h"
 #include "Config.h"
+#include "Driver.h"
 #include "InputFiles.h"
 
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Strings.h"
 #include "lld/Common/TargetOptionsCommandFlags.h"
 #include "llvm/LTO/LTO.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace lld;
 using namespace lld::macho;
 using namespace llvm;
+using namespace llvm::sys;
 
 static lto::Config createConfig() {
   lto::Config c;
@@ -73,12 +77,26 @@ std::vector BitcodeCompiler::compile() {
   saveBuffer(buf[i], config->outputFile + Twine(i) + ".lto.o");
   }
 
-  // TODO: set modTime properly
+  if (!config->ltoObjPath.empty())
+fs::create_directories(config->ltoObjPath);
+
   std::vector ret;
-  for (unsigned i = 0; i != maxTasks; ++i)
-if (!buf[i].empty())
-  ret.push_back(
-  make(MemoryBufferRef(buf[i], "lto.tmp"), /*modTime=*/0, 
""));
+  for (unsigned i = 0; i != maxTasks; ++i) {
+if (buf[i].empty()) {
+  continue;
+}
+SmallString<261> filePath("/tmp/lto.tmp");
+uint32_t modTime = 0;
+if (!config->ltoObjPath.empty()) {
+  filePath = config->ltoObjPath;
+  path::append(filePath, Twine(i) + "." +
+ getArchitectureName(config->arch) + ".lto.o");
+  saveBuffer(buf[i], filePath);
+  modTime = getModTime(filePath);
+}
+ret.push_back(make(
+MemoryBufferRef(buf[i], saver.save(filePath.str())), modTime, ""));
+  }
 
   return ret;
 }

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index b333d2b714f6..b05bc9fc8073 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -840,7 +840,6 @@ def no_objc_category_merging : Flag<["-"], 
"no_objc_category_merging">,
 def object_path_lto : Separate<["-"], "object_path_lto">,
  MetaVarName<"">,
  HelpText<"Retain any temporary mach-o file in  that would otherwise 
be deleted during LTO">,
- Flags<[HelpHidden]>,
  Group;
 def lto_library : Separate<["-"], "lto_library">,
  MetaVarName<"">,

diff  --git a/lld/test/MachO/lto-object-path.ll 
b/lld/test/MachO/lto-object-path.ll
new file mode 100644
index ..b362bf45b133
--- /dev/null
+++ b/lld/test/MachO/lto-object-path.ll
@@ -0,0 +1,37 @@
+; REQUIRES: x86
+
+; RUN: rm -rf %t; mkdir %t
+; RUN: llvm-as %s -o %t/test.o
+
+; RUN: %lld %t/test.o -o %t/test
+; RUN: llvm-nm -pa %t/test | FileCheck %s --check-prefixes CHECK,NOOBJPATH
+
+; RUN: %lld %t/test.o -o %t/test -object_path_lto %t/lto-temps
+; RUN: llvm-nm -pa %t/test | FileCheck %s --check-prefixes CHECK,OBJPATH 
-DDIR=%t/lto-temps
+
+; CHECK:  - 00 SO /tmp/test.cpp
+; NOOBJPATH-NEXT: - 03 0001   OSO /tmp/lto.tmp
+;; check that modTime is nonzero when `-object_path_lto` is provided
+; OBJPATH-NEXT:   

[llvm-branch-commits] [llvm] dd1aa4f - Revert "[WebAssembly] Support COMDAT sections in assembly syntax"

2020-12-10 Thread Derek Schuff via llvm-branch-commits

Author: Derek Schuff
Date: 2020-12-10T15:55:33-08:00
New Revision: dd1aa4fdd82bc4b33e9661eda6039760408501d9

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

LOG: Revert "[WebAssembly] Support COMDAT sections in assembly syntax"

This reverts commit 4564553b8d8ab81dc21431a35275581cb42329c8.
It broke several buildbots.

Added: 


Modified: 
llvm/lib/MC/MCParser/WasmAsmParser.cpp
llvm/lib/MC/MCSectionWasm.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/test/MC/WebAssembly/comdat-sections.ll
llvm/test/MC/WebAssembly/comdat.ll

Removed: 
llvm/test/MC/WebAssembly/comdat-sections.s



diff  --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp 
b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
index 0c255ef02d2a..c8f9807d0c54 100644
--- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
@@ -90,40 +90,15 @@ class WasmAsmParser : public MCAsmParserExtension {
 return false;
   }
 
-  bool parseSectionFlags(StringRef FlagStr, bool , bool ) {
-for (char C : FlagStr) {
-  switch (C) {
-  case 'p':
+  bool parseSectionFlags(StringRef FlagStr, bool ) {
+SmallVector Flags;
+// If there are no flags, keep Flags empty
+FlagStr.split(Flags, ",", -1, false);
+for (auto  : Flags) {
+  if (Flag == "passive")
 Passive = true;
-break;
-  case 'G':
-Group = true;
-break;
-  default:
-return Parser->Error(getTok().getLoc(),
- StringRef("Unexepcted section flag: ") + FlagStr);
-  }
-}
-return false;
-  }
-
-  bool parseGroup(StringRef ) {
-if (Lexer->isNot(AsmToken::Comma))
-  return TokError("expected group name");
-Lex();
-if (Lexer->is(AsmToken::Integer)) {
-  GroupName = getTok().getString();
-  Lex();
-} else if (Parser->parseIdentifier(GroupName)) {
-  return TokError("invalid group name");
-}
-if (Lexer->is(AsmToken::Comma)) {
-  Lex();
-  StringRef Linkage;
-  if (Parser->parseIdentifier(Linkage))
-return TokError("invalid linkage");
-  if (Linkage != "comdat")
-return TokError("Linkage must be 'comdat'");
+  else
+return error("Expected section flags, instead got: ", Lexer->getTok());
 }
 return false;
   }
@@ -155,34 +130,27 @@ class WasmAsmParser : public MCAsmParserExtension {
 if (!Kind.hasValue())
   return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name);
 
+MCSectionWasm *Section = getContext().getWasmSection(Name, 
Kind.getValue());
 
 // Update section flags if present in this .section directive
 bool Passive = false;
-bool Group = false;
-if (parseSectionFlags(getTok().getStringContents(), Passive, Group))
-  return true;
-
-Lex();
-
-if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@"))
-  return true;
-
-StringRef GroupName;
-if (Group && parseGroup(GroupName))
-  return true;
-
-if (expect(AsmToken::EndOfStatement, "eol"))
+if (parseSectionFlags(getTok().getStringContents(), Passive))
   return true;
 
-// TODO: Parse UniqueID
-MCSectionWasm *WS = getContext().getWasmSection(
-Name, Kind.getValue(), GroupName, MCContext::GenericSectionID);
 if (Passive) {
-  if (!WS->isWasmData())
+  if (!Section->isWasmData())
 return Parser->Error(getTok().getLoc(),
  "Only data sections can be passive");
-  WS->setPassive();
+  Section->setPassive();
 }
+
+Lex();
+
+if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@") ||
+expect(AsmToken::EndOfStatement, "eol"))
+  return true;
+
+auto WS = getContext().getWasmSection(Name, Kind.getValue());
 getStreamer().SwitchSection(WS);
 return false;
   }
@@ -221,13 +189,9 @@ class WasmAsmParser : public MCAsmParserExtension {
   Lexer->is(AsmToken::Identifier)))
   return error("Expected label,@type declaration, got: ", Lexer->getTok());
 auto TypeName = Lexer->getTok().getString();
-if (TypeName == "function") {
+if (TypeName == "function")
   WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
-  auto *Current =
-  cast(getStreamer().getCurrentSection().first);
-  if (Current->getGroup())
-WasmSym->setComdat(true);
-} else if (TypeName == "global")
+else if (TypeName == "global")
   WasmSym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL);
 else if (TypeName == "object")
   WasmSym->setType(wasm::WASM_SYMBOL_TYPE_DATA);

diff  --git a/llvm/lib/MC/MCSectionWasm.cpp b/llvm/lib/MC/MCSectionWasm.cpp
index 81dc4329be6a..27ed51802a2e 100644
--- a/llvm/lib/MC/MCSectionWasm.cpp
+++ 

[llvm-branch-commits] [llvm] 7ead5f5 - Revert "[CSSPGO] Pseudo probe encoding and emission."

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T15:53:39-08:00
New Revision: 7ead5f5aa3803864015c110ccfc7766948b210e3

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

LOG: Revert "[CSSPGO] Pseudo probe encoding and emission."

This reverts commit b035513c06d1cba2bae8f3e88798334e877523e1.

Reason: Broke the ASan buildbots:
  http://lab.llvm.org:8011/#/builders/5/builds/2269

Added: 


Modified: 
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/IR/MDBuilder.h
llvm/include/llvm/IR/PseudoProbe.h
llvm/include/llvm/MC/MCAssembler.h
llvm/include/llvm/MC/MCContext.h
llvm/include/llvm/MC/MCFragment.h
llvm/include/llvm/MC/MCObjectFileInfo.h
llvm/include/llvm/MC/MCStreamer.h
llvm/include/llvm/Passes/PassBuilder.h
llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/IR/MDBuilder.cpp
llvm/lib/MC/CMakeLists.txt
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MCFragment.cpp
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll

Removed: 
llvm/include/llvm/MC/MCPseudoProbe.h
llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.h
llvm/lib/MC/MCPseudoProbe.cpp
llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll



diff  --git a/llvm/include/llvm/CodeGen/AsmPrinter.h 
b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 76486b0b48ce..7fac3613251b 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -66,7 +66,6 @@ class MCSymbol;
 class MCTargetOptions;
 class MDNode;
 class Module;
-class PseudoProbeHandler;
 class raw_ostream;
 class StackMaps;
 class StringRef;
@@ -207,10 +206,6 @@ class AsmPrinter : public MachineFunctionPass {
   /// If the target supports dwarf debug info, this pointer is non-null.
   DwarfDebug *DD = nullptr;
 
-  /// A handler that supports pseudo probe emission with embedded inline
-  /// context.
-  PseudoProbeHandler *PP = nullptr;
-
   /// If the current module uses dwarf CFI annotations strictly for debugging.
   bool isCFIMoveForDebugging = false;
 
@@ -365,8 +360,6 @@ class AsmPrinter : public MachineFunctionPass {
 
   void emitBBAddrMapSection(const MachineFunction );
 
-  void emitPseudoProbe(const MachineInstr );
-
   void emitRemarksSection(remarks::RemarkStreamer );
 
   enum CFIMoveType { CFI_M_None, CFI_M_EH, CFI_M_Debug };

diff  --git a/llvm/include/llvm/IR/MDBuilder.h 
b/llvm/include/llvm/IR/MDBuilder.h
index 51be8667f1c1..08cd60c30e6a 100644
--- a/llvm/include/llvm/IR/MDBuilder.h
+++ b/llvm/include/llvm/IR/MDBuilder.h
@@ -76,9 +76,6 @@ class MDBuilder {
   /// Return metadata containing the section prefix for a function.
   MDNode *createFunctionSectionPrefix(StringRef Prefix);
 
-  /// Return metadata containing the pseudo probe descriptor for a function.
-  MDNode *createPseudoProbeDesc(uint64_t GUID, uint64_t Hash, Function *F);
-
   //===--===//
   // Range metadata.
   //===--===//

diff  --git a/llvm/include/llvm/IR/PseudoProbe.h 
b/llvm/include/llvm/IR/PseudoProbe.h
index 9b4645aed6e9..fd3a0075efbe 100644
--- a/llvm/include/llvm/IR/PseudoProbe.h
+++ b/llvm/include/llvm/IR/PseudoProbe.h
@@ -18,8 +18,6 @@
 
 namespace llvm {
 
-constexpr const char *PseudoProbeDescMetadataName = "llvm.pseudo_probe_desc";
-
 enum class PseudoProbeType { Block = 0, IndirectCall, DirectCall };
 
 struct PseudoProbeDwarfDiscriminator {

diff  --git a/llvm/include/llvm/MC/MCAssembler.h 
b/llvm/include/llvm/MC/MCAssembler.h
index 15c0be436fd8..b57439f02ca5 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -202,7 +202,6 @@ class MCAssembler {
   bool relaxCVInlineLineTable(MCAsmLayout ,
   MCCVInlineLineTableFragment );
   bool relaxCVDefRange(MCAsmLayout , MCCVDefRangeFragment );
-  bool relaxPseudoProbeAddr(MCAsmLayout , MCPseudoProbeAddrFragment 
);
 
   /// finishLayout - Finalize a layout, including fragment lowering.
   void finishLayout(MCAsmLayout );

diff  --git a/llvm/include/llvm/MC/MCContext.h 
b/llvm/include/llvm/MC/MCContext.h
index 75e6dbe069e2..242b5da6bd1a 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -22,7 +22,6 @@
 #include "llvm/BinaryFormat/XCOFF.h"
 #include 

[llvm-branch-commits] [llvm] 9aafa9f - Revert "[NFC] Fix a gcc build break by not using an initializer."

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T15:53:38-08:00
New Revision: 9aafa9fc15228e69393782026930fbe2ab403dac

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

LOG: Revert "[NFC] Fix a gcc build break by not using an initializer."

This reverts commit 1dc0a8521f616af5897327e4c03098f9312e9c59.

Reason: Dependency of patch that broke the ASan buildbots:
  http://lab.llvm.org:8011/#/builders/5/builds/2269

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
index 5c3952b12e07..69adc77730d1 100644
--- a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
@@ -62,7 +62,7 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, 
uint64_t Index,
 uint64_t CallerGuid = Names[Name];
 uint64_t CallerProbeId = PseudoProbeDwarfDiscriminator::extractProbeIndex(
 InlinedAt->getDiscriminator());
-ReversedInlineStack.emplace_back(CallerGuid, CallerProbeId);
+ReversedInlineStack.push_back({CallerGuid, CallerProbeId});
 InlinedAt = InlinedAt->getInlinedAt();
   }
 



___
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] b955eb6 - Revert "[NFC] Fix a gcc build break by using an explict constructor."

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T15:53:38-08:00
New Revision: b955eb688da31e85780bae8fc424bb344ef5daee

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

LOG: Revert "[NFC] Fix a gcc build break by using an explict constructor."

This reverts commit 248b279cf04d9e439a1e426ffd24f2dfa93d02f8.

Reason: Dependency of patch that broke the ASan buildbots:
  http://lab.llvm.org:8011/#/builders/5/builds/2269

Added: 


Modified: 
llvm/lib/MC/MCParser/AsmParser.cpp

Removed: 




diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp 
b/llvm/lib/MC/MCParser/AsmParser.cpp
index bf50a95bc70c..bf2e5d8b41d4 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -5833,7 +5833,7 @@ bool AsmParser::parseDirectivePseudoProbe() {
 return true;
 }
 
-InlineSite Site(CallerGuid, CallerProbeId);
+InlineSite Site = {CallerGuid, CallerProbeId};
 InlineStack.push_back(Site);
   }
 



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


[llvm-branch-commits] [compiler-rt] 97260ab - [llvm-cov][gcov] Optimize the cycle counting algorithm by skipping zero count cycles

2020-12-10 Thread Fangrui Song via llvm-branch-commits

Author: Xinhao Yuan
Date: 2020-12-10T15:22:29-08:00
New Revision: 97260ab4786f87211b8553b56fd0600016b1d6fa

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

LOG: [llvm-cov][gcov] Optimize the cycle counting algorithm by skipping zero 
count cycles

This change is similar to http://gcc.gnu.org/PR90380

This reduces the complexity from exponential to polynomial of the arcs.

Reviewed By: MaskRay

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

Added: 
compiler-rt/test/profile/gcov-complex-line.c

Modified: 
llvm/include/llvm/ProfileData/GCOV.h
llvm/lib/ProfileData/GCOV.cpp

Removed: 




diff  --git a/compiler-rt/test/profile/gcov-complex-line.c 
b/compiler-rt/test/profile/gcov-complex-line.c
new file mode 100644
index ..86286c4a93a5
--- /dev/null
+++ b/compiler-rt/test/profile/gcov-complex-line.c
@@ -0,0 +1,55 @@
+// This test checks that the cycle detection algorithm in llvm-cov is able to
+// handle complex block graphs by skipping zero count cycles.
+//
+// RUN: mkdir -p %t.dir && cd %t.dir
+// RUN: %clang --coverage %s -o %t
+// RUN: rm -f gcov-complex-line.gcda && %run %t
+// RUN: llvm-cov gcov -t gcov-complex-line.c | FileCheck %s
+
+#define M_0 \
+  do {  \
+if (x == 0) \
+  x = 0;\
+else\
+  x = 1;\
+  } while (0)
+#define M_1 \
+  do {  \
+M_0;\
+M_0;\
+M_0;\
+M_0;\
+  } while (0)
+#define M_2 \
+  do {  \
+M_1;\
+M_1;\
+M_1;\
+M_1;\
+  } while (0)
+#define M_3 \
+  do {  \
+M_2;\
+M_2;\
+M_2;\
+M_2;\
+  } while (0)
+#define M_4 \
+  do {  \
+M_3;\
+M_3;\
+M_3;\
+M_3;\
+  } while (0)
+#define COMPLEX_LINE  \
+  do {\
+for (int i = 0; i < 100; ++i) \
+  M_4;\
+  } while (0)
+
+int main() {
+  volatile int x = 0;
+  // In the following line, the number of cycles in the block graph is at least
+  // 2^256, where 256 is the number of expansions of M_0.
+  COMPLEX_LINE; // CHECK: 101: [[#@LINE]]: COMPLEX_LINE;
+}

diff  --git a/llvm/include/llvm/ProfileData/GCOV.h 
b/llvm/include/llvm/ProfileData/GCOV.h
index 2766ff52e4a0..b15c5a6a6c65 100644
--- a/llvm/include/llvm/ProfileData/GCOV.h
+++ b/llvm/include/llvm/ProfileData/GCOV.h
@@ -295,6 +295,7 @@ class GCOVBlock {
   static uint64_t getCycleCount(const Edges );
   static void unblock(const GCOVBlock *U, BlockVector ,
   BlockVectorLists );
+  static void trimZeroCountSuffix(Edges );
   static bool lookForCircuit(const GCOVBlock *V, const GCOVBlock *Start,
  Edges , BlockVector ,
  BlockVectorLists ,

diff  --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index c0735250cfd8..b8bc0cc48376 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -427,6 +427,11 @@ LLVM_DUMP_METHOD void GCOVBlock::dump() const { 
print(dbgs()); }
 // The algorithm in GCC is based on the algorithm by Hawick & James:
 //   "Enumerating Circuits and Loops in Graphs with Self-Arcs and 
Multiple-Arcs"
 //   http://complexity.massey.ac.nz/cstn/013/cstn-013.pdf.
+//
+// An optimization is to skip any arc with zero count and to backtrack if the
+// current path has such arcs: any cycle with such arc makes no contribution to
+// the final cycle count. This reduces the complexity from exponential to
+// polynomial of the arcs.
 
 /// Get the count for the detected cycle.
 uint64_t GCOVBlock::getCycleCount(const Edges ) {
@@ -458,6 +463,15 @@ void GCOVBlock::unblock(const GCOVBlock *U, BlockVector 
,
   }
 }
 
+void GCOVBlock::trimZeroCountSuffix(Edges ) {
+  for (size_t index = 0; index < Path.size(); ++index) {
+if (Path[index]->cycleCount == 0) {
+  Path.resize(index);
+  return;
+}
+  }
+}
+
 bool GCOVBlock::lookForCircuit(const GCOVBlock *V, const GCOVBlock *Start,
Edges , BlockVector ,
BlockVectorLists ,
@@ -465,10 +479,11 @@ bool GCOVBlock::lookForCircuit(const GCOVBlock *V, const 
GCOVBlock *Start,
   Blocked.push_back(V);
   BlockLists.emplace_back(BlockVector());
   bool FoundCircuit = false;
+  const size_t PrefixLength = Path.size();
 
   for (auto E : V->dsts()) {
 const GCOVBlock *W = >dst;
-if (W < Start || find(Blocks, W) == Blocks.end()) {
+if (E->cycleCount == 0 || W < Start || find(Blocks, W) == Blocks.end()) {
   continue;
 }
 
@@ -477,6 +492,7 @@ bool GCOVBlock::lookForCircuit(const GCOVBlock *V, const 
GCOVBlock *Start,
 if (W == Start) {
   // We've a cycle.
   Count += GCOVBlock::getCycleCount(Path);
+  

[llvm-branch-commits] [llvm] 4564553 - [WebAssembly] Support COMDAT sections in assembly syntax

2020-12-10 Thread Derek Schuff via llvm-branch-commits

Author: Derek Schuff
Date: 2020-12-10T14:46:24-08:00
New Revision: 4564553b8d8ab81dc21431a35275581cb42329c8

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

LOG: [WebAssembly] Support COMDAT sections in assembly syntax

This CL changes the asm syntax for section flags, making them more like ELF
(previously "passive" was the only option). Now we also allow "G" to designate
COMDAT group sections. In these sections we set the appropriate comdat flag on
function symbols, and also avoid auto-creating a new section for them.

This also adds asm-based tests for the changes D92691 to go along with
the direct-to-object tests.

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

Added: 
llvm/test/MC/WebAssembly/comdat-sections.s

Modified: 
llvm/lib/MC/MCParser/WasmAsmParser.cpp
llvm/lib/MC/MCSectionWasm.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/test/MC/WebAssembly/comdat-sections.ll
llvm/test/MC/WebAssembly/comdat.ll

Removed: 




diff  --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp 
b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
index c8f9807d0c54..0c255ef02d2a 100644
--- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
@@ -90,15 +90,40 @@ class WasmAsmParser : public MCAsmParserExtension {
 return false;
   }
 
-  bool parseSectionFlags(StringRef FlagStr, bool ) {
-SmallVector Flags;
-// If there are no flags, keep Flags empty
-FlagStr.split(Flags, ",", -1, false);
-for (auto  : Flags) {
-  if (Flag == "passive")
+  bool parseSectionFlags(StringRef FlagStr, bool , bool ) {
+for (char C : FlagStr) {
+  switch (C) {
+  case 'p':
 Passive = true;
-  else
-return error("Expected section flags, instead got: ", Lexer->getTok());
+break;
+  case 'G':
+Group = true;
+break;
+  default:
+return Parser->Error(getTok().getLoc(),
+ StringRef("Unexepcted section flag: ") + FlagStr);
+  }
+}
+return false;
+  }
+
+  bool parseGroup(StringRef ) {
+if (Lexer->isNot(AsmToken::Comma))
+  return TokError("expected group name");
+Lex();
+if (Lexer->is(AsmToken::Integer)) {
+  GroupName = getTok().getString();
+  Lex();
+} else if (Parser->parseIdentifier(GroupName)) {
+  return TokError("invalid group name");
+}
+if (Lexer->is(AsmToken::Comma)) {
+  Lex();
+  StringRef Linkage;
+  if (Parser->parseIdentifier(Linkage))
+return TokError("invalid linkage");
+  if (Linkage != "comdat")
+return TokError("Linkage must be 'comdat'");
 }
 return false;
   }
@@ -130,27 +155,34 @@ class WasmAsmParser : public MCAsmParserExtension {
 if (!Kind.hasValue())
   return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name);
 
-MCSectionWasm *Section = getContext().getWasmSection(Name, 
Kind.getValue());
 
 // Update section flags if present in this .section directive
 bool Passive = false;
-if (parseSectionFlags(getTok().getStringContents(), Passive))
+bool Group = false;
+if (parseSectionFlags(getTok().getStringContents(), Passive, Group))
   return true;
 
-if (Passive) {
-  if (!Section->isWasmData())
-return Parser->Error(getTok().getLoc(),
- "Only data sections can be passive");
-  Section->setPassive();
-}
-
 Lex();
 
-if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@") ||
-expect(AsmToken::EndOfStatement, "eol"))
+if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@"))
+  return true;
+
+StringRef GroupName;
+if (Group && parseGroup(GroupName))
+  return true;
+
+if (expect(AsmToken::EndOfStatement, "eol"))
   return true;
 
-auto WS = getContext().getWasmSection(Name, Kind.getValue());
+// TODO: Parse UniqueID
+MCSectionWasm *WS = getContext().getWasmSection(
+Name, Kind.getValue(), GroupName, MCContext::GenericSectionID);
+if (Passive) {
+  if (!WS->isWasmData())
+return Parser->Error(getTok().getLoc(),
+ "Only data sections can be passive");
+  WS->setPassive();
+}
 getStreamer().SwitchSection(WS);
 return false;
   }
@@ -189,9 +221,13 @@ class WasmAsmParser : public MCAsmParserExtension {
   Lexer->is(AsmToken::Identifier)))
   return error("Expected label,@type declaration, got: ", Lexer->getTok());
 auto TypeName = Lexer->getTok().getString();
-if (TypeName == "function")
+if (TypeName == "function") {
   WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
-else if (TypeName == "global")
+  auto *Current =
+ 

[llvm-branch-commits] [compiler-rt] b1dd1a0 - [msan] Do not use 77 as exit code, instead use 1

2020-12-10 Thread Evgenii Stepanov via llvm-branch-commits

Author: Florian Schmaus
Date: 2020-12-10T14:23:12-08:00
New Revision: b1dd1a099771543cf0ca133b6342af1b3ce61a44

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

LOG: [msan] Do not use 77 as exit code, instead use 1

MSan uses 77 as exit code since it appeared with c5033786ba34 ("[msan]
MemorySanitizer runtime."). However, Test runners like the one from
Meson use the GNU standard approach where a exit code of 77 signals
that the test should be skipped [1]. As a result Meson's test runner
reports tests as skipped if MSan is enabled and finds issues:

build $ meson test
ninja: Entering directory `/home/user/code/project/build'
ninja: no work to do.
1/1 PROJECT:all / SimpleTestSKIP   0.09s

I could not find any rationale why 77 was initially chosen, and I
found no other clang sanitizer that uses this value as exit
code. Hence I believe it is safe to change this to a safe
default. You can restore the old behavior by setting the environment
variable MSAN_OPTIONS to "exitcode=77", e.g.

export MSAN_OPTIONS="exitcode=77"

1: https://mesonbuild.com/Unit-tests.html#skipped-tests-and-hard-errors

Reviewed By: #sanitizers, eugenis

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

Added: 


Modified: 
compiler-rt/lib/msan/msan.cpp

Removed: 




diff  --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index 7abb3b4b65dc..4be1630cd302 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -151,7 +151,6 @@ static void InitializeFlags() {
 // FIXME: test and enable.
 cf.check_printf = false;
 cf.intercept_tls_get_addr = true;
-cf.exitcode = 77;
 OverrideCommonFlags(cf);
   }
 



___
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] 10b5eae - [SmallVector] Copy new docs into Doxygen comment

2020-12-10 Thread Scott Linder via llvm-branch-commits

Author: Scott Linder
Date: 2020-12-10T22:20:37Z
New Revision: 10b5eaed917d6f91aa2d416c08c93697bd1d446f

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

LOG: [SmallVector] Copy new docs into Doxygen comment

Copy the `ProgrammersManual.rst` changes from D92522 to the Doxygen
comment for `SmallVector`, to hopefully encourage new uses migrating to
the no-explicit-`N` form.

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

Added: 


Modified: 
llvm/include/llvm/ADT/SmallVector.h

Removed: 




diff  --git a/llvm/include/llvm/ADT/SmallVector.h 
b/llvm/include/llvm/ADT/SmallVector.h
index 1b2787b88932..10b9d4e9c0f1 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -1012,7 +1012,14 @@ template  struct 
CalculateSmallVectorDefaultInlinedElements {
 /// elements is below that threshold.  This allows normal "small" cases to be
 /// fast without losing generality for large inputs.
 ///
-/// Note that this does not attempt to be exception safe.
+/// \note
+/// In the absence of a well-motivated choice for the number of inlined
+/// elements \p N, it is recommended to use \c SmallVector (that is,
+/// omitting the \p N). This will choose a default number of inlined elements
+/// reasonable for allocation on the stack (for example, trying to keep \c
+/// sizeof(SmallVector) around 64 bytes).
+///
+/// \warning This does not attempt to be exception safe.
 ///
 template ::value>



___
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] 186c154 - [mlir] Remove the dependency on StandardOps from FoldUtils

2020-12-10 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-10T14:13:57-08:00
New Revision: 186c154991e85f8d6a4a77c5add3322351862725

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

LOG: [mlir] Remove the dependency on StandardOps from FoldUtils

OperationFolder currently uses ConstantOp as a backup when trying to 
materialize a constant after an operation is folded. This dependency isn't 
really useful or necessary given that dialects can/should provide a 
`materializeConstant` implementation.

Fixes PR#44866

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

Added: 


Modified: 
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/lib/Transforms/Utils/FoldUtils.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/mlir-tblgen/pattern.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp 
b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index c71360cdaba5..ef29ddc510ae 100644
--- a/mlir/lib/Dialect/Shape/IR/Shape.cpp
+++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp
@@ -110,7 +110,7 @@ Operation *ShapeDialect::materializeConstant(OpBuilder 
,
 return builder.create(loc, type, value.cast());
   if (type.isa())
 return builder.create(loc, type, value.cast());
-  if (type.isa())
+  if (ConstantOp::isBuildableWith(value, type))
 return builder.create(loc, type, value);
   return nullptr;
 }

diff  --git a/mlir/lib/Transforms/Utils/FoldUtils.cpp 
b/mlir/lib/Transforms/Utils/FoldUtils.cpp
index 074f71c92fff..ba755a748418 100644
--- a/mlir/lib/Transforms/Utils/FoldUtils.cpp
+++ b/mlir/lib/Transforms/Utils/FoldUtils.cpp
@@ -13,7 +13,6 @@
 
 #include "mlir/Transforms/FoldUtils.h"
 
-#include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/Operation.h"
@@ -60,11 +59,6 @@ static Operation *materializeConstant(Dialect *dialect, 
OpBuilder ,
 assert(matchPattern(constOp, m_Constant()));
 return constOp;
   }
-
-  // If the dialect is unable to materialize a constant, check to see if the
-  // standard constant can be used.
-  if (ConstantOp::isBuildableWith(value, type))
-return builder.create(loc, type, value);
   return nullptr;
 }
 

diff  --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp 
b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index c7e1b7f48f43..eeff840daeea 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -178,6 +178,11 @@ void TestDialect::initialize() {
   allowUnknownOperations();
 }
 
+Operation *TestDialect::materializeConstant(OpBuilder , Attribute 
value,
+Type type, Location loc) {
+  return builder.create(loc, type, value);
+}
+
 static Type parseTestType(MLIRContext *ctxt, DialectAsmParser ,
   llvm::SetVector ) {
   StringRef typeTag;

diff  --git a/mlir/test/lib/Dialect/Test/TestOps.td 
b/mlir/test/lib/Dialect/Test/TestOps.td
index 1579e53e5277..9008ee7ca99f 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -23,6 +23,7 @@ include "TestInterfaces.td"
 def Test_Dialect : Dialect {
   let name = "test";
   let cppNamespace = "::mlir::test";
+  let hasConstantMaterializer = 1;
   let hasOperationAttrVerify = 1;
   let hasRegionArgAttrVerify = 1;
   let hasRegionResultAttrVerify = 1;

diff  --git a/mlir/test/mlir-tblgen/pattern.mlir 
b/mlir/test/mlir-tblgen/pattern.mlir
index 5496209d3886..0425cf819e60 100644
--- a/mlir/test/mlir-tblgen/pattern.mlir
+++ b/mlir/test/mlir-tblgen/pattern.mlir
@@ -254,7 +254,7 @@ func @verifyUnitAttr() -> (i32, i32) {
 
 // CHECK-LABEL: testConstOp
 func @testConstOp() -> (i32) {
-  // CHECK-NEXT: [[C0:%.+]] = constant 1
+  // CHECK-NEXT: [[C0:%.+]] = "test.constant"() {value = 1
   %0 = "test.constant"() {value = 1 : i32} : () -> i32
 
   // CHECK-NEXT: return [[C0]]
@@ -263,7 +263,7 @@ func @testConstOp() -> (i32) {
 
 // CHECK-LABEL: testConstOpUsed
 func @testConstOpUsed() -> (i32) {
-  // CHECK-NEXT: [[C0:%.+]] = constant 1
+  // CHECK-NEXT: [[C0:%.+]] = "test.constant"() {value = 1
   %0 = "test.constant"() {value = 1 : i32} : () -> i32
 
   // CHECK-NEXT: [[V0:%.+]] = "test.op_s"([[C0]])
@@ -275,7 +275,7 @@ func @testConstOpUsed() -> (i32) {
 
 // CHECK-LABEL: testConstOpReplaced
 func @testConstOpReplaced() -> (i32) {
-  // CHECK-NEXT: [[C0:%.+]] = constant 1
+  // CHECK-NEXT: [[C0:%.+]] = "test.constant"() {value = 1
   %0 = "test.constant"() {value = 1 : i32} : () -> i32
   %1 = "test.constant"() {value = 2 : i32} : () -> i32
 
@@ -288,10 +288,10 @@ func @testConstOpReplaced() -> (i32) {
 
 // CHECK-LABEL: testConstOpMatchFailure
 func @testConstOpMatchFailure() -> (i64) {
-  // CHECK-DAG: [[C0:%.+]] = constant 1
+  // CHECK-DAG: [[C0:%.+]] = 

[llvm-branch-commits] [compiler-rt] 5ff3535 - [DFSan] Appease the custom wrapper lint script.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T14:12:26-08:00
New Revision: 5ff35356f1af2bb92785b38c657463924d9ec386

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

LOG: [DFSan] Appease the custom wrapper lint script.

Added: 


Modified: 
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index e21f35426cf0..a78152f5dcc1 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -800,6 +800,10 @@ void test_pthread_create() {
   ASSERT_ZERO_LABEL(cbrv);
 }
 
+// Tested by test_pthread_create().  This empty function is here to appease the
+// check-wrappers script.
+void test_pthread_join() {}
+
 int dl_iterate_phdr_test_cb(struct dl_phdr_info *info, size_t size,
 void *data) {
   assert(data == (void *)3);
@@ -1220,6 +1224,7 @@ int main(void) {
   test_poll();
   test_pread();
   test_pthread_create();
+  test_pthread_join();
   test_read();
   test_recvmsg();
   test_sched_getaffinity();



___
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] 0978c83 - Basic: Initialize FileEntry's fields inline, almost NFC

2020-12-10 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-10T13:57:21-08:00
New Revision: 0978c83e6fcc7a8aea18e24eb3b2ad5523581757

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

LOG: Basic: Initialize FileEntry's fields inline, almost NFC

Initialize most of FileEntry's fields inline (all the ones that can be).
The only functionality change is to avoid leaving some fields
uninitialized.

Added: 


Modified: 
clang/include/clang/Basic/FileEntry.h
clang/lib/Basic/FileEntry.cpp
clang/unittests/Basic/FileEntryTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index 8db5446aa8d4..aa7bedec44ac 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -328,13 +328,13 @@ class FileEntry {
   friend class FileManager;
 
   std::string RealPathName;   // Real path to the file; could be empty.
-  off_t Size; // File size in bytes.
-  time_t ModTime; // Modification time of file.
-  const DirectoryEntry *Dir;  // Directory file lives in.
+  off_t Size = 0; // File size in bytes.
+  time_t ModTime = 0; // Modification time of file.
+  const DirectoryEntry *Dir = nullptr; // Directory file lives in.
   llvm::sys::fs::UniqueID UniqueID;
-  unsigned UID;   // A unique (small) ID for the file.
-  bool IsNamedPipe;
-  bool IsValid;   // Is this \c FileEntry initialized and valid?
+  unsigned UID = 0; // A unique (small) ID for the file.
+  bool IsNamedPipe = false;
+  bool IsValid = false; // Is this \c FileEntry initialized and valid?
 
   /// The open file, if it is owned by the \p FileEntry.
   mutable std::unique_ptr File;

diff  --git a/clang/lib/Basic/FileEntry.cpp b/clang/lib/Basic/FileEntry.cpp
index 29218c7e0ec8..2efdcbbd46aa 100644
--- a/clang/lib/Basic/FileEntry.cpp
+++ b/clang/lib/Basic/FileEntry.cpp
@@ -16,7 +16,7 @@
 
 using namespace clang;
 
-FileEntry::FileEntry() : UniqueID(0, 0), IsNamedPipe(false), IsValid(false) {}
+FileEntry::FileEntry() : UniqueID(0, 0) {}
 
 FileEntry::~FileEntry() = default;
 

diff  --git a/clang/unittests/Basic/FileEntryTest.cpp 
b/clang/unittests/Basic/FileEntryTest.cpp
index 3cc01870b800..a3e03e6c7c29 100644
--- a/clang/unittests/Basic/FileEntryTest.cpp
+++ b/clang/unittests/Basic/FileEntryTest.cpp
@@ -55,6 +55,17 @@ struct RefMaps {
   }
 };
 
+TEST(FileEntryTest, Constructor) {
+  FileEntry FE;
+  EXPECT_EQ(0U, FE.getSize());
+  EXPECT_EQ(0, FE.getModificationTime());
+  EXPECT_EQ(nullptr, FE.getDir());
+  EXPECT_EQ(0U, FE.getUniqueID().getDevice());
+  EXPECT_EQ(0U, FE.getUniqueID().getFile());
+  EXPECT_EQ(false, FE.isNamedPipe());
+  EXPECT_EQ(false, FE.isValid());
+}
+
 TEST(FileEntryTest, FileEntryRef) {
   RefMaps Refs;
   FileEntryRef R1 = Refs.addFile("1");



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


[llvm-branch-commits] [libcxx] 092e8a7 - [libc++] NFCI: Refactor __shared_ptr_emplace

2020-12-10 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-10T16:45:58-05:00
New Revision: 092e8a7ea3652c418400275746c1800d31390008

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

LOG: [libc++] NFCI: Refactor __shared_ptr_emplace

This is the first of a series of patches leading up to the implementation
of P0674r1, i.e. array support in allocate_shared. I am splitting this
up into multiple patches because the overall change is very tricky and
I want to isolate potential breakage.

Added: 


Modified: 
libcxx/include/memory

Removed: 




diff  --git a/libcxx/include/memory b/libcxx/include/memory
index 77d7b67112e32..f3b890ad2b3e9 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -3305,57 +3305,47 @@ __shared_ptr_pointer<_Tp, _Dp, 
_Alloc>::__on_zero_shared_weak() _NOEXCEPT
 }
 
 template 
-class __shared_ptr_emplace
-: public __shared_weak_count
+struct __shared_ptr_emplace
+: __shared_weak_count
 {
-__compressed_pair<_Alloc, _Tp> __data_;
-public:
-
-_LIBCPP_INLINE_VISIBILITY
-__shared_ptr_emplace(_Alloc __a)
-:  __data_(_VSTD::move(__a), __value_init_tag()) {}
+_LIBCPP_HIDE_FROM_ABI
+explicit __shared_ptr_emplace(_Alloc __a)
+:  __data_(_VSTD::move(__a), __value_init_tag())
+{ }
 
-#ifndef _LIBCPP_CXX03_LANG
 template 
-_LIBCPP_INLINE_VISIBILITY
-__shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
-:  __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),
-   _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) 
{}
+_LIBCPP_HIDE_FROM_ABI
+explicit __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
+#ifndef _LIBCPP_CXX03_LANG
+: __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),
+  _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...))
 #else
-template 
-_LIBCPP_INLINE_VISIBILITY
-__shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
-:  __data_(__a, _Tp(_VSTD::forward<_Args>(__args)...)) {}
+: __data_(__a, _Tp(_VSTD::forward<_Args>(__args)...))
 #endif
+{ }
+
+_LIBCPP_HIDE_FROM_ABI
+_Tp* __get_elem() _NOEXCEPT { return _VSTD::addressof(__data_.second()); }
+
+_LIBCPP_HIDE_FROM_ABI
+_Alloc& __get_alloc() _NOEXCEPT { return __data_.first(); }
 
 private:
-virtual void __on_zero_shared() _NOEXCEPT;
-virtual void __on_zero_shared_weak() _NOEXCEPT;
-public:
-_LIBCPP_INLINE_VISIBILITY
-_Alloc& __get_alloc() _NOEXCEPT {return __data_.first();}
-_LIBCPP_INLINE_VISIBILITY
-_Tp* __get_elem() _NOEXCEPT {return _VSTD::addressof(__data_.second());}
-};
+virtual void __on_zero_shared() _NOEXCEPT {
+__get_elem()->~_Tp();
+}
 
-template 
-void
-__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT
-{
-__get_elem()->~_Tp();
-}
+virtual void __on_zero_shared_weak() _NOEXCEPT {
+using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, 
__shared_ptr_emplace>::type;
+using _ControlBlockPointer = typename 
allocator_traits<_ControlBlockAlloc>::pointer;
+_ControlBlockAlloc __tmp(__get_alloc());
+__get_alloc().~_Alloc();
+allocator_traits<_ControlBlockAlloc>::deallocate(__tmp,
+pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
+}
 
-template 
-void
-__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
-{
-typedef typename __allocator_traits_rebind<_Alloc, 
__shared_ptr_emplace>::type _Al;
-typedef allocator_traits<_Al> _ATraits;
-typedef pointer_traits _PTraits;
-_Al __a(__get_alloc());
-__get_alloc().~_Alloc();
-__a.deallocate(_PTraits::pointer_to(*this), 1);
-}
+__compressed_pair<_Alloc, _Tp> __data_;
+};
 
 struct __shared_ptr_dummy_rebind_allocator_type;
 template <>



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


[llvm-branch-commits] [compiler-rt] 0099316 - [DFSan] Add custom wrapper for pthread_join.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T13:41:24-08:00
New Revision: 009931644a9d2cecdc6e5bf71ed83d59b776eaa3

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

LOG: [DFSan] Add custom wrapper for pthread_join.

The wrapper clears shadow for retval.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 259bec4207dd..0da66c7a440d 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -427,6 +427,18 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_pthread_create(
   return rv;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_pthread_join(pthread_t thread,
+  void **retval,
+  dfsan_label thread_label,
+  dfsan_label retval_label,
+  dfsan_label *ret_label) {
+  int ret = pthread_join(thread, retval);
+  if (ret == 0 && retval)
+dfsan_set_label(0, retval, sizeof(*retval));
+  *ret_label = 0;
+  return ret;
+}
+
 struct dl_iterate_phdr_info {
   int (*callback_trampoline)(void *callback, struct dl_phdr_info *info,
  size_t size, void *data, dfsan_label info_label,

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index 5d3d31f2e162..513c9ea13de3 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -319,6 +319,10 @@ fun:pthread_setspecific=discard
 # Functions that take a callback (wrap the callback manually).
 fun:pthread_create=custom
 
+# Functions that produce output does not depend on the input (need to zero the
+# shadow manually).
+fun:pthread_join=custom
+
 ###
 # libffi/libgo
 ###

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 14cddd8e2a3c..e21f35426cf0 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -792,8 +792,12 @@ void test_pthread_create() {
   pthread_t pt;
   pthread_create(, 0, pthread_create_test_cb, (void *)1);
   void *cbrv;
-  pthread_join(pt, );
+  dfsan_set_label(i_label, , sizeof(cbrv));
+  int ret = pthread_join(pt, );
+  assert(ret == 0);
   assert(cbrv == (void *)2);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_ZERO_LABEL(cbrv);
 }
 
 int dl_iterate_phdr_test_cb(struct dl_phdr_info *info, size_t size,



___
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] e19d525 - [gn build] fix up arm64 builtin sources a bit

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

Author: Nico Weber
Date: 2020-12-10T16:22:48-05:00
New Revision: e19d5258461ce7838e4be6973ba519d250c000f1

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

LOG: [gn build] fix up arm64 builtin sources a bit

The fp_mode.c removal is done by filter_builtin_sources in the cmake build.

Added: 


Modified: 
llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn 
b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
index e7b532f57dab..4f0738292b2c 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
@@ -427,7 +427,11 @@ static_library("builtins") {
   }
 
   if (current_cpu == "arm64") {
-sources += [ "aarch64/fp_mode.c" ]
+sources -= [ "fp_mode.c" ]
+sources += [
+  "cpu_model.c",
+  "aarch64/fp_mode.c",
+]
 if (current_os == "mingw") {
   sources += [ "aarch64/chkstk.S" ]
 }



___
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] 0e72f19 - [gn build] only build iOS builtins with full Xcode

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

Author: Nico Weber
Date: 2020-12-10T16:22:31-05:00
New Revision: 0e72f1978d64dff1094f9da024d7f45fd3f984f8

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

LOG: [gn build] only build iOS builtins with full Xcode

Commandline tools doesn't include the iOS SDK.

Added: 


Modified: 
llvm/utils/gn/secondary/compiler-rt/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn 
b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
index 5444f6621350..af23e330b6ef 100644
--- a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
@@ -1,4 +1,5 @@
 import("//llvm/lib/Target/targets.gni")
+import("//llvm/utils/gn/build/mac_sdk.gni")
 import("//llvm/utils/gn/build/toolchain/compiler.gni")
 
 # In the GN build, compiler-rt is always built by just-built clang and lld.
@@ -19,7 +20,8 @@ group("compiler-rt") {
 
   # FIXME: Do this only if a gn arg compiler_rt_enable_ios is set?
   # That would match the cmake build.
-  if (host_os == "mac") {
+  # iOS SDKs aren't available in the commandline tools SDK.
+  if (host_os == "mac" && !mac_use_commandline_tools_sdk) {
 if (llvm_build_AArch64) {
   deps += [ 
"//compiler-rt/lib/builtins(//llvm/utils/gn/build/toolchain:stage2_ios_aarch64)"
 ]
 }



___
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] c923518 - [gn build] add a missing dependency

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

Author: Nico Weber
Date: 2020-12-10T16:22:26-05:00
New Revision: c9235180d1f3f8a42459e83de7e273c60a41dce1

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

LOG: [gn build] add a missing dependency

Added: 


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

Removed: 




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 3936f2b9dec6..34ba224fa7e0 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
@@ -27,6 +27,7 @@ unittest("ClangdTests") {
 "//clang/lib/Tooling/Core",
 "//clang/lib/Tooling/Inclusions",
 "//clang/lib/Tooling/Syntax",
+"//llvm/include/llvm/Config:llvm-config",
 "//llvm/lib/Support",
 "//llvm/lib/Testing/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] ea475c7 - [SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing.

2020-12-10 Thread Jonas Paulsson via llvm-branch-commits

Author: Jonas Paulsson
Date: 2020-12-10T15:06:18-06:00
New Revision: ea475c77ff9eab1de7d44684c8fb453b39f70081

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

LOG: [SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing.

The loop-based probing done for stack clash protection altered R1D which
corrupted the backchain value to be stored after the probing was done.

By using R0D instead for the loop exit value, R1D is not modified.

Review: Ulrich Weigand.

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

Added: 


Modified: 
llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
llvm/test/CodeGen/SystemZ/stack-clash-dynamic-alloca.ll
llvm/test/CodeGen/SystemZ/stack-clash-protection.ll

Removed: 




diff  --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp 
b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index 57529c8685de..0bfab129edb1 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
@@ -488,15 +488,6 @@ void SystemZFrameLowering::emitPrologue(MachineFunction 
,
   MFFrame.setStackSize(StackSize);
 
   if (StackSize) {
-// Determine if we want to store a backchain.
-bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
-
-// If we need backchain, save current stack pointer.  R1 is free at this
-// point.
-if (StoreBackchain)
-  BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LGR))
-.addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
-
 // Allocate StackSize bytes.
 int64_t Delta = -int64_t(StackSize);
 const unsigned ProbeSize = TLI.getStackProbeSize(MF);
@@ -512,18 +503,23 @@ void SystemZFrameLowering::emitPrologue(MachineFunction 
,
 .addImm(StackSize);
 }
 else {
+  bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
+  // If we need backchain, save current stack pointer.  R1 is free at
+  // this point.
+  if (StoreBackchain)
+BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LGR))
+  .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
   emitIncrement(MBB, MBBI, DL, SystemZ::R15D, Delta, ZII);
   buildCFAOffs(MBB, MBBI, DL, SPOffsetFromCFA + Delta, ZII);
+  if (StoreBackchain) {
+// The back chain is stored topmost with packed-stack.
+int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
+BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG))
+  .addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D)
+  .addImm(Offset).addReg(0);
+  }
 }
 SPOffsetFromCFA += Delta;
-
-if (StoreBackchain) {
-  // The back chain is stored topmost with packed-stack.
-  int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
-  BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG))
-.addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D)
-.addImm(Offset).addReg(0);
-}
   }
 
   if (HasFP) {
@@ -668,6 +664,11 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction ,
   .addMemOperand(MMO);
   };
 
+  bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
+  if (StoreBackchain)
+BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR))
+  .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
+
   if (NumFullBlocks < 3) {
 // Emit unrolled probe statements.
 for (unsigned int i = 0; i < NumFullBlocks; i++)
@@ -677,10 +678,11 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction ,
 uint64_t LoopAlloc = ProbeSize * NumFullBlocks;
 SPOffsetFromCFA -= LoopAlloc;
 
-BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR), SystemZ::R1D)
+// Use R0D to hold the exit value.
+BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR), SystemZ::R0D)
   .addReg(SystemZ::R15D);
-buildDefCFAReg(*MBB, MBBI, DL, SystemZ::R1D, ZII);
-emitIncrement(*MBB, MBBI, DL, SystemZ::R1D, -int64_t(LoopAlloc), ZII);
+buildDefCFAReg(*MBB, MBBI, DL, SystemZ::R0D, ZII);
+emitIncrement(*MBB, MBBI, DL, SystemZ::R0D, -int64_t(LoopAlloc), ZII);
 buildCFAOffs(*MBB, MBBI, DL, -int64_t(SystemZMC::CallFrameSize + 
LoopAlloc),
  ZII);
 
@@ -693,7 +695,7 @@ void SystemZFrameLowering::inlineStackProbe(MachineFunction 
,
 MBB = LoopMBB;
 allocateAndProbe(*MBB, MBB->end(), ProbeSize, false/*EmitCFI*/);
 BuildMI(*MBB, MBB->end(), DL, ZII->get(SystemZ::CLGR))
-  .addReg(SystemZ::R15D).addReg(SystemZ::R1D);
+  .addReg(SystemZ::R15D).addReg(SystemZ::R0D);
 BuildMI(*MBB, MBB->end(), DL, ZII->get(SystemZ::BRC))
   .addImm(SystemZ::CCMASK_ICMP).addImm(SystemZ::CCMASK_CMP_GT).addMBB(MBB);
 
@@ -708,6 +710,14 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction ,
   if (Residual)
 

[llvm-branch-commits] [mlir] c24f88b - [mlir][SCCP] Don't visit private callables unless they are used when tracking interprocedural arguments/results

2020-12-10 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-10T12:53:27-08:00
New Revision: c24f88b4db2ef359f47e976d8d79334ced221288

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

LOG: [mlir][SCCP] Don't visit private callables unless they are used when 
tracking interprocedural arguments/results

This fixes a subtle bug where SCCP could incorrectly optimize a private 
callable while waiting for its arguments to be resolved.

Fixes PR#48457

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

Added: 


Modified: 
mlir/lib/Transforms/SCCP.cpp
mlir/test/Transforms/sccp-callgraph.mlir

Removed: 




diff  --git a/mlir/lib/Transforms/SCCP.cpp b/mlir/lib/Transforms/SCCP.cpp
index 919559c8a6df..9886331820e3 100644
--- a/mlir/lib/Transforms/SCCP.cpp
+++ b/mlir/lib/Transforms/SCCP.cpp
@@ -236,6 +236,11 @@ class SCCPSolver {
   /// state.
   void visitBlockArgument(Block *block, int i);
 
+  /// Mark the entry block of the given region as executable. Returns false if
+  /// the block was already marked executable. If `markArgsOverdefined` is 
true,
+  /// the arguments of the entry block are also set to overdefined.
+  bool markEntryBlockExecutable(Region *region, bool markArgsOverdefined);
+
   /// Mark the given block as executable. Returns false if the block was 
already
   /// marked executable.
   bool markBlockExecutable(Block *block);
@@ -313,16 +318,9 @@ class SCCPSolver {
 SCCPSolver::SCCPSolver(Operation *op) {
   /// Initialize the solver with the regions within this operation.
   for (Region  : op->getRegions()) {
-if (region.empty())
-  continue;
-Block *entryBlock = ();
-
-// Mark the entry block as executable.
-markBlockExecutable(entryBlock);
-
-// The values passed to these regions are invisible, so mark any arguments
-// as overdefined.
-markAllOverdefined(entryBlock->getArguments());
+// Mark the entry block as executable. The values passed to these regions
+// are also invisible, so mark any arguments as overdefined.
+markEntryBlockExecutable(, /*markArgsOverdefined=*/true);
   }
   initializeSymbolCallables(op);
 }
@@ -405,8 +403,10 @@ void SCCPSolver::initializeSymbolCallables(Operation *op) {
 
   // If not all of the uses of this symbol are visible, we can't track the
   // state of the arguments.
-  if (symbol.isPublic() || (!allUsesVisible && symbol.isNested()))
-markAllOverdefined(callableRegion->getArguments());
+  if (symbol.isPublic() || (!allUsesVisible && symbol.isNested())) {
+for (Region  : callable->getRegions())
+  markEntryBlockExecutable(, /*markArgsOverdefined=*/true);
+  }
 }
 if (callableLatticeState.empty())
   return;
@@ -443,8 +443,10 @@ void SCCPSolver::initializeSymbolCallables(Operation *op) {
   // This use isn't a call, so don't we know all of the callers.
   auto *symbol = symbolTable.lookupSymbolIn(op, use.getSymbolRef());
   auto it = callableLatticeState.find(symbol);
-  if (it != callableLatticeState.end())
-markAllOverdefined(it->second.getCallableArguments());
+  if (it != callableLatticeState.end()) {
+for (Region  : it->first->getRegions())
+  markEntryBlockExecutable(, /*markArgsOverdefined=*/true);
+  }
 }
   };
   SymbolTable::walkSymbolTables(op, /*allSymUsesVisible=*/!op->getBlock(),
@@ -495,8 +497,14 @@ void SCCPSolver::visitOperation(Operation *op) {
 
   // Process callable operations. These are specially handled region operations
   // that track dataflow via calls.
-  if (isa(op))
+  if (isa(op)) {
+// If this callable has a tracked lattice state, it will be visited by 
calls
+// that reference it instead. This way, we don't assume that it is
+// executable unless there is a proper reference to it.
+if (callableLatticeState.count(op))
+  return;
 return visitCallableOperation(op);
+  }
 
   // Process region holding operations. The region visitor processes result
   // values, so we can exit afterwards.
@@ -551,19 +559,11 @@ void SCCPSolver::visitOperation(Operation *op) {
 }
 
 void SCCPSolver::visitCallableOperation(Operation *op) {
-  // Mark the regions as executable.
+  // Mark the regions as executable. If we aren't tracking lattice state for
+  // this callable, mark all of the region arguments as overdefined.
   bool isTrackingLatticeState = callableLatticeState.count(op);
-  for (Region  : op->getRegions()) {
-if (region.empty())
-  continue;
-Block *entryBlock = ();
-markBlockExecutable(entryBlock);
-
-// If we aren't tracking lattice state for this callable, mark all of the
-// region arguments as overdefined.
-if (!isTrackingLatticeState)
-  markAllOverdefined(entryBlock->getArguments());
-  }
+  for (Region  : 

[llvm-branch-commits] [mlir] 285c0aa - Add MLIR Python binding for Array Attribute

2020-12-10 Thread Mehdi Amini via llvm-branch-commits

Author: Mehdi Amini
Date: 2020-12-10T20:51:34Z
New Revision: 285c0aa262c9255e6ea4efbce1418e5f5f17e9c1

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

LOG: Add MLIR Python binding for Array Attribute

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

Added: 


Modified: 
mlir/lib/Bindings/Python/IRModules.cpp
mlir/test/Bindings/Python/ir_attributes.py

Removed: 




diff  --git a/mlir/lib/Bindings/Python/IRModules.cpp 
b/mlir/lib/Bindings/Python/IRModules.cpp
index 5519c66ee1ab..5ebb2e4ccee3 100644
--- a/mlir/lib/Bindings/Python/IRModules.cpp
+++ b/mlir/lib/Bindings/Python/IRModules.cpp
@@ -1461,6 +1461,83 @@ class PyConcreteAttribute : public BaseTy {
   static void bindDerived(ClassTy ) {}
 };
 
+class PyArrayAttribute : public PyConcreteAttribute {
+public:
+  static constexpr IsAFunctionTy isaFunction = mlirAttributeIsAArray;
+  static constexpr const char *pyClassName = "ArrayAttr";
+  using PyConcreteAttribute::PyConcreteAttribute;
+
+  class PyArrayAttributeIterator {
+  public:
+PyArrayAttributeIterator(PyAttribute attr) : attr(attr) {}
+
+PyArrayAttributeIterator () { return *this; }
+
+PyAttribute dunderNext() {
+  if (nextIndex >= mlirArrayAttrGetNumElements(attr.get())) {
+throw py::stop_iteration();
+  }
+  return PyAttribute(attr.getContext(),
+ mlirArrayAttrGetElement(attr.get(), nextIndex++));
+}
+
+static void bind(py::module ) {
+  py::class_(m, "ArrayAttributeIterator")
+  .def("__iter__", ::dunderIter)
+  .def("__next__", ::dunderNext);
+}
+
+  private:
+PyAttribute attr;
+int nextIndex = 0;
+  };
+
+  static void bindDerived(ClassTy ) {
+c.def_static(
+"get",
+[](py::list attributes, DefaultingPyMlirContext context) {
+  SmallVector mlirAttributes;
+  mlirAttributes.reserve(py::len(attributes));
+  for (auto attribute : attributes) {
+try {
+  mlirAttributes.push_back(attribute.cast());
+} catch (py::cast_error ) {
+  std::string msg = std::string("Invalid attribute when attempting 
"
+"to create an ArrayAttribute (") +
+err.what() + ")";
+  throw py::cast_error(msg);
+} catch (py::reference_cast_error ) {
+  // This exception seems thrown when the value is "None".
+  std::string msg =
+  std::string("Invalid attribute (None?) when attempting to "
+  "create an ArrayAttribute (") +
+  err.what() + ")";
+  throw py::cast_error(msg);
+}
+  }
+  MlirAttribute attr = mlirArrayAttrGet(
+  context->get(), mlirAttributes.size(), mlirAttributes.data());
+  return PyArrayAttribute(context->getRef(), attr);
+},
+py::arg("attributes"), py::arg("context") = py::none(),
+"Gets a uniqued Array attribute");
+c.def("__getitem__",
+  [](PyArrayAttribute , intptr_t i) {
+if (i >= mlirArrayAttrGetNumElements(arr))
+  throw py::index_error("ArrayAttribute index out of range");
+return PyAttribute(arr.getContext(),
+   mlirArrayAttrGetElement(arr, i));
+  })
+.def("__len__",
+ [](const PyArrayAttribute ) {
+   return mlirArrayAttrGetNumElements(arr);
+ })
+.def("__iter__", [](const PyArrayAttribute ) {
+  return PyArrayAttributeIterator(arr);
+});
+  }
+};
+
 /// Float Point Attribute subclass - FloatAttr.
 class PyFloatAttribute : public PyConcreteAttribute {
 public:
@@ -3089,6 +3166,8 @@ void mlir::python::populateIRSubmodule(py::module ) {
 
   // Builtin attribute bindings.
   PyFloatAttribute::bind(m);
+  PyArrayAttribute::bind(m);
+  PyArrayAttribute::PyArrayAttributeIterator::bind(m);
   PyIntegerAttribute::bind(m);
   PyBoolAttribute::bind(m);
   PyStringAttribute::bind(m);

diff  --git a/mlir/test/Bindings/Python/ir_attributes.py 
b/mlir/test/Bindings/Python/ir_attributes.py
index 4ad180bb1b37..642c1f6a836c 100644
--- a/mlir/test/Bindings/Python/ir_attributes.py
+++ b/mlir/test/Bindings/Python/ir_attributes.py
@@ -269,3 +269,54 @@ def testTypeAttr():
 
 
 run(testTypeAttr)
+
+
+# CHECK-LABEL: TEST: testArrayAttr
+def testArrayAttr():
+  with Context():
+raw = Attribute.parse("[42, true, vector<4xf32>]")
+  # CHECK: attr: [42, true, vector<4xf32>]
+  print("raw attr:", raw)
+  # CHECK: - 42
+  # CHECK: - true
+  # CHECK: - vector<4xf32>
+  for attr in ArrayAttr(raw):
+print("- ", attr)
+
+  with Context():
+intAttr = Attribute.parse("42")
+

[llvm-branch-commits] [compiler-rt] 61a038f - [GWP-ASan] IWYU & clang-format

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T12:42:01-08:00
New Revision: 61a038f8528f12c0c2ee5a9794c257fdae626d29

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

LOG: [GWP-ASan] IWYU & clang-format

Run an IWYU pass and clang-format GWP-ASan code.

Reviewed By: eugenis, mcgrathr

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

Added: 


Modified: 
compiler-rt/lib/gwp_asan/crash_handler.cpp
compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
compiler-rt/lib/gwp_asan/mutex.h
compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp
compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp

Removed: 




diff  --git a/compiler-rt/lib/gwp_asan/crash_handler.cpp 
b/compiler-rt/lib/gwp_asan/crash_handler.cpp
index b9baacecfecb..bd7ca5abbb6b 100644
--- a/compiler-rt/lib/gwp_asan/crash_handler.cpp
+++ b/compiler-rt/lib/gwp_asan/crash_handler.cpp
@@ -10,6 +10,7 @@
 #include "gwp_asan/stack_trace_compressor.h"
 
 #include 
+#include 
 #include 
 
 using AllocationMetadata = gwp_asan::AllocationMetadata;

diff  --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp 
b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
index 13888cbbe3c3..a1dbbe4f25e9 100644
--- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
+++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
@@ -8,23 +8,10 @@
 
 #include "gwp_asan/guarded_pool_allocator.h"
 
-#include "gwp_asan/optional/segv_handler.h"
 #include "gwp_asan/options.h"
 #include "gwp_asan/utilities.h"
 
-// RHEL creates the PRIu64 format macro (for printing uint64_t's) only when 
this
-// macro is defined before including .
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS 1
-#endif
-
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 
 using AllocationMetadata = gwp_asan::AllocationMetadata;
 using Error = gwp_asan::Error;

diff  --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h 
b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
index 84ebda13955f..b9972ffd98f7 100644
--- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
+++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
@@ -13,10 +13,9 @@
 #include "gwp_asan/definitions.h"
 #include "gwp_asan/mutex.h"
 #include "gwp_asan/options.h"
-#include "gwp_asan/platform_specific/guarded_pool_allocator_fuchsia.h"
-#include "gwp_asan/platform_specific/guarded_pool_allocator_posix.h"
+#include "gwp_asan/platform_specific/guarded_pool_allocator_fuchsia.h" // IWYU 
pragma: keep
+#include "gwp_asan/platform_specific/guarded_pool_allocator_posix.h" // IWYU 
pragma: keep
 #include "gwp_asan/platform_specific/guarded_pool_allocator_tls.h"
-#include "gwp_asan/stack_trace_compressor.h"
 
 #include 
 #include 

diff  --git a/compiler-rt/lib/gwp_asan/mutex.h 
b/compiler-rt/lib/gwp_asan/mutex.h
index a7214f527b29..34b91a2880dd 100644
--- a/compiler-rt/lib/gwp_asan/mutex.h
+++ b/compiler-rt/lib/gwp_asan/mutex.h
@@ -9,8 +9,8 @@
 #ifndef GWP_ASAN_MUTEX_H_
 #define GWP_ASAN_MUTEX_H_
 
-#include "gwp_asan/platform_specific/mutex_fuchsia.h"
-#include "gwp_asan/platform_specific/mutex_posix.h"
+#include "gwp_asan/platform_specific/mutex_fuchsia.h" // IWYU pragma: keep
+#include "gwp_asan/platform_specific/mutex_posix.h"   // IWYU pragma: keep
 
 namespace gwp_asan {
 class Mutex final : PlatformMutex {

diff  --git a/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp 
b/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp
index 813882ad915a..0637fc2a4245 100644
--- a/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp
+++ b/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp
@@ -8,7 +8,9 @@
 
 #include "gwp_asan/common.h"
 
-#include 
+#include 
+#include  // IWYU pragma: keep
+// IWYU pragma: no_include 
 #include 
 
 namespace gwp_asan {

diff  --git 
a/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp 
b/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
index dad749bde8be..adb7330a431e 100644
--- 
a/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
+++ 
b/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
@@ -6,16 +6,16 @@
 //
 
//===--===//
 
+#include "gwp_asan/common.h"
 #include "gwp_asan/guarded_pool_allocator.h"
+#include "gwp_asan/platform_specific/guarded_pool_allocator_tls.h"
 #include "gwp_asan/utilities.h"
 
 #include 
-#include 
-#include 
+#include 
+#include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 

diff  --git 

[llvm-branch-commits] [mlir] 1f5f006 - [mlir][StandardOps] Verify that the result of an integer constant is signless

2020-12-10 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-10T12:40:10-08:00
New Revision: 1f5f006d9d53e785296d1a8fbb0e90904a5eaf60

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

LOG: [mlir][StandardOps] Verify that the result of an integer constant is 
signless

This was missed when supported for unsigned/signed integer types was first 
added, and results in crashes if a user tries to create/print a constant with 
the incorrect integer type.

Fixes PR#46222

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

Added: 


Modified: 
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/test/Dialect/Standard/invalid.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp 
b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index 34c3da9b5eca..0efba0d9d4d8 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -1136,7 +1136,7 @@ static LogicalResult verify(ConstantOp ) {
   if (!value)
 return op.emitOpError("requires a 'value' attribute");
 
-  auto type = op.getType();
+  Type type = op.getType();
   if (!value.getType().isa() && type != value.getType())
 return op.emitOpError() << "requires attribute's type (" << value.getType()
 << ") to match op's return type (" << type << ")";
@@ -1145,10 +1145,14 @@ static LogicalResult verify(ConstantOp ) {
 return success();
 
   if (auto intAttr = value.dyn_cast()) {
+IntegerType intType = type.cast();
+if (!intType.isSignless())
+  return op.emitOpError("requires integer result types to be signless");
+
 // If the type has a known bitwidth we verify that the value can be
 // represented with the given bitwidth.
-auto bitwidth = type.cast().getWidth();
-auto intVal = intAttr.getValue();
+unsigned bitwidth = intType.getWidth();
+APInt intVal = intAttr.getValue();
 if (!intVal.isSignedIntN(bitwidth) && !intVal.isIntN(bitwidth))
   return op.emitOpError("requires 'value' to be an integer within the "
 "range of the integer result type");
@@ -1228,9 +1232,13 @@ bool ConstantOp::isBuildableWith(Attribute value, Type 
type) {
   // SymbolRefAttr can only be used with a function type.
   if (value.isa())
 return type.isa();
-  // Otherwise, the attribute must have the same type as 'type'.
+  // The attribute must have the same type as 'type'.
   if (value.getType() != type)
 return false;
+  // If the type is an integer type, it must be signless.
+  if (IntegerType integerTy = type.dyn_cast())
+if (!integerTy.isSignless())
+  return false;
   // Finally, check that the attribute kind is handled.
   return value.isa();
 }

diff  --git a/mlir/test/Dialect/Standard/invalid.mlir 
b/mlir/test/Dialect/Standard/invalid.mlir
index 04ecdc64351a..48d2ae23466c 100644
--- a/mlir/test/Dialect/Standard/invalid.mlir
+++ b/mlir/test/Dialect/Standard/invalid.mlir
@@ -298,3 +298,18 @@ func @mismatched_types() {
   return
 }
 
+// -
+
+func @non_signless_constant() {
+  // expected-error @+1 {{requires integer result types to be signless}}
+  %0 = constant 0 : ui32
+  return
+}
+
+// -
+
+func @non_signless_constant() {
+  // expected-error @+1 {{requires integer result types to be signless}}
+  %0 = constant 0 : si32
+  return
+}



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


[llvm-branch-commits] [compiler-rt] ebff66b - [scudo] [standalone] [NFC] clang-format code.

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T12:25:42-08:00
New Revision: ebff66be655acccd2bed3798c2b6879d18c509e1

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

LOG: [scudo] [standalone] [NFC] clang-format code.

clang-format the scudo standalone codebase.

Reviewed By: cryptoad

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp
compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp 
b/compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp
index d29f515215e6..f20a8a84a010 100644
--- a/compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp
+++ b/compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp
@@ -22,21 +22,25 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *Data, size_t 
Size) {
   uintptr_t FaultAddr = FDP.ConsumeIntegral();
   uintptr_t MemoryAddr = FDP.ConsumeIntegral();
 
-  std::string MemoryAndTags = 
FDP.ConsumeRandomLengthString(FDP.remaining_bytes());
+  std::string MemoryAndTags =
+  FDP.ConsumeRandomLengthString(FDP.remaining_bytes());
   const char *Memory = MemoryAndTags.c_str();
   // Assume 16-byte alignment.
   size_t MemorySize = (MemoryAndTags.length() / 17) * 16;
   const char *MemoryTags = Memory + MemorySize;
 
-  std::string StackDepotBytes = 
FDP.ConsumeRandomLengthString(FDP.remaining_bytes());
+  std::string StackDepotBytes =
+  FDP.ConsumeRandomLengthString(FDP.remaining_bytes());
   std::vector StackDepot(sizeof(scudo::StackDepot), 0);
-  for (size_t i = 0; i < StackDepotBytes.length() && i < StackDepot.size(); 
++i) {
+  for (size_t i = 0; i < StackDepotBytes.length() && i < StackDepot.size();
+   ++i) {
 StackDepot[i] = StackDepotBytes[i];
   }
 
   std::string RegionInfoBytes = FDP.ConsumeRemainingBytesAsString();
   std::vector RegionInfo(AllocatorT::getRegionInfoArraySize(), 0);
-  for (size_t i = 0; i < RegionInfoBytes.length() && i < RegionInfo.size(); 
++i) {
+  for (size_t i = 0; i < RegionInfoBytes.length() && i < RegionInfo.size();
+   ++i) {
 RegionInfo[i] = RegionInfoBytes[i];
   }
 

diff  --git 
a/compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp 
b/compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp
index 82f37b6647ef..8b17be0e965b 100644
--- a/compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp
+++ b/compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp
@@ -19,9 +19,8 @@ struct Alloc {
 };
 
 size_t measureWastage(const std::vector ,
-   const std::vector ,
-   size_t pageSize,
-   size_t headerSize) {
+  const std::vector , size_t pageSize,
+  size_t headerSize) {
   size_t totalWastage = 0;
   for (auto  : allocs) {
 size_t sizePlusHeader = a.size + headerSize;
@@ -55,7 +54,8 @@ void readAllocs(std::vector , const char *path) 
{
   }
 
   Alloc a;
-  while (fscanf(f, "\n", , ) 
== 2)
+  while (fscanf(f, "\n", ,
+) == 2)
 allocs.push_back(a);
   fclose(f);
 }
@@ -157,5 +157,6 @@ struct MySizeClassConfig {
   };
   static const uptr SizeDelta = %zu;
 };
-)", headerSize);
+)",
+ headerSize);
 }



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


[llvm-branch-commits] [compiler-rt] fa4bd4b - [DFSan] Add custom wrapper for getpeername.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T12:26:06-08:00
New Revision: fa4bd4b338d1c8c0a95b63b13640b10694b8185c

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

LOG: [DFSan] Add custom wrapper for getpeername.

The wrapper clears shadow for addr and addrlen when written to.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 3b8c46d642a4..259bec4207dd 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -966,6 +966,21 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getsockname(
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getpeername(
+int sockfd, struct sockaddr *addr, socklen_t *addrlen,
+dfsan_label sockfd_label, dfsan_label addr_label, dfsan_label 
addrlen_label,
+dfsan_label *ret_label) {
+  socklen_t origlen = addrlen ? *addrlen : 0;
+  int ret = getpeername(sockfd, addr, addrlen);
+  if (ret != -1 && addr && addrlen) {
+socklen_t written_bytes = origlen < *addrlen ? origlen : *addrlen;
+dfsan_set_label(0, addrlen, sizeof(*addrlen));
+dfsan_set_label(0, addr, written_bytes);
+  }
+  *ret_label = 0;
+  return ret;
+}
+
 // Type of the trampoline function passed to the custom version of
 // dfsan_set_write_callback.
 typedef void (*write_trampoline_t)(

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index f4d0950e65dc..5d3d31f2e162 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -193,6 +193,7 @@ fun:fstat=custom
 fun:getcwd=custom
 fun:get_current_dir_name=custom
 fun:gethostname=custom
+fun:getpeername=custom
 fun:getrlimit=custom
 fun:getrusage=custom
 fun:getsockname=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 3098616c0e50..14cddd8e2a3c 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -956,6 +956,28 @@ void test_socketpair() {
   ASSERT_READ_ZERO_LABEL(fd, sizeof(fd));
 }
 
+void test_getpeername() {
+  int sockfds[2];
+  int ret = socketpair(AF_UNIX, SOCK_DGRAM, 0, sockfds);
+  assert(ret != -1);
+
+  struct sockaddr addr = {};
+  socklen_t addrlen = sizeof(addr);
+  dfsan_set_label(i_label, , addrlen);
+  dfsan_set_label(i_label, , sizeof(addrlen));
+
+  ret = getpeername(sockfds[0], , );
+  assert(ret != -1);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_ZERO_LABEL(addrlen);
+  assert(addrlen < sizeof(addr));
+  ASSERT_READ_ZERO_LABEL(, addrlen);
+  ASSERT_READ_LABEL(((char *)) + addrlen, 1, i_label);
+
+  close(sockfds[0]);
+  close(sockfds[1]);
+}
+
 void test_getsockname() {
   int sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
   assert(sockfd != -1);
@@ -1177,6 +1199,7 @@ int main(void) {
   test_get_current_dir_name();
   test_getcwd();
   test_gethostname();
+  test_getpeername();
   test_getpwuid_r();
   test_getrlimit();
   test_getrusage();



___
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] c29af37 - [AArch64] Don't try to compress jump tables if there are any inline asm instructions.

2020-12-10 Thread Amara Emerson via llvm-branch-commits

Author: Amara Emerson
Date: 2020-12-10T12:20:02-08:00
New Revision: c29af37c6c9d74ca330bd7f1d084f1f676ba2824

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

LOG: [AArch64] Don't try to compress jump tables if there are any inline asm 
instructions.

Inline asm can contain constructs like .bytes which may have arbitrary size.
In some cases, this causes us to miscalculate the size of blocks and therefore
offsets, causing us to incorrectly compress a JT.

To be safe, just bail out of the whole thing if we find any inline asm.

Fixes PR48255

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

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
llvm/test/CodeGen/AArch64/jump-table-compress.mir
llvm/test/CodeGen/AArch64/jump-table.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp 
b/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
index c265592d05a7..2328a8b4deb8 100644
--- a/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
+++ b/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
@@ -37,8 +37,13 @@ class AArch64CompressJumpTables : public MachineFunctionPass 
{
   MachineFunction *MF;
   SmallVector BlockInfo;
 
-  int computeBlockSize(MachineBasicBlock );
-  void scanFunction();
+  /// Returns the size in instructions of the block \p MBB, or None if we
+  /// couldn't get a safe upper bound.
+  Optional computeBlockSize(MachineBasicBlock );
+
+  /// Gather information about the function, returns false if we can't perform
+  /// this optimization for some reason.
+  bool scanFunction();
 
   bool compressJumpTable(MachineInstr , int Offset);
 
@@ -64,14 +69,22 @@ char AArch64CompressJumpTables::ID = 0;
 INITIALIZE_PASS(AArch64CompressJumpTables, DEBUG_TYPE,
 "AArch64 compress jump tables pass", false, false)
 
-int AArch64CompressJumpTables::computeBlockSize(MachineBasicBlock ) {
+Optional
+AArch64CompressJumpTables::computeBlockSize(MachineBasicBlock ) {
   int Size = 0;
-  for (const MachineInstr  : MBB)
+  for (const MachineInstr  : MBB) {
+// Inline asm may contain some directives like .bytes which we don't
+// currently have the ability to parse accurately. To be safe, just avoid
+// computing a size and bail out.
+if (MI.getOpcode() == AArch64::INLINEASM ||
+MI.getOpcode() == AArch64::INLINEASM_BR)
+  return None;
 Size += TII->getInstSizeInBytes(MI);
+  }
   return Size;
 }
 
-void AArch64CompressJumpTables::scanFunction() {
+bool AArch64CompressJumpTables::scanFunction() {
   BlockInfo.clear();
   BlockInfo.resize(MF->getNumBlockIDs());
 
@@ -84,8 +97,12 @@ void AArch64CompressJumpTables::scanFunction() {
 else
   AlignedOffset = alignTo(Offset, Alignment);
 BlockInfo[MBB.getNumber()] = AlignedOffset;
-Offset = AlignedOffset + computeBlockSize(MBB);
+auto BlockSize = computeBlockSize(MBB);
+if (!BlockSize)
+  return false;
+Offset = AlignedOffset + *BlockSize;
   }
+  return true;
 }
 
 bool AArch64CompressJumpTables::compressJumpTable(MachineInstr ,
@@ -152,7 +169,8 @@ bool 
AArch64CompressJumpTables::runOnMachineFunction(MachineFunction ) {
   if (ST.force32BitJumpTables() && !MF->getFunction().hasMinSize())
 return false;
 
-  scanFunction();
+  if (!scanFunction())
+return false;
 
   for (MachineBasicBlock  : *MF) {
 int Offset = BlockInfo[MBB.getNumber()];

diff  --git a/llvm/test/CodeGen/AArch64/jump-table-compress.mir 
b/llvm/test/CodeGen/AArch64/jump-table-compress.mir
index 272de36f8b6e..a46b7c6ac9c0 100644
--- a/llvm/test/CodeGen/AArch64/jump-table-compress.mir
+++ b/llvm/test/CodeGen/AArch64/jump-table-compress.mir
@@ -4,6 +4,8 @@
 unreachable
   }
 
+  define void @test_inline_asm_no_compress() { ret void }
+
 ...
 ---
 name:test_jumptable
@@ -110,3 +112,88 @@ body: |
 early-clobber $x10, dead early-clobber $x11 = JumpTableDest32 undef killed 
$x9, undef killed $x8, %jump-table.5
 BR killed $x10
 ...
+---
+name:test_inline_asm_no_compress
+alignment:   4
+tracksRegLiveness: true
+liveins:
+  - { reg: '$w0' }
+  - { reg: '$w1' }
+  - { reg: '$w2' }
+frameInfo:
+  maxAlignment:1
+  maxCallFrameSize: 0
+machineFunctionInfo:
+  hasRedZone:  false
+jumpTable:
+  kind:label-
diff erence32
+  entries:
+- id:  0
+  blocks:  [ '%bb.2', '%bb.4', '%bb.5', '%bb.6', '%bb.7', '%bb.8' ]
+body: |
+  bb.0:
+successors: %bb.3(0x12492492), %bb.1(0x6db6db6e)
+liveins: $w0, $w1, $w2
+  
+dead $wzr = SUBSWri renamable $w0, 5, 0, implicit-def $nzcv
+Bcc 8, %bb.3, implicit $nzcv
+  
+  bb.1:
+successors: %bb.2, %bb.4, %bb.5, %bb.6, %bb.7, %bb.8
+liveins: $w0, $w1, $w2
+; 

[llvm-branch-commits] [llvm] b7901e4 - [RISCV][NFC] Fix Sext/Zext Tests

2020-12-10 Thread Sam Elliott via llvm-branch-commits

Author: Sam Elliott
Date: 2020-12-10T20:10:29Z
New Revision: b7901e4c1a2ef0de73f133d5ecc6abbc3f427bdc

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

LOG: [RISCV][NFC] Fix Sext/Zext Tests

These were missed in a rebase of https://reviews.llvm.org/D92793

Added: 


Modified: 
llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll
llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll 
b/llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll
index c53b79913b1c..53bed26f448c 100644
--- a/llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll
+++ b/llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll
@@ -81,7 +81,7 @@ define i8 @test_cttz_i8(i8 %a) nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:andi a1, a0, 255
+; RV32I-NEXT:zext.b a1, a0
 ; RV32I-NEXT:beqz a1, .LBB3_2
 ; RV32I-NEXT:  # %bb.1: # %cond.false
 ; RV32I-NEXT:addi a1, a0, -1

diff  --git a/llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll 
b/llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll
index ac060f9469ac..1d5db5e7a49a 100644
--- a/llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll
+++ b/llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll
@@ -122,7 +122,7 @@ define signext i32 @ret_callresult_uint8_as_anyint32() 
nounwind {
 define zeroext i8 @sint8_arg_to_uint8_ret(i8 signext %a) nounwind {
 ; RV32I-LABEL: sint8_arg_to_uint8_ret:
 ; RV32I:   # %bb.0:
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:ret
   ret i8 %a
 }
@@ -132,7 +132,7 @@ define void @pass_sint8_as_uint8(i8 signext %a) nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:call receive_uint8@plt
 ; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32I-NEXT:addi sp, sp, 16
@@ -149,7 +149,7 @@ define zeroext i8 @ret_callresult_sint8_as_uint8() nounwind 
{
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
 ; RV32I-NEXT:call return_sint8@plt
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32I-NEXT:addi sp, sp, 16
 ; RV32I-NEXT:ret
@@ -229,7 +229,7 @@ define signext i32 @ret_callresult_sint8_as_anyint32() 
nounwind {
 define zeroext i8 @anyint32_arg_to_uint8_ret(i32 signext %a) nounwind {
 ; RV32I-LABEL: anyint32_arg_to_uint8_ret:
 ; RV32I:   # %bb.0:
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:ret
   %1 = trunc i32 %a to i8
   ret i8 %1
@@ -240,7 +240,7 @@ define void @pass_anyint32_as_uint8(i32 signext %a) 
nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:call receive_uint8@plt
 ; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32I-NEXT:addi sp, sp, 16
@@ -258,7 +258,7 @@ define zeroext i8 @ret_callresult_anyint32_as_uint8() 
nounwind {
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
 ; RV32I-NEXT:call return_anyint32@plt
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32I-NEXT:addi sp, sp, 16
 ; RV32I-NEXT:ret



___
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] 1dc0a85 - [NFC] Fix a gcc build break by not using an initializer.

2020-12-10 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2020-12-10T11:54:41-08:00
New Revision: 1dc0a8521f616af5897327e4c03098f9312e9c59

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

LOG: [NFC] Fix a gcc build break by not using an initializer.

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
index 69adc77730d1..5c3952b12e07 100644
--- a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
@@ -62,7 +62,7 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, 
uint64_t Index,
 uint64_t CallerGuid = Names[Name];
 uint64_t CallerProbeId = PseudoProbeDwarfDiscriminator::extractProbeIndex(
 InlinedAt->getDiscriminator());
-ReversedInlineStack.push_back({CallerGuid, CallerProbeId});
+ReversedInlineStack.emplace_back(CallerGuid, CallerProbeId);
 InlinedAt = InlinedAt->getInlinedAt();
   }
 



___
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] 12406ad - [RISCV] Add (Proposed) Assembler Extend Pseudo-Instructions

2020-12-10 Thread Sam Elliott via llvm-branch-commits

Author: Sam Elliott
Date: 2020-12-10T19:25:51Z
New Revision: 12406ade0625ffa3939e2fa684293e02eb8791ff

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

LOG: [RISCV] Add (Proposed) Assembler Extend Pseudo-Instructions

There is an in-progress proposal for the following pseudo-instructions
in the assembler, to complement the existing `sext.w` rv64i instruction:
- sext.b
- sext.h
- zext.b
- zext.h
- zext.w

The `.b` and `.h` variants are available with rv32i and rv64i, and `zext.w` is
only available with `rv64i`.

These are implemented primarily as pseudo-instructions, as these instructions
expand to multiple real instructions. In the case of `zext.b`, this expands to a
single rv32/64i instruction, so it is implemented with an InstAlias (like
`sext.w` is on rv64i).

The proposal is available here: 
https://github.com/riscv/riscv-asm-manual/pull/61

Reviewed By: asb

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

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
llvm/test/CodeGen/RISCV/alu8.ll
llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll
llvm/test/CodeGen/RISCV/atomic-rmw.ll
llvm/test/CodeGen/RISCV/calling-conv-ilp32-ilp32f-ilp32d-common.ll
llvm/test/CodeGen/RISCV/calling-conv-lp64-lp64f-lp64d-common.ll
llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll
llvm/test/CodeGen/RISCV/rv32Zbbp.ll
llvm/test/CodeGen/RISCV/rv64Zbbp.ll
llvm/test/CodeGen/RISCV/sext-zext-trunc.ll
llvm/test/MC/RISCV/rv32i-aliases-invalid.s
llvm/test/MC/RISCV/rv32i-aliases-valid.s
llvm/test/MC/RISCV/rv64i-aliases-valid.s

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 768b34ad45f1..aa483041e635 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -124,6 +124,10 @@ class RISCVAsmParser : public MCTargetAsmParser {
   void emitLoadStoreSymbol(MCInst , unsigned Opcode, SMLoc IDLoc,
MCStreamer , bool HasTmpReg);
 
+  // Helper to emit pseudo sign/zero extend instruction.
+  void emitPseudoExtend(MCInst , bool SignExtend, int64_t Width,
+SMLoc IDLoc, MCStreamer );
+
   // Checks that a PseudoAddTPRel is using x4/tp in its second input operand.
   // Enforcing this using a restricted register class for the second input
   // operand of PseudoAddTPRel results in a poor diagnostic due to the fact
@@ -2269,6 +2273,35 @@ void RISCVAsmParser::emitLoadStoreSymbol(MCInst , 
unsigned Opcode,
 Opcode, IDLoc, Out);
 }
 
+void RISCVAsmParser::emitPseudoExtend(MCInst , bool SignExtend,
+  int64_t Width, SMLoc IDLoc,
+  MCStreamer ) {
+  // The sign/zero extend pseudo-instruction does two shifts, with the shift
+  // amounts dependent on the XLEN.
+  //
+  // The expansion looks like this
+  //
+  //SLLI rd, rs, XLEN - Width
+  //SR[A|R]I rd, rd, XLEN - Width
+  MCOperand DestReg = Inst.getOperand(0);
+  MCOperand SourceReg = Inst.getOperand(1);
+
+  unsigned SecondOpcode = SignExtend ? RISCV::SRAI : RISCV::SRLI;
+  int64_t ShAmt = (isRV64() ? 64 : 32) - Width;
+
+  assert(ShAmt > 0 && "Shift amount must be non-zero.");
+
+  emitToStreamer(Out, MCInstBuilder(RISCV::SLLI)
+  .addOperand(DestReg)
+  .addOperand(SourceReg)
+  .addImm(ShAmt));
+
+  emitToStreamer(Out, MCInstBuilder(SecondOpcode)
+  .addOperand(DestReg)
+  .addOperand(DestReg)
+  .addImm(ShAmt));
+}
+
 bool RISCVAsmParser::checkPseudoAddTPRel(MCInst ,
  OperandVector ) {
   assert(Inst.getOpcode() == RISCV::PseudoAddTPRel && "Invalid instruction");
@@ -2431,6 +2464,18 @@ bool RISCVAsmParser::processInstruction(MCInst , 
SMLoc IDLoc,
 if (checkPseudoAddTPRel(Inst, Operands))
   return true;
 break;
+  case RISCV::PseudoSEXT_B:
+emitPseudoExtend(Inst, /*SignExtend=*/true, /*Width=*/8, IDLoc, Out);
+return false;
+  case RISCV::PseudoSEXT_H:
+emitPseudoExtend(Inst, /*SignExtend=*/true, /*Width=*/16, IDLoc, Out);
+return false;
+  case RISCV::PseudoZEXT_H:
+emitPseudoExtend(Inst, /*SignExtend=*/false, /*Width=*/16, IDLoc, Out);
+return false;
+  case RISCV::PseudoZEXT_W:
+emitPseudoExtend(Inst, /*SignExtend=*/false, /*Width=*/32, IDLoc, Out);
+return false;
   }
 
   emitToStreamer(Out, Inst);

diff  --git a/llvm/lib/Target/RISCV/RISCV.td 

[llvm-branch-commits] [llvm] 3631e08 - [Doc] Update branch name in Phabricator documentation

2020-12-10 Thread Alexey Bader via llvm-branch-commits

Author: Alexey Bader
Date: 2020-12-10T22:25:04+03:00
New Revision: 3631e080c4e85b762fffce63abfe3aadfa43884b

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

LOG: [Doc] Update branch name in Phabricator documentation

master -> main

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

Added: 


Modified: 
llvm/docs/Phabricator.rst

Removed: 




diff  --git a/llvm/docs/Phabricator.rst b/llvm/docs/Phabricator.rst
index 6df1a8b755c4..cbc7c34eab68 100644
--- a/llvm/docs/Phabricator.rst
+++ b/llvm/docs/Phabricator.rst
@@ -200,7 +200,7 @@ click Submit.  Note the review must have been Accepted 
first.
 Committing someone's change from Phabricator
 
 
-On a clean Git repository on an up to date ``master`` branch run the
+On a clean Git repository on an up to date ``main`` branch run the
 following (where  is the Phabricator review number):
 
 ::
@@ -209,7 +209,7 @@ following (where  is the Phabricator review 
number):
 
 
 This will create a new branch called ``arcpatch-D`` based on the
-current ``master`` and will create a commit corresponding to ``D`` 
with a
+current ``main`` and will create a commit corresponding to ``D`` 
with a
 commit message derived from information in the Phabricator review.
 
 Check you are happy with the commit message and amend it if necessary.
@@ -225,10 +225,10 @@ the following:
 
 ::
 
-  git pull --rebase https://github.com/llvm/llvm-project.git master
+  git pull --rebase https://github.com/llvm/llvm-project.git main
   git show # Ensure the patch looks correct.
   ninja check-$whatever # Rerun the appropriate tests if needed.
-  git push https://github.com/llvm/llvm-project.git HEAD:master
+  git push https://github.com/llvm/llvm-project.git HEAD:main
 
 
 Abandoning a change



___
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] 248b279 - [NFC] Fix a gcc build break by using an explict constructor.

2020-12-10 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2020-12-10T11:21:40-08:00
New Revision: 248b279cf04d9e439a1e426ffd24f2dfa93d02f8

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

LOG: [NFC] Fix a gcc build break by using an explict constructor.

Added: 


Modified: 
llvm/lib/MC/MCParser/AsmParser.cpp

Removed: 




diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp 
b/llvm/lib/MC/MCParser/AsmParser.cpp
index bf2e5d8b41d4..bf50a95bc70c 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -5833,7 +5833,7 @@ bool AsmParser::parseDirectivePseudoProbe() {
 return true;
 }
 
-InlineSite Site = {CallerGuid, CallerProbeId};
+InlineSite Site(CallerGuid, CallerProbeId);
 InlineStack.push_back(Site);
   }
 



___
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] 57db6d2 - [gn build] Port ea6641085d0

2020-12-10 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-10T19:09:35Z
New Revision: 57db6d20c6dadbc129f0bf842b2028e2716b67f6

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

LOG: [gn build] Port ea6641085d0

Added: 


Modified: 
llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn
llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn
index d6d22ad5411e..6ea252aa718c 100644
--- a/llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn
@@ -23,14 +23,19 @@ static_library("Analysis") {
 "Consumed.cpp",
 "Dominators.cpp",
 "ExprMutationAnalyzer.cpp",
+"HTMLPathDiagnosticConsumer.cpp",
 "IssueHash.cpp",
 "LiveVariables.cpp",
 "ObjCNoReturn.cpp",
 "PathDiagnostic.cpp",
+"PlistHTMLPathDiagnosticConsumer.cpp",
+"PlistPathDiagnosticConsumer.cpp",
 "PostOrderCFGView.cpp",
 "ProgramPoint.cpp",
 "ReachableCode.cpp",
 "RetainSummaryManager.cpp",
+"SarifPathDiagnosticConsumer.cpp",
+"TextPathDiagnosticConsumer.cpp",
 "ThreadSafety.cpp",
 "ThreadSafetyCommon.cpp",
 "ThreadSafetyLogical.cpp",

diff  --git a/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
index c16c37d47b28..44be3eee1310 100644
--- a/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
@@ -39,11 +39,9 @@ static_library("Core") {
 "ExprEngineCallAndReturn.cpp",
 "ExprEngineObjC.cpp",
 "FunctionSummary.cpp",
-"HTMLDiagnostics.cpp",
 "LoopUnrolling.cpp",
 "LoopWidening.cpp",
 "MemRegion.cpp",
-"PlistDiagnostics.cpp",
 "ProgramState.cpp",
 "RangeConstraintManager.cpp",
 "RangedConstraintManager.cpp",
@@ -51,12 +49,10 @@ static_library("Core") {
 "SMTConstraintManager.cpp",
 "SValBuilder.cpp",
 "SVals.cpp",
-"SarifDiagnostics.cpp",
 "SimpleConstraintManager.cpp",
 "SimpleSValBuilder.cpp",
 "Store.cpp",
 "SymbolManager.cpp",
-"TextDiagnostics.cpp",
 "WorkList.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] [clang] 00ffea7 - [analyzer][CTU] Add an abstraction layer between libCrossTU and libAnalysis.

2020-12-10 Thread Artem Dergachev via llvm-branch-commits

Author: Artem Dergachev
Date: 2020-12-10T11:02:54-08:00
New Revision: 00ffea77ad887b576e9db82d98c97a31fee172cb

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

LOG: [analyzer][CTU] Add an abstraction layer between libCrossTU and 
libAnalysis.

Fixes shared libs build after D67422.

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

Added: 
clang/include/clang/Analysis/CrossTUAnalysisHelper.h

Modified: 
clang/include/clang/Analysis/PathDiagnosticConsumers.h
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistPathDiagnosticConsumer.cpp
clang/lib/Analysis/SarifPathDiagnosticConsumer.cpp
clang/lib/Analysis/TextPathDiagnosticConsumer.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/CrossTUAnalysisHelper.h 
b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
new file mode 100644
index ..ba2562b43055
--- /dev/null
+++ b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
@@ -0,0 +1,41 @@
+//===- CrossTUAnalysisHelper.h - Abstraction layer for CTU --*- 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
+//
+//===--===//
+#ifndef LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
+#define LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
+
+#include "llvm/ADT/Optional.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+
+class ASTUnit;
+
+/// This class is an abstract interface acting as a bridge between
+/// an analysis that requires lookups across translation units (a user
+/// of that interface) and the facility that implements such lookups
+/// (an implementation of that interface). This is useful to break direct
+/// link-time dependencies between the (possibly shared) libraries in which
+/// the user and the implementation live.
+class CrossTUAnalysisHelper {
+public:
+  /// Determine the original source location in the original TU for an
+  /// imported source location.
+  /// \p ToLoc Source location in the imported-to AST.
+  /// \return Source location in the imported-from AST and the corresponding
+  /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit
+  /// object that is returned here).
+  /// If any error happens (ToLoc is a non-imported source location) empty is
+  /// returned.
+  virtual llvm::Optional>
+  getImportedFromSourceLocation(SourceLocation ToLoc) const = 0;
+
+  virtual ~CrossTUAnalysisHelper() {}
+};
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H

diff  --git a/clang/include/clang/Analysis/PathDiagnosticConsumers.h 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.h
index 9f23bea1b4c1..fde2e3498216 100644
--- a/clang/include/clang/Analysis/PathDiagnosticConsumers.h
+++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.h
@@ -24,9 +24,7 @@ namespace clang {
 
 class AnalyzerOptions;
 class Preprocessor;
-namespace cross_tu {
-class CrossTranslationUnitContext;
-}
+class CrossTUAnalysisHelper;
 
 namespace ento {
 
@@ -36,8 +34,7 @@ typedef std::vector 
PathDiagnosticConsumers;
 #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
\
   void CREATEFN(PathDiagnosticConsumerOptions Diagopts,
\
 PathDiagnosticConsumers , const std::string , 
\
-const Preprocessor ,
\
-const cross_tu::CrossTranslationUnitContext );
+const Preprocessor , const CrossTUAnalysisHelper );
 #include "clang/Analysis/PathDiagnosticConsumers.def"
 
 } // end 'ento' namespace

diff  --git a/clang/include/clang/CrossTU/CrossTranslationUnit.h 
b/clang/include/clang/CrossTU/CrossTranslationUnit.h
index 027c6f16430b..2926ad288dbb 100644
--- a/clang/include/clang/CrossTU/CrossTranslationUnit.h
+++ b/clang/include/clang/CrossTU/CrossTranslationUnit.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H
 #define LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H
 
+#include "clang/Analysis/CrossTUAnalysisHelper.h"
 #include "clang/AST/ASTImporterSharedState.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
@@ -120,10 +121,10 @@ bool containsConst(const VarDecl *VD, const ASTContext 
);
 /// the locations of the AST files for each definition.
 ///
 /// Note that this class also implements caching.
-class CrossTranslationUnitContext {
+class CrossTranslationUnitContext : public CrossTUAnalysisHelper 

[llvm-branch-commits] [clang] ea66410 - Revert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.""""

2020-12-10 Thread Artem Dergachev via llvm-branch-commits

Author: Artem Dergachev
Date: 2020-12-10T11:02:54-08:00
New Revision: ea6641085d025ca0a5cef940465ef14d0ccace02

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

LOG: Revert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic 
consumer implementations to libAnalysis.

This reverts commit 6a89cb8136f3435bd977b419b683dc0acc98e61e.

Added: 
clang/include/clang/Analysis/PathDiagnosticConsumers.def
clang/include/clang/Analysis/PathDiagnosticConsumers.h
clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistPathDiagnosticConsumer.cpp
clang/lib/Analysis/SarifPathDiagnosticConsumer.cpp
clang/lib/Analysis/TextPathDiagnosticConsumer.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/Analyses.def
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
clang/include/clang/module.modulemap
clang/lib/Analysis/CMakeLists.txt
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/StaticAnalyzer/Core/CMakeLists.txt
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Removed: 
clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp



diff  --git a/clang/include/clang/Analysis/PathDiagnosticConsumers.def 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
new file mode 100644
index ..33d2072fcf31
--- /dev/null
+++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
@@ -0,0 +1,50 @@
+//===-- PathDiagnosticConsumers.def - Visualizing warnings --*- 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
+//
+//===--===//
+//
+// This file defines the set of path diagnostic consumers - objects that
+// implement 
diff erent representations of static analysis results.
+//
+//===--===//
+
+#ifndef ANALYSIS_DIAGNOSTICS
+#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
+#endif
+
+ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML",
+ createHTMLDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(
+HTML_SINGLE_FILE, "html-single-file",
+"Output analysis results using HTML (not allowing for multi-file bugs)",
+createHTMLSingleFileDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists",
+ createPlistDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(
+PLIST_MULTI_FILE, "plist-multi-file",
+"Output analysis results using Plists (allowing for multi-file bugs)",
+createPlistMultiFileDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html",
+ "Output analysis results using HTML wrapped with Plists",
+ createPlistHTMLDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(SARIF, "sarif", "Output analysis results in a SARIF file",
+ createSarifDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results to stderr",
+ createTextPathDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(TEXT_MINIMAL, "text-minimal",
+ "Emits minimal diagnostics to stderr, stating only the "
+ "warning message and the associated notes. Usually "
+ "used in addition to other analysis types",
+ createTextMinimalPathDiagnosticConsumer)
+
+#undef ANALYSIS_DIAGNOSTICS

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.h
similarity index 89%
rename from clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
rename to clang/include/clang/Analysis/PathDiagnosticConsumers.h
index f40f88eb32ff..9f23bea1b4c1 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
+++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.h
@@ -18,6 +18,8 @@
 #include 
 #include 
 
+#include "clang/Analysis/PathDiagnostic.h"
+
 namespace clang {
 
 class AnalyzerOptions;
@@ -29,14 +31,14 @@ class CrossTranslationUnitContext;
 namespace ento {
 
 class PathDiagnosticConsumer;
-typedef std::vector PathDiagnosticConsumers;
+typedef std::vector PathDiagnosticConsumers;
 
 #define 

[llvm-branch-commits] [lld] 1994970 - [lld][WebAssembly] Delay creation of internal __wasm_memory_init function

2020-12-10 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2020-12-10T10:47:18-08:00
New Revision: 199497086e46804084e4b8841b39e3604c678f34

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

LOG: [lld][WebAssembly] Delay creation of internal __wasm_memory_init function

This also allows for its creation to be conditional so it is completely
elided when not needed.

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

Added: 


Modified: 
lld/test/wasm/data-segment-merging.ll
lld/test/wasm/data-segments.ll
lld/test/wasm/no-tls.s
lld/test/wasm/tls.s
lld/wasm/Driver.cpp
lld/wasm/MarkLive.cpp
lld/wasm/SyntheticSections.h
lld/wasm/Writer.cpp

Removed: 




diff  --git a/lld/test/wasm/data-segment-merging.ll 
b/lld/test/wasm/data-segment-merging.ll
index 1dee1ccbda29..99f1a95c5854 100644
--- a/lld/test/wasm/data-segment-merging.ll
+++ b/lld/test/wasm/data-segment-merging.ll
@@ -98,9 +98,9 @@
 ; PASSIVE-MERGE-NEXT:  - Index:   0
 ; PASSIVE-MERGE-NEXT:Name:__wasm_call_ctors
 ; PASSIVE-MERGE-NEXT:  - Index:   1
-; PASSIVE-MERGE-NEXT:Name:__wasm_init_memory
-; PASSIVE-MERGE-NEXT:  - Index:   2
 ; PASSIVE-MERGE-NEXT:Name:__wasm_init_tls
+; PASSIVE-MERGE-NEXT:  - Index:   2
+; PASSIVE-MERGE-NEXT:Name:__wasm_init_memory
 
 ; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 
-no-merge-data-segments -o %t.separate.passive.wasm %t.passive.o
 ; RUN: obj2yaml %t.separate.passive.wasm | FileCheck %s 
--check-prefix=PASSIVE-SEPARATE
@@ -135,6 +135,6 @@
 ; PASSIVE-SEPARATE-NEXT:- Index:   0
 ; PASSIVE-SEPARATE-NEXT:  Name:__wasm_call_ctors
 ; PASSIVE-SEPARATE-NEXT:- Index:   1
-; PASSIVE-SEPARATE-NEXT:  Name:__wasm_init_memory
-; PASSIVE-SEPARATE-NEXT:- Index:   2
 ; PASSIVE-SEPARATE-NEXT:  Name:__wasm_init_tls
+; PASSIVE-SEPARATE-NEXT:- Index:   2
+; PASSIVE-SEPARATE-NEXT:  Name:__wasm_init_memory

diff  --git a/lld/test/wasm/data-segments.ll b/lld/test/wasm/data-segments.ll
index ecd18190b9c3..6f6d96a30fa5 100644
--- a/lld/test/wasm/data-segments.ll
+++ b/lld/test/wasm/data-segments.ll
@@ -64,7 +64,7 @@
 ; ACTIVE-NEXT:Name:__wasm_call_ctors
 
 ; PASSIVE-LABEL: - Type:START
-; PASSIVE-NEXT:StartFunction:   1
+; PASSIVE-NEXT:StartFunction:   2
 ; PASSIVE-LABEL: - Type:DATACOUNT
 ; PASSIVE-NEXT:Count:   2
 ; PASSIVE-LABEL: - Type:CODE
@@ -74,12 +74,11 @@
 ; PASSIVE-NEXT:Body:0B
 ; PASSIVE-NEXT:  - Index:   1
 ; PASSIVE-NEXT:Locals:  []
+; PASSIVE-NEXT:Body:0B
+; PASSIVE-NEXT:  - Index:   2
+; PASSIVE-NEXT:Locals:  []
 ; PASSIVE32-NEXT:Body:
41B4D60041004101FE480200044041B4D6004101427FFE0102001A054180084100410DFC0841900841004114FC08010041B4D6004102FE17020041B4D600417FFE0002001A0BFC0900FC09010B
 ; PASSIVE64-NEXT:Body:
42B4D60041004101FE480200044042B4D6004101427FFE0102001A054280084100410DFC0842900841004114FC08010042B4D6004102FE17020042B4D600417FFE0002001A0BFC0900FC09010B
-
-; PASSIVE-NEXT:  - Index:   2
-; PASSIVE-NEXT:Locals:  []
-; PASSIVE-NEXT:Body:0B
 ; PASSIVE-NEXT:  - Type:DATA
 ; PASSIVE-NEXT:Segments:
 ; PASSIVE-NEXT:  - SectionOffset:   3
@@ -94,12 +93,12 @@
 ; PASSIVE-NEXT:  - Index:   0
 ; PASSIVE-NEXT:Name:__wasm_call_ctors
 ; PASSIVE-NEXT:  - Index:   1
-; PASSIVE-NEXT:Name:__wasm_init_memory
-; PASSIVE-NEXT:  - Index:   2
 ; PASSIVE-NEXT:Name:__wasm_init_tls
+; PASSIVE-NEXT:  - Index:   2
+; PASSIVE-NEXT:Name:__wasm_init_memory
 
 ;  PASSIVE-PIC:  - Type:START
-; PASSIVE-PIC-NEXT:StartFunction:   2
+; PASSIVE-PIC-NEXT:StartFunction:   3
 ; PASSIVE-PIC-NEXT:  - Type:DATACOUNT
 ; PASSIVE-PIC-NEXT:Count:   1
 ; PASSIVE-PIC-NEXT:  - Type:CODE
@@ -111,15 +110,15 @@
 ; PASSIVE-PIC-NEXT:Locals:  []
 ; PASSIVE-PIC-NEXT:Body:0B
 ; PASSIVE-PIC-NEXT:  - Index:   2
+; PASSIVE-PIC-NEXT:Locals:  []
+; PASSIVE-PIC-NEXT:Body:0B
+; PASSIVE-PIC-NEXT:  - Index:   3
 ; PASSIVE-PIC-NEXT:Locals:
 ; PASSIVE32-PIC-NEXT:  - Type:I32
 ; PASSIVE64-PIC-NEXT:  - Type:I64
 ; PASSIVE-PIC-NEXT:Count:   1
 ; 

[llvm-branch-commits] [lldb] 47e7ecd - [lldb] Introduce separate scratch ASTs for debug info types and types imported from C++ modules.

2020-12-10 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-10T19:28:01+01:00
New Revision: 47e7ecdd7d36ca0924aa89c0fb2d956a6345a8f5

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

LOG: [lldb] Introduce separate scratch ASTs for debug info types and types 
imported from C++ modules.

Right now we have one large AST for all types in LLDB. All ODR violations in
types we reconstruct are resolved by just letting the ASTImporter handle the
conflicts (either by merging types or somehow trying to introduce a duplicated
declaration in the AST). This works ok for the normal types we build from debug
information as most of them are just simple CXXRecordDecls or empty template
declarations.

However, with a loaded `std` C++ module we have alternative versions of pretty
much all declarations in the `std` namespace that are much more fleshed out than
the debug information declarations. They have all the information that is lost
when converting to DWARF, such as default arguments, template default arguments,
the actual uninstantiated template declarations and so on.

When we merge these C++ module types into the big scratch AST (that might
already contain debug information types) we give the ASTImporter the tricky task
of somehow creating a consistent AST out of all these declarations. Usually this
ends in a messy AST that contains a mostly broken mix of both module and debug
info declarations. The ASTImporter in LLDB is also importing types with the
MinimalImport setting, which usually means the only information we have when
merging two types is often just the name of the declaration and the information
that it contains some child declarations. This makes it pretty much impossible
to even implement a better merging logic (as the names of C++ module
declarations and debug info declarations are identical).

This patch works around this whole merging problem by separating C++ module
types from debug information types. This is done by splitting up the single
scratch AST into two: One default AST for debug information and a dedicated AST
for C++ module types.

The C++ module AST is implemented as a 'specialised AST' that lives within the
default ScratchTypeSystemClang. When we select the scratch AST we can explicitly
request that we want such a isolated sub-AST of the scratch AST. I kept the
infrastructure more general as we probably can use the same mechanism for other
features that introduce conflicting types (such as programs that are compiled
with a custom -wchar-size= option).

There are just two places where we explicitly have request the C++ module AST:
When we export persistent declarations (`$mytype`) and when we create our
persistent result variable (`$0`, `$1`, ...). There are a few formatters that
were previously assuming that there is only one scratch AST which I cleaned up
in a preparation revision here (D92757).

Reviewed By: aprantl

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

Added: 

lldb/test/API/commands/expression/import-std-module/non-module-type-separation/Makefile

lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py

lldb/test/API/commands/expression/import-std-module/non-module-type-separation/main.cpp

Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/unittests/Symbol/TestTypeSystemClang.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index 66a87ba924db..3edbc4ab98c0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -443,7 +443,9 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
 return;
 
   auto *persistent_vars = llvm::cast(state);
-  TypeSystemClang *scratch_ctx = 
ScratchTypeSystemClang::GetForTarget(m_target);
+
+  TypeSystemClang *scratch_ctx = ScratchTypeSystemClang::GetForTarget(
+  m_target, m_ast_context->getLangOpts());
 
   for (clang::NamedDecl *decl : m_decls) {
 StringRef name = decl->getName();

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index cf34d9359f11..79ee565a3fdd 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ 

[llvm-branch-commits] [compiler-rt] bdaeb82 - [DFSan] Add custom wrapper for sigaltstack.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T10:16:36-08:00
New Revision: bdaeb82a5f84b813f5eb7e63e6e111c4566c61ab

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

LOG: [DFSan] Add custom wrapper for sigaltstack.

The wrapper clears shadow for old_ss.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 576f7f64e301..b43f978d8a2c 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -799,6 +799,16 @@ int __dfsw_sigaction(int signum, const struct sigaction 
*act,
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE
+int __dfsw_sigaltstack(const stack_t *ss, stack_t *old_ss, dfsan_label 
ss_label,
+   dfsan_label old_ss_label, dfsan_label *ret_label) {
+  int ret = sigaltstack(ss, old_ss);
+  if (ret != -1 && old_ss)
+dfsan_set_label(0, old_ss, sizeof(*old_ss));
+  *ret_label = 0;
+  return ret;
+}
+
 SANITIZER_INTERFACE_ATTRIBUTE
 int __dfsw_gettimeofday(struct timeval *tv, struct timezone *tz,
 dfsan_label tv_label, dfsan_label tz_label,

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index 9a92098f22eb..b8cfa3b9941b 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -200,6 +200,7 @@ fun:nanosleep=custom
 fun:pread=custom
 fun:read=custom
 fun:recvmsg=custom
+fun:sigaltstack=custom
 fun:socketpair=custom
 fun:stat=custom
 fun:time=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 8305941d0054..a03f33f769af 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -762,6 +762,15 @@ void test_sigaction() {
   ASSERT_READ_ZERO_LABEL(, sizeof(oldact));
 }
 
+void test_sigaltstack() {
+  stack_t old_altstack = {};
+  dfsan_set_label(j_label, _altstack, sizeof(old_altstack));
+  int ret = sigaltstack(NULL, _altstack);
+  assert(ret == 0);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_READ_ZERO_LABEL(_altstack, sizeof(old_altstack));
+}
+
 void test_gettimeofday() {
   struct timeval tv;
   struct timezone tz;
@@ -1172,6 +1181,7 @@ int main(void) {
   test_sched_getaffinity();
   test_select();
   test_sigaction();
+  test_sigaltstack();
   test_sigemptyset();
   test_snprintf();
   test_socketpair();



___
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] 12b684a - [VectorCombine] improve readability; NFC

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

Author: Sanjay Patel
Date: 2020-12-10T13:10:26-05:00
New Revision: 12b684ae02226f7785d3fb412fb155d4e15cc9bd

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

LOG: [VectorCombine] improve readability; NFC

If we are going to allow adjusting the pointer for GEPs,
rearranging the code a bit will make it easier to follow.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp 
b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 0d0a338afca3..19f5a2b432f7 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -116,15 +116,16 @@ bool VectorCombine::vectorizeLoadInsert(Instruction ) {
 return false;
 
   // TODO: Extend this to match GEP with constant offsets.
-  Value *PtrOp = Load->getPointerOperand()->stripPointerCasts();
-  assert(isa(PtrOp->getType()) && "Expected a pointer type");
-  unsigned AS = Load->getPointerAddressSpace();
+  const DataLayout  = I.getModule()->getDataLayout();
+  Value *SrcPtr = Load->getPointerOperand()->stripPointerCasts();
+  assert(isa(SrcPtr->getType()) && "Expected a pointer type");
 
   // If original AS != Load's AS, we can't bitcast the original pointer and 
have
   // to use Load's operand instead. Ideally we would want to strip pointer 
casts
   // without changing AS, but there's no API to do that ATM.
-  if (AS != PtrOp->getType()->getPointerAddressSpace())
-PtrOp = Load->getPointerOperand();
+  unsigned AS = Load->getPointerAddressSpace();
+  if (AS != SrcPtr->getType()->getPointerAddressSpace())
+SrcPtr = Load->getPointerOperand();
 
   Type *ScalarTy = Scalar->getType();
   uint64_t ScalarSize = ScalarTy->getPrimitiveSizeInBits();
@@ -136,11 +137,9 @@ bool VectorCombine::vectorizeLoadInsert(Instruction ) {
   unsigned MinVecNumElts = MinVectorSize / ScalarSize;
   auto *MinVecTy = VectorType::get(ScalarTy, MinVecNumElts, false);
   Align Alignment = Load->getAlign();
-  const DataLayout  = I.getModule()->getDataLayout();
-  if (!isSafeToLoadUnconditionally(PtrOp, MinVecTy, Alignment, DL, Load, ))
+  if (!isSafeToLoadUnconditionally(SrcPtr, MinVecTy, Alignment, DL, Load, ))
 return false;
 
-
   // Original pattern: insertelt undef, load [free casts of] PtrOp, 0
   Type *LoadTy = Load->getType();
   int OldCost = TTI.getMemoryOpCost(Instruction::Load, LoadTy, Alignment, AS);
@@ -159,7 +158,7 @@ bool VectorCombine::vectorizeLoadInsert(Instruction ) {
   // It is safe and potentially profitable to load a vector directly:
   // inselt undef, load Scalar, 0 --> load VecPtr
   IRBuilder<> Builder(Load);
-  Value *CastedPtr = Builder.CreateBitCast(PtrOp, MinVecTy->getPointerTo(AS));
+  Value *CastedPtr = Builder.CreateBitCast(SrcPtr, MinVecTy->getPointerTo(AS));
   Value *VecLd = Builder.CreateAlignedLoad(MinVecTy, CastedPtr, Alignment);
 
   // If the insert type does not match the target's minimum vector type,



___
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] ed4783f - [gn build] Port b035513c06d

2020-12-10 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-10T17:56:12Z
New Revision: ed4783fc595be5e5001a0e68c18b44e15c9a1f49

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

LOG: [gn build] Port b035513c06d

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
index 5bd7ec8f5818..e26d0bd01521 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
@@ -38,6 +38,7 @@ static_library("AsmPrinter") {
 "EHStreamer.cpp",
 "ErlangGCPrinter.cpp",
 "OcamlGCPrinter.cpp",
+"PseudoProbePrinter.cpp",
 "WasmException.cpp",
 "WinCFGuard.cpp",
 "WinException.cpp",

diff  --git a/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
index e0c7701e9896..9aa3f8539ad1 100644
--- a/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
@@ -43,6 +43,7 @@ static_library("MC") {
 "MCObjectFileInfo.cpp",
 "MCObjectStreamer.cpp",
 "MCObjectWriter.cpp",
+"MCPseudoProbe.cpp",
 "MCRegisterInfo.cpp",
 "MCSchedule.cpp",
 "MCSection.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] [clang] 764690b - [clang] Remove `-triple` from the invocations of `flang-new -fc1`

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

Author: Andrzej Warzynski
Date: 2020-12-10T17:54:12Z
New Revision: 764690b8a883c9466324f9c33ab1047a0661e8ef

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

LOG: [clang] Remove `-triple` from the invocations of `flang-new -fc1`

This is just a small change in the Flang tool within libclangDriver.
Currently it passes `-triple` when calling `flang-new -fc1` for various
driver Jobs. As there is no support for code-generation, `-triple` is
not required and should remain unsupported. It is safe to remove it.

This hasn't been a problem as the affected driver Jobs are not yet
implemented or used. However, we will be adding support for them in the
near future and the fact `-triple` is added will become a problem.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Flang.cpp
clang/test/Driver/flang/flang.f90
clang/test/Driver/flang/flang_ucase.F90

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 6d79fbe6aa8f..d7dee9594e45 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -40,8 +40,6 @@ void Flang::ConstructJob(Compilation , const JobAction ,
 else
   CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(JA)) {
-CmdArgs.push_back("-triple");
-CmdArgs.push_back(Args.MakeArgString(TripleStr));
 if (JA.getType() == types::TY_Nothing) {
   CmdArgs.push_back("-fsyntax-only");
 } else if (JA.getType() == types::TY_AST) {

diff  --git a/clang/test/Driver/flang/flang.f90 
b/clang/test/Driver/flang/flang.f90
index e4629d527d18..9b16f233b231 100644
--- a/clang/test/Driver/flang/flang.f90
+++ b/clang/test/Driver/flang/flang.f90
@@ -23,7 +23,6 @@
 ! CHECK-E-DAG: "-o" "-"
 
 ! RUN: %clang --driver-mode=flang -### -emit-ast   %s 2>&1 | FileCheck 
--check-prefixes=ALL,CHECK-EMIT-AST %s
-! CHECK-EMIT-AST-DAG: "-triple"
 ! CHECK-EMIT-AST-DAG: "-emit-ast"
 ! CHECK-EMIT-AST-DAG: "-o" "{{[^"]*}}.ast"
 

diff  --git a/clang/test/Driver/flang/flang_ucase.F90 
b/clang/test/Driver/flang/flang_ucase.F90
index 4da09e138b59..113ef75f45b8 100644
--- a/clang/test/Driver/flang/flang_ucase.F90
+++ b/clang/test/Driver/flang/flang_ucase.F90
@@ -23,7 +23,6 @@
 ! CHECK-E-DAG: "-o" "-"
 
 ! RUN: %clang --driver-mode=flang -### -emit-ast   %s 2>&1 | FileCheck 
--check-prefixes=ALL,CHECK-EMIT-AST %s
-! CHECK-EMIT-AST-DAG: "-triple"
 ! CHECK-EMIT-AST-DAG: "-emit-ast"
 ! CHECK-EMIT-AST-DAG: "-o" "{{[^"]*}}.ast"
 



___
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] b035513 - [CSSPGO] Pseudo probe encoding and emission.

2020-12-10 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2020-12-10T09:50:08-08:00
New Revision: b035513c06d1cba2bae8f3e88798334e877523e1

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

LOG: [CSSPGO] Pseudo probe encoding and emission.

This change implements pseudo probe encoding and emission for CSSPGO. Please 
see RFC here for more context: 
https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s

Pseudo probes are in the form of intrinsic calls on IR/MIR but they do not turn 
into any machine instructions. Instead they are emitted into the binary as a 
piece of data in standalone sections.  The probe-specific sections are not 
needed to be loaded into memory at execution time, thus they do not incur a 
runtime overhead. 

**ELF object emission**

The binary data to emit are organized as two ELF sections, i.e, the 
`.pseudo_probe_desc` section and the `.pseudo_probe` section. The 
`.pseudo_probe_desc` section stores a function descriptor for each function and 
the `.pseudo_probe` section stores the actual probes, each fo which corresponds 
to an IR basic block or an IR function callsite. A function descriptor is 
stored as a module-level metadata during the compilation and is serialized into 
the object file during object emission.

Both the probe descriptors and pseudo probes can be emitted into a separate ELF 
section per function to leverage the linker for deduplication.  A 
`.pseudo_probe` section shares the same COMDAT group with the function code so 
that when the function is dead, the probes are dead and disposed too. On the 
contrary, a `.pseudo_probe_desc` section has its own COMDAT group. This is 
because even if a function is dead, its probes may be inlined into other 
functions and its descriptor is still needed by the profile generation tool.

The format of `.pseudo_probe_desc` section looks like:

```
.section   .pseudo_probe_desc,"",@progbits
.quad   6309742469962978389  // Func GUID
.quad   4294967295   // Func Hash
.byte   9// Length of func name
.ascii  "_Z5funcAi"  // Func name
.quad   7102633082150537521
.quad   138828622701
.byte   12
.ascii  "_Z8funcLeafi"
.quad   446061515086924981
.quad   4294967295
.byte   9
.ascii  "_Z5funcBi"
.quad   -2016976694713209516
.quad   72617220756
.byte   7
.ascii  "_Z3fibi"
```

For each `.pseudoprobe` section, the encoded binary data consists of a single 
function record corresponding to an outlined function (i.e, a function with a 
code entry in the `.text` section). A function record has the following format :

```
FUNCTION BODY (one for each outlined function present in the text section)
GUID (uint64)
GUID of the function
NPROBES (ULEB128)
Number of probes originating from this function.
NUM_INLINED_FUNCTIONS (ULEB128)
Number of callees inlined into this function, aka number of
first-level inlinees
PROBE RECORDS
A list of NPROBES entries. Each entry contains:
  INDEX (ULEB128)
  TYPE (uint4)
0 - block probe, 1 - indirect call, 2 - direct call
  ATTRIBUTE (uint3)
reserved
  ADDRESS_TYPE (uint1)
0 - code address, 1 - address delta
  CODE_ADDRESS (uint64 or ULEB128)
code address or address delta, depending on ADDRESS_TYPE
INLINED FUNCTION RECORDS
A list of NUM_INLINED_FUNCTIONS entries describing each of the inlined
callees.  Each record contains:
  INLINE SITE
GUID of the inlinee (uint64)
ID of the callsite probe (ULEB128)
  FUNCTION BODY
A FUNCTION BODY entry describing the inlined function.
```

To support building a context-sensitive profile, probes from inlinees are 
grouped by their inline contexts. An inline context is logically a call path 
through which a callee function lands in a caller function. The probe emitter 
builds an inline tree based on the debug metadata for each outlined function in 
the form of a trie tree. A tree root is the outlined function. Each tree edge 
stands for a callsite where inlining happens. Pseudo probes originating from an 
inlinee function are stored in a tree node and the tree path starting from the 
root all the way down to the tree node is the inline context of the probes. The 
emission happens on the whole tree top-down recursively. Probes of a tree node 
will be emitted altogether with their direct parent edge. Since a pseudo probe 
corresponds to a real code address, for size savings, the address is encoded as 
a delta from the previous probe except for the first probe. Variant-sized 
integer encoding, aka LEB128, is used for address delta and probe index.

**Assembling**

Pseudo probes can be printed as assembly directives alternatively. This allows 
for good assembly code readability and also provides a view of how 
optimizations and pseudo probes 

[llvm-branch-commits] [llvm] 512a64d - [test] Fix scev-expander-preserve-lcssa.ll under NPM

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

Author: Arthur Eubanks
Date: 2020-12-10T09:46:08-08:00
New Revision: 512a64de6a977891b52b59c765f7775e0c8ad6cf

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

LOG: [test] Fix scev-expander-preserve-lcssa.ll under NPM

The NPM runs loop passes over loops in forward program order, rather
than the legacy loop PM's reverse program order. This seems to produce
better results as shown here.

I verified that changing the loop order to reverse program order results
in the same IR with the NPM.

Reviewed By: fhahn

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

Added: 


Modified: 
llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll

Removed: 




diff  --git 
a/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll 
b/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll
index d26d3b23b772..6c275f3bca48 100644
--- a/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll
+++ b/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -indvars -S -indvars -verify-loop-lcssa %s | FileCheck %s
+; RUN: opt -aa-pipeline=basic-aa -passes=indvars,indvars -S -verify-loop-lcssa 
%s | FileCheck %s
 
 ; Make sure SCEVExpander does not crash and introduce unnecessary LCSSA PHI 
nodes.
 ; The tests are a collection of cases with crashes when preserving LCSSA PHI
@@ -113,13 +113,10 @@ define void @test2(i16 %x)  {
 ; CHECK:   for.body84.preheader:
 ; CHECK-NEXT:br label [[FOR_BODY84:%.*]]
 ; CHECK:   for.body84:
-; CHECK-NEXT:[[I_144:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END106:%.*]] ], [ 
0, [[FOR_BODY84_PREHEADER]] ]
 ; CHECK-NEXT:[[C_2:%.*]] = call i1 @cond()
-; CHECK-NEXT:br i1 [[C_2]], label [[IF_END106]], label 
[[RETURN_LOOPEXIT:%.*]]
+; CHECK-NEXT:br i1 [[C_2]], label [[IF_END106:%.*]], label 
[[RETURN_LOOPEXIT:%.*]]
 ; CHECK:   if.end106:
-; CHECK-NEXT:[[INC]] = add nuw nsw i32 [[I_144]], 1
-; CHECK-NEXT:[[CMP82:%.*]] = icmp slt i32 [[INC]], [[I_0_LCSSA2]]
-; CHECK-NEXT:br i1 [[CMP82]], label [[FOR_BODY84]], label 
[[RETURN_LOOPEXIT]]
+; CHECK-NEXT:br i1 false, label [[FOR_BODY84]], label [[RETURN_LOOPEXIT]]
 ; CHECK:   return.loopexit:
 ; CHECK-NEXT:br label [[RETURN]]
 ; CHECK:   return.loopexit1:



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


[llvm-branch-commits] [lldb] ac25e86 - [lldb] Deal gracefully with concurrency in the API instrumentation.

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

Author: Jonas Devlieghere
Date: 2020-12-10T09:37:49-08:00
New Revision: ac25e8628c443cddd841c6c91d1c9e23e88969e5

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

LOG: [lldb] Deal gracefully with concurrency in the API instrumentation.

Prevent lldb from crashing when multiple threads are concurrently
accessing the SB API with reproducer capture enabled.

The API instrumentation records both the input arguments and the return
value, but it cannot block for the duration of the API call. Therefore
we introduce a sequence number that allows to to correlate the function
with its result and add locking to ensure those two parts are emitted
atomically.

Using the sequence number, we can detect situations where the return
value does not succeed the function call, in which case we print an
error saying that concurrency is not (currently) supported. In the
future we might attempt to be smarter and read ahead until we've found
the return value matching the current call.

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

Added: 


Modified: 
lldb/include/lldb/Utility/ReproducerInstrumentation.h
lldb/source/Utility/ReproducerInstrumentation.cpp
lldb/unittests/Utility/ReproducerInstrumentationTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h 
b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index e4c31522c4fc..c8a98adf85c7 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -333,6 +333,7 @@ class Deserializer {
   }
 
   template  const T (const T ) {
+CheckSequence(Deserialize());
 unsigned result = Deserialize();
 if (is_trivially_serializable::value)
   return t;
@@ -342,6 +343,7 @@ class Deserializer {
 
   /// Store the returned value in the index-to-object mapping.
   template  T (T ) {
+CheckSequence(Deserialize());
 unsigned result = Deserialize();
 if (is_trivially_serializable::value)
   return t;
@@ -351,6 +353,7 @@ class Deserializer {
 
   /// Store the returned value in the index-to-object mapping.
   template  T *HandleReplayResult(T *t) {
+CheckSequence(Deserialize());
 unsigned result = Deserialize();
 if (is_trivially_serializable::value)
   return t;
@@ -360,6 +363,7 @@ class Deserializer {
   /// All returned types are recorded, even when the function returns a void.
   /// The latter requires special handling.
   void HandleReplayResultVoid() {
+CheckSequence(Deserialize());
 unsigned result = Deserialize();
 assert(result == 0);
 (void)result;
@@ -369,6 +373,10 @@ class Deserializer {
 return m_index_to_object.GetAllObjects();
   }
 
+  void SetExpectedSequence(unsigned sequence) {
+m_expected_sequence = sequence;
+  }
+
 private:
   template  T Read(ValueTag) {
 assert(HasData(sizeof(T)));
@@ -410,11 +418,17 @@ class Deserializer {
 return *(new UnderlyingT(Deserialize()));
   }
 
+  /// Verify that the given sequence number matches what we expect.
+  void CheckSequence(unsigned sequence);
+
   /// Mapping of indices to objects.
   IndexToObject m_index_to_object;
 
   /// Buffer containing the serialized data.
   llvm::StringRef m_buffer;
+
+  /// The result's expected sequence number.
+  llvm::Optional m_expected_sequence;
 };
 
 /// Partial specialization for C-style strings. We read the string value
@@ -745,12 +759,15 @@ class Recorder {
 if (!ShouldCapture())
   return;
 
+std::lock_guard lock(g_mutex);
+unsigned sequence = GetSequenceNumber();
 unsigned id = registry.GetID(uintptr_t(f));
 
 #ifdef LLDB_REPRO_INSTR_TRACE
 Log(id);
 #endif
 
+serializer.SerializeAll(sequence);
 serializer.SerializeAll(id);
 serializer.SerializeAll(args...);
 
@@ -758,6 +775,7 @@ class Recorder {
 typename std::remove_reference::type>::type>::value) {
   m_result_recorded = false;
 } else {
+  serializer.SerializeAll(sequence);
   serializer.SerializeAll(0);
   m_result_recorded = true;
 }
@@ -771,16 +789,20 @@ class Recorder {
 if (!ShouldCapture())
   return;
 
+std::lock_guard lock(g_mutex);
+unsigned sequence = GetSequenceNumber();
 unsigned id = registry.GetID(uintptr_t(f));
 
 #ifdef LLDB_REPRO_INSTR_TRACE
 Log(id);
 #endif
 
+serializer.SerializeAll(sequence);
 serializer.SerializeAll(id);
 serializer.SerializeAll(args...);
 
 // Record result.
+serializer.SerializeAll(sequence);
 serializer.SerializeAll(0);
 m_result_recorded = true;
   }
@@ -806,7 +828,9 @@ class Recorder {
 if (update_boundary)
   UpdateBoundary();
 if (m_serializer && ShouldCapture()) {
+  std::lock_guard lock(g_mutex);
   

[llvm-branch-commits] [mlir] 563879b - [NFC] Use ConvertOpToLLVMPattern instead of ConvertToLLVMPattern.

2020-12-10 Thread Rahul Joshi via llvm-branch-commits

Author: Rahul Joshi
Date: 2020-12-10T09:33:43-08:00
New Revision: 563879b6f9465982b422a69a901e3d84e7cb7764

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

LOG: [NFC] Use ConvertOpToLLVMPattern instead of ConvertToLLVMPattern.

- use ConvertOpToLLVMPattern to avoid explicit casting and in most cases the
  constructor can be reused to save a few lines of code.

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

Added: 


Modified: 
mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h
mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp

Removed: 




diff  --git a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h 
b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
index b7c9d0016d65..948c2a4be6f2 100644
--- a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
+++ b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
@@ -18,8 +18,7 @@ template  class OperationPass;
 
 /// Populate the given list with patterns that convert from Linalg to LLVM.
 void populateLinalgToLLVMConversionPatterns(LLVMTypeConverter ,
-OwningRewritePatternList ,
-MLIRContext *ctx);
+OwningRewritePatternList 
);
 
 /// Create a pass to convert Linalg operations to the LLVMIR dialect.
 std::unique_ptr> createConvertLinalgToLLVMPass();

diff  --git a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h 
b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
index ace07ac7223b..4eae84cd0135 100644
--- a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
+++ b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
@@ -19,8 +19,7 @@ class OperationPass;
 class OwningRewritePatternList;
 
 /// Populate the given list with patterns that convert from OpenMP to LLVM.
-void populateOpenMPToLLVMConversionPatterns(MLIRContext *context,
-LLVMTypeConverter ,
+void populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter ,
 OwningRewritePatternList 
);
 
 /// Create a pass to convert OpenMP operations to the LLVMIR dialect.

diff  --git 
a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h 
b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index bf41f29749de..7c069c9cd556 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -565,8 +565,8 @@ class ConvertToLLVMPattern : public ConversionPattern {
 template 
 class ConvertOpToLLVMPattern : public ConvertToLLVMPattern {
 public:
-  ConvertOpToLLVMPattern(LLVMTypeConverter ,
- PatternBenefit benefit = 1)
+  explicit ConvertOpToLLVMPattern(LLVMTypeConverter ,
+  PatternBenefit benefit = 1)
   : ConvertToLLVMPattern(SourceOp::getOperationName(),
  (), typeConverter,
  benefit) {}

diff  --git a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp 
b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
index fe06e12c8f21..06a19b057f71 100644
--- a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
+++ b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
@@ -34,8 +34,7 @@ static Type getSrcVectorElementType(OpTy op) {
 /// operands as is, preserve attributes.
 template 
 static LogicalResult
-matchAndRewriteOneToOne(const ConvertToLLVMPattern ,
-LLVMTypeConverter , Operation *op,
+matchAndRewriteOneToOne(LLVMTypeConverter , Operation *op,
 ArrayRef operands,
 ConversionPatternRewriter ) {
   unsigned numResults = op->getNumResults();
@@ -73,71 +72,61 @@ namespace {
 // TODO: Patterns are too verbose due to the fact that we have 1 op (e.g.
 // MaskRndScaleOp) and 
diff erent possible target ops. It would be better to take
 // a Functor so that all these conversions become 1-liners.
-struct MaskRndScaleOpPS512Conversion : public ConvertToLLVMPattern {
-  

[llvm-branch-commits] [llvm] a1ae3c6 - [RISCV][LegalizeDAG] Expand SETO and SETUO comparisons. Teach LegalizeDAG to expand SETUO expansion when UNE isn't legal.

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

Author: Craig Topper
Date: 2020-12-10T09:15:52-08:00
New Revision: a1ae3c6ac91305711658c75de48415e5b647f1df

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

LOG: [RISCV][LegalizeDAG] Expand SETO and SETUO comparisons. Teach LegalizeDAG 
to expand SETUO expansion when UNE isn't legal.

If SETUNE isn't legal, UO can use the NOT of the SETO expansion.

Removes some complex isel patterns. Most of the test changes are
from using XORI instead of SEQZ.

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoD.td
llvm/lib/Target/RISCV/RISCVInstrInfoF.td
llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
llvm/test/CodeGen/RISCV/double-br-fcmp.ll
llvm/test/CodeGen/RISCV/double-fcmp.ll
llvm/test/CodeGen/RISCV/double-isnan.ll
llvm/test/CodeGen/RISCV/double-select-fcmp.ll
llvm/test/CodeGen/RISCV/float-br-fcmp.ll
llvm/test/CodeGen/RISCV/float-fcmp.ll
llvm/test/CodeGen/RISCV/float-isnan.ll
llvm/test/CodeGen/RISCV/float-select-fcmp.ll
llvm/test/CodeGen/RISCV/half-br-fcmp.ll
llvm/test/CodeGen/RISCV/half-fcmp.ll
llvm/test/CodeGen/RISCV/half-isnan.ll
llvm/test/CodeGen/RISCV/half-select-fcmp.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 361ab78d8455..7342c663776c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -1726,14 +1726,19 @@ bool SelectionDAGLegalize::LegalizeSetCCCondCode(
 unsigned Opc = 0;
 switch (CCCode) {
 default: llvm_unreachable("Don't know how to expand this condition!");
+case ISD::SETUO:
+if (TLI.isCondCodeLegal(ISD::SETUNE, OpVT)) {
+  CC1 = ISD::SETUNE; CC2 = ISD::SETUNE; Opc = ISD::OR;
+  break;
+}
+assert(TLI.isCondCodeLegal(ISD::SETOEQ, OpVT) &&
+   "If SETUE is expanded, SETOEQ or SETUNE must be legal!");
+NeedInvert = true;
+LLVM_FALLTHROUGH;
 case ISD::SETO:
 assert(TLI.isCondCodeLegal(ISD::SETOEQ, OpVT)
 && "If SETO is expanded, SETOEQ must be legal!");
 CC1 = ISD::SETOEQ; CC2 = ISD::SETOEQ; Opc = ISD::AND; break;
-case ISD::SETUO:
-assert(TLI.isCondCodeLegal(ISD::SETUNE, OpVT)
-&& "If SETUO is expanded, SETUNE must be legal!");
-CC1 = ISD::SETUNE; CC2 = ISD::SETUNE; Opc = ISD::OR;  break;
 case ISD::SETOEQ:
 case ISD::SETOGT:
 case ISD::SETOGE:

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index c58d44771f50..78909b2f4039 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -246,7 +246,7 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine ,
   ISD::CondCode FPCCToExpand[] = {
   ISD::SETOGT, ISD::SETOGE, ISD::SETONE, ISD::SETUEQ, ISD::SETUGT,
   ISD::SETUGE, ISD::SETULT, ISD::SETULE, ISD::SETUNE, ISD::SETGT,
-  ISD::SETGE,  ISD::SETNE};
+  ISD::SETGE,  ISD::SETNE,  ISD::SETO,   ISD::SETUO};
 
   ISD::NodeType FPOpToExpand[] = {
   ISD::FSIN, ISD::FCOS, ISD::FSINCOS, ISD::FPOW, ISD::FREM, 
ISD::FP16_TO_FP,

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
index 182c3990f74d..133599e13b8b 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
@@ -299,23 +299,6 @@ def : PatFpr64Fpr64;
 def : PatFpr64Fpr64;
 def : PatFpr64Fpr64;
 
-// Define pattern expansions for setcc operations which aren't directly
-// handled by a RISC-V instruction and aren't expanded in the SelectionDAG
-// Legalizer.
-
-def : Pat<(seto FPR64:$rs1, FPR64:$rs2),
-  (AND (FEQ_D FPR64:$rs1, FPR64:$rs1),
-   (FEQ_D FPR64:$rs2, FPR64:$rs2))>;
-def : Pat<(seto FPR64:$rs1, FPR64:$rs1),
-  (FEQ_D $rs1, $rs1)>;
-
-def : Pat<(setuo FPR64:$rs1, FPR64:$rs2),
-  (SLTIU (AND (FEQ_D FPR64:$rs1, FPR64:$rs1),
-  (FEQ_D FPR64:$rs2, FPR64:$rs2)),
- 1)>;
-def : Pat<(setuo FPR64:$rs1, FPR64:$rs1),
-  (SLTIU (FEQ_D $rs1, $rs1), 1)>;
-
 def Select_FPR64_Using_CC_GPR : SelectCC_rrirr;
 
 /// Loads

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
index 7a069dafc230..4529949f693e 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
@@ -355,23 +355,6 @@ def : PatFpr32Fpr32;
 def : PatFpr32Fpr32;
 def : PatFpr32Fpr32;
 
-// Define pattern expansions for setcc operations which aren't directly
-// 

[llvm-branch-commits] [llvm] bb9cef7 - [CallBase] Add hasRetAttr version that takes StringRef.

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

Author: Florian Hahn
Date: 2020-12-10T17:00:16Z
New Revision: bb9cef7628ecda692081e5690dbb890dcececd15

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

LOG: [CallBase] Add hasRetAttr version that takes StringRef.

This makes it slightly easier to deal with custom attributes and
CallBase already provides hasFnAttr versions that support both AttrKind
and StringRef arguments in a similar fashion.

Reviewed By: jdoerfert

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

Added: 


Modified: 
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/IR/Instructions.cpp
llvm/unittests/IR/InstructionsTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/InstrTypes.h 
b/llvm/include/llvm/IR/InstrTypes.h
index 8af18e14c474..8a702e3c9c5c 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1553,7 +1553,11 @@ class CallBase : public Instruction {
   }
 
   /// Determine whether the return value has the given attribute.
-  bool hasRetAttr(Attribute::AttrKind Kind) const;
+  bool hasRetAttr(Attribute::AttrKind Kind) const {
+return hasRetAttrImpl(Kind);
+  }
+  /// Determine whether the return value has the given attribute.
+  bool hasRetAttr(StringRef Kind) const { return hasRetAttrImpl(Kind); }
 
   /// Determine whether the argument or parameter has the given attribute.
   bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const;
@@ -2232,6 +2236,18 @@ class CallBase : public Instruction {
 
 return hasFnAttrOnCalledFunction(Kind);
   }
+
+  /// Determine whether the return value has the given attribute. Supports
+  /// Attribute::AttrKind and StringRef as \p AttrKind types.
+  template  bool hasRetAttrImpl(AttrKind Kind) const {
+if (Attrs.hasAttribute(AttributeList::ReturnIndex, Kind))
+  return true;
+
+// Look at the callee, if available.
+if (const Function *F = getCalledFunction())
+  return F->getAttributes().hasAttribute(AttributeList::ReturnIndex, Kind);
+return false;
+  }
 };
 
 template <>

diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 74a95da79932..47bf3966bc27 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -322,16 +322,6 @@ Value *CallBase::getReturnedArgOperand() const {
   return nullptr;
 }
 
-bool CallBase::hasRetAttr(Attribute::AttrKind Kind) const {
-  if (Attrs.hasAttribute(AttributeList::ReturnIndex, Kind))
-return true;
-
-  // Look at the callee, if available.
-  if (const Function *F = getCalledFunction())
-return F->getAttributes().hasAttribute(AttributeList::ReturnIndex, Kind);
-  return false;
-}
-
 /// Determine whether the argument or parameter has the given attribute.
 bool CallBase::paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
   assert(ArgNo < getNumArgOperands() && "Param index out of bounds!");

diff  --git a/llvm/unittests/IR/InstructionsTest.cpp 
b/llvm/unittests/IR/InstructionsTest.cpp
index 419cddc0c370..c9d6d846cbab 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -94,6 +94,11 @@ TEST_F(ModuleWithFunctionTest, CallInst) {
 EXPECT_EQ(Call->getArgOperand(Idx)->getType(), Arg->getType());
 Idx++;
   }
+
+  Call->addAttribute(llvm::AttributeList::ReturnIndex,
+ Attribute::get(Call->getContext(), "test-str-attr"));
+  EXPECT_TRUE(Call->hasRetAttr("test-str-attr"));
+  EXPECT_FALSE(Call->hasRetAttr("not-on-call"));
 }
 
 TEST_F(ModuleWithFunctionTest, InvokeInst) {



___
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] 9c4cddb - [Clang] Add vcmla and rotated variants for Arm ACLE.

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

Author: Florian Hahn
Date: 2020-12-10T16:54:08Z
New Revision: 9c4cddb53a7b94d83d1a7417c9a1aea00a139545

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

LOG: [Clang] Add vcmla and rotated variants for Arm ACLE.

This patch adds vcmla and the rotated variants as defined in
"Arm Neon Intrinsics Reference for ACLE Q3 2020" [1]

The *_lane_* are still missing, but they can be added separately.

This patch only adds the builtin mapping for AArch64.

[1] https://developer.arm.com/documentation/ihi0073/latest

Reviewed By: t.p.northover

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

Added: 
clang/test/CodeGen/aarch64-neon-vcmla.c

Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index feccf2e15dc0..4d4e42dd514b 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1902,22 +1902,34 @@ let ArchGuard = 
"defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)" in {
   def VFMLALT_LANEQ_BF : SOpInst<"vbfmlalt_laneq", "..B(BQ)I", "Qf", 
OP_BFMLALT_LN>;
 }
 
+multiclass VCMLA_ROTS {
+  foreach ROT = ["", "_rot90", "_rot180", "_rot270" ] in {
+def   : SInst<"vcmla" # ROT, "", type # "Q" # type>;
+  }
+}
+
 // v8.3-A Vector complex addition intrinsics
 let ArchGuard = "defined(__ARM_FEATURE_COMPLEX) && 
defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)" in {
   def VCADD_ROT90_FP16   : SInst<"vcadd_rot90", "...", "h">;
   def VCADD_ROT270_FP16  : SInst<"vcadd_rot270", "...", "h">;
   def VCADDQ_ROT90_FP16  : SInst<"vcaddq_rot90", "QQQ", "h">;
   def VCADDQ_ROT270_FP16 : SInst<"vcaddq_rot270", "QQQ", "h">;
+
+  defm VCMLA_FP16  : VCMLA_ROTS<"h", "uint32x2_t", "uint32x4_t">;
 }
 let ArchGuard = "defined(__ARM_FEATURE_COMPLEX)" in {
   def VCADD_ROT90   : SInst<"vcadd_rot90", "...", "f">;
   def VCADD_ROT270  : SInst<"vcadd_rot270", "...", "f">;
   def VCADDQ_ROT90  : SInst<"vcaddq_rot90", "QQQ", "f">;
   def VCADDQ_ROT270 : SInst<"vcaddq_rot270", "QQQ", "f">;
+
+  defm VCMLA_F32: VCMLA_ROTS<"f", "uint64x1_t", "uint64x2_t">;
 }
 let ArchGuard = "defined(__ARM_FEATURE_COMPLEX) && defined(__aarch64__)" in {
   def VCADDQ_ROT90_FP64  : SInst<"vcaddq_rot90", "QQQ", "d">;
   def VCADDQ_ROT270_FP64 : SInst<"vcaddq_rot270", "QQQ", "d">;
+
+  defm VCMLA_FP64 : VCMLA_ROTS<"d", "uint64x2_t", "uint64x2_t">;
 }
 
 // V8.2-A BFloat intrinsics

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 73897a27bd94..db7ae582b1d6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5548,6 +5548,14 @@ static const ARMVectorIntrinsicInfo 
AArch64SIMDIntrinsicMap[] = {
   NEONMAP0(vcltzq_v),
   NEONMAP1(vclz_v, ctlz, Add1ArgType),
   NEONMAP1(vclzq_v, ctlz, Add1ArgType),
+  NEONMAP1(vcmla_rot180_v, aarch64_neon_vcmla_rot180, Add1ArgType),
+  NEONMAP1(vcmla_rot270_v, aarch64_neon_vcmla_rot270, Add1ArgType),
+  NEONMAP1(vcmla_rot90_v, aarch64_neon_vcmla_rot90, Add1ArgType),
+  NEONMAP1(vcmla_v, aarch64_neon_vcmla_rot0, Add1ArgType),
+  NEONMAP1(vcmlaq_rot180_v, aarch64_neon_vcmla_rot180, Add1ArgType),
+  NEONMAP1(vcmlaq_rot270_v, aarch64_neon_vcmla_rot270, Add1ArgType),
+  NEONMAP1(vcmlaq_rot90_v, aarch64_neon_vcmla_rot90, Add1ArgType),
+  NEONMAP1(vcmlaq_v, aarch64_neon_vcmla_rot0, Add1ArgType),
   NEONMAP1(vcnt_v, ctpop, Add1ArgType),
   NEONMAP1(vcntq_v, ctpop, Add1ArgType),
   NEONMAP1(vcvt_f16_f32, aarch64_neon_vcvtfp2hf, 0),

diff  --git a/clang/test/CodeGen/aarch64-neon-vcmla.c 
b/clang/test/CodeGen/aarch64-neon-vcmla.c
new file mode 100644
index ..2ecc1d5fbb3d
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-neon-vcmla.c
@@ -0,0 +1,146 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple arm64-apple-ios -target-feature +neon \
+// RUN:-target-feature +v8.3a \
+// RUN:-target-feature +fullfp16 \
+// RUN:-disable-O0-optnone -emit-llvm -o - %s | opt -S -O1 | FileCheck 
%s
+#include 
+
+// CHECK-LABEL: @test_vcmla_f16(
+// CHECK: [[RES:%.*]] = call <4 x half> @llvm.aarch64.neon.vcmla.rot0.v4f16(<4 
x half> %acc, <4 x half> %lhs, <4 x half> %rhs)
+// CHECK: ret <4 x half> [[RES]]
+float16x4_t test_vcmla_f16(float16x4_t acc, float16x4_t lhs, float16x4_t rhs) {
+  return vcmla_f16(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmla_f32(
+// CHECK: [[RES:%.*]] = call <2 x float> 
@llvm.aarch64.neon.vcmla.rot0.v2f32(<2 x float> %acc, <2 x float> %lhs, <2 x 
float> %rhs)
+// CHECK: ret <2 x float> [[RES]]
+float32x2_t test_vcmla_f32(float32x2_t acc, float32x2_t lhs, float32x2_t rhs) {
+  return vcmla_f32(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_f16(
+// CHECK: [[RES:%.*]] = call <8 x half> 

[llvm-branch-commits] [clang] a84599f - [OpenCL] Implement extended subgroups fully in headers.

2020-12-10 Thread Anastasia Stulova via llvm-branch-commits

Author: Anastasia Stulova
Date: 2020-12-10T16:40:15Z
New Revision: a84599f177a67d4a8c1c30ccd96c99fa40af75f7

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

LOG: [OpenCL] Implement extended subgroups fully in headers.

Extended subgroups are library style extensions and therefore
they require no changes in the frontend. This commit:
1. Moves extension macro definitions to the internal headers.
2. Removes extension pragmas because they are not needed.

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/OpenCLExtensions.def
clang/lib/Headers/opencl-c-base.h
clang/test/Headers/opencl-c-header.cl
clang/test/SemaOpenCL/extension-version.cl

Removed: 




diff  --git a/clang/include/clang/Basic/OpenCLExtensions.def 
b/clang/include/clang/Basic/OpenCLExtensions.def
index d67cb3ff019b..17d402f300f1 100644
--- a/clang/include/clang/Basic/OpenCLExtensions.def
+++ b/clang/include/clang/Basic/OpenCLExtensions.def
@@ -66,13 +66,6 @@ OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_extended_types, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_non_uniform_vote, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_ballot, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_non_uniform_arithmetic, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_shuffle, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_shuffle_relative, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_clustered_reduce, 200, ~0U)
 
 // Clang Extensions.
 OPENCLEXT_INTERNAL(cl_clang_storage_class_specifiers, 100, ~0U)

diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index 4c52ebed1709..e8dcd70377e5 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -9,6 +9,21 @@
 #ifndef _OPENCL_BASE_H_
 #define _OPENCL_BASE_H_
 
+// Define extension macros
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+// For SPIR all extensions are supported.
+#if defined(__SPIR__)
+#define cl_khr_subgroup_extended_types 1
+#define cl_khr_subgroup_non_uniform_vote 1
+#define cl_khr_subgroup_ballot 1
+#define cl_khr_subgroup_non_uniform_arithmetic 1
+#define cl_khr_subgroup_shuffle 1
+#define cl_khr_subgroup_shuffle_relative 1
+#define cl_khr_subgroup_clustered_reduce 1
+#endif // defined(__SPIR__)
+#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+
 // built-in scalar data types:
 
 /**

diff  --git a/clang/test/Headers/opencl-c-header.cl 
b/clang/test/Headers/opencl-c-header.cl
index 1b151ffdd16a..13a3b62481ec 100644
--- a/clang/test/Headers/opencl-c-header.cl
+++ b/clang/test/Headers/opencl-c-header.cl
@@ -84,7 +84,11 @@ void test_atomics(__generic volatile unsigned int* a) {
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
+// CHECK-MOD: Reading modules
+
+// Check that extension macros are defined correctly.
 
+// FIXME: this should not be defined for all targets
 // Verify that non-builtin cl_intel_planar_yuv extension is defined from
 // OpenCL 1.2 onwards.
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
@@ -94,4 +98,57 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
 
-// CHECK-MOD: Reading modules
+// For SPIR all extensions are supported.
+#if defined(__SPIR__)
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+
+#if cl_khr_subgroup_extended_types != 1
+#error "Incorrectly defined cl_khr_subgroup_extended_types"
+#endif
+#if cl_khr_subgroup_non_uniform_vote != 1
+#error "Incorrectly defined cl_khr_subgroup_non_uniform_vote"
+#endif
+#if cl_khr_subgroup_ballot != 1
+#error "Incorrectly defined cl_khr_subgroup_ballot"
+#endif
+#if cl_khr_subgroup_non_uniform_arithmetic != 1
+#error "Incorrectly defined cl_khr_subgroup_non_uniform_arithmetic"
+#endif
+#if cl_khr_subgroup_shuffle != 1
+#error "Incorrectly defined cl_khr_subgroup_shuffle"
+#endif
+#if cl_khr_subgroup_shuffle_relative != 1
+#error "Incorrectly defined cl_khr_subgroup_shuffle_relative"
+#endif
+#if cl_khr_subgroup_clustered_reduce != 1
+#error "Incorrectly defined cl_khr_subgroup_clustered_reduce"
+#endif
+
+#else
+
+#ifdef cl_khr_subgroup_extended_types
+#error "Incorrect cl_khr_subgroup_extended_types define"
+#endif
+#ifdef cl_khr_subgroup_non_uniform_vote
+#error "Incorrect cl_khr_subgroup_non_uniform_vote define"
+#endif
+#ifdef cl_khr_subgroup_ballot
+#error 

[llvm-branch-commits] [lldb] 839e845 - [lldb] Remove assumption from Clang-based data formatters that their types are in the scratch AST

2020-12-10 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-10T17:35:03+01:00
New Revision: 839e845277894ad37fbca8063cbf1955331fbeff

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

LOG: [lldb] Remove assumption from Clang-based data formatters that their types 
are in the scratch AST

Several data formatters assume their types are in the Target's scratch AST and
build new types from that scratch AST instance. However, types from different
ASTs shouldn't be mixed, so this (unchecked) assumption may lead to problems if
we ever have more than one scratch AST or someone somehow invokes data
formatters on a type that are not in the scratch AST.

Instead we can use in all the formatters just the TypeSystem of the type we're
formatting. That's much simpler and avoids all the headache of finding the right
TypeSystem that matches the one of the formatted type.

Right now LLDB only has one scratch TypeSystemClang instance and we format only
types that are in the scratch AST, so this doesn't change anything in the
current way LLDB works. The intention here is to allow follow up refactorings
that introduce multiple scratch ASTs with the same Target.

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

Added: 


Modified: 
lldb/source/DataFormatters/VectorType.cpp
lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
lldb/source/Plugins/Language/ObjC/CoreMedia.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/VectorType.cpp 
b/lldb/source/DataFormatters/VectorType.cpp
index fd1c0bc96cd4..cc24bb1de428 100644
--- a/lldb/source/DataFormatters/VectorType.cpp
+++ b/lldb/source/DataFormatters/VectorType.cpp
@@ -220,20 +220,8 @@ class VectorTypeSyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
 CompilerType parent_type(m_backend.GetCompilerType());
 CompilerType element_type;
 parent_type.IsVectorType(_type, nullptr);
-TypeSystem *type_system = nullptr;
-if (auto target_sp = m_backend.GetTargetSP()) {
-  auto type_system_or_err =
-  target_sp->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC);
-  if (auto err = type_system_or_err.takeError()) {
-LLDB_LOG_ERROR(
-lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS),
-std::move(err), "Unable to update from scratch TypeSystem");
-  } else {
-type_system = _system_or_err.get();
-  }
-}
-m_child_type =
-::GetCompilerTypeForFormat(m_parent_format, element_type, type_system);
+m_child_type = ::GetCompilerTypeForFormat(m_parent_format, element_type,
+  parent_type.GetTypeSystem());
 m_num_children = ::CalculateNumChildren(parent_type, m_child_type);
 m_item_format = GetItemFormatForFormat(m_parent_format, m_child_type);
 return false;

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 42f6bd9ffb7b..35788a6445c2 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -50,11 +50,7 @@ class BlockPointerSyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
 }
 
 TypeSystemClang *clang_ast_context =
-llvm::dyn_cast(_system_or_err.get());
-
-if (!clang_ast_context) {
-  return;
-}
+llvm::cast(block_pointer_type.GetTypeSystem());
 
 std::shared_ptr clang_ast_importer;
 auto *state = target_sp->GetPersistentExpressionStateForLanguage(

diff  --git a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp 
b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
index ac2f45b8354f..efc80cc75557 100644
--- a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
+++ b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
@@ -25,21 +25,12 @@ bool lldb_private::formatters::CMTimeSummaryProvider(
   if (!type.IsValid())
 return false;
 
-  auto type_system_or_err =
-  valobj.GetExecutionContextRef()
-  .GetTargetSP()
-  ->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC);
-  if (auto err = type_system_or_err.takeError()) {
-LLDB_LOG_ERROR(
-lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS),
-std::move(err), "Failed to get scratch type system");
-return false;
-  }
+  TypeSystem *type_system = type.GetTypeSystem();
   // fetch children by offset to compensate for potential lack of debug info
-  auto int64_ty = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
-  eEncodingSint, 64);
-  auto int32_ty = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
-  eEncodingSint, 32);
+  auto int64_ty =
+  type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 64);
+  auto int32_ty =
+  

[llvm-branch-commits] [llvm] c9e967a - [flang]Add Parser Support for Allocate Directive

2020-12-10 Thread Irina Dobrescu via llvm-branch-commits

Author: Irina Dobrescu
Date: 2020-12-10T16:21:19Z
New Revision: c9e967af3fc7ce824cd811379c5e99a998819779

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

LOG: [flang]Add Parser Support for Allocate Directive

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

Added: 
flang/test/Parser/omp-allocate-unparse.f90
flang/test/Semantics/omp-allocate-directive.f90

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

Removed: 




diff  --git a/flang/include/flang/Parser/dump-parse-tree.h 
b/flang/include/flang/Parser/dump-parse-tree.h
index c86c2ec6e66b..791e21fa4b62 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -545,6 +545,7 @@ class ParseTreeDumper {
   NODE(parser, OpenMPCancellationPointConstruct)
   NODE(parser, OpenMPConstruct)
   NODE(parser, OpenMPCriticalConstruct)
+  NODE(parser, OpenMPDeclarativeAllocate)
   NODE(parser, OpenMPDeclarativeConstruct)
   NODE(parser, OpenMPDeclareReductionConstruct)
   NODE(parser, OpenMPDeclareSimdConstruct)
@@ -552,6 +553,7 @@ class ParseTreeDumper {
   NODE(parser, OmpMemoryOrderClause)
   NODE(parser, OpenMPFlushConstruct)
   NODE(parser, OpenMPLoopConstruct)
+  NODE(parser, OpenMPExecutableAllocate)
   NODE(parser, OpenMPSimpleStandaloneConstruct)
   NODE(parser, OpenMPStandaloneConstruct)
   NODE(parser, OpenMPSectionsConstruct)

diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index 6bed37c2b871..ca73af210c15 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3583,11 +3583,19 @@ struct OpenMPThreadprivate {
   std::tuple t;
 };
 
+// 2.11.3 allocate -> ALLOCATE (variable-name-list) [clause]
+struct OpenMPDeclarativeAllocate {
+  TUPLE_CLASS_BOILERPLATE(OpenMPDeclarativeAllocate);
+  CharBlock source;
+  std::tuple t;
+};
+
 struct OpenMPDeclarativeConstruct {
   UNION_CLASS_BOILERPLATE(OpenMPDeclarativeConstruct);
   CharBlock source;
-  std::variant
+  std::variant
   u;
 };
 
@@ -3607,6 +3615,19 @@ struct OpenMPCriticalConstruct {
   std::tuple t;
 };
 
+// 2.11.3 allocate -> ALLOCATE [(variable-name-list)] [clause]
+//[ALLOCATE (variable-name-list) [clause] [...]]
+//allocate-statement
+//clause -> allocator-clause
+struct OpenMPExecutableAllocate {
+  TUPLE_CLASS_BOILERPLATE(OpenMPExecutableAllocate);
+  CharBlock source;
+  std::tuple, OmpClauseList,
+  std::optional>,
+  Statement>
+  t;
+};
+
 // 2.17.7 atomic -> ATOMIC [clause[,]] atomic-clause [[,]clause] |
 //  ATOMIC [clause]
 //clause -> memory-order-clause | HINT(hint-expression)
@@ -3777,6 +3798,7 @@ struct OpenMPConstruct {
   UNION_CLASS_BOILERPLATE(OpenMPConstruct);
   std::variant
   u;
 };

diff  --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 780aea9664fc..cfe4b0b86b67 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -256,6 +256,10 @@ void Fortran::lower::genOpenMPConstruct(
   [&](const Fortran::parser::OpenMPLoopConstruct ) {
 TODO("");
   },
+  [&](const Fortran::parser::OpenMPDeclarativeAllocate
+  ) { TODO(""); },
+  [&](const Fortran::parser::OpenMPExecutableAllocate
+  ) { TODO(""); },
   [&](const Fortran::parser::OpenMPBlockConstruct ) {
 genOMP(converter, eval, blockConstruct);
   },

diff  --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index da10f9ffb0a8..69fc4f0e67ee 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -159,6 +159,8 @@ TYPE_PARSER(
 construct(parenthesized(Parser{})) ||
 "ALLOCATE" >>
 construct(parenthesized(Parser{})) ||
+"ALLOCATOR" >> construct(construct(
+   parenthesized(scalarIntExpr))) ||
 "COLLAPSE" >> construct(construct(
   parenthesized(scalarIntConstantExpr))) ||
 "COPYIN" >> construct(construct(
@@ -454,6 +456,13 @@ 
TYPE_PARSER(sourced(construct(verbatim("CRITICAL"_tok),
 TYPE_PARSER(construct(
 Parser{}, block, Parser{}))
 
+// 2.11.3 Executable Allocate directive
+TYPE_PARSER(
+sourced(construct(verbatim("ALLOCATE"_tok),
+maybe(parenthesized(Parser{})), Parser{},
+maybe(nonemptyList(Parser{})) / endOmpLine,
+

[llvm-branch-commits] [compiler-rt] 8a874a4 - [DFSan] Add custom wrapper for getsockname.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T08:13:05-08:00
New Revision: 8a874a42298d030715e041dcaae132095dee

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

LOG: [DFSan] Add custom wrapper for getsockname.

The wrapper clears shadow for any bytes written to addr or addrlen.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 0cb075ac632a..576f7f64e301 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -927,6 +927,21 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getsockopt(
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getsockname(
+int sockfd, struct sockaddr *addr, socklen_t *addrlen,
+dfsan_label sockfd_label, dfsan_label addr_label, dfsan_label 
addrlen_label,
+dfsan_label *ret_label) {
+  socklen_t origlen = addrlen ? *addrlen : 0;
+  int ret = getsockname(sockfd, addr, addrlen);
+  if (ret != -1 && addr && addrlen) {
+socklen_t written_bytes = origlen < *addrlen ? origlen : *addrlen;
+dfsan_set_label(0, addrlen, sizeof(*addrlen));
+dfsan_set_label(0, addr, written_bytes);
+  }
+  *ret_label = 0;
+  return ret;
+}
+
 // Type of the trampoline function passed to the custom version of
 // dfsan_set_write_callback.
 typedef void (*write_trampoline_t)(

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index 13513cbb0f23..9a92098f22eb 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -194,6 +194,7 @@ fun:get_current_dir_name=custom
 fun:gethostname=custom
 fun:getrlimit=custom
 fun:getrusage=custom
+fun:getsockname=custom
 fun:getsockopt=custom
 fun:nanosleep=custom
 fun:pread=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index b57f172d7e4c..8305941d0054 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -931,6 +931,26 @@ void test_socketpair() {
   ASSERT_READ_ZERO_LABEL(fd, sizeof(fd));
 }
 
+void test_getsockname() {
+  int sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
+  assert(sockfd != -1);
+
+  struct sockaddr addr = {};
+  socklen_t addrlen = sizeof(addr);
+  dfsan_set_label(i_label, , addrlen);
+  dfsan_set_label(i_label, , sizeof(addrlen));
+
+  int ret = getsockname(sockfd, , );
+  assert(ret != -1);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_ZERO_LABEL(addrlen);
+  assert(addrlen < sizeof(addr));
+  ASSERT_READ_ZERO_LABEL(, addrlen);
+  ASSERT_READ_LABEL(((char *)) + addrlen, 1, i_label);
+
+  close(sockfd);
+}
+
 void test_getsockopt() {
   int sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
   assert(sockfd != -1);
@@ -1134,6 +1154,7 @@ int main(void) {
   test_getpwuid_r();
   test_getrlimit();
   test_getrusage();
+  test_getsockname();
   test_getsockopt();
   test_gettimeofday();
   test_inet_pton();



___
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] 4ce242a - [clangd] Find relations in Dex exploration tool.

2020-12-10 Thread Utkarsh Saxena via llvm-branch-commits

Author: Utkarsh Saxena
Date: 2020-12-10T16:54:03+01:00
New Revision: 4ce242a163c3b98385a5cb949a7e6b1e1ae7eb83

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

LOG: [clangd] Find relations in Dex exploration tool.

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index d7da330e2ed0..49f16e72be92 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 
//===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@ class Refs : public Command {
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID , const Symbol ) {
+  llvm::outs() << toYAML(S);
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@ struct {
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", 
std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 



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


[llvm-branch-commits] [flang] 9168a0f - [flang] Fix bogus message on index-names in the presence of associated entities

2020-12-10 Thread Peter Steinfeld via llvm-branch-commits

Author: Peter Steinfeld
Date: 2020-12-10T07:36:41-08:00
New Revision: 9168a0f515c908dc3c3df822f17d489ec8a0caf2

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

LOG: [flang] Fix bogus message on index-names in the presence of associated 
entities

The semantic analysis of index-names of FORALL statements looks up symbols with
the same name as the index-name.  This is needed to exclude symbols that are
not objects.  But if the symbol found is host-, use-, or construct-associated
with another entity, the check fails.

I fixed this by getting the root symbol of the symbol found and doing the check
on the root symbol.  This required creating a non-const version of
"GetAssociationRoot()".

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

Added: 
flang/test/Semantics/resolve99.f90

Modified: 
flang/include/flang/Evaluate/tools.h
flang/lib/Evaluate/tools.cpp
flang/lib/Semantics/resolve-names.cpp

Removed: 




diff  --git a/flang/include/flang/Evaluate/tools.h 
b/flang/include/flang/Evaluate/tools.h
index e7305d47ed10..0501023116d9 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -919,6 +919,7 @@ bool IsLenTypeParameter(const Symbol &);
 
 // Follow use, host, and construct assocations to a variable, if any.
 const Symbol *GetAssociationRoot(const Symbol &);
+Symbol *GetAssociationRoot(Symbol &);
 const Symbol *FindCommonBlockContaining(const Symbol &);
 int CountLenParameters(const DerivedTypeSpec &);
 int CountNonConstantLenParameters(const DerivedTypeSpec &);

diff  --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index 1ae0fce193b1..452ff0f35841 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -931,6 +931,11 @@ const Symbol *GetAssociationRoot(const Symbol ) {
   return details ? GetAssociatedVariable(*details) : 
 }
 
+Symbol *GetAssociationRoot(Symbol ) {
+  return const_cast(
+  GetAssociationRoot(const_cast(symbol)));
+}
+
 bool IsVariableName(const Symbol ) {
   const Symbol *root{GetAssociationRoot(symbol)};
   return root && root->has() && !IsNamedConstant(*root);

diff  --git a/flang/lib/Semantics/resolve-names.cpp 
b/flang/lib/Semantics/resolve-names.cpp
index 0d2b8813c7bb..b0e0b0b80ebf 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -4927,17 +4927,21 @@ void ConstructVisitor::ResolveIndexName(
 // type came from explicit type-spec
   } else if (!prev) {
 ApplyImplicitRules(symbol);
-  } else if (!prev->has() && !prev->has()) 
{
-Say2(name, "Index name '%s' conflicts with existing identifier"_err_en_US,
-*prev, "Previous declaration of '%s'"_en_US);
-return;
-  } else {
-if (const auto *type{prev->GetType()}) {
-  symbol.SetType(*type);
-}
-if (prev->IsObjectArray()) {
-  SayWithDecl(name, *prev, "Index variable '%s' is not scalar"_err_en_US);
+  } else if (const Symbol * prevRoot{GetAssociationRoot(*prev)}) {
+// prev could be host- use- or construct-associated with another symbol
+if (!prevRoot->has() &&
+!prevRoot->has()) {
+  Say2(name, "Index name '%s' conflicts with existing 
identifier"_err_en_US,
+  *prev, "Previous declaration of '%s'"_en_US);
   return;
+} else {
+  if (const auto *type{prevRoot->GetType()}) {
+symbol.SetType(*type);
+  }
+  if (prevRoot->IsObjectArray()) {
+SayWithDecl(name, *prev, "Index variable '%s' is not 
scalar"_err_en_US);
+return;
+  }
 }
   }
   EvaluateExpr(parser::Scalar{parser::Integer{common::Clone(name)}});

diff  --git a/flang/test/Semantics/resolve99.f90 
b/flang/test/Semantics/resolve99.f90
new file mode 100644
index ..a1c8c10af4ee
--- /dev/null
+++ b/flang/test/Semantics/resolve99.f90
@@ -0,0 +1,51 @@
+! RUN: %S/test_errors.sh %s %t %f18
+
+! Tests for the index-name of a FORALL statement
+
+module m1
+  integer modVar
+end module m1
+
+program indexName
+  common /iCommonName/ x
+  type ::  typeName
+  end type
+  iGlobalVar = 216
+
+contains
+  subroutine hostAssoc()
+integer, dimension(4) :: table
+
+  ! iGlobalVar is host associated with the global variable
+iGlobalVar = 1
+FORALL (iGlobalVar=1:4) table(iGlobalVar) = 343
+  end subroutine hostAssoc
+
+  subroutine useAssoc()
+use m1
+integer, dimension(4) :: tab
+  ! modVar is use associated with the module variable
+FORALL (modVar=1:4) tab(modVar) = 343
+  end subroutine useAssoc
+
+  subroutine constructAssoc()
+integer, dimension(4) :: table
+integer :: localVar
+associate (assocVar => localVar)
+  ! assocVar is construct associated with localVar
+  FORALL (assocVar=1:4) table(assocVar) = 343
+end associate
+  end subroutine 

[llvm-branch-commits] [llvm] 456c885 - Revert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"

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

Author: clementval
Date: 2020-12-10T10:34:59-05:00
New Revision: 456c885df369f1e94d60da2658055b21c88e471d

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

LOG: Revert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"

This reverts commit a7b2847216b4f7a84ef75461fd47a5adfbb63e27.

failing buildbot on warnings

Added: 


Modified: 
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/include/llvm/TableGen/DirectiveEmitter.h
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTFwd.h 
b/clang/include/clang/AST/ASTFwd.h
index 6eceb526ca4c..65319a19728b 100644
--- a/clang/include/clang/AST/ASTFwd.h
+++ b/clang/include/clang/AST/ASTFwd.h
@@ -27,9 +27,9 @@ class Type;
 #include "clang/AST/TypeNodes.inc"
 class CXXCtorInitializer;
 class OMPClause;
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) class Class;
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class;
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index 92123ed2a32a..ea3da8d90c5b 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -147,9 +147,8 @@ class ASTNodeKind {
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.inc"
 NKI_OMPClause,
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 NKI_NumberOfKinds
   };
 
@@ -206,9 +205,8 @@ KIND_TO_KIND_ID(CXXBaseSpecifier)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.inc"
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream <<(raw_ostream , ASTNodeKind K) {

diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 57ba4fa5510f..cc6d3a93ba09 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7758,22 +7758,20 @@ class OMPClauseVisitorBase {
 #define DISPATCH(CLASS) \
   return 
static_cast(this)->Visit##CLASS(static_cast(S))
 
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) 
\
-  RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
+  RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 
   RetTy Visit(PTR(OMPClause) S) {
 // Top switch clause: visit each OMPClause.
 switch (S->getClauseKind()) {
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) 
\
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) 
\
   case llvm::omp::Clause::Enum:
\
 return Visit##Class(static_cast(S));
-#define CLAUSE_NO_CLASS(Enum, Str) 
\
+#define OMP_CLAUSE_NO_CLASS(Enum, Str) 
\
   case llvm::omp::Clause::Enum:
\
 break;
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 default:
   break;
 }
@@ -7806,9 +7804,9 @@ class OMPClausePrinter final : public 
OMPClauseVisitor {
   OMPClausePrinter(raw_ostream , const PrintingPolicy )
   : OS(OS), Policy(Policy) {}
 
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class)

[llvm-branch-commits] [llvm] d2a7b83 - AA: make AliasAnalysis.h compatible with C++20 (NFC)

2020-12-10 Thread Nuno Lopes via llvm-branch-commits

Author: Nuno Lopes
Date: 2020-12-10T15:32:11Z
New Revision: d2a7b83c5c7b9b26e73261be2a4d60a5b53ba80f

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

LOG: AA: make AliasAnalysis.h compatible with C++20 (NFC)
can't mix arithmetic with different enums

Added: 


Modified: 
llvm/include/llvm/Analysis/AliasAnalysis.h

Removed: 




diff  --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index ce4ebab3efa4..cc5cec44b455 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -540,7 +540,7 @@ class AAResults {
   /// write at most from objects pointed to by their pointer-typed arguments
   /// (with arbitrary offsets).
   static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB) {
-return !(MRB & FMRL_Anywhere & ~FMRL_ArgumentPointees);
+return !((unsigned)MRB & FMRL_Anywhere & ~FMRL_ArgumentPointees);
   }
 
   /// Checks if functions with the specified behavior are known to potentially
@@ -548,26 +548,27 @@ class AAResults {
   /// (with arbitrary offsets).
   static bool doesAccessArgPointees(FunctionModRefBehavior MRB) {
 return isModOrRefSet(createModRefInfo(MRB)) &&
-   (MRB & FMRL_ArgumentPointees);
+   ((unsigned)MRB & FMRL_ArgumentPointees);
   }
 
   /// Checks if functions with the specified behavior are known to read and
   /// write at most from memory that is inaccessible from LLVM IR.
   static bool onlyAccessesInaccessibleMem(FunctionModRefBehavior MRB) {
-return !(MRB & FMRL_Anywhere & ~FMRL_InaccessibleMem);
+return !((unsigned)MRB & FMRL_Anywhere & ~FMRL_InaccessibleMem);
   }
 
   /// Checks if functions with the specified behavior are known to potentially
   /// read or write from memory that is inaccessible from LLVM IR.
   static bool doesAccessInaccessibleMem(FunctionModRefBehavior MRB) {
-return isModOrRefSet(createModRefInfo(MRB)) && (MRB & 
FMRL_InaccessibleMem);
+return isModOrRefSet(createModRefInfo(MRB)) &&
+ ((unsigned)MRB & FMRL_InaccessibleMem);
   }
 
   /// Checks if functions with the specified behavior are known to read and
   /// write at most from memory that is inaccessible from LLVM IR or objects
   /// pointed to by their pointer-typed arguments (with arbitrary offsets).
   static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB) {
-return !(MRB & FMRL_Anywhere &
+return !((unsigned)MRB & FMRL_Anywhere &
  ~(FMRL_InaccessibleMem | FMRL_ArgumentPointees));
   }
 



___
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] 985739e - [gn build] fix build after a7b2847216b4f7

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

Author: Nico Weber
Date: 2020-12-10T10:28:48-05:00
New Revision: 985739ec059d23d7478ea1eee5a14e8160658c1b

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

LOG: [gn build] fix build after a7b2847216b4f7

Ports 6e42a417bacb since it's now needed, and undo an accidental
deletion from d69762c404ded while here (this part is not needed to fix
the build, it's just in the vicinity).

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn
llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn
index acb545f41986..26c9b52a1660 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn
@@ -6,7 +6,7 @@ tablegen("ACC") {
   output_name = "ACC.h.inc"
 }
 
-tablegen("ACC.cpp") {
+tablegen("ACCcpp") {
   visibility = [ ":acc_gen" ]
   args = [ "-gen-directive-gen" ]
   output_name = "ACC.cpp.inc"
@@ -14,5 +14,8 @@ tablegen("ACC.cpp") {
 }
 
 group("acc_gen") {
-  deps = [ ":ACC" ]
+  deps = [
+":ACC",
+":ACCcpp",
+  ]
 }

diff  --git 
a/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn
index a18f8db5f5eb..6fe62a0f5a71 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn
@@ -6,6 +6,13 @@ tablegen("OMP") {
   output_name = "OMP.h.inc"
 }
 
+tablegen("OMPcpp") {
+  visibility = [ ":public_tablegen" ]
+  args = [ "-gen-directive-gen" ]
+  output_name = "OMP.cpp.inc"
+  td_file = "OMP.td"
+}
+
 # Groups all tablegen() calls that create .inc files that are included in
 # Frontent/OpenMP's public headers (just one so far).
 # //llvm/lib/Frontend/OpenMP has this as a public_dep, so targets depending on
@@ -14,5 +21,6 @@ group("public_tablegen") {
   public_deps = [
 # Frontend/OpenMP's public headers include OMP.h.inc.
 ":OMP",
+":OMPcpp",
   ]
 }



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


[llvm-branch-commits] [lldb] b505142 - [lldb/test] Change base class of lldb-server tests

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

Author: Pavel Labath
Date: 2020-12-10T16:21:28+01:00
New Revision: b505142fa5d301238796318d2d092d6fb3bd2d31

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

LOG: [lldb/test] Change base class of lldb-server tests

lldb-server tests are a very special subclass of "api" tests. As they
communicate with lldb-server directly, they don't actually need most of
facilities provided by our TestBase class. In particular, they don't
need the ability to fork debug info flavours of tests (but they could
use debug server flavours).

This makes them inherit from "Base" instead. This avoids the need to
explicitly mark these tests as NO_DEBUG_INFO_TEST_CASE. Two additional
necessary tweaks were:
- move run_platform_command to the base (Base) class. This is used in
  one test, and can be generally useful when running tests remotely.
- add a "build" method, forwarding to buildDefault. This is to avoid
  updating each test case to use buildDefault (also, "build" sounds
  better). It might be interesting to refactor the (Test)Base classes so
  that all debug info flavour handling happens in TestBase, and the Base
  class provides a simple build method automatically.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 1f3bc7722290..d240050cc4c6 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1785,6 +1785,12 @@ def getLibcPlusPlusLibs(self):
 else:
 return ['libc++.1.dylib', 'libc++abi.']
 
+def run_platform_command(self, cmd):
+platform = self.dbg.GetSelectedPlatform()
+shell_command = lldb.SBPlatformShellCommand(cmd)
+err = platform.Run(shell_command)
+return (err, shell_command.GetStatus(), shell_command.GetOutput())
+
 # Metaclass for TestBase to change the list of test metods when a new TestCase 
is loaded.
 # We change the test methods to create a new test method for each test for 
each debug info we are
 # testing. The name of the new test method will be 
'_' and with adding
@@ -2656,12 +2662,6 @@ def build(
 else:
 self.fail("Can't build for debug info: %s" % self.getDebugInfo())
 
-def run_platform_command(self, cmd):
-platform = self.dbg.GetSelectedPlatform()
-shell_command = lldb.SBPlatformShellCommand(cmd)
-err = platform.Run(shell_command)
-return (err, shell_command.GetStatus(), shell_command.GetOutput())
-
 """Assert that an lldb.SBError is in the "success" state."""
 def assertSuccess(self, obj, msg=None):
 if not obj.Success():

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 2908ca2809a9..b578aae12062 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -27,9 +27,7 @@ class _ConnectionRefused(IOError):
 pass
 
 
-class GdbRemoteTestCaseBase(TestBase):
-
-NO_DEBUG_INFO_TESTCASE = True
+class GdbRemoteTestCaseBase(Base):
 
 # Default time out in seconds. The timeout is increased tenfold under Asan.
 DEFAULT_TIMEOUT =  20 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
@@ -83,7 +81,7 @@ def isVerboseLoggingRequested(self):
for channel in lldbtest_config.channels)
 
 def setUp(self):
-TestBase.setUp(self)
+super(GdbRemoteTestCaseBase, self).setUp()
 
 self.setUpBaseLogging()
 self.debug_monitor_extra_args = []
@@ -121,6 +119,9 @@ def tearDown(self):
 self._verbose_log_handler = None
 TestBase.tearDown(self)
 
+def build(self, *args, **kwargs):
+self.buildDefault(*args, **kwargs)
+
 def getLocalServerLogFile(self):
 return self.log_basename + "-server.log"
 



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


[llvm-branch-commits] [lldb] db84208 - [lldb/test] Replace ad-hoc server test choice with test categories

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

Author: Pavel Labath
Date: 2020-12-10T16:21:28+01:00
New Revision: db8420825073371ddc077b020634e71e315e38a1

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

LOG: [lldb/test] Replace ad-hoc server test choice with test categories

This makes things consistent, and enables further simplifications down
the road.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/test_categories.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index bcf665f6cc4c..ff445fa0b926 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -373,20 +373,12 @@ def should_skip_simulator_test():
 
 def debugserver_test(func):
 """Decorate the item as a debugserver test."""
-def should_skip_debugserver_test():
-return ("debugserver tests"
-if not configuration.debugserver_platform
-else None)
-return skipTestIfFn(should_skip_debugserver_test)(func)
+return add_test_categories(["debugserver"])(func)
 
 
 def llgs_test(func):
 """Decorate the item as a lldb-server test."""
-def should_skip_llgs_tests():
-return ("llgs tests"
-if not configuration.llgs_platform
-else None)
-return skipTestIfFn(should_skip_llgs_tests)(func)
+return add_test_categories(["llgs"])(func)
 
 
 def expectedFailureOS(

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 64a197872f9e..86ea34ee2582 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -850,6 +850,14 @@ def checkDebugInfoSupport():
 if skipped:
 print("Skipping following debug info categories:", skipped)
 
+def checkDebugServerSupport():
+from lldbsuite.test import lldbplatformutil
+
+if lldbplatformutil.platformIsDarwin():
+configuration.skip_categories.append("llgs")
+else:
+configuration.skip_categories.append("debugserver")
+
 def run_suite():
 # On MacOS X, check to make sure that domain for com.apple.DebugSymbols 
defaults
 # does not exist before proceeding to running the test suite.
@@ -944,15 +952,9 @@ def run_suite():
 checkLibstdcxxSupport()
 checkWatchpointSupport()
 checkDebugInfoSupport()
+checkDebugServerSupport()
 checkObjcSupport()
 
-# Perform LLGS tests only on platforms using it.
-configuration.llgs_platform = (
-target_platform in ["freebsd", "linux", "netbsd", "windows"])
-
-# Perform debugserver tests elsewhere (i.e. on Darwin platforms).
-configuration.debugserver_platform = not configuration.llgs_platform
-
 for testdir in configuration.testdirs:
 for (dirpath, dirnames, filenames) in os.walk(testdir):
 visit('Test', dirpath, filenames)

diff  --git a/lldb/packages/Python/lldbsuite/test/test_categories.py 
b/lldb/packages/Python/lldbsuite/test/test_categories.py
index 699fcf4cb887..9f1196ea6497 100644
--- a/lldb/packages/Python/lldbsuite/test/test_categories.py
+++ b/lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -23,6 +23,7 @@
 'cmdline': 'Tests related to the LLDB command-line interface',
 'darwin-log': 'Darwin log tests',
 'dataformatters': 'Tests related to the type command and the data 
formatters subsystem',
+'debugserver': 'Debugserver tests',
 'dsym': 'Tests that can be run with DSYM debug information',
 'dwarf': 'Tests that can be run with DWARF debug information',
 'dwo': 'Tests that can be run with DWO debug information',
@@ -35,6 +36,7 @@
 'libstdcxx': 'Test for libstdcxx data formatters',
 'lldb-server': 'Tests related to lldb-server',
 'lldb-vscode': 'Visual Studio Code debug adaptor tests',
+'llgs': 'Tests for the gdb-server functionality of lldb-server',
 'objc': 'Tests related to the Objective-C programming language support',
 'pyapi': 'Tests related to the Python API',
 'std-module': 'Tests related to importing the std module',



___
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] a7b2847 - [openmp] Remove clause from OMPKinds.def and use OMP.td info

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

Author: Valentin Clement
Date: 2020-12-10T10:19:09-05:00
New Revision: a7b2847216b4f7a84ef75461fd47a5adfbb63e27

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

LOG: [openmp] Remove clause from OMPKinds.def and use OMP.td info

Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for 
the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros 
previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/include/llvm/TableGen/DirectiveEmitter.h
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTFwd.h 
b/clang/include/clang/AST/ASTFwd.h
index 65319a19728b..6eceb526ca4c 100644
--- a/clang/include/clang/AST/ASTFwd.h
+++ b/clang/include/clang/AST/ASTFwd.h
@@ -27,9 +27,9 @@ class Type;
 #include "clang/AST/TypeNodes.inc"
 class CXXCtorInitializer;
 class OMPClause;
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
-
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) class Class;
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index ea3da8d90c5b..92123ed2a32a 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -147,8 +147,9 @@ class ASTNodeKind {
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.inc"
 NKI_OMPClause,
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 NKI_NumberOfKinds
   };
 
@@ -205,8 +206,9 @@ KIND_TO_KIND_ID(CXXBaseSpecifier)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.inc"
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream <<(raw_ostream , ASTNodeKind K) {

diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index cc6d3a93ba09..57ba4fa5510f 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7758,20 +7758,22 @@ class OMPClauseVisitorBase {
 #define DISPATCH(CLASS) \
   return 
static_cast(this)->Visit##CLASS(static_cast(S))
 
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
-  RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) 
\
+  RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 
   RetTy Visit(PTR(OMPClause) S) {
 // Top switch clause: visit each OMPClause.
 switch (S->getClauseKind()) {
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) 
\
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) 
\
   case llvm::omp::Clause::Enum:
\
 return Visit##Class(static_cast(S));
-#define OMP_CLAUSE_NO_CLASS(Enum, Str) 
\
+#define CLAUSE_NO_CLASS(Enum, Str) 
\
   case llvm::omp::Clause::Enum:
\
 break;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 default:
   break;
 }
@@ -7804,9 

[llvm-branch-commits] [clang-tools-extra] a0cf2b8 - [clangd][NFC] Remove unnecessary vector.

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

Author: Nathan James
Date: 2020-12-10T14:59:17Z
New Revision: a0cf2b8f712e0bca9185d77cf1def8160f165548

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

LOG: [clangd][NFC] Remove unnecessary vector.

As pointed out in D92788.

Reviewed By: kbobyrev

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/TestTU.cpp 
b/clang-tools-extra/clangd/unittests/TestTU.cpp
index 27019403ae85..3b1130444671 100644
--- a/clang-tools-extra/clangd/unittests/TestTU.cpp
+++ b/clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -187,9 +187,6 @@ const Symbol (const SymbolSlab , 
llvm::StringRef QName) {
 }
 
 const NamedDecl (ParsedAST , llvm::StringRef QName) {
-  llvm::SmallVector Components;
-  QName.split(Components, "::");
-
   auto  = AST.getASTContext();
   auto LookupDecl = [](const DeclContext ,
llvm::StringRef Name) -> const NamedDecl & {
@@ -200,11 +197,13 @@ const NamedDecl (ParsedAST , llvm::StringRef 
QName) {
   };
 
   const DeclContext *Scope = Ctx.getTranslationUnitDecl();
-  for (auto NameIt = Components.begin(), End = Components.end() - 1;
-   NameIt != End; ++NameIt) {
-Scope = (LookupDecl(*Scope, *NameIt));
+
+  StringRef Cur, Rest;
+  for (std::tie(Cur, Rest) = QName.split("::"); !Rest.empty();
+   std::tie(Cur, Rest) = Rest.split("::")) {
+Scope = (LookupDecl(*Scope, Cur));
   }
-  return LookupDecl(*Scope, Components.back());
+  return LookupDecl(*Scope, Cur);
 }
 
 const NamedDecl (ParsedAST ,



___
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] 7c9afe9 - [Hexagon] Fix gcc6 compilation issue

2020-12-10 Thread Krzysztof Parzyszek via llvm-branch-commits

Author: Krzysztof Parzyszek
Date: 2020-12-10T08:17:07-06:00
New Revision: 7c9afe9183ee5b2b649bfa34da2a83eca886a924

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

LOG: [Hexagon] Fix gcc6 compilation issue

Added: 


Modified: 
llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Removed: 




diff  --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp 
b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
index 8af1f6d15ad1..7791fb9a1a74 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -483,7 +483,7 @@ auto AlignVectors::createAddressGroups() -> bool {
   auto traverseBlock = [&](DomTreeNode *DomN, auto Visit) -> void {
 BasicBlock  = *DomN->getBlock();
 for (Instruction  : Block) {
-  auto AI = getAddrInfo(I);
+  auto AI = this->getAddrInfo(I); // Use this-> for gcc6.
   if (!AI)
 continue;
   auto F = findBaseAndOffset(*AI);



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


[llvm-branch-commits] [lldb] 25c40a4 - [lldb] [docs] Add a manpage for lldb-server

2020-12-10 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-12-10T15:02:25+01:00
New Revision: 25c40a45999e59e3b2902cd91373cd47e7a93488

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

LOG: [lldb] [docs] Add a manpage for lldb-server

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

Added: 
lldb/docs/man/lldb-server.rst

Modified: 
lldb/docs/conf.py

Removed: 




diff  --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index cdab1b00e1b7..4d894bf050da 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -246,7 +246,9 @@
 
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
-man_pages = [('man/lldb', 'lldb', u'LLDB Documentation', [u'LLVM project'], 1)]
+man_pages = [('man/lldb', 'lldb', u'LLDB Documentation', [u'LLVM project'], 1),
+ ('man/lldb-server', 'lldb-server', u'LLDB Documentation', [u'LLVM 
project'], 1),
+ ]
 
 # If true, show URL addresses after external links.
 #man_show_urls = False

diff  --git a/lldb/docs/man/lldb-server.rst b/lldb/docs/man/lldb-server.rst
new file mode 100644
index ..a67c00b305f6
--- /dev/null
+++ b/lldb/docs/man/lldb-server.rst
@@ -0,0 +1,209 @@
+:orphan:
+
+lldb-server -- Server for LLDB Debugging Sessions
+=
+
+.. program:: lldb-server
+
+SYNOPSIS
+
+
+| :program:`lldb-server` v[ersion]
+| :program:`lldb-server` g[dbserver] [*options*]
+| :program:`lldb-server` p[latform] [*options*]
+
+DESCRIPTION
+---
+
+:program:`lldb-server` provides the server counterpart of the LLVM debugger.
+The server runs and monitors the debugged program, while the user interfaces
+with it via a client, either running locally or connecting remotely.
+
+All of the code in the LLDB project is available under the Apache 2.0 License
+with LLVM exceptions.
+
+COMMANDS
+
+
+The first argument to lldb-server specifies a command to run.
+
+.. option:: v[ersion]
+
+ Prints lldb-server version and exits.
+
+.. option:: g[dbserver]
+
+ Runs the server using the gdb-remote protocol. LLDB can afterwards
+ connect to the server using *gdb-remote* command.
+
+.. option:: p[latform]
+
+ Runs the platform server. LLDB can afterwards connect to the server using
+ *platform select*, followed by *platform connect*.
+
+GDBSERVER COMMAND
+-
+
+| :program:`lldb-server` g[dbserver] [*options*] [[*host*]:*port*] [[--] 
*program* *args*...]
+
+CONNECTION
+~~
+
+.. option:: host:port
+
+ Specifies the hostname and TCP port to listen on. Obligatory unless another
+ listening option is used. If host is empty, *localhost* will be used.  If port
+ is zero, a random port will be selected, and written as specified by --pipe
+ or --named-pipe options.
+
+.. option:: --fd 
+
+ Communicate over the given file descriptor instead of sockets.
+
+.. option:: --named-pipe 
+
+ Write the listening port number to the specified named pipe.
+
+.. option:: --pipe 
+
+ Write the listening port number to the specified pipe (fd).
+
+.. option:: --reverse-connect
+
+ Connect to the client instead of passively waiting for a connection. In this
+ case, [host]:port denotes the remote address to connect to.
+
+GENERAL OPTIONS
+~~~
+
+.. option:: --help
+
+ Prints out the usage information and exits.
+
+.. option:: --log-channels 
+
+ Channels to log. A colon-separated list of entries. Each entry starts with
+ a channel followed by a space-separated list of categories.
+
+.. option:: --log-file 
+
+ Destination file to log to. If empty, log to stderr.
+
+.. option:: --setsid
+
+ Run lldb-server in a new session.
+
+TARGET SELECTION
+
+
+.. option:: --attach 
+
+ Attach to the process given by a (numeric) process id or a name.
+
+.. option:: -- program args
+
+ Launch a program for debugging.
+
+If neither of target options are used, :program:`lldb-server` is started
+without a specific target. It can be afterwards instructed by the client
+to launch or attach.
+
+PLATFORM COMMAND
+
+
+| :program:`lldb-server` p[latform] [*options*] --server --listen 
[[*host*]:*port*]
+
+CONNECTION
+~~
+
+.. option:: --server
+
+ Run in server mode, handling multiple connections. If this is not specified,
+ lldb-server will accept only one connection and exit when it is finished.
+
+.. option:: --listen :
+
+ Hostname and port to listen on. Obligatory. If *port* is zero, a random port
+ will be used.
+
+.. option:: --socket-file 
+
+ Write the listening socket port number to the specified file.
+
+GENERAL OPTIONS
+~~~
+
+.. option:: --log-channels 
+
+ Channels to log. A colon-separated list of entries. Each entry starts with
+ a channel followed by a space-separated list of categories.
+
+.. option:: 

[llvm-branch-commits] [llvm] abe7775 - [SVE][CodeGen] Extend index of masked gathers

2020-12-10 Thread Kerry McLaughlin via llvm-branch-commits

Author: Kerry McLaughlin
Date: 2020-12-10T13:54:45Z
New Revision: abe7775f5a43e5a0d8ec237542274ba3e73937e4

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

LOG: [SVE][CodeGen] Extend index of masked gathers

This patch changes performMSCATTERCombine to also promote the indices of
masked gathers where the element type is i8 or i16, and adds various tests
for gathers with illegal types.

Reviewed By: sdesmalen

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

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sve-masked-gather-legalize.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 5d9c66e170eab..01301abf10e3d 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -849,6 +849,7 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine ,
   if (Subtarget->supportsAddressTopByteIgnored())
 setTargetDAGCombine(ISD::LOAD);
 
+  setTargetDAGCombine(ISD::MGATHER);
   setTargetDAGCombine(ISD::MSCATTER);
 
   setTargetDAGCombine(ISD::MUL);
@@ -14063,20 +14064,19 @@ static SDValue performSTORECombine(SDNode *N,
   return SDValue();
 }
 
-static SDValue performMSCATTERCombine(SDNode *N,
+static SDValue performMaskedGatherScatterCombine(SDNode *N,
   TargetLowering::DAGCombinerInfo ,
   SelectionDAG ) {
-  MaskedScatterSDNode *MSC = cast(N);
-  assert(MSC && "Can only combine scatter store nodes");
+  MaskedGatherScatterSDNode *MGS = cast(N);
+  assert(MGS && "Can only combine gather load or scatter store nodes");
 
-  SDLoc DL(MSC);
-  SDValue Chain = MSC->getChain();
-  SDValue Scale = MSC->getScale();
-  SDValue Index = MSC->getIndex();
-  SDValue Data = MSC->getValue();
-  SDValue Mask = MSC->getMask();
-  SDValue BasePtr = MSC->getBasePtr();
-  ISD::MemIndexType IndexType = MSC->getIndexType();
+  SDLoc DL(MGS);
+  SDValue Chain = MGS->getChain();
+  SDValue Scale = MGS->getScale();
+  SDValue Index = MGS->getIndex();
+  SDValue Mask = MGS->getMask();
+  SDValue BasePtr = MGS->getBasePtr();
+  ISD::MemIndexType IndexType = MGS->getIndexType();
 
   EVT IdxVT = Index.getValueType();
 
@@ -14086,16 +14086,27 @@ static SDValue performMSCATTERCombine(SDNode *N,
 if ((IdxVT.getVectorElementType() == MVT::i8) ||
 (IdxVT.getVectorElementType() == MVT::i16)) {
   EVT NewIdxVT = IdxVT.changeVectorElementType(MVT::i32);
-  if (MSC->isIndexSigned())
+  if (MGS->isIndexSigned())
 Index = DAG.getNode(ISD::SIGN_EXTEND, DL, NewIdxVT, Index);
   else
 Index = DAG.getNode(ISD::ZERO_EXTEND, DL, NewIdxVT, Index);
 
-  SDValue Ops[] = { Chain, Data, Mask, BasePtr, Index, Scale };
-  return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
-  MSC->getMemoryVT(), DL, Ops,
-  MSC->getMemOperand(), IndexType,
-  MSC->isTruncatingStore());
+  if (auto *MGT = dyn_cast(MGS)) {
+SDValue PassThru = MGT->getPassThru();
+SDValue Ops[] = { Chain, PassThru, Mask, BasePtr, Index, Scale };
+return DAG.getMaskedGather(DAG.getVTList(N->getValueType(0), 
MVT::Other),
+   PassThru.getValueType(), DL, Ops,
+   MGT->getMemOperand(),
+   MGT->getIndexType(), 
MGT->getExtensionType());
+  } else {
+auto *MSC = cast(MGS);
+SDValue Data = MSC->getValue();
+SDValue Ops[] = { Chain, Data, Mask, BasePtr, Index, Scale };
+return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
+MSC->getMemoryVT(), DL, Ops,
+MSC->getMemOperand(), IndexType,
+MSC->isTruncatingStore());
+  }
 }
   }
 
@@ -15072,9 +15083,6 @@ static SDValue performGatherLoadCombine(SDNode *N, 
SelectionDAG ,
 static SDValue
 performSignExtendInRegCombine(SDNode *N, TargetLowering::DAGCombinerInfo ,
   SelectionDAG ) {
-  if (DCI.isBeforeLegalizeOps())
-return SDValue();
-
   SDLoc DL(N);
   SDValue Src = N->getOperand(0);
   unsigned Opc = Src->getOpcode();
@@ -15109,6 +15117,9 @@ performSignExtendInRegCombine(SDNode *N, 
TargetLowering::DAGCombinerInfo ,
 return DAG.getNode(SOpc, DL, N->getValueType(0), Ext);
   }
 
+  if (DCI.isBeforeLegalizeOps())
+return SDValue();
+
   if (!EnableCombineMGatherIntrinsics)
 return SDValue();
 
@@ -15296,8 +15307,9 @@ SDValue AArch64TargetLowering::PerformDAGCombine(SDNode 
*N,
 

[llvm-branch-commits] [llvm] 2fc4afd - Fix a -Wunused-variable warning in release build.

2020-12-10 Thread Haojian Wu via llvm-branch-commits

Author: Haojian Wu
Date: 2020-12-10T14:52:45+01:00
New Revision: 2fc4afda0f57d6c99b591c1f71f6da933d5e7b31

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

LOG: Fix a -Wunused-variable warning in release build.

Added: 


Modified: 
llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp

Removed: 




diff  --git a/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp 
b/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
index 909d478a95ca..62f23cf49073 100644
--- a/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
+++ b/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
@@ -257,6 +257,7 @@ bool MVEVPTOptimisations::MergeLoopEnd(MachineLoop *ML) {
   TII->get(ARM::t2LoopEndDec), DecReg)
   .addReg(PhiReg)
   .add(LoopEnd->getOperand(1));
+  (void)MI;
   LLVM_DEBUG(dbgs() << "Merged LoopDec and End into: " << *MI.getInstr());
 
   LoopDec->eraseFromParent();



___
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] 4b1e329 - [VE] Add vector reduce intrinsic instructions

2020-12-10 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-12-10T22:21:17+09:00
New Revision: 4b1e32925528b546de445ca81999f270acd54618

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

LOG: [VE] Add vector reduce intrinsic instructions

Add vrmax, vrmin, vfrmax, vfrmin, vrand, vror, and vrxor intrinsic
instructions and regression tests.

Reviewed By: simoll

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

Added: 
llvm/test/CodeGen/VE/VELIntrinsics/vfrmax.ll
llvm/test/CodeGen/VE/VELIntrinsics/vfrmin.ll
llvm/test/CodeGen/VE/VELIntrinsics/vrand.ll
llvm/test/CodeGen/VE/VELIntrinsics/vrmax.ll
llvm/test/CodeGen/VE/VELIntrinsics/vrmin.ll
llvm/test/CodeGen/VE/VELIntrinsics/vror.ll
llvm/test/CodeGen/VE/VELIntrinsics/vrxor.ll

Modified: 
llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td 
b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
index d2d965085526..1db7003f0ffd 100644
--- a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
+++ b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
@@ -1094,3 +1094,49 @@ let TargetPrefix = "ve" in def int_ve_vl_vfsumd_vvl : 
GCCBuiltin<"__builtin_ve_v
 let TargetPrefix = "ve" in def int_ve_vl_vfsumd_vvml : 
GCCBuiltin<"__builtin_ve_vl_vfsumd_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
 let TargetPrefix = "ve" in def int_ve_vl_vfsums_vvl : 
GCCBuiltin<"__builtin_ve_vl_vfsums_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
 let TargetPrefix = "ve" in def int_ve_vl_vfsums_vvml : 
GCCBuiltin<"__builtin_ve_vl_vfsums_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswfstsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswfstsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswfstsx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswfstsx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswlstsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswlstsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswlstsx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswlstsx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswfstzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswfstzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswfstzx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswfstzx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswlstzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswlstzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswlstzx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswlstzx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswfstsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswfstsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswfstsx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswfstsx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswlstsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswlstsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswlstsx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswlstsx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswfstzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswfstzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswfstzx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswfstzx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswlstzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswlstzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswlstzx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswlstzx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxslfst_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxslfst_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxslfst_vvvl : 

[llvm-branch-commits] [llvm] 99ad078 - [AArch64] Cortex-R82: remove crypto

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

Author: Sjoerd Meijer
Date: 2020-12-10T12:54:51Z
New Revision: 99ad078b91ed601cd19c75a44106a4f86bfa1a41

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

LOG: [AArch64] Cortex-R82: remove crypto

Remove target features crypto for Cortex-R82, because it doesn't have any, and
add LSE which was missing while we are at it.
This also removes crypto from the v8-R architecture description because that
aligns better with GCC and so far none of the R-cores have implemented crypto,
so is probably a more sensible default.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index fca6d95d361b..13e4cac292d0 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -317,8 +317,7 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   NoCrypto = true;
   }
 
-  if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd ||
-  std::find(ItBegin, ItEnd, "+v8r") != ItEnd) {
+  if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd) {
 if (HasCrypto && !NoCrypto) {
   // Check if we have NOT disabled an algorithm with something like:
   //   +crypto, -algorithm

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index f0b01f519a85..178098197d53 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -240,7 +240,7 @@
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
-// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fp16fml" "-target-feature" "+ras" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" 
"+fullfp16" "-target-feature" "+sm4" "-target-feature" "+sha3" 
"-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+fullfp16"
 // CHECK-MCPU-M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-M4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fullfp16"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"

diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.def 
b/llvm/include/llvm/Support/AArch64TargetParser.def
index 7625f5a6f6ab..34b6f72d4621 100644
--- a/llvm/include/llvm/Support/AArch64TargetParser.def
+++ b/llvm/include/llvm/Support/AArch64TargetParser.def
@@ -51,14 +51,14 @@ AARCH64_ARCH("armv8.6-a", ARMV8_6A, "8.6-A", "v8.6a",
   AArch64::AEK_RDM  | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
   AArch64::AEK_SM4  | AArch64::AEK_SHA3 | AArch64::AEK_BF16|
   AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM))
+// For v8-R, we do not enable crypto and align with GCC that enables a more
+// minimal set of optional architecture extensions.
 AARCH64_ARCH("armv8-r", ARMV8R, "8-R", "v8r",
  ARMBuildAttrs::CPUArch::v8_R, FK_CRYPTO_NEON_FP_ARMV8,
- (AArch64::AEK_CRC | AArch64::AEK_RDM  | AArch64::AEK_SSBS|
-  AArch64::AEK_CRYPTO  | AArch64::AEK_SM4  | AArch64::AEK_SHA3|
-  AArch64::AEK_SHA2| AArch64::AEK_AES  | AArch64::AEK_DOTPROD |
-  AArch64::AEK_FP  | AArch64::AEK_SIMD | AArch64::AEK_FP16|
-  AArch64::AEK_FP16FML | AArch64::AEK_RAS  | AArch64::AEK_RCPC|
-  AArch64::AEK_SB))
+ 

[llvm-branch-commits] [lldb] b9f0713 - [lldb/Docs] Fix lldb-x86_64-fedora URL as it is still a silent bot

2020-12-10 Thread Jan Kratochvil via llvm-branch-commits

Author: Jan Kratochvil
Date: 2020-12-10T13:52:10+01:00
New Revision: b9f0713f73a5aae97262f3cf07d74a96cbef8aa8

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

LOG: [lldb/Docs] Fix lldb-x86_64-fedora URL as it is still a silent bot

Added: 


Modified: 
lldb/docs/resources/bots.rst

Removed: 




diff  --git a/lldb/docs/resources/bots.rst b/lldb/docs/resources/bots.rst
index 926259bd92be..f80a2333992b 100644
--- a/lldb/docs/resources/bots.rst
+++ b/lldb/docs/resources/bots.rst
@@ -11,7 +11,7 @@ LLVM Buildbot is the place where volunteers provide build 
machines. Everyone can
 * `lldb-x86_64-debian `_
 * `lldb-aarch64-ubuntu `_
 * `lldb-arm-ubuntu `_
-* `lldb-x86_64-fedora `_
+* `lldb-x86_64-fedora `_
 
 An overview of all LLDB builders can be found here:
 



___
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] 2315e98 - [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

2020-12-10 Thread Peter Waller via llvm-branch-commits

Author: Peter Waller
Date: 2020-12-10T12:43:14Z
New Revision: 2315e9874c92bf625ec84a5f45a4fa28bfbc16ce

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

LOG: [AArch64][Driver][SVE] Push missing SVE feature error from driver to 
frontend

... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features".
   This would result in this error being raised for -march=...+sve2,
   even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down
   the stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is 
not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.

Reviewed By: sdesmalen

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

Added: 
clang/test/Sema/arm-vector-types-support.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Driver/aarch64-sve-vector-bits.c

Removed: 
clang/test/Sema/neon-vector-types-support.c



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 8ca176d3bb43..0e85be8f058b 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -534,9 +534,6 @@ def err_drv_cannot_mix_options : Error<"cannot specify '%1' 
along with '%0'">;
 
 def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not 
recognized and is not a valid setting.">;
 
-def err_drv_invalid_sve_vector_bits : Error<
-  "'-msve-vector-bits' is not supported without SVE enabled">;
-
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 97773d35a694..363bcc1d383d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2843,7 +2843,8 @@ def warn_unsupported_target_attribute
   "attribute ignored">,
   InGroup;
 def err_attribute_unsupported
-: Error<"%0 attribute is not supported for this target">;
+: Error<"%0 attribute is not supported on targets missing %1;"
+" specify an appropriate -march= or -mcpu=">;
 // The err_*_attribute_argument_not_int are separate because they're used by
 // VerifyIntegerConstantExpression.
 def err_aligned_attribute_argument_not_int : Error<

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 0fc531b8c3a0..fca6d95d361b 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -381,12 +381,6 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   if (V8_6Pos != std::end(Features))
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
-  bool HasSve = llvm::is_contained(Features, "+sve");
-  // -msve-vector-bits= flag is valid only if SVE is enabled.
-  if (Args.hasArg(options::OPT_msve_vector_bits_EQ))
-if (!HasSve)
-  D.Diag(diag::err_drv_invalid_sve_vector_bits);
-
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index fbdbfbc9f8ec..6485bebc0e8e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7799,7 +7799,8 @@ static void HandleNeonVectorTypeAttr(QualType , 
const ParsedAttr ,
   // not to need a separate attribute)
   if (!S.Context.getTargetInfo().hasFeature("neon") &&
   !S.Context.getTargetInfo().hasFeature("mve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'neon' or 'mve'";
 Attr.setInvalid();
 return;
   }
@@ -7842,7 +7843,7 @@ static void HandleArmSveVectorBitsTypeAttr(QualType 
, ParsedAttr ,
Sema ) {
   // Target must 

[llvm-branch-commits] [lldb] 208e3f5 - [lldb] Fix that symbols.clang-modules-cache-path is never initialized

2020-12-10 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-10T13:37:40+01:00
New Revision: 208e3f5d9b6c172f65dbb9cdbc9354c81c6d8911

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

LOG: [lldb] Fix that symbols.clang-modules-cache-path is never initialized

LLDB is supposed to ask the Clang Driver what the default module cache path is
and then use that value as the default for the
`symbols.clang-modules-cache-path` setting. However, we use the property type
`String` to change `symbols.clang-modules-cache-path` even though the type of
that setting is `FileSpec`, so the setter will simply do nothing and return
`false`. We also don't check the return value of the setter, so this whole code
ends up not doing anything at all.

This changes the setter to use the correct property type and adds an assert that
we actually successfully set the default path. Also adds a test that checks that
the default value for this setting is never unset/empty path as this would
effectively disable the import-std-module feature from working by default.

Reviewed By: JDevlieghere, shafik

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

Added: 
lldb/test/Shell/Settings/TestDefaultModuleCachePath.test

Modified: 
lldb/include/lldb/Core/ModuleList.h
lldb/source/Core/ModuleList.cpp
lldb/test/Shell/helper/toolchain.py

Removed: 




diff  --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index d90b27e474ac..1609f0f77c56 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -56,7 +56,7 @@ class ModuleListProperties : public Properties {
   ModuleListProperties();
 
   FileSpec GetClangModulesCachePath() const;
-  bool SetClangModulesCachePath(llvm::StringRef path);
+  bool SetClangModulesCachePath(const FileSpec );
   bool GetEnableExternalLookup() const;
   bool SetEnableExternalLookup(bool new_value);
 

diff  --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index cf276ba65931..b6e1ceb40889 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -82,8 +82,9 @@ ModuleListProperties::ModuleListProperties() {
[this] { UpdateSymlinkMappings(); 
});
 
   llvm::SmallString<128> path;
-  clang::driver::Driver::getDefaultModuleCachePath(path);
-  SetClangModulesCachePath(path);
+  if (clang::driver::Driver::getDefaultModuleCachePath(path)) {
+lldbassert(SetClangModulesCachePath(FileSpec(path)));
+  }
 }
 
 bool ModuleListProperties::GetEnableExternalLookup() const {
@@ -104,8 +105,8 @@ FileSpec ModuleListProperties::GetClangModulesCachePath() 
const {
   ->GetCurrentValue();
 }
 
-bool ModuleListProperties::SetClangModulesCachePath(llvm::StringRef path) {
-  return m_collection_sp->SetPropertyAtIndexAsString(
+bool ModuleListProperties::SetClangModulesCachePath(const FileSpec ) {
+  return m_collection_sp->SetPropertyAtIndexAsFileSpec(
   nullptr, ePropertyClangModulesCachePath, path);
 }
 

diff  --git a/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test 
b/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test
new file mode 100644
index ..80dc0f25ce58
--- /dev/null
+++ b/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test
@@ -0,0 +1,9 @@
+# RUN: %lldb-noinit -x -s %s | FileCheck %s
+settings show symbols.clang-modules-cache-path
+q
+# This test checks that we get *any* clang modules cache path by default. The
+# actual path depends on the operating system.
+# CHECK: symbols.clang-modules-cache-path (file) = "
+# Clang treats an empty path in the same way as 'no path', so explicitly check
+# that we never have an empty path by default.
+# CHECK-NOT: symbols.clang-modules-cache-path (file) = ""

diff  --git a/lldb/test/Shell/helper/toolchain.py 
b/lldb/test/Shell/helper/toolchain.py
index ebf9e03d81a0..59b078411c1c 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -54,6 +54,10 @@ def use_lldb_substitutions(config):
   command=FindTool('lldb'),
   extra_args=['-S', lldb_init],
   unresolved='fatal'),
+ToolSubst('%lldb-noinit',
+  command=FindTool('lldb'),
+  extra_args=['--no-lldbinit'],
+  unresolved='fatal'),
 ToolSubst('%lldb-server',
   command=FindTool("lldb-server"),
   extra_args=[],



___
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] 2fd3147 - [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

2020-12-10 Thread Peter Waller via llvm-branch-commits

Author: Peter Waller
Date: 2020-12-10T12:34:26Z
New Revision: 2fd31472992f39eaa57e86b6c10969978ada2c3e

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

LOG: [AArch64][Driver][SVE] Push missing SVE feature error from driver to 
frontend

... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features".
   This would result in this error being raised for -march=...+sve2,
   even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down
   the stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is 
not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.

Reviewed By: sdesmalen

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

Added: 
clang/test/Sema/arm-vector-types-support.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Driver/aarch64-sve-vector-bits.c

Removed: 
clang/test/Sema/neon-vector-types-support.c



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 8ca176d3bb43..0e85be8f058b 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -534,9 +534,6 @@ def err_drv_cannot_mix_options : Error<"cannot specify '%1' 
along with '%0'">;
 
 def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not 
recognized and is not a valid setting.">;
 
-def err_drv_invalid_sve_vector_bits : Error<
-  "'-msve-vector-bits' is not supported without SVE enabled">;
-
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 97773d35a694..363bcc1d383d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2843,7 +2843,8 @@ def warn_unsupported_target_attribute
   "attribute ignored">,
   InGroup;
 def err_attribute_unsupported
-: Error<"%0 attribute is not supported for this target">;
+: Error<"%0 attribute is not supported on targets missing %1;"
+" specify an appropriate -march= or -mcpu=">;
 // The err_*_attribute_argument_not_int are separate because they're used by
 // VerifyIntegerConstantExpression.
 def err_aligned_attribute_argument_not_int : Error<

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 0fc531b8c3a0..fca6d95d361b 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -381,12 +381,6 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   if (V8_6Pos != std::end(Features))
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
-  bool HasSve = llvm::is_contained(Features, "+sve");
-  // -msve-vector-bits= flag is valid only if SVE is enabled.
-  if (Args.hasArg(options::OPT_msve_vector_bits_EQ))
-if (!HasSve)
-  D.Diag(diag::err_drv_invalid_sve_vector_bits);
-
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index fbdbfbc9f8ec..6485bebc0e8e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7799,7 +7799,8 @@ static void HandleNeonVectorTypeAttr(QualType , 
const ParsedAttr ,
   // not to need a separate attribute)
   if (!S.Context.getTargetInfo().hasFeature("neon") &&
   !S.Context.getTargetInfo().hasFeature("mve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'neon' or 'mve'";
 Attr.setInvalid();
 return;
   }
@@ -7842,7 +7843,7 @@ static void HandleArmSveVectorBitsTypeAttr(QualType 
, ParsedAttr ,
Sema ) {
   // Target must 

[llvm-branch-commits] [clang-tools-extra] ee02e20 - [clangd] NFC: Use SmallVector where possible

2020-12-10 Thread Kirill Bobyrev via llvm-branch-commits

Author: Kirill Bobyrev
Date: 2020-12-10T13:36:49+01:00
New Revision: ee02e20c0817745c47ea9be8e26e9a49afc9a7fd

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

LOG: [clangd] NFC: Use SmallVector where possible

SmallVector with default size is now the recommended version (D92522).

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/CompileCommands.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/FileDistance.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/Headers.h
clang-tools-extra/clangd/QueryDriverDatabase.cpp
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/Selection.h
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TidyProvider.cpp
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/support/Markup.cpp
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
clang-tools-extra/clangd/unittests/TestIndex.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
clang-tools-extra/clangd/unittests/support/TraceTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index d1702b2d25b6..d3615e23b0d6 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -258,7 +258,7 @@ std::string printTemplateSpecializationArgs(const NamedDecl 
) {
   // TemplateArgumentTypeLocs, they only have TemplateArgumentTypes. So we
   // create a new argument location list from TypeSourceInfo.
   auto STL = TSI->getTypeLoc().getAs();
-  llvm::SmallVector ArgLocs;
+  llvm::SmallVector ArgLocs;
   ArgLocs.reserve(STL.getNumArgs());
   for (unsigned I = 0; I < STL.getNumArgs(); ++I)
 ArgLocs.push_back(STL.getArgLoc(I));

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f6210a43b34e..96cbd8806ff6 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -367,7 +367,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
 for (unsigned ID = 1 /*Skip INVALID */; ID < DriverID::LastOption; ++ID) {
   if (PrevAlias[ID] || ID == DriverID::OPT_Xclang)
 continue; // Not canonical, or specially handled.
-  llvm::SmallVector Rules;
+  llvm::SmallVector Rules;
   // Iterate over each alias, to add rules for parsing it.
   for (unsigned A = ID; A != DriverID::OPT_INVALID; A = NextAlias[A]) {
 if (Prefixes[A] == nullptr) // option groups.

diff  --git a/clang-tools-extra/clangd/CompileCommands.h 
b/clang-tools-extra/clangd/CompileCommands.h
index 3efd80026cf6..2ba17a0e6c0d 100644
--- a/clang-tools-extra/clangd/CompileCommands.h
+++ b/clang-tools-extra/clangd/CompileCommands.h
@@ -92,7 +92,7 @@ class ArgStripper {
   static llvm::ArrayRef rulesFor(llvm::StringRef Arg);
   const Rule *matchingRule(llvm::StringRef Arg, unsigned Mode,
unsigned ) const;
-  llvm::SmallVector Rules;
+  llvm::SmallVector Rules;
   std::deque Storage; // Store strings not found in option table.
 };
 

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 846c6a170b38..b1189e286826 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -137,7 +137,7 @@ struct FragmentCompiler {
 llvm::StringRef EnumName;
 const Located 
 llvm::Optional Result;
-llvm::SmallVector ValidValues;
+llvm::SmallVector ValidValues;
 
   public:
 EnumSwitch(llvm::StringRef EnumName, const Located ,

diff  --git a/clang-tools-extra/clangd/FileDistance.cpp 
b/clang-tools-extra/clangd/FileDistance.cpp
index 584c64d077e1..e1cead329189 100644
--- a/clang-tools-extra/clangd/FileDistance.cpp
+++ b/clang-tools-extra/clangd/FileDistance.cpp
@@ -58,8 +58,7 @@ const llvm::hash_code FileDistance::RootHash =
 FileDistance::FileDistance(llvm::StringMap Sources,
const FileDistanceOptions )
 : Opts(Opts) {
-  llvm::DenseMap>
-  DownEdges;
+  llvm::DenseMap> 
DownEdges;
   // Compute the best distance following only up edges.
   // Keep track of down edges, in case we can use them to improve on this.
   for (const auto  : Sources) {
@@ -118,7 +117,7 @@ 

  1   2   >