[llvm-branch-commits] [clang] 8c1f2d1 - Following up on PR48517, fix handling of template arguments that refer

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

Author: Richard Smith
Date: 2020-12-17T23:54:37-08:00
New Revision: 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e

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

LOG: Following up on PR48517, fix handling of template arguments that refer
to dependent declarations.

Treat an id-expression that names a local variable in a templated
function as being instantiation-dependent.

This addresses a language defect whereby a reference to a dependent
declaration can be formed without any construct being value-dependent.
Fixing that through value-dependence turns out to be problematic, so
instead this patch takes the approach (proposed on the core reflector)
of allowing the use of pointers or references to (but not values of)
dependent declarations inside value-dependent expressions, and instead
treating template arguments as dependent if they evaluate to a constant
involving such dependent declarations.

This ends up affecting a bunch of OpenMP tests, due to OpenMP
imprecisely handling instantiation-dependent constructs, bailing out
early instead of processing dependent constructs to the extent possible
when handling the template.

Added: 
clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp

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

clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_messages.cpp

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

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

Removed: 
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp



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

[llvm-branch-commits] [llvm] 477b650 - [PowerPC] Select the D-Form load if we know its offset meets the requirement

2020-12-17 Thread QingShan Zhang via llvm-branch-commits

Author: QingShan Zhang
Date: 2020-12-18T07:27:26Z
New Revision: 477b6505fa1d49339c81fbbda937dc8bb5e53cfd

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

LOG: [PowerPC] Select the D-Form load if we know its offset meets the 
requirement

The LD/STD likewise instruction are selected only when the alignment in
the load/store >= 4 to deal with the case that the offset might not be
known(i.e. relocations). That means we have to select the X-Form load
for %0 = load i64, i64* %arrayidx, align 2 In fact, we can still select
the D-Form load if the offset is known. So, we only query the load/store
alignment when we don't know if the offset is a multiple of 4.

Reviewed By: jji, Nemanjai

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCInstr64Bit.td
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/test/CodeGen/PowerPC/ldst-align.ll
llvm/test/CodeGen/PowerPC/memCmpUsedInZeroEqualityComparison.ll
llvm/test/CodeGen/PowerPC/memcmp-mergeexpand.ll
llvm/test/CodeGen/PowerPC/pr45186.ll
llvm/test/CodeGen/PowerPC/store-combine.ll
llvm/test/CodeGen/PowerPC/unal4-std.ll
llvm/test/CodeGen/PowerPC/unaligned.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td 
b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
index 9265c513c031..e19ea6a07a0d 100644
--- a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
+++ b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
@@ -1062,7 +1062,7 @@ def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
 def LWA  : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
 "lwa $rD, $src", IIC_LdStLWA,
 [(set i64:$rD,
-  (aligned4sextloadi32 iaddrX4:$src))]>, isPPC64,
+  (DSFormSextLoadi32 iaddrX4:$src))]>, isPPC64,
 PPC970_DGroup_Cracked;
 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
 def LHAX8: XForm_1_memOp<31, 343, (outs g8rc:$rD), (ins memrr:$src),
@@ -1173,7 +1173,7 @@ def LWZUX8 : XForm_1_memOp<31, 55, (outs g8rc:$rD, 
ptr_rc_nor0:$ea_result),
 let PPC970_Unit = 2 in {
 def LD   : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
 "ld $rD, $src", IIC_LdStLD,
-[(set i64:$rD, (aligned4load iaddrX4:$src))]>, isPPC64;
+[(set i64:$rD, (DSFormLoad iaddrX4:$src))]>, isPPC64;
 // The following four definitions are selected for small code model only.
 // Otherwise, we need to create two instructions to form a 32-bit offset,
 // so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
@@ -1380,7 +1380,7 @@ def STWX8 : XForm_8_memOp<31, 151, (outs), (ins g8rc:$rS, 
memrr:$dst),
 // Normal 8-byte stores.
 def STD  : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
 "std $rS, $dst", IIC_LdStSTD,
-[(aligned4store i64:$rS, iaddrX4:$dst)]>, isPPC64;
+[(DSFormStore i64:$rS, iaddrX4:$dst)]>, isPPC64;
 def STDX  : XForm_8_memOp<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
   "stdx $rS, $dst", IIC_LdStSTD,
   [(store i64:$rS, xaddrX4:$dst)]>, isPPC64,
@@ -1447,7 +1447,7 @@ def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, 
iaddroff:$ptroff),
   (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
   (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
-def : Pat<(aligned4pre_store i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
+def : Pat<(DSFormPreStore i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
   (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
 
 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
@@ -1591,11 +1591,11 @@ def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
 
 // Patterns to match r+r indexed loads and stores for
 // addresses without at least 4-byte alignment.
-def : Pat<(i64 (unaligned4sextloadi32 xoaddr:$src)),
+def : Pat<(i64 (NonDSFormSextLoadi32 xoaddr:$src)),
   (LWAX xoaddr:$src)>;
-def : Pat<(i64 (unaligned4load xoaddr:$src)),
+def : Pat<(i64 (NonDSFormLoad xoaddr:$src)),
   (LDX xoaddr:$src)>;
-def : Pat<(unaligned4store i64:$rS, xoaddr:$dst),
+def : Pat<(NonDSFormStore i64:$rS, xoaddr:$dst),
   (STDX $rS, xoaddr:$dst)>;
 
 // 64-bits atomic loads and stores

diff  --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
index 849b96f507bd..018fb8ffe16c 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -495,37 +495,41 @@ def imm64ZExt32  : Operand, ImmLeaf(Imm);
 }]>;
 
-// Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
+// This is a somewhat weaker condition than actually checking 

[llvm-branch-commits] [clang] 4b38885 - Ensure that we transform types into the current instantiation even if

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

Author: Richard Smith
Date: 2020-12-17T23:23:05-08:00
New Revision: 4b388859f527f822a27bcee409242c421f199f1d

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

LOG: Ensure that we transform types into the current instantiation even if
they're only instantiation-dependent.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaTemplate/class-template-decl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2b6eb397b82b..949df53b40e0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5491,7 +5491,7 @@ static bool RebuildDeclaratorInCurrentInstantiation(Sema 
, Declarator ,
 // Grab the type from the parser.
 TypeSourceInfo *TSI = nullptr;
 QualType T = S.GetTypeFromParser(DS.getRepAsType(), );
-if (T.isNull() || !T->isDependentType()) break;
+if (T.isNull() || !T->isInstantiationDependentType()) break;
 
 // Make sure there's a type source info.  This isn't really much
 // of a waste; most dependent types should have type source info

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index dd361ec91abe..64259767d98a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -10730,7 +10730,7 @@ namespace {
 /// For the purposes of type reconstruction, a type has already been
 /// transformed if it is NULL or if it is not dependent.
 bool AlreadyTransformed(QualType T) {
-  return T.isNull() || !T->isDependentType();
+  return T.isNull() || !T->isInstantiationDependentType();
 }
 
 /// Returns the location of the entity whose type is being
@@ -10783,7 +10783,7 @@ namespace {
 TypeSourceInfo *Sema::RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
 SourceLocation Loc,
 DeclarationName Name) {
-  if (!T || !T->getType()->isDependentType())
+  if (!T || !T->getType()->isInstantiationDependentType())
 return T;
 
   CurrentInstantiationRebuilder Rebuilder(*this, Loc, Name);

diff  --git a/clang/test/SemaTemplate/class-template-decl.cpp 
b/clang/test/SemaTemplate/class-template-decl.cpp
index 453218ac3b40..c054a6a8d82f 100644
--- a/clang/test/SemaTemplate/class-template-decl.cpp
+++ b/clang/test/SemaTemplate/class-template-decl.cpp
@@ -167,3 +167,17 @@ namespace abstract_dependent_class {
   };
   template A *A::clone() { return new A; } // 
expected-error {{abstract class type 'A'}}
 }
+
+namespace qualified_out_of_line {
+  struct rbnode {};
+  template struct pair {};
+  template struct rbtree {
+using base = rbnode;
+pair f();
+  };
+  template
+  pair::base, typename rbtree::base>
+  rbtree::f() {
+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] [clang] 71886c5 - Where possible, don't try to ask whether a template argument is

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

Author: Richard Smith
Date: 2020-12-17T23:23:05-08:00
New Revision: 71886c56f336667969be4cac0b6a17a3f75b7555

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

LOG: Where possible, don't try to ask whether a template argument is
dependent until it's been converted to match its parameter.

The type of a non-type template parameter can in general affect whether
the template argument is dependent.

Note that this is not always possible. For template arguments that name
static local variables in templates, the type of the template parameter
affects whether the argument is dependent, so the query is imprecise
until we know the parameter type. For example, in:

template void f() {
  static const int n = 5;
  typename T::template X x;
}

... we don't know whether 'n' is dependent until we know whether the
corresponding template parameter is of type 'int' or 'const int&'.

Added: 
clang/test/SemaTemplate/instantiate-static-local.cpp

Modified: 
clang/include/clang/AST/Type.h
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplate.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index a3059b83c1be..21c8bf79152e 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5112,11 +5112,24 @@ class alignas(8) TemplateSpecializationType
 
 public:
   /// Determine whether any of the given template arguments are dependent.
-  static bool anyDependentTemplateArguments(ArrayRef Args,
-bool );
-
-  static bool anyDependentTemplateArguments(const TemplateArgumentListInfo &,
-bool );
+  ///
+  /// The converted arguments should be supplied when known; whether an
+  /// argument is dependent can depend on the conversions performed on it
+  /// (for example, a 'const int' passed as a template argument might be
+  /// dependent if the parameter is a reference but non-dependent if the
+  /// parameter is an int).
+  ///
+  /// Note that the \p Args parameter is unused: this is intentional, to remind
+  /// the caller that they need to pass in the converted arguments, not the
+  /// specified arguments.
+  static bool
+  anyDependentTemplateArguments(ArrayRef Args,
+ArrayRef Converted);
+  static bool
+  anyDependentTemplateArguments(const TemplateArgumentListInfo &,
+ArrayRef Converted);
+  static bool anyInstantiationDependentTemplateArguments(
+  ArrayRef Args);
 
   /// True if this template specialization type matches a current
   /// instantiation in the context in which it is found.

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index e5811dbc44c5..5dec80be9ccb 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3590,24 +3590,24 @@ void 
SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID ,
 ID.AddPointer(P.getAsType().getAsOpaquePtr());
 }
 
-bool TemplateSpecializationType::
-anyDependentTemplateArguments(const TemplateArgumentListInfo ,
-  bool ) {
-  return anyDependentTemplateArguments(Args.arguments(),
-   InstantiationDependent);
+bool TemplateSpecializationType::anyDependentTemplateArguments(
+const TemplateArgumentListInfo , ArrayRef 
Converted) {
+  return anyDependentTemplateArguments(Args.arguments(), Converted);
 }
 
-bool TemplateSpecializationType::
-anyDependentTemplateArguments(ArrayRef Args,
-  bool ) {
-  for (const TemplateArgumentLoc  : Args) {
-if (ArgLoc.getArgument().isDependent()) {
-  InstantiationDependent = true;
+bool TemplateSpecializationType::anyDependentTemplateArguments(
+ArrayRef Args, ArrayRef Converted) {
+  for (const TemplateArgument  : Converted)
+if (Arg.isDependent())
   return true;
-}
+  return false;
+}
 
+bool TemplateSpecializationType::anyInstantiationDependentTemplateArguments(
+  ArrayRef Args) {
+  for (const TemplateArgumentLoc  : Args) {
 if (ArgLoc.getArgument().isInstantiationDependent())
-  InstantiationDependent = true;
+  return true;
   }
   return false;
 }

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index ddd95faebe99..1ff7b1cdd515 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1053,25 +1053,20 @@ ReturnTypeRequirement(TemplateParameterList *TPL) :
   auto *Constraint =
   cast_or_null(
   TC->getImmediatelyDeclaredConstraint());
-  bool Dependent = false;
-  if (Constraint->getTemplateArgsAsWritten()) {
-for (auto  :
- 

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

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

Author: Richard Smith
Date: 2020-12-17T23:23:05-08:00
New Revision: 638867afd4bce4a2c56dea041299428af3727d61

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

LOG: DR2064: decltype(E) is only a dependent type if E is type-dependent, not
if E is merely instantiation-dependent.

Added: 


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

Removed: 




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

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

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

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

[llvm-branch-commits] [libc] d599ed4 - [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.

2020-12-17 Thread Siva Chandra Reddy via llvm-branch-commits

Author: Siva Chandra Reddy
Date: 2020-12-17T23:16:26-08:00
New Revision: d599ed49b355f1481bf8b22774e1a902352c9766

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

LOG: [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.

This is a continuation of the previous CL which did a similar change in
other tests. To elaborate a little about why we need this - under C++
compilation with headers not from LLVM libc, libraries like libc++ and
libstdc++ provide their own math.h which undefine macros like `isnan`
and provide the overloaded C++ isnan functions which return a boolean
value instead of an integer value returned by the isnan macro.

Added: 


Modified: 
libc/test/src/math/FDimTest.h
libc/test/src/math/RemQuoTest.h
libc/test/src/math/fmax_test.cpp
libc/test/src/math/fmaxf_test.cpp
libc/test/src/math/fmaxl_test.cpp
libc/test/src/math/fmin_test.cpp
libc/test/src/math/fminf_test.cpp
libc/test/src/math/fminl_test.cpp

Removed: 




diff  --git a/libc/test/src/math/FDimTest.h b/libc/test/src/math/FDimTest.h
index f052dc382f16..4b95427b113b 100644
--- a/libc/test/src/math/FDimTest.h
+++ b/libc/test/src/math/FDimTest.h
@@ -26,7 +26,7 @@ class FDimTestTemplate : public __llvm_libc::testing::Test {
 EXPECT_FP_EQ(nan, func(negZero, nan));
 EXPECT_FP_EQ(nan, func(nan, T(-1.2345)));
 EXPECT_FP_EQ(nan, func(T(1.2345), nan));
-EXPECT_NE(isnan(func(nan, nan)), 0);
+EXPECT_FP_EQ(func(nan, nan), nan);
   }
 
   void testInfArg(FuncPtr func) {

diff  --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h
index 29fcdb83b6a2..66f2f0956348 100644
--- a/libc/test/src/math/RemQuoTest.h
+++ b/libc/test/src/math/RemQuoTest.h
@@ -38,27 +38,27 @@ class RemQuoTestTemplate : public 
__llvm_libc::testing::Test {
 
 y = T(1.0);
 x = inf;
-EXPECT_NE(isnan(func(x, y, )), 0);
+EXPECT_FP_EQ(nan, func(x, y, ));
 x = negInf;
-EXPECT_NE(isnan(func(x, y, )), 0);
+EXPECT_FP_EQ(nan, func(x, y, ));
 
 x = T(1.0);
 y = zero;
-EXPECT_NE(isnan(func(x, y, )), 0);
+EXPECT_FP_EQ(nan, func(x, y, ));
 y = negZero;
-EXPECT_NE(isnan(func(x, y, )), 0);
+EXPECT_FP_EQ(nan, func(x, y, ));
 
 y = nan;
 x = T(1.0);
-EXPECT_NE(isnan(func(x, y, )), 0);
+EXPECT_FP_EQ(nan, func(x, y, ));
 
 y = T(1.0);
 x = nan;
-EXPECT_NE(isnan(func(x, y, )), 0);
+EXPECT_FP_EQ(nan, func(x, y, ));
 
 x = nan;
 y = nan;
-EXPECT_NE(isnan(func(x, y, )), 0);
+EXPECT_FP_EQ(nan, func(x, y, ));
 
 x = zero;
 y = T(1.0);

diff  --git a/libc/test/src/math/fmax_test.cpp 
b/libc/test/src/math/fmax_test.cpp
index b84db3003cc6..4be7e0208dc7 100644
--- a/libc/test/src/math/fmax_test.cpp
+++ b/libc/test/src/math/fmax_test.cpp
@@ -23,7 +23,7 @@ TEST(FmaxTest, NaNArg) {
   EXPECT_FP_EQ(-0.0, __llvm_libc::fmax(-0.0, aNaN));
   EXPECT_FP_EQ(-1.2345, __llvm_libc::fmax(aNaN, -1.2345));
   EXPECT_FP_EQ(1.2345, __llvm_libc::fmax(1.2345, aNaN));
-  EXPECT_NE(isnan(__llvm_libc::fmax(aNaN, aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::fmax(aNaN, aNaN));
 }
 
 TEST(FmaxTest, InfArg) {

diff  --git a/libc/test/src/math/fmaxf_test.cpp 
b/libc/test/src/math/fmaxf_test.cpp
index 7d6661cb4b8b..812dd4c8e5af 100644
--- a/libc/test/src/math/fmaxf_test.cpp
+++ b/libc/test/src/math/fmaxf_test.cpp
@@ -23,7 +23,7 @@ TEST(FmaxfTest, NaNArg) {
   EXPECT_FP_EQ(-0.0f, __llvm_libc::fmaxf(-0.0f, aNaN));
   EXPECT_FP_EQ(-1.2345f, __llvm_libc::fmaxf(aNaN, -1.2345f));
   EXPECT_FP_EQ(1.2345f, __llvm_libc::fmaxf(1.2345f, aNaN));
-  EXPECT_NE(isnan(__llvm_libc::fmaxf(aNaN, aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::fmaxf(aNaN, aNaN));
 }
 
 TEST(FmaxfTest, InfArg) {

diff  --git a/libc/test/src/math/fmaxl_test.cpp 
b/libc/test/src/math/fmaxl_test.cpp
index 72f7636cb0eb..6eac0095c62a 100644
--- a/libc/test/src/math/fmaxl_test.cpp
+++ b/libc/test/src/math/fmaxl_test.cpp
@@ -23,7 +23,7 @@ TEST(FmaxlTest, NaNArg) {
   EXPECT_FP_EQ(-0.0L, __llvm_libc::fmaxl(-0.0L, aNaN));
   EXPECT_FP_EQ(-1.2345L, __llvm_libc::fmaxl(aNaN, -1.2345L));
   EXPECT_FP_EQ(1.2345L, __llvm_libc::fmaxl(1.2345L, aNaN));
-  EXPECT_NE(isnan(__llvm_libc::fmaxl(aNaN, aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, __llvm_libc::fmaxl(aNaN, aNaN));
 }
 
 TEST(FmaxlTest, InfArg) {

diff  --git a/libc/test/src/math/fmin_test.cpp 
b/libc/test/src/math/fmin_test.cpp
index 5deaa857c1f2..6782e8cb9e80 100644
--- a/libc/test/src/math/fmin_test.cpp
+++ b/libc/test/src/math/fmin_test.cpp
@@ -23,7 +23,7 @@ TEST(FminTest, NaNArg) {
   EXPECT_FP_EQ(-0.0, __llvm_libc::fmin(-0.0, aNaN));
   EXPECT_FP_EQ(-1.2345, __llvm_libc::fmin(aNaN, -1.2345));
   EXPECT_FP_EQ(1.2345, __llvm_libc::fmin(1.2345, aNaN));
-  EXPECT_NE(isnan(__llvm_libc::fmin(aNaN, aNaN)), 0);
+  EXPECT_FP_EQ(aNaN, 

[llvm-branch-commits] [lld] fdd6ed8 - [LLD] Rename lld port driver entry function to a consistent name

2020-12-17 Thread Reshabh Sharma via llvm-branch-commits

Author: Reshabh Sharma
Date: 2020-12-18T12:18:37+05:30
New Revision: fdd6ed8e9341f5161673e962cbd36e1f4c3968f5

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

LOG: [LLD] Rename lld port driver entry function to a consistent name

Libraries linked to the lld elf library exposes a function named main.
When debugging code linked to such libraries and intending to set a
breakpoint at main, the debugger also sets breakpoint at the main
function at lld elf driver. The possible choice was to rename it to
link but that would again clash with lld::*::link. This patch tries
to consistently rename them to linkerMain.

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

Added: 


Modified: 
lld/COFF/Driver.cpp
lld/COFF/Driver.h
lld/ELF/Driver.cpp
lld/ELF/Driver.h
lld/wasm/Driver.cpp

Removed: 




diff  --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 08862b062f91..96ac7957f557 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -91,7 +91,7 @@ bool link(ArrayRef args, bool canExitEarly, 
raw_ostream ,
   symtab = make();
   driver = make();
 
-  driver->link(args);
+  driver->linkerMain(args);
 
   // Call exit() if we can to avoid calling destructors.
   if (canExitEarly)
@@ -1197,7 +1197,7 @@ Optional getReproduceFile(const 
opt::InputArgList ) {
   return None;
 }
 
-void LinkerDriver::link(ArrayRef argsArr) {
+void LinkerDriver::linkerMain(ArrayRef argsArr) {
   ScopedTimer rootTimer(Timer::root());
 
   // Needed for LTO.

diff  --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h
index dc766eeac8ed..6f71a37f729f 100644
--- a/lld/COFF/Driver.h
+++ b/lld/COFF/Driver.h
@@ -78,7 +78,7 @@ class ArgParser {
 
 class LinkerDriver {
 public:
-  void link(llvm::ArrayRef args);
+  void linkerMain(llvm::ArrayRef args);
 
   // Used by the resolver to parse .drectve section contents.
   void parseDirectives(InputFile *file);

diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index d7a6cd13ca11..3eaa893a3ff5 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -119,7 +119,7 @@ bool elf::link(ArrayRef args, bool 
canExitEarly,
 
   config->progName = args[0];
 
-  driver->main(args);
+  driver->linkerMain(args);
 
   // Exit immediately if we don't need to return to the caller.
   // This saves time because the overhead of calling destructors
@@ -470,7 +470,7 @@ static void checkZOptions(opt::InputArgList ) {
   error("unknown -z value: " + StringRef(arg->getValue()));
 }
 
-void LinkerDriver::main(ArrayRef argsArr) {
+void LinkerDriver::linkerMain(ArrayRef argsArr) {
   ELFOptTable parser;
   opt::InputArgList args = parser.parse(argsArr.slice(1));
 

diff  --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h
index 3115e28d1669..96d040041c5a 100644
--- a/lld/ELF/Driver.h
+++ b/lld/ELF/Driver.h
@@ -26,7 +26,7 @@ extern class LinkerDriver *driver;
 
 class LinkerDriver {
 public:
-  void main(ArrayRef args);
+  void linkerMain(ArrayRef args);
   void addFile(StringRef path, bool withLOption);
   void addLibrary(StringRef name);
 

diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index c1e888466628..fb699c55fc8c 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -67,7 +67,7 @@ static void initLLVM() {
 
 class LinkerDriver {
 public:
-  void link(ArrayRef argsArr);
+  void linkerMain(ArrayRef argsArr);
 
 private:
   void createFiles(opt::InputArgList );
@@ -98,7 +98,7 @@ bool link(ArrayRef args, bool canExitEarly, 
raw_ostream ,
   symtab = make();
 
   initLLVM();
-  LinkerDriver().link(args);
+  LinkerDriver().linkerMain(args);
 
   // Exit immediately if we don't need to return to the caller.
   // This saves time because the overhead of calling destructors
@@ -787,7 +787,7 @@ static void wrapSymbols(ArrayRef wrapped) {
 symtab->wrap(w.sym, w.real, w.wrap);
 }
 
-void LinkerDriver::link(ArrayRef argsArr) {
+void LinkerDriver::linkerMain(ArrayRef argsArr) {
   WasmOptTable parser;
   opt::InputArgList args = parser.parse(argsArr.slice(1));
 



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


[llvm-branch-commits] [llvm] 93fd523 - [NFC][utils] Factor remaining APIs under FunctionTestBuilder

2020-12-17 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2020-12-17T22:13:14-08:00
New Revision: 93fd52329fe530d10ace5d24327e2b6d457c2ac8

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

LOG: [NFC][utils] Factor remaining APIs under FunctionTestBuilder

Finishing the refactoring started in D93413.

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

Added: 


Modified: 
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index 128792da5b90..4befaec651ae 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -258,71 +258,6 @@ def repl_arg_names(match):
   def __str__(self):
 return self.scrub
 
-def get_failed_prefixes(func_dict):
-  # This returns the list of those prefixes that failed to match any function,
-  # because there were conflicting bodies produced by 
diff erent RUN lines, in
-  # all instances of the prefix. Effectively, this prefix is unused and should
-  # be removed.
-  for prefix in func_dict:
-if func_dict[prefix] and (not [fct for fct in func_dict[prefix] 
- if func_dict[prefix][fct] is not None]):
-  yield prefix
-
-def warn_on_failed_prefixes(func_dict):
-  for prefix in get_failed_prefixes(func_dict):
-  warn('Prefix %s had conflicting output from 
diff erent RUN lines for all functions' % (prefix,))
-
-def build_function_body_dictionary(function_re, scrubber, scrubber_args, 
raw_tool_output, prefixes, func_dict, func_order, verbose, record_args, 
check_attributes):
-  for m in function_re.finditer(raw_tool_output):
-if not m:
-  continue
-func = m.group('func')
-body = m.group('body')
-attrs = m.group('attrs') if check_attributes else ''
-# Determine if we print arguments, the opening brace, or nothing after the 
function name
-if record_args and 'args_and_sig' in m.groupdict():
-args_and_sig = scrub_body(m.group('args_and_sig').strip())
-elif 'args_and_sig' in m.groupdict():
-args_and_sig = '('
-else:
-args_and_sig = ''
-scrubbed_body = do_scrub(body, scrubber, scrubber_args, extra = False)
-scrubbed_extra = do_scrub(body, scrubber, scrubber_args, extra = True)
-if 'analysis' in m.groupdict():
-  analysis = m.group('analysis')
-  if analysis.lower() != 'cost model analysis':
-warn('Unsupported analysis mode: %r!' % (analysis,))
-if func.startswith('stress'):
-  # We only use the last line of the function body for stress tests.
-  scrubbed_body = '\n'.join(scrubbed_body.splitlines()[-1:])
-if verbose:
-  print('Processing function: ' + func, file=sys.stderr)
-  for l in scrubbed_body.splitlines():
-print('  ' + l, file=sys.stderr)
-for prefix in prefixes:
-  if func in func_dict[prefix]:
-if (func_dict[prefix][func] is None or
-str(func_dict[prefix][func]) != scrubbed_body or
-func_dict[prefix][func].args_and_sig != args_and_sig or
-func_dict[prefix][func].attrs != attrs):
-  if (func_dict[prefix][func] is not None and
-  func_dict[prefix][func].is_same_except_arg_names(scrubbed_extra,
-   args_and_sig,
-   attrs)):
-func_dict[prefix][func].scrub = scrubbed_extra
-func_dict[prefix][func].args_and_sig = args_and_sig
-continue
-  else:
-# This means a previous RUN line produced a body for this function
-# that is 
diff erent from the one produced by this current RUN line,
-# so the body can't be common accross RUN lines. We use None to
-# indicate that.
-func_dict[prefix][func] = None
-continue
-
-  func_dict[prefix][func] = function_body(scrubbed_body, scrubbed_extra, 
args_and_sig, attrs)
-  func_order[prefix].append(func)
-
 class FunctionTestBuilder:
   def __init__(self, run_list, flags, scrubber_args):
 self._verbose = flags.verbose
@@ -337,17 +272,80 @@ def __init__(self, run_list, flags, scrubber_args):
 self._func_order.update({prefix: []})
 
   def finish_and_get_func_dict(self):
-warn_on_failed_prefixes(self._func_dict)
+for prefix in self._get_failed_prefixes():
+  warn('Prefix %s had conflicting output from 
diff erent RUN lines for all functions' % (prefix,))
 return self._func_dict
 
   def func_order(self):
 return self._func_order
   
   def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
-build_function_body_dictionary(function_re, scrubber, self._scrubber_args,
-   

[llvm-branch-commits] [llvm] f0e3d1d - [IndVars] Fix adding trunc instructions to unwind blocks

2020-12-17 Thread Yevgeny Rouban via llvm-branch-commits

Author: Yevgeny Rouban
Date: 2020-12-18T12:52:23+07:00
New Revision: f0e3d1d6ca8c9c0d1191de1db90bd4906d16cb28

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

LOG: [IndVars] Fix adding trunc instructions to unwind blocks

Truncate instruction must not be inserted before landing pads.
The insertion point is fixed.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp 
b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 189130f0e0ac..f3b198094bd1 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1654,7 +1654,7 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse 
DU) {
 assert(LoopExitingBlock && L->contains(LoopExitingBlock) &&
"Not a LCSSA Phi?");
 WidePN->addIncoming(WideBO, LoopExitingBlock);
-Builder.SetInsertPoint(User->getParent()->getFirstNonPHI());
+Builder.SetInsertPoint(&*User->getParent()->getFirstInsertionPt());
 auto *TruncPN = Builder.CreateTrunc(WidePN, User->getType());
 User->replaceAllUsesWith(TruncPN);
 DeadInsts.emplace_back(User);



___
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] d3bf0bb - PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of

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

Author: Richard Smith
Date: 2020-12-17T21:31:23-08:00
New Revision: d3bf0bb18952d830fe6df6f791a64552b271000b

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

LOG: PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of
the nested-name-specifier when determining whether a qualified type is
instantiation-dependent.

Added: 
clang/test/SemaTemplate/instantiation-dependence.cpp

Modified: 
clang/include/clang/AST/Type.h
clang/lib/AST/ItaniumMangle.cpp
clang/test/CXX/drs/dr15xx.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/SemaTemplate/partial-spec-instantiate.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 945ea7a600c0..a3059b83c1be 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5398,7 +5398,9 @@ class ElaboratedType final
   ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
  QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl)
   : TypeWithKeyword(Keyword, Elaborated, CanonType,
-NamedType->getDependence()),
+NamedType->getDependence() |
+(NNS ? toTypeDependence(NNS->getDependence())
+ : TypeDependence::None)),
 NNS(NNS), NamedType(NamedType) {
 ElaboratedTypeBits.HasOwnedTagDecl = false;
 if (OwnedTagDecl) {

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 73c8f17a5d36..6c8d5687c64a 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2578,6 +2578,10 @@ void CXXNameMangler::mangleType(QualType T) {
 if (!TST->isTypeAlias())
   break;
 
+  // FIXME: We presumably shouldn't strip off ElaboratedTypes with
+  // instantation-dependent qualifiers. See
+  // https://github.com/itanium-cxx-abi/cxx-abi/issues/114.
+
   QualType Desugared
 = T.getSingleStepDesugaredType(Context.getASTContext());
   if (Desugared == T)

diff  --git a/clang/test/CXX/drs/dr15xx.cpp b/clang/test/CXX/drs/dr15xx.cpp
index 478a0d7d00dd..8bfa29a8b667 100644
--- a/clang/test/CXX/drs/dr15xx.cpp
+++ b/clang/test/CXX/drs/dr15xx.cpp
@@ -239,6 +239,20 @@ namespace dr1550 { // dr1550: yes
   }
 }
 
+namespace dr1558 { // dr1558: 12
+#if __cplusplus >= 201103L
+  template using first_of = T;
+  template first_of f(int); // expected-note 
{{'int' cannot be used prior to '::'}}
+  template void f(...) = delete; // expected-note {{deleted}}
+
+  struct X { typedef void type; };
+  void test() {
+f(0);
+f(0); // expected-error {{deleted}}
+  }
+#endif
+}
+
 namespace dr1560 { // dr1560: 3.5
   void f(bool b, int n) {
 (b ? throw 0 : n) = (b ? n : throw 0) = 0;

diff  --git a/clang/test/CodeGenCXX/mangle-template.cpp 
b/clang/test/CodeGenCXX/mangle-template.cpp
index 9b5220572c2e..40688de7e12e 100644
--- a/clang/test/CodeGenCXX/mangle-template.cpp
+++ b/clang/test/CodeGenCXX/mangle-template.cpp
@@ -342,3 +342,23 @@ namespace fixed_size_parameter_pack {
   template void f(A::B<0, Ns...>);
   void g() { f<1, 2>({}); }
 }
+
+namespace type_qualifier {
+  template using int_t = int;
+  template void f(decltype(int_t() + 1)) {}
+  // FIXME: This mangling doesn't work: we need to mangle the
+  // instantiation-dependent 'int_t' operand.
+  // CHECK: @_ZN14type_qualifier1fIPiEEvDTplcvi_ELi1EE
+  template void f(int);
+
+  // Note that this template has 
diff erent constraints but would mangle the
+  // same:
+  //template void f(decltype(int_t() + 1)) {}
+
+  struct impl { using type = void; };
+  template using alias = impl;
+  template void g(decltype(alias::type(), 1)) {}
+  // FIXME: Similarly we need to mangle the `T*` in here.
+  // CHECK: @_ZN14type_qualifier1gIPiEEvDTcmcvv_ELi1EE
+  template void g(int);
+}

diff  --git a/clang/test/SemaTemplate/instantiation-dependence.cpp 
b/clang/test/SemaTemplate/instantiation-dependence.cpp
new file mode 100644
index ..75eb510cb68d
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-dependence.cpp
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+// Ensure we substitute into instantiation-dependent but non-dependent
+// constructs. The poster-child for this is...
+template using void_t = void;
+
+namespace PR24076 {
+  template T declval();
+  struct s {};
+
+  template() + 1)>>
+void foo(T) {} // expected-note {{invalid operands to binary expression}}
+
+  void f() {
+foo(s{}); // expected-error {{no matching function}}
+  }
+
+  template() + 1)>> // expected-error 
{{invalid operands to binary expression}}
+  struct bar {};
+
+  bar bar; // expected-note {{in instantiation of}}

[llvm-branch-commits] [lld] d4ec334 - [lld-macho][nfc] Refactor to accommodate paired relocs

2020-12-17 Thread Greg McGary via llvm-branch-commits

Author: Greg McGary
Date: 2020-12-17T20:21:41-08:00
New Revision: d4ec3346b1baf31819d20a8950ced8be8f66a408

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

LOG: [lld-macho][nfc] Refactor to accommodate paired relocs

This is a refactor to pave the way for supporting paired-ADDEND for ARM64. The 
only paired reloc type for X86_64 is SUBTRACTOR. In a later diff, I will add 
SUBTRACTOR for both X86_64 and ARM64.

* s/`getImplicitAddend`/`getAddend`/ because it handles all forms of addend: 
implicit, explicit, paired.
* add predicate `bool isPairedReloc()`
* check range of `relInfo.r_symbolnum` is internal, unrelated to user-input, so 
use `assert()`, not `error()`
* minor cleanups & rearrangements in `InputFile::parseRelocations()`

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

Added: 


Modified: 
lld/MachO/Arch/X86_64.cpp
lld/MachO/InputFiles.cpp
lld/MachO/Target.h

Removed: 




diff  --git a/lld/MachO/Arch/X86_64.cpp b/lld/MachO/Arch/X86_64.cpp
index c776e21d6f5f..729ef603adb7 100644
--- a/lld/MachO/Arch/X86_64.cpp
+++ b/lld/MachO/Arch/X86_64.cpp
@@ -25,8 +25,9 @@ namespace {
 struct X86_64 : TargetInfo {
   X86_64();
 
-  uint64_t getImplicitAddend(MemoryBufferRef, const section_64 &,
- const relocation_info &) const override;
+  bool isPairedReloc(relocation_info) const override;
+  uint64_t getAddend(MemoryBufferRef, const section_64 &, relocation_info,
+ relocation_info) const override;
   void relocateOne(uint8_t *loc, const Reloc &, uint64_t val) const override;
 
   void writeStub(uint8_t *buf, const macho::Symbol &) const override;
@@ -43,7 +44,7 @@ struct X86_64 : TargetInfo {
 } // namespace
 
 static std::string getErrorLocation(MemoryBufferRef mb, const section_64 ,
-const relocation_info ) {
+relocation_info rel) {
   return ("invalid relocation at offset " + std::to_string(rel.r_address) +
   " of " + sec.segname + "," + sec.sectname + " in " +
   mb.getBufferIdentifier())
@@ -51,7 +52,7 @@ static std::string getErrorLocation(MemoryBufferRef mb, const 
section_64 ,
 }
 
 static void validateLength(MemoryBufferRef mb, const section_64 ,
-   const relocation_info ,
+   relocation_info rel,
ArrayRef validLengths) {
   if (find(validLengths, rel.r_length) != validLengths.end())
 return;
@@ -68,8 +69,13 @@ static void validateLength(MemoryBufferRef mb, const 
section_64 ,
   fatal(msg);
 }
 
-uint64_t X86_64::getImplicitAddend(MemoryBufferRef mb, const section_64 ,
-   const relocation_info ) const {
+bool X86_64::isPairedReloc(relocation_info rel) const {
+  return rel.r_type == X86_64_RELOC_SUBTRACTOR;
+}
+
+uint64_t X86_64::getAddend(MemoryBufferRef mb, const section_64 ,
+   relocation_info rel,
+   relocation_info pairedRel) const {
   auto *buf = reinterpret_cast(mb.getBufferStart());
   const uint8_t *loc = buf + sec.offset + rel.r_address;
 
@@ -139,7 +145,7 @@ void X86_64::relocateOne(uint8_t *loc, const Reloc , 
uint64_t val) const {
 break;
   default:
 llvm_unreachable(
-"getImplicitAddend should have flagged all unhandled relocation 
types");
+"getAddend should have flagged all unhandled relocation types");
   }
 
   switch (r.length) {

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index ce66c9650446..3a4466dd123a 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -206,31 +206,53 @@ static InputSection 
*findContainingSubsection(SubsectionMap ,
 void ObjFile::parseRelocations(const section_64 ,
SubsectionMap ) {
   auto *buf = reinterpret_cast(mb.getBufferStart());
-  ArrayRef anyRelInfos(
-  reinterpret_cast(buf + sec.reloff),
-  sec.nreloc);
-
-  for (const any_relocation_info  : anyRelInfos) {
-if (anyRelInfo.r_word0 & R_SCATTERED)
+  ArrayRef relInfos(
+  reinterpret_cast(buf + sec.reloff), sec.nreloc);
+
+  for (size_t i = 0; i < relInfos.size(); i++) {
+// Paired relocations serve as Mach-O's method for attaching a
+// supplemental datum to a primary relocation record. ELF does not
+// need them because the *_RELOC_RELA records contain the extra
+// addend field, vs. *_RELOC_REL which omit the addend.
+//
+// The {X86_64,ARM64}_RELOC_SUBTRACTOR record holds the subtrahend,
+// and the paired *_RELOC_UNSIGNED record holds the minuend. The
+// datum for each is a symbolic address. The result is the runtime
+// offset between two addresses.
+//
+// The ARM64_RELOC_ADDEND record holds the 

[llvm-branch-commits] [llvm] ed6a135 - [IVDescriptors] Remove getConsecutiveDirection (NFC)

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

Author: Kazu Hirata
Date: 2020-12-17T20:19:15-08:00
New Revision: ed6a135246f01eb7a52bbe321a0b4de1d40b513d

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

LOG: [IVDescriptors] Remove getConsecutiveDirection (NFC)

The last use of the function was removed on Sep 18, 2016 in commit
5f8cc0c3469ba3a7aa440b43aaababa3a6274213.

The function was later moved to llvm/lib/Analysis/IVDescriptors.cpp on
Sep 12, 2018 in commit 7e98d69847aefb1028aaa7131b508f4b4e9896ae.

Added: 


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

Removed: 




diff  --git a/llvm/include/llvm/Analysis/IVDescriptors.h 
b/llvm/include/llvm/Analysis/IVDescriptors.h
index 6e825c7d5351..e736adf899b8 100644
--- a/llvm/include/llvm/Analysis/IVDescriptors.h
+++ b/llvm/include/llvm/Analysis/IVDescriptors.h
@@ -268,12 +268,6 @@ class InductionDescriptor {
   /// Default constructor - creates an invalid induction.
   InductionDescriptor() = default;
 
-  /// Get the consecutive direction. Returns:
-  ///   0 - unknown or non-consecutive.
-  ///   1 - consecutive and increasing.
-  ///  -1 - consecutive and decreasing.
-  int getConsecutiveDirection() const;
-
   Value *getStartValue() const { return StartValue; }
   InductionKind getKind() const { return IK; }
   const SCEV *getStep() const { return Step; }

diff  --git a/llvm/lib/Analysis/IVDescriptors.cpp 
b/llvm/lib/Analysis/IVDescriptors.cpp
index c7e7ddbd8fc2..d9756512de77 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -927,13 +927,6 @@ InductionDescriptor::InductionDescriptor(Value *Start, 
InductionKind K,
   }
 }
 
-int InductionDescriptor::getConsecutiveDirection() const {
-  ConstantInt *ConstStep = getConstIntStepValue();
-  if (ConstStep && (ConstStep->isOne() || ConstStep->isMinusOne()))
-return ConstStep->getSExtValue();
-  return 0;
-}
-
 ConstantInt *InductionDescriptor::getConstIntStepValue() const {
   if (isa(Step))
 return dyn_cast(cast(Step)->getValue());



___
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] b621116 - [Transforms] Use llvm::erase_if (NFC)

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

Author: Kazu Hirata
Date: 2020-12-17T19:53:10-08:00
New Revision: b62111671619a78e61b603493478fbac6e487df7

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

LOG: [Transforms] Use llvm::erase_if (NFC)

Added: 


Modified: 
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
llvm/lib/Transforms/Scalar/GuardWidening.cpp
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Scalar/SpeculateAroundPHIs.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/LowerSwitch.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp 
b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
index 9bfb176dcd7f..ab7e0ae9d4a5 100644
--- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -950,10 +950,9 @@ void CHR::checkScopeHoistable(CHRScope *Scope) {
 << "Dropped select due to unhoistable branch";
   });
 }
-Selects.erase(std::remove_if(Selects.begin(), Selects.end(),
- [EntryBB](SelectInst *SI) {
-   return SI->getParent() == EntryBB;
- }), Selects.end());
+llvm::erase_if(Selects, [EntryBB](SelectInst *SI) {
+  return SI->getParent() == EntryBB;
+});
 Unhoistables.clear();
 InsertPoint = Branch;
   }

diff  --git a/llvm/lib/Transforms/Scalar/GuardWidening.cpp 
b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
index a3eba27a4d90..b09def442d7a 100644
--- a/llvm/lib/Transforms/Scalar/GuardWidening.cpp
+++ b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
@@ -666,7 +666,7 @@ bool GuardWideningImpl::combineRangeChecks(
 };
 
 copy_if(Checks, std::back_inserter(CurrentChecks), IsCurrentCheck);
-Checks.erase(remove_if(Checks, IsCurrentCheck), Checks.end());
+erase_if(Checks, IsCurrentCheck);
 
 assert(CurrentChecks.size() != 0 && "We know we have at least one!");
 

diff  --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp 
b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index ab40a9e533de..ae1fff0fa844 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1399,7 +1399,7 @@ bool IndVarSimplify::optimizeLoopExits(Loop *L, 
SCEVExpander ) {
 
   // Remove all exits which aren't both rewriteable and execute on every
   // iteration.
-  auto NewEnd = llvm::remove_if(ExitingBlocks, [&](BasicBlock *ExitingBB) {
+  llvm::erase_if(ExitingBlocks, [&](BasicBlock *ExitingBB) {
 // If our exitting block exits multiple loops, we can only rewrite the
 // innermost one.  Otherwise, we're changing how many times the innermost
 // loop runs before it exits.
@@ -1421,7 +1421,6 @@ bool IndVarSimplify::optimizeLoopExits(Loop *L, 
SCEVExpander ) {
 
 return false;
   });
-  ExitingBlocks.erase(NewEnd, ExitingBlocks.end());
 
   if (ExitingBlocks.empty())
 return false;

diff  --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp 
b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 91cd4c8e7abf..42036a801c4f 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -2038,8 +2038,7 @@ static void relocationViaAlloca(
 /// tests in ways which make them less useful in testing fused safepoints.
 template  static void unique_unsorted(SmallVectorImpl ) {
   SmallSet Seen;
-  Vec.erase(remove_if(Vec, [&](const T ) { return !Seen.insert(V).second; }),
-Vec.end());
+  erase_if(Vec, [&](const T ) { return !Seen.insert(V).second; });
 }
 
 /// Insert holders so that each Value is obviously live through the entire

diff  --git a/llvm/lib/Transforms/Scalar/SROA.cpp 
b/llvm/lib/Transforms/Scalar/SROA.cpp
index 6c02b38c1e9d..600863d50d54 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -467,12 +467,8 @@ class AllocaSlices::partition_iterator
 // Remove the uses which have ended in the prior partition. This
 // cannot change the max split slice end because we just checked that
 // the prior partition ended prior to that max.
-P.SplitTails.erase(llvm::remove_if(P.SplitTails,
-   [&](Slice *S) {
- return S->endOffset() <=
-P.EndOffset;
-   }),
-   P.SplitTails.end());
+

[llvm-branch-commits] [llvm] 7087ae7 - [RISCV] Remove NoVReg to avoid compile warning messages.

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

Author: Hsiangkai Wang
Date: 2020-12-18T11:37:47+08:00
New Revision: 7087ae7be9f00b95d14bfba41264bbbd8f8711f2

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

LOG: [RISCV] Remove NoVReg to avoid compile warning messages.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index 7f5210310df7..3363aed34f39 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -47,7 +47,7 @@ class LMULInfo {
 def V_M1  : LMULInfo<0b000,   VR,   VRM2, "M1">;
 def V_M2  : LMULInfo<0b001, VRM2,   VRM4, "M2">;
 def V_M4  : LMULInfo<0b010, VRM4,   VRM8, "M4">;
-def V_M8  : LMULInfo<0b011, VRM8, NoVReg, "M8">;
+def V_M8  : LMULInfo<0b011, VRM8, VR, "M8">;
 
 def V_MF8 : LMULInfo<0b101,   VR, VR, "MF8">;
 def V_MF4 : LMULInfo<0b110,   VR, VR, "MF4">;

diff  --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index b87658fea59a..442cb2e4b0b8 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -396,9 +396,6 @@ class VReg regTypes, dag regList, int Vlmul>
   int Size = !mul(Vlmul, 64); // FIXME: assuming ELEN=64
 }
 
-// Dummy V register class.
-def NoVReg : VReg<[vint8m1_t], (add V0), 0>;
-
 def VR : VReg<[vint8mf2_t, vint8mf4_t, vint8mf8_t,
vint16mf2_t, vint16mf4_t, vint32mf2_t,
vint8m1_t, vint16m1_t, vint32m1_t, vint64m1_t,



___
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] 31c0b87 - Fix clang-ppc64le-rhel buildbot build error

2020-12-17 Thread Rong Xu via llvm-branch-commits

Author: Rong Xu
Date: 2020-12-17T19:14:43-08:00
New Revision: 31c0b8700b4f531b2353fbb0e72d6934f65814f8

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

LOG: Fix clang-ppc64le-rhel buildbot build error

ix buildbot build error due to
commit 3733463d: [IR][PGO] Add hot func attribute and use hot/cold
attribute in func section

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp 
b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index 91297b8dea19..e30812935426 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -943,6 +943,7 @@ Function *CodeExtractor::constructFunction(const ValueSet 
,
   // Those attributes should be safe to propagate to the extracted 
function.
   case Attribute::AlwaysInline:
   case Attribute::Cold:
+  case Attribute::Hot:
   case Attribute::NoRecurse:
   case Attribute::InlineHint:
   case Attribute::MinSize:



___
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] f6b577e - [flang] Fix -intrinsic-module-directory in flang script

2020-12-17 Thread Tim Keith via llvm-branch-commits

Author: Tim Keith
Date: 2020-12-17T19:08:19-08:00
New Revision: f6b577ed5bf61078cdcf60e94867b75c94f540a7

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

LOG: [flang] Fix -intrinsic-module-directory in flang script

The flang wrapper script that was created as bin/flang in an in-tree
build did not have a correct -intrinsic-module-directory option.
It was correct for out-of-tree builds and for both kinds of installs.

The fix is to pick the correct directory based on what exists.

The script is no longer configured by cmake (just copied) so that
mechanism can be deleted from the cmake file.

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

Added: 
flang/tools/f18/flang

Modified: 
flang/tools/f18/CMakeLists.txt

Removed: 
flang/tools/f18/flang.sh.in



diff  --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index cdc09fc7a68a..8f30bfa47b79 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -65,28 +65,12 @@ add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
 
 install(TARGETS f18 DESTINATION bin)
 
-set(FLANG_INTRINSIC_MODULES_DIR ${FLANG_BINARY_DIR}/include/flang)
-
 # This flang shell script will only work in a POSIX shell.
 if (NOT WIN32)
-  if (FLANG_STANDALONE_BUILD)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in 
${CMAKE_BINARY_DIR}/tools/flang/bin/flang @ONLY)
-file(COPY ${CMAKE_BINARY_DIR}/tools/flang/bin/flang DESTINATION 
${CMAKE_BINARY_DIR}/bin FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)
-  else()
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in
-  ${CMAKE_CURRENT_BINARY_DIR}/tools/flang/bin/flang @ONLY)
-add_custom_command(TARGET f18
-POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E copy
-  ${CMAKE_CURRENT_BINARY_DIR}/tools/flang/bin/flang
-  ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang
-COMMAND chmod +x ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang)
-  endif()
+  file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/flang
+DESTINATION ${CMAKE_BINARY_DIR}/bin
+FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)
+  install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang DESTINATION bin)
 endif()
 
-# The flang script to be installed needs a 
diff erent path to the headers.
-set(FLANG_INTRINSIC_MODULES_DIR ${CMAKE_INSTALL_PREFIX}/include/flang)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.sh.in 
${FLANG_BINARY_DIR}/bin/flang-install.sh @ONLY)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/f18_version.h.in 
${CMAKE_CURRENT_BINARY_DIR}/f18_version.h @ONLY)
-
-install(PROGRAMS ${FLANG_BINARY_DIR}/bin/flang-install.sh DESTINATION bin 
RENAME flang)

diff  --git a/flang/tools/f18/flang b/flang/tools/f18/flang
new file mode 100644
index ..01bdffdd20c7
--- /dev/null
+++ b/flang/tools/f18/flang
@@ -0,0 +1,15 @@
+#!/bin/bash
+#===-- tools/f18/flang.sh -*- sh 
-*-===#
+#
+# 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
+#
+#======#
+
+wd=$(cd $(dirname "$0")/.. && pwd)
+module_dir=$wd/include/flang
+if [[ ! -d $module_dir ]]; then
+  module_dir=$wd/tools/flang/include/flang
+fi
+$wd/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory $module_dir 
"$@"

diff  --git a/flang/tools/f18/flang.sh.in b/flang/tools/f18/flang.sh.in
deleted file mode 100644
index 295d93abbeb6..
--- a/flang/tools/f18/flang.sh.in
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-#===-- tools/f18/flang.sh -*- sh 
-*-===#
-#
-# 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
-#
-#======#
-
-function abspath() {
-  pushd . > /dev/null;
-  if [ -d "$1" ]; then
-cd "$1";
-dirs -l +0;
-  else
-cd "`dirname \"$1\"`";
-cur_dir=`dirs -l +0`;
-if [ "$cur_dir" == "/" ]; then
-  echo "$cur_dir`basename \"$1\"`";
-else
-  echo "$cur_dir/`basename \"$1\"`";
-fi;
-  fi;
-  popd > /dev/null;
-}
-
-wd=`abspath $(dirname "$0")/..`
-
-${wd}/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory 
${wd}/include/flang $*



___
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] 3733463 - [IR][PGO] Add hot func attribute and use hot/cold attribute in func section

2020-12-17 Thread Rong Xu via llvm-branch-commits

Author: Rong Xu
Date: 2020-12-17T18:41:12-08:00
New Revision: 3733463dbb58a29892be3872bd32f93cb9af492c

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

LOG: [IR][PGO] Add hot func attribute and use hot/cold attribute in func section

Clang FE currently has hot/cold function attribute. But we only have
cold function attribute in LLVM IR.

This patch adds support of hot function attribute to LLVM IR.  This
attribute will be used in setting function section prefix/suffix.
Currently .hot and .unlikely suffix only are added in PGO (Sample PGO)
compilation (through isFunctionHotInCallGraph and
isFunctionColdInCallGraph).

This patch changes the behavior. The new behavior is:
(1) If the user annotates a function as hot or isFunctionHotInCallGraph
is true, this function will be marked as hot. Otherwise,
(2) If the user annotates a function as cold or
isFunctionColdInCallGraph is true, this function will be marked as
cold.

The changes are:
(1) user annotated function attribute will used in setting function
section prefix/suffix.
(2) hot attribute overwrites profile count based hotness.
(3) profile count based hotness overwrite user annotated cold attribute.

The intention for these changes is to provide the user a way to mark
certain function as hot in cases where training input is hard to cover
all the hot functions.

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

Added: 
llvm/test/CodeGen/X86/hot-unlikely-section-prefix.ll
llvm/test/MC/AsmParser/function_hot_attr.ll

Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attributes.c
llvm/docs/LangRef.rst
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.td
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Bitcode/attributes.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index bfc7b8e74d8f..e28736bd3d2f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1944,6 +1944,8 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::Cold);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute(llvm::Attribute::Hot);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
 if (TargetDecl->hasAttr())

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 7dd343dbcc16..93916e85a461 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1744,7 +1744,8 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
 B.addAttribute(llvm::Attribute::OptimizeForSize);
   B.addAttribute(llvm::Attribute::Cold);
 }
-
+if (D->hasAttr())
+  B.addAttribute(llvm::Attribute::Hot);
 if (D->hasAttr())
   B.addAttribute(llvm::Attribute::MinSize);
   }

diff  --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
index 0c1455d3c612..5ef176c138af 100644
--- a/clang/test/CodeGen/attributes.c
+++ b/clang/test/CodeGen/attributes.c
@@ -63,6 +63,13 @@ void t72() { t71(); }
 // CHECK: call void @t71() [[COLDSITE:#[0-9]+]]
 // CHECK: declare void @t71() [[COLDDECL:#[0-9]+]]
 
+// CHECK: define void @t82() [[HOTDEF:#[0-9]+]] {
+void t81(void) __attribute__((hot));
+void t82() __attribute__((hot));
+void t82() { t81(); }
+// CHECK: call void @t81() [[HOTSITE:#[0-9]+]]
+// CHECK: declare void @t81() [[HOTDECL:#[0-9]+]]
+
 // CHECK: define void @t10() [[NUW]] section "xSECT" {
 void t10(void) __attribute__((section("xSECT")));
 void t10(void) {}
@@ -72,6 +79,9 @@ void __attribute__((section("xSECT"))) t11(void) {}
 // CHECK: define i32 @t19() [[NUW]] {
 extern int t19(void) __attribute__((weak_import));
 int t19(void) {
+// RUN: %clang_cc1 -emit-llvm -fcf-protection=branch -triple i386-linux-gnu -o 
%t %s
+// RUN: %clang_cc1 -emit-llvm -fcf-protection=branch -triple i386-linux-gnu -o 
%t %s
+// RUN: %clang_cc1 -emit-llvm -fcf-protection=branch -triple i386-linux-gnu -o 
%t %s
   return 10;
 }
 
@@ -111,6 +121,9 @@ void t24(f_t f1) {
 // CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} }
 // CHECK: attributes [[COLDDEF]] = { cold {{.*}}}
 // CHECK: attributes [[COLDDECL]] = { cold {{.*}}}
+// CHECK: attributes [[HOTDEF]] = { hot {{.*}}}
+// CHECK: attributes [[HOTDECL]] = { hot {{.*}}}
 // CHECK: attributes 

[llvm-branch-commits] [llvm] 385e9a2 - [DAGCombiner] Improve shift by select of constant

2020-12-17 Thread QingShan Zhang via llvm-branch-commits

Author: Layton Kifer
Date: 2020-12-18T02:21:42Z
New Revision: 385e9a2a047bc0bee13a21a9016763e694a686a3

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

LOG: [DAGCombiner] Improve shift by select of constant

Clean up a TODO, to support folding a shift of a constant by a
select of constants, on targets with different shift operand sizes.

Reviewed By: RKSimon, lebedev.ri

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/select_const.ll
llvm/test/CodeGen/PowerPC/select_const.ll
llvm/test/CodeGen/X86/dagcombine-select.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 212e0a2ea988..74d3e1adcd6c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2150,16 +2150,7 @@ SDValue DAGCombiner::foldBinOpIntoSelect(SDNode *BO) {
   !isConstantFPBuildVectorOrConstantFP(CBO))
 return SDValue();
 
-  EVT VT = Sel.getValueType();
-
-  // In case of shift value and shift amount may have 
diff erent VT. For instance
-  // on x86 shift amount is i8 regardles of LHS type. Bail out if we have
-  // swapped operands and value types do not match. NB: x86 is fine if operands
-  // are not swapped with shift amount VT being not bigger than shifted value.
-  // TODO: that is possible to check for a shift operation, correct VTs and
-  // still perform optimization on x86 if needed.
-  if (SelOpNo && VT != CBO.getValueType())
-return SDValue();
+  EVT VT = BO->getValueType(0);
 
   // We have a select-of-constants followed by a binary operator with a
   // constant. Eliminate the binop by pulling the constant math into the 
select.

diff  --git a/llvm/test/CodeGen/AArch64/select_const.ll 
b/llvm/test/CodeGen/AArch64/select_const.ll
index 945e7cdc35ad..f58232e2ee89 100644
--- a/llvm/test/CodeGen/AArch64/select_const.ll
+++ b/llvm/test/CodeGen/AArch64/select_const.ll
@@ -437,10 +437,9 @@ define i8 @shl_constant_sel_constants(i1 %cond) {
 ; CHECK-LABEL: shl_constant_sel_constants:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:tst w0, #0x1
-; CHECK-NEXT:mov w8, #2
-; CHECK-NEXT:cinc x8, x8, eq
-; CHECK-NEXT:mov w9, #1
-; CHECK-NEXT:lsl w0, w9, w8
+; CHECK-NEXT:mov w8, #8
+; CHECK-NEXT:mov w9, #4
+; CHECK-NEXT:csel w0, w9, w8, ne
 ; CHECK-NEXT:ret
   %sel = select i1 %cond, i8 2, i8 3
   %bo = shl i8 1, %sel
@@ -463,10 +462,9 @@ define i8 @lshr_constant_sel_constants(i1 %cond) {
 ; CHECK-LABEL: lshr_constant_sel_constants:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:tst w0, #0x1
-; CHECK-NEXT:mov w8, #2
-; CHECK-NEXT:cinc x8, x8, eq
-; CHECK-NEXT:mov w9, #64
-; CHECK-NEXT:lsr w0, w9, w8
+; CHECK-NEXT:mov w8, #8
+; CHECK-NEXT:mov w9, #16
+; CHECK-NEXT:csel w0, w9, w8, ne
 ; CHECK-NEXT:ret
   %sel = select i1 %cond, i8 2, i8 3
   %bo = lshr i8 64, %sel
@@ -488,10 +486,9 @@ define i8 @ashr_constant_sel_constants(i1 %cond) {
 ; CHECK-LABEL: ashr_constant_sel_constants:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:tst w0, #0x1
-; CHECK-NEXT:mov w8, #2
-; CHECK-NEXT:cinc x8, x8, eq
-; CHECK-NEXT:mov w9, #-128
-; CHECK-NEXT:asr w0, w9, w8
+; CHECK-NEXT:mov w8, #-16
+; CHECK-NEXT:mov w9, #-32
+; CHECK-NEXT:csel w0, w9, w8, ne
 ; CHECK-NEXT:ret
   %sel = select i1 %cond, i8 2, i8 3
   %bo = ashr i8 128, %sel

diff  --git a/llvm/test/CodeGen/PowerPC/select_const.ll 
b/llvm/test/CodeGen/PowerPC/select_const.ll
index 7e8b6297ed3c..804cc7736bf8 100644
--- a/llvm/test/CodeGen/PowerPC/select_const.ll
+++ b/llvm/test/CodeGen/PowerPC/select_const.ll
@@ -610,13 +610,24 @@ define i8 @sel_constants_shl_constant(i1 %cond) {
 }
 
 define i8 @shl_constant_sel_constants(i1 %cond) {
-; ALL-LABEL: shl_constant_sel_constants:
-; ALL:   # %bb.0:
-; ALL-NEXT:clrlwi 3, 3, 31
-; ALL-NEXT:li 4, 1
-; ALL-NEXT:subfic 3, 3, 3
-; ALL-NEXT:slw 3, 4, 3
-; ALL-NEXT:blr
+; ISEL-LABEL: shl_constant_sel_constants:
+; ISEL:   # %bb.0:
+; ISEL-NEXT:andi. 3, 3, 1
+; ISEL-NEXT:li 4, 4
+; ISEL-NEXT:li 3, 8
+; ISEL-NEXT:iselgt 3, 4, 3
+; ISEL-NEXT:blr
+;
+; NO_ISEL-LABEL: shl_constant_sel_constants:
+; NO_ISEL:   # %bb.0:
+; NO_ISEL-NEXT:andi. 3, 3, 1
+; NO_ISEL-NEXT:li 4, 4
+; NO_ISEL-NEXT:li 3, 8
+; NO_ISEL-NEXT:bc 12, 1, .LBB37_1
+; NO_ISEL-NEXT:blr
+; NO_ISEL-NEXT:  .LBB37_1:
+; NO_ISEL-NEXT:addi 3, 4, 0
+; NO_ISEL-NEXT:blr
   %sel = select i1 %cond, i8 2, i8 3
   %bo = shl i8 1, %sel
   ret i8 %bo
@@ -647,13 +658,24 @@ define i8 @sel_constants_lshr_constant(i1 %cond) {
 }
 
 define i8 @lshr_constant_sel_constants(i1 

[llvm-branch-commits] [clang-tools-extra] 2808f59 - [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.

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

Author: Nathan James
Date: 2020-12-18T02:07:27Z
New Revision: 2808f597f872e68a8bd69d5b53f5d583665b4c4f

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

LOG: [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.

Currently warnings when parsing .clang-tidy are printed directly to errs.
This is less than ideal as there is no synchronisation printing to errs, 
leading to potential races.

Reviewed By: sammccall

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/TidyProvider.cpp 
b/clang-tools-extra/clangd/TidyProvider.cpp
index c6ee09ae16d2..c12dab7e2e5e 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 
@@ -44,8 +45,25 @@ class DotClangTidyCache : private FileCache {
 [this](llvm::Optional Data) {
   Value.reset();
   if (Data && !Data->empty()) {
-if (auto Parsed = tidy::parseConfiguration(
-llvm::MemoryBufferRef(*Data, path(
+tidy::DiagCallback Diagnostics = [](const llvm::SMDiagnostic ) {
+  switch (D.getKind()) {
+  case llvm::SourceMgr::DK_Error:
+elog("tidy-config error at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Warning:
+log("tidy-config warning at {0}:{1}:{2}: {3}", D.getFilename(),
+D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  case llvm::SourceMgr::DK_Note:
+  case llvm::SourceMgr::DK_Remark:
+vlog("tidy-config note at {0}:{1}:{2}: {3}", D.getFilename(),
+ D.getLineNo(), D.getColumnNo(), D.getMessage());
+break;
+  }
+};
+if (auto Parsed = tidy::parseConfigurationWithDiags(
+llvm::MemoryBufferRef(*Data, path()), Diagnostics))
   Value = std::make_shared(
   std::move(*Parsed));
 else



___
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] cc1cf63 - [lld-macho] Implement option: -undefined TREATMENT

2020-12-17 Thread Greg McGary via llvm-branch-commits

Author: Greg McGary
Date: 2020-12-17T17:40:50-08:00
New Revision: cc1cf6332a301331ef1b20e24948159dc291014a

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

LOG: [lld-macho] Implement option: -undefined TREATMENT

TREATMENT can be `error`, `warning`, `suppress`, or `dynamic_lookup`
The `dymanic_lookup` remains unimplemented for now.

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

Added: 
lld/test/MachO/treat-undef-sym.s

Modified: 
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/MachO/SymbolTable.cpp
lld/MachO/SymbolTable.h
lld/MachO/Writer.cpp
lld/test/MachO/demangle.s
lld/test/MachO/invalid/stub-link.s
lld/test/MachO/invalid/undefined-symbol.s
lld/test/MachO/weak-reference.s

Removed: 




diff  --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index 029b9ab2296c..4f27ec2db45f 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -30,6 +30,14 @@ struct PlatformInfo {
   llvm::VersionTuple sdk;
 };
 
+enum class UndefinedSymbolTreatment {
+  unknown,
+  error,
+  warning,
+  suppress,
+  dynamic_lookup,
+};
+
 struct Configuration {
   Symbol *entry;
   bool hasReexports = false;
@@ -52,6 +60,8 @@ struct Configuration {
   bool demangle = false;
   llvm::MachO::Architecture arch;
   PlatformInfo platform;
+  UndefinedSymbolTreatment undefinedSymbolTreatment =
+  UndefinedSymbolTreatment::error;
   llvm::MachO::HeaderFileType outputType;
   std::vector systemLibraryRoots;
   std::vector librarySearchPaths;

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 4f9c111bd8fb..63d101270cf5 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -599,6 +599,22 @@ static void handlePlatformVersion(const opt::Arg *arg) {
 error(Twine("malformed sdk version: ") + sdkVersionStr);
 }
 
+static void handleUndefined(const opt::Arg *arg) {
+  StringRef treatmentStr = arg->getValue(0);
+  config->undefinedSymbolTreatment =
+  llvm::StringSwitch(treatmentStr)
+  .Case("error", UndefinedSymbolTreatment::error)
+  .Case("warning", UndefinedSymbolTreatment::warning)
+  .Case("suppress", UndefinedSymbolTreatment::suppress)
+  .Case("dynamic_lookup", UndefinedSymbolTreatment::dynamic_lookup)
+  .Default(UndefinedSymbolTreatment::unknown);
+  if (config->undefinedSymbolTreatment == UndefinedSymbolTreatment::unknown) {
+warn(Twine("unknown -undefined TREATMENT '") + treatmentStr +
+ "', defaulting to 'error'");
+config->undefinedSymbolTreatment = UndefinedSymbolTreatment::error;
+  }
+}
+
 static void warnIfDeprecatedOption(const opt::Option ) {
   if (!opt.getGroup().isValid())
 return;
@@ -809,6 +825,9 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
 case OPT_platform_version:
   handlePlatformVersion(arg);
   break;
+case OPT_undefined:
+  handleUndefined(arg);
+  break;
 default:
   break;
 }

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index e3ee14a74328..1ab2f9109ee0 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -408,7 +408,6 @@ def U : Separate<["-"], "U">,
 def undefined : Separate<["-"], "undefined">,
  MetaVarName<"">,
  HelpText<"Handle undefined symbols according to : error, 
warning, suppress, or dynamic_lookup (default is error)">,
- Flags<[HelpHidden]>,
  Group;
 def rpath : Separate<["-"], "rpath">,
  MetaVarName<"">,

diff  --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index 93a2508951a5..ea231c9786e2 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "SymbolTable.h"
+#include "Config.h"
 #include "InputFiles.h"
 #include "Symbols.h"
 #include "lld/Common/ErrorHandler.h"
@@ -154,4 +155,26 @@ Symbol *SymbolTable::addDSOHandle(const MachHeaderSection 
*header) {
   return s;
 }
 
+void lld::macho::treatUndefinedSymbol(StringRef symbolName,
+  StringRef fileName) {
+  std::string message = ("undefined symbol: " + symbolName).str();
+  if (!fileName.empty())
+message += ("\n>>> referenced by " + fileName).str();
+  switch (config->undefinedSymbolTreatment) {
+  case UndefinedSymbolTreatment::suppress:
+break;
+  case UndefinedSymbolTreatment::error:
+error(message);
+break;
+  case UndefinedSymbolTreatment::warning:
+warn(message);
+break;
+  case UndefinedSymbolTreatment::dynamic_lookup:
+error("dynamic_lookup unimplemented for " + message);
+break;
+  case UndefinedSymbolTreatment::unknown:
+llvm_unreachable("unknown -undefined TREATMENT");
+  }
+}
+
 SymbolTable *macho::symtab;

diff  --git 

[llvm-branch-commits] [llvm] cea8076 - [IRSim][IROutliner] Adding InstVisitor to disallow certain operations.

2020-12-17 Thread Andrew Litteken via llvm-branch-commits

Author: Andrew Litteken
Date: 2020-12-17T19:33:57-06:00
New Revision: cea807602a2fb0b8d79b0eef30ce717ae4645fbc

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

LOG: [IRSim][IROutliner] Adding InstVisitor to disallow certain operations.

This adds a custom InstVisitor to return false on instructions that
should not be allowed to be outlined.  These match the illegal
instructions in the IRInstructionMapper with exception of the addition
of the llvm.assume intrinsic.

Tests all the tests marked: illegal-*-.ll with a test for each kind of
instruction that has been marked as illegal.

Reviewers: jroelofs, paquette

Differential Revisions: https://reviews.llvm.org/D86976

Added: 
llvm/test/Transforms/IROutliner/illegal-allocas.ll
llvm/test/Transforms/IROutliner/illegal-assumes.ll
llvm/test/Transforms/IROutliner/illegal-branches.ll
llvm/test/Transforms/IROutliner/illegal-callbr.ll
llvm/test/Transforms/IROutliner/illegal-calls.ll
llvm/test/Transforms/IROutliner/illegal-catchpad.ll
llvm/test/Transforms/IROutliner/illegal-cleanup.ll
llvm/test/Transforms/IROutliner/illegal-frozen.ll
llvm/test/Transforms/IROutliner/illegal-gep.ll
llvm/test/Transforms/IROutliner/illegal-invoke.ll
llvm/test/Transforms/IROutliner/illegal-landingpad.ll
llvm/test/Transforms/IROutliner/illegal-memcpy.ll
llvm/test/Transforms/IROutliner/illegal-memmove.ll
llvm/test/Transforms/IROutliner/illegal-memset.ll
llvm/test/Transforms/IROutliner/illegal-phi-nodes.ll
llvm/test/Transforms/IROutliner/illegal-vaarg.ll
llvm/test/Transforms/IROutliner/legal-debug.ll

Modified: 
llvm/include/llvm/Transforms/IPO/IROutliner.h
llvm/lib/Transforms/IPO/IROutliner.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/IPO/IROutliner.h 
b/llvm/include/llvm/Transforms/IPO/IROutliner.h
index 80ba40d91ed8..b49970e7056d 100644
--- a/llvm/include/llvm/Transforms/IPO/IROutliner.h
+++ b/llvm/include/llvm/Transforms/IPO/IROutliner.h
@@ -178,6 +178,61 @@ class IROutliner {
 
   /// The memory allocator used to allocate new IRInstructionData.
   SpecificBumpPtrAllocator InstDataAllocator;
+
+  /// Custom InstVisitor to classify 
diff erent instructions for whether it can
+  /// be analyzed for similarity.  This is needed as there may be instruction 
we
+  /// can identify as having similarity, but are more complicated to outline.
+  struct InstructionAllowed
+  : public InstVisitor {
+InstructionAllowed() {}
+
+// TODO: Determine a scheme to resolve when the label is similar enough.
+bool visitBranchInst(BranchInst ) { return false; }
+// TODO: Determine a scheme to resolve when the labels are similar enough.
+bool visitPHINode(PHINode ) { return false; }
+// TODO: Handle allocas.
+bool visitAllocaInst(AllocaInst ) { return false; }
+// VAArg instructions are not allowed since this could cause 
diff iculty when
+// 
diff erentiating between 
diff erent sets of variable instructions in
+// the deduplicated outlined regions.
+bool visitVAArgInst(VAArgInst ) { return false; }
+// We exclude all exception handling cases since they are so context
+// dependent.
+bool visitLandingPadInst(LandingPadInst ) { return false; }
+bool visitFuncletPadInst(FuncletPadInst ) { return false; }
+// DebugInfo should be included in the regions, but should not be
+// analyzed for similarity as it has no bearing on the outcome of the
+// program.
+bool visitDbgInfoIntrinsic(DbgInfoIntrinsic ) {
+  return true;
+}
+// TODO: Handle GetElementPtrInsts
+bool visitGetElementPtrInst(GetElementPtrInst ) {
+  return false;
+}
+// TODO: Handle specific intrinsics individually from those that can be
+// handled.
+bool IntrinsicInst(IntrinsicInst ) { return false; }
+// TODO: Handle CallInsts, there will need to be handling for special kinds
+// of calls, as well as calls to intrinsics.
+bool visitCallInst(CallInst ) { return false; }
+// TODO: Handle FreezeInsts.  Since a frozen value could be frozen inside
+// the outlined region, and then returned as an output, this will have to 
be
+// handled 
diff erently.
+bool visitFreezeInst(FreezeInst ) { return false; }
+// TODO: We do not current handle similarity that changes the control flow.
+bool visitInvokeInst(InvokeInst ) { return false; }
+// TODO: We do not current handle similarity that changes the control flow.
+bool visitCallBrInst(CallBrInst ) { return false; }
+// TODO: Handle interblock similarity.
+bool visitTerminator(Instruction ) { return false; }
+bool visitInstruction(Instruction ) { 
+  return true;
+}
+  };
+
+  /// A InstVisitor used to exclude certain 

[llvm-branch-commits] [mlir] fc5cf50 - [mlir] Remove the MutableDictionaryAttr class

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

Author: River Riddle
Date: 2020-12-17T17:18:42-08:00
New Revision: fc5cf50e892b5e2307de924923fe799702b055d2

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

LOG: [mlir] Remove the MutableDictionaryAttr class

This class used to serve a few useful purposes:
* Allowed containing a null DictionaryAttr
* Provided some simple mutable API around a DictionaryAttr

The first of which is no longer an issue now that there is much better caching 
support for attributes in general, and a cache in the context for empty 
dictionaries. The second results in more trouble than it's worth because it 
mutates the internal dictionary on every action, leading to a potentially large 
number of dictionary copies. NamedAttrList is a much better alternative for the 
second use case, and should be modified as needed to better fit it's usage as a 
DictionaryAttrBuilder.

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

Added: 


Modified: 
flang/lib/Optimizer/Dialect/FIROps.cpp
mlir/docs/OpDefinitions.md
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/IR/BuiltinAttributes.h
mlir/include/mlir/IR/BuiltinOps.td
mlir/include/mlir/IR/FunctionSupport.h
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/Operation.h
mlir/include/mlir/IR/OperationSupport.h
mlir/lib/CAPI/IR/IR.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/IR/Attributes.cpp
mlir/lib/IR/BuiltinAttributes.cpp
mlir/lib/IR/BuiltinDialect.cpp
mlir/lib/IR/FunctionSupport.cpp
mlir/lib/IR/Operation.cpp
mlir/lib/IR/OperationSupport.cpp
mlir/lib/IR/SymbolTable.cpp
mlir/lib/Pass/IRPrinting.cpp
mlir/lib/Target/SPIRV/Deserialization.cpp
mlir/lib/Transforms/SCCP.cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/OpFormatGen.cpp

Removed: 




diff  --git a/flang/lib/Optimizer/Dialect/FIROps.cpp 
b/flang/lib/Optimizer/Dialect/FIROps.cpp
index e8d8d6c64d1e..7ab24320a666 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -1008,7 +1008,7 @@ getMutableSuccessorOperands(unsigned pos, 
mlir::MutableOperandRange operands,
 StringRef offsetAttr) {
   Operation *owner = operands.getOwner();
   NamedAttribute targetOffsetAttr =
-  *owner->getMutableAttrDict().getNamed(offsetAttr);
+  *owner->getAttrDictionary().getNamed(offsetAttr);
   return getSubOperands(
   pos, operands, targetOffsetAttr.second.cast(),
   mlir::MutableOperandRange::OperandSegment(pos, targetOffsetAttr));

diff  --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md
index c5ffe452b927..0b235f993e3d 100644
--- a/mlir/docs/OpDefinitions.md
+++ b/mlir/docs/OpDefinitions.md
@@ -761,7 +761,7 @@ declarative parameter to `print` method argument is 
detailed below:
 -   Single: `Type`
 -   Optional: `Type`
 -   Variadic: `TypeRange`
-*   `attr-dict` Directive: `const MutableDictionaryAttr&`
+*   `attr-dict` Directive: `DictionaryAttr`
 
 When a variable is optional, the provided value may be null.
 

diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 9608e15bb81a..df022ef47b33 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -962,7 +962,7 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func",
 OpBuilderDAG<(ins "StringRef":$name, "LLVMType":$type,
   CArg<"Linkage", "Linkage::External">:$linkage,
   CArg<"ArrayRef", "{}">:$attrs,
-  CArg<"ArrayRef", "{}">:$argAttrs)>
+  CArg<"ArrayRef", "{}">:$argAttrs)>
   ];
 
   let extraClassDeclaration = [{

diff  --git a/mlir/include/mlir/IR/BuiltinAttributes.h 
b/mlir/include/mlir/IR/BuiltinAttributes.h
index 300741a7923b..34e7e8cfce12 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.h
+++ b/mlir/include/mlir/IR/BuiltinAttributes.h
@@ -1472,75 +1472,6 @@ auto ElementsAttr::getValues() const -> 
iterator_range {
   llvm_unreachable("unexpected attribute kind");
 }
 
-//===--===//
-// MutableDictionaryAttr
-//===--===//
-
-/// A MutableDictionaryAttr is a mutable wrapper around a DictionaryAttr. It
-/// provides additional interfaces for adding, removing, replacing attributes
-/// within a DictionaryAttr.
-///
-/// We assume there will be relatively few attributes on a given operation
-/// (maybe a dozen or so, but not hundreds or thousands) 

[llvm-branch-commits] [compiler-rt] 13261f4 - Revert "[sanitizer-common] Force pickup of llvm-symbolizer from new binaries."

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

Author: Mitch Phillips
Date: 2020-12-17T16:17:56-08:00
New Revision: 13261f4c03492542f756f5ec986510a89f4a1f4b

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

LOG: Revert "[sanitizer-common] Force pickup of llvm-symbolizer from new 
binaries."

This reverts commit 66ee0d3d84a6ea04e895249aef2ea8a812664728.

Broke the bots, reverting for full fix.

Added: 


Modified: 
compiler-rt/test/sanitizer_common/lit.common.cfg.py
compiler-rt/test/sanitizer_common/lit.site.cfg.py.in

Removed: 




diff  --git a/compiler-rt/test/sanitizer_common/lit.common.cfg.py 
b/compiler-rt/test/sanitizer_common/lit.common.cfg.py
index f7c526b6b37b..b4f0670f9959 100644
--- a/compiler-rt/test/sanitizer_common/lit.common.cfg.py
+++ b/compiler-rt/test/sanitizer_common/lit.common.cfg.py
@@ -43,14 +43,6 @@
   # which does not work for abort()-terminated programs.
   default_tool_options += ['abort_on_error=0']
 
-# If the user has a poisoned *SAN_SYMBOLIZER_PATH (like what's setup by
-# build/envsetup.sh on Android), then they can end up with an out-of-date
-# symbolizer for the tests. Ensure they get the one from the recent build tree.
-symbolizer_path="''"
-if len(config.binary_path):
-  symbolizer_path = os.path.join(config.binary_path, "llvm-symbolizer")
-default_tool_options += ['external_symbolizer_path=' + symbolizer_path]
-
 default_tool_options_str = ':'.join(default_tool_options)
 if default_tool_options_str:
   config.environment[tool_options] = default_tool_options_str

diff  --git a/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in 
b/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
index 3ff7c44aeab4..38f5ca158463 100644
--- a/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
+++ b/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
@@ -5,7 +5,6 @@ config.name_suffix = "@CONFIG_NAME@"
 config.tool_name = "@SANITIZER_COMMON_LIT_TEST_MODE@"
 config.target_cflags = "@SANITIZER_COMMON_TEST_TARGET_CFLAGS@"
 config.target_arch = "@SANITIZER_COMMON_TEST_TARGET_ARCH@"
-config.binary_path = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, 
"@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")



___
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] ab1a05d - Revert "[sanitizer-common] Pickup llvm-symbolizer from $OUT/bin IFF exists."

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

Author: Mitch Phillips
Date: 2020-12-17T16:17:56-08:00
New Revision: ab1a05d57f6f10ed36372ae47dad828c5202d07a

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

LOG: Revert "[sanitizer-common] Pickup llvm-symbolizer from $OUT/bin IFF 
exists."

This reverts commit 30d292ddbb7ec84b422738cf52ee0cf49b0369f3.

Broke the bots, reverting for full fix.

Added: 


Modified: 
compiler-rt/test/sanitizer_common/lit.common.cfg.py
compiler-rt/test/sanitizer_common/lit.site.cfg.py.in

Removed: 




diff  --git a/compiler-rt/test/sanitizer_common/lit.common.cfg.py 
b/compiler-rt/test/sanitizer_common/lit.common.cfg.py
index 1f037c00eb15..f7c526b6b37b 100644
--- a/compiler-rt/test/sanitizer_common/lit.common.cfg.py
+++ b/compiler-rt/test/sanitizer_common/lit.common.cfg.py
@@ -46,9 +46,10 @@
 # If the user has a poisoned *SAN_SYMBOLIZER_PATH (like what's setup by
 # build/envsetup.sh on Android), then they can end up with an out-of-date
 # symbolizer for the tests. Ensure they get the one from the recent build tree.
-symbolizer_path = os.path.join(config.binary_path, "bin", "llvm-symbolizer")
-if os.path.exists(symbolizer_path):
-  default_tool_options += ['external_symbolizer_path=' + symbolizer_path]
+symbolizer_path="''"
+if len(config.binary_path):
+  symbolizer_path = os.path.join(config.binary_path, "llvm-symbolizer")
+default_tool_options += ['external_symbolizer_path=' + symbolizer_path]
 
 default_tool_options_str = ':'.join(default_tool_options)
 if default_tool_options_str:

diff  --git a/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in 
b/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
index fa7e54e51e27..3ff7c44aeab4 100644
--- a/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
+++ b/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
@@ -5,7 +5,7 @@ config.name_suffix = "@CONFIG_NAME@"
 config.tool_name = "@SANITIZER_COMMON_LIT_TEST_MODE@"
 config.target_cflags = "@SANITIZER_COMMON_TEST_TARGET_CFLAGS@"
 config.target_arch = "@SANITIZER_COMMON_TEST_TARGET_ARCH@"
-config.binary_path = "@LLVM_BINARY_DIR@"
+config.binary_path = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, 
"@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")



___
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] 14da25b - [mlir][sparse] scalarize reductions in for-loops during sparse codegen

2020-12-17 Thread Aart Bik via llvm-branch-commits

Author: Aart Bik
Date: 2020-12-17T16:12:21-08:00
New Revision: 14da25b4b2eedf8a16aae34edfefd7bcaa5ceae5

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

LOG: [mlir][sparse] scalarize reductions in for-loops during sparse codegen

Reductions in innermost loops become harder for the backend to disambiguate
after bufferization into memrefs, resulting in less efficient load-update-store
cycles. By scalarizing innermost reductions, the backend is more likely to 
assign
a register to perform the reduction (also prepares vectorization). Even though
we could scalarize reductions for more outer loops and while-loops as well,
currently scalarization is only done for chains of innermost for-loops, where
it matters most, to avoid complicating codegen unnecessary (viz. adding lots
of yield instructions).

This CL also refactors condition simplification into the merger class,
where it belongs, so that conditions are simplified only once per loop
nest and not repeatedly as was currently done. This CL also fixes a few
minor bugs, some layout issues, and comments.

Reviewed By: penpornk

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

Added: 


Modified: 
mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
mlir/test/Dialect/Linalg/sparse_1d.mlir
mlir/test/Dialect/Linalg/sparse_2d.mlir
mlir/test/Dialect/Linalg/sparse_3d.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
index cfdb371e3234..fed2eedd41a4 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
@@ -52,6 +52,7 @@ using namespace mlir;
 namespace {
 
 enum class Kind { kTensor, kInvariant, kMulF, kMulI, kAddF, kAddI };
+enum class Dim { kSparse, kDense, kUndef };
 
 /// Tensor expression. Represents a MLIR expression in tensor index notation.
 /// For tensors, e0 denotes the tensor index. For invariants, the IR value is
@@ -81,8 +82,13 @@ struct LatPoint {
 bits.set(b);
   }
   LatPoint(const llvm::BitVector , unsigned e) : bits(b), exp(e) {}
-  /// Conjunction of tensor loop indices as bitvector.
+  /// Conjunction of tensor loop indices as bitvector. This represents
+  /// all indices involved in the tensor expression
   llvm::BitVector bits;
+  /// Simplified conjunction of tensor loop indices as bitvector. This
+  /// represents a simplified condition under which this tensor expression
+  /// must execute. Pre-computed during codegen to avoid repeated eval.
+  llvm::BitVector simple;
   /// Index of the tensor expresssion.
   unsigned exp;
 };
@@ -93,8 +99,14 @@ struct LatPoint {
 /// independently from the basic algorithm if bottlenecks are identified.
 class Merger {
 public:
+  /// Constructs a merger for the given number of tensors and loops. The
+  /// user supplies the number of tensors involved in the kernel, with the
+  /// last tensor in this set denoting the output tensor. The merger adds an
+  /// additional synthetic tensor at the end of this set to represent all
+  /// invariant expressions in the kernel.
   Merger(unsigned t, unsigned l)
-  : numTensors(t), numLoops(l), isSparse(t, std::vector(l, false)) {}
+  : outTensor(t - 1), numTensors(t + 1), numLoops(l),
+dims(t + 1, std::vector(l, Dim::kUndef)) {}
 
   /// Adds a tensor expression. Returns its index.
   unsigned addExp(Kind k, unsigned e0, unsigned e1 = -1u, Value v = Value()) {
@@ -132,8 +144,8 @@ class Merger {
 return p;
   }
 
-  /// Conjunctive merge of L1 and L2 is conjunction of cartesian product.
-  /// Returns the index of the new set.
+  /// Conjunctive merge of two lattice sets L0 and L1 is conjunction of
+  /// cartesian product. Returns the index of the new set.
   unsigned takeConj(Kind kind, unsigned s0, unsigned s1) {
 unsigned s = addSet();
 for (unsigned p0 : latSets[s0])
@@ -142,7 +154,7 @@ class Merger {
 return s;
   }
 
-  /// Disjunctive merge of L0 and L1 is (L0 /\_op L1, L0, L1).
+  /// Disjunctive merge of two lattice sets L0 and L1 is (L0 /\_op L1, L0, L1).
   /// Returns the index of the new set.
   unsigned takeDisj(Kind kind, unsigned s0, unsigned s1) {
 unsigned s = takeConj(kind, s0, s1);
@@ -156,26 +168,27 @@ class Merger {
   /// Optimizes the iteration lattice points in the given set. This
   /// method should be called right before code generation to avoid
   /// generating redundant loops and conditions.
-  unsigned optimize(unsigned s0) {
+  unsigned optimizeSet(unsigned s0) {
 unsigned s = addSet();
 assert(latSets[s0].size() != 0);
 unsigned p0 = latSets[s0][0];
 for (unsigned p1 : latSets[s0]) {
   bool add = true;
+  llvm::BitVector simple = simplifyCond(s0, p1);
   

[llvm-branch-commits] [mlir] 9887097 - Remove unneeded header include (NFC)

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

Author: Mehdi Amini
Date: 2020-12-18T00:10:26Z
New Revision: 9887097d802d0a585807e693727ab8836790da8d

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

LOG: Remove unneeded header include (NFC)

Added: 


Modified: 
mlir/lib/Support/MlirOptMain.cpp

Removed: 




diff  --git a/mlir/lib/Support/MlirOptMain.cpp 
b/mlir/lib/Support/MlirOptMain.cpp
index dbda704dc7d8..5d852292fd06 100644
--- a/mlir/lib/Support/MlirOptMain.cpp
+++ b/mlir/lib/Support/MlirOptMain.cpp
@@ -24,7 +24,6 @@
 #include "mlir/Pass/PassManager.h"
 #include "mlir/Support/FileUtilities.h"
 #include "mlir/Support/ToolUtilities.h"
-#include "mlir/Transforms/Passes.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"



___
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] 129d6e5 - [mlir] Move `std.tensor_cast` -> `tensor.cast`.

2020-12-17 Thread Sean Silva via llvm-branch-commits

Author: Sean Silva
Date: 2020-12-17T16:06:56-08:00
New Revision: 129d6e554e7a0dba3443ffd8f1df185b90cc6fd5

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

LOG: [mlir] Move `std.tensor_cast` -> `tensor.cast`.

This is almost entirely mechanical.

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
mlir/include/mlir/IR/OpDefinition.h
mlir/integration_test/Dialect/Linalg/CPU/test-elementwise.mlir

mlir/integration_test/Dialect/Linalg/CPU/test-subtensor-insert-multiple-uses.mlir
mlir/integration_test/Dialect/Linalg/CPU/test-subtensor-insert.mlir
mlir/integration_test/Dialect/Linalg/CPU/test-tensor-e2e.mlir
mlir/integration_test/Dialect/Linalg/CPU/test-tensor-matmul.mlir
mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp
mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp
mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/Shape/IR/CMakeLists.txt
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp
mlir/lib/IR/Operation.cpp
mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir
mlir/test/Dialect/Linalg/canonicalize.mlir
mlir/test/Dialect/Shape/canonicalize.mlir
mlir/test/Dialect/Standard/bufferize.mlir
mlir/test/Dialect/Standard/canonicalize.mlir
mlir/test/Dialect/Tensor/bufferize.mlir
mlir/test/Dialect/Tensor/canonicalize.mlir
mlir/test/Dialect/Tensor/invalid.mlir
mlir/test/Dialect/Tensor/ops.mlir
mlir/test/IR/core-ops.mlir
mlir/test/Transforms/canonicalize.mlir
mlir/test/Transforms/cse.mlir
mlir/utils/vim/syntax/mlir.vim

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h 
b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
index 3df609f295cc..2ef32cfe378b 100644
--- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
+++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
@@ -34,7 +34,7 @@ namespace linalg {
 class LinalgDependenceGraph;
 
 /// A struct containing the Linalg producer before and after fusion.
-/// When operating on tensors, `fusedProducer` may feed into a `tensor_cast` op
+/// When operating on tensors, `fusedProducer` may feed into a `tensor.cast` op
 /// before the consumer Linalg op, until enough canonicalizations have applied.
 struct FusionInfo {
   LinalgOp originalProducer;

diff  --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h 
b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
index 7302bd486657..56ff32252fee 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
@@ -354,31 +354,6 @@ computeRankReductionMask(ArrayRef originalShape,
 /// ```
 bool canFoldIntoConsumerOp(MemRefCastOp castOp);
 
-/// Counterpart of `canFoldIntoConsumerOp(MemRefCastOp castOp)` for tensors.
-/// Determines whether TensorCastOp casts to a more dynamic version of the
-/// source tensor. This is useful to fold a tensor_cast into a consuming op and
-/// implement canonicalization patterns for ops in 
diff erent dialects that may
-/// consume the results of tensor_cast operations. Such foldable tensor_cast
-/// operations are typically inserted as `subtensor` ops and are canonicalized,
-/// to preserve the type compatibility of their uses.
-///
-/// Returns true when all conditions are met:
-/// 1. source and result are ranked tensors with same element type and rank.
-/// 2. the tensor type has more static information than the result
-///
-/// Example:
-/// ```mlir
-///   %1 = tensor_cast %0 : tensor<8x16xf32> to tensor
-///   %2 = consumer %1 ... : tensor ...
-/// ```
-///
-/// folds into:
-///
-/// ```mlir
-///   %2 = consumer %0 ... : tensor<8x16xf32> ...
-/// ```
-bool canFoldIntoConsumerOp(TensorCastOp castOp);
-
 /// Compute `lhs` `pred` `rhs`, where `pred` is one of the known integer
 /// comparison predicates.
 bool applyCmpPredicate(CmpIPredicate predicate, const APInt ,

diff  --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td 
b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index 481dfaf4b34d..7af44f8435ff 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ 

[llvm-branch-commits] [mlir] a555ca8 - Workaround around clang 5.0 bug by including SmallVector.h in LLVM.h (PR41549)

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

Author: Mehdi Amini
Date: 2020-12-18T00:00:36Z
New Revision: a555ca8b3d67267c19db48fc2470d20daae80aeb

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

LOG: Workaround around clang 5.0 bug by including SmallVector.h in LLVM.h 
(PR41549)

The forward declaration for SmallVector does not play well with clang-5.

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

Added: 


Modified: 
mlir/include/mlir/Support/LLVM.h

Removed: 




diff  --git a/mlir/include/mlir/Support/LLVM.h 
b/mlir/include/mlir/Support/LLVM.h
index e8595ae29ed7..ced7a7a35363 100644
--- a/mlir/include/mlir/Support/LLVM.h
+++ b/mlir/include/mlir/Support/LLVM.h
@@ -23,6 +23,13 @@
 #include "llvm/ADT/None.h"
 #include "llvm/Support/Casting.h"
 
+// Workaround for clang-5 (PR41549)
+#if defined(__clang_major__)
+#if __clang_major__ <= 5
+#include "llvm/ADT/SmallVector.h"
+#endif
+#endif
+
 // Forward declarations.
 namespace llvm {
 // String types



___
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] 118a715 - [mlir][Linalg] Define a linalg.init_tensor operation.

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

Author: MaheshRavishankar
Date: 2020-12-17T14:45:51-08:00
New Revision: 118a71565462db41cab1dbb0349200627d6e8524

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

LOG: [mlir][Linalg] Define a linalg.init_tensor operation.

This operation is used to materialize a tensor of a particular
shape. The shape could be specified as a mix of static and dynamic
values.

The use of this operation is to be an `init` tensor for Linalg
structured operation on tensors where the bounds of the computation
depends on the shape of the output of the linalg operation. The result
of this operation will be used as the `init` tensor of such Linalg
operations. To note,

1) The values in the tensor materialized is not used. Any operation to
   which this is an init tensor is expected to overwrite the entire
   tensor.
2) The tensor is materialized only for the shape of the output and to
   make the loop bounds depend only on operands of the structured
   operation.

Based on (1) and (2) it is assumed that these operations eventually go
away since they are only used in `dim` operations that can be
canonicalized to make this operation dead. Such canonicalization are
added here too.

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
mlir/include/mlir/Interfaces/ViewLikeInterface.h
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Interfaces/ViewLikeInterface.cpp
mlir/test/Dialect/Linalg/canonicalize.mlir
mlir/test/Dialect/Linalg/roundtrip.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td 
b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
index 454dde1bff93..a2e7d436eeb8 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
@@ -32,6 +32,91 @@ class Linalg_Op traits = []> :
   let parser = [{ return ::parse$cppClass(parser, result); }];
 }
 
+def Linalg_InitTensorOp : Linalg_Op<"init_tensor", [NoSideEffect]> {
+  let summary = "operation to define a tensor of particular value";
+
+  let description = [{
+`linalg.init_tensor` is an operation that materializes a tensor of
+a given shape. The shape could be dynamic or static.
+  }];
+
+  let arguments =
+(ins Variadic:$sizes, I64ArrayAttr:$static_sizes);
+
+  let results = (outs AnyTensor:$result);
+
+  let verifier = [{ return ::verify(*this); }];
+
+  let extraClassDeclaration = [{
+static StringRef getStaticSizesAttrName() {
+  return "static_sizes";
+}
+
+RankedTensorType getType() {
+  return getResult().getType().cast(); }
+
+// Infer the shape of the result tensor given the static shapes
+// and element type of the result tensor.
+static Type inferResultType(ArrayRef staticSizes, Type 
elementType);
+
+// Return true if the size of the tensor is dynamic at `idx`
+bool isDynamicSize(unsigned idx) {
+  APInt v = *(static_sizes().getAsValueRange().begin() + idx);
+  return ShapedType::isDynamic(v.getSExtValue());
+}
+
+// Assert that the size of the result tensor is static at `idx`
+// and return the shape.
+int64_t getStaticSize(unsigned idx) {
+  assert(!isDynamicSize(idx) && "expected static size");
+  APInt v = *(static_sizes().
+  template getAsValueRange().begin() + idx);
+return v.getSExtValue();
+}
+
+// Return the argument position that contains the dynamic size of
+// the tensor at dimension `idx`. Asserts that the shape is
+// dynamic at that `idx`.
+unsigned getIndexOfDynamicSize(unsigned idx) {
+  assert(isDynamicSize(idx) && "expected dynamic size");
+  return std::count_if(
+  static_sizes().getValue().begin(),
+  static_sizes().getValue().begin() + idx,
+  [&](Attribute attr) {
+return ShapedType::isDynamic(attr.cast().getInt());
+  });
+}
+
+// Return the Value of the dynamic size of the tensor at dimension
+// `idx`. Asserts that the shape is dynamic at that `idx.
+Value getDynamicSize(unsigned idx) {
+  return getOperand(getIndexOfDynamicSize(idx));
+}
+  }];
+
+  let builders = [
+OpBuilderDAG<(ins "ValueRange":$shape,
+  "ArrayRef":$staticShape, "Type":$elementType),
+[{
+  build($_builder, $_state,
+InitTensorOp::inferResultType(staticShape, elementType),
+shape, $_builder.getI64ArrayAttr(staticShape));
+}]>,
+OpBuilderDAG<(ins "ValueRange":$shape, "Type":$elementType),
+[{
+  SmallVector staticShape(
+shape.size(), ShapedType::kDynamicSize);
+  build($_builder, $_state, shape, staticShape, elementType);
+}]>,
+OpBuilderDAG<(ins "ArrayRef":$staticShape, 

[llvm-branch-commits] [mlir] de03121 - [mlir] Add canonicalization from `tensor_cast` to `dim` op.

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

Author: MaheshRavishankar
Date: 2020-12-17T14:45:51-08:00
New Revision: de031216bf1755e61418a1515f2b0db0a9cfeddc

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

LOG: [mlir] Add canonicalization from `tensor_cast` to `dim` op.

Fold a `tensor_cast` -> `dim` to take the `dim` of the original tensor.

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

Added: 


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

Removed: 




diff  --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp 
b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index b19264ec4972..7ed9cffa8806 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -1472,11 +1472,29 @@ struct DimOfMemRefReshape : public 
OpRewritePattern {
 return success();
   }
 };
+
+/// Fold dim of a dim of a cast into the the dim of the source of the tensor
+/// cast.
+template 
+struct DimOfCastOp : public OpRewritePattern {
+  using OpRewritePattern::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(DimOp dimOp,
+PatternRewriter ) const override {
+auto castOp = dimOp.memrefOrTensor().getDefiningOp();
+if (!castOp)
+  return failure();
+Value newSource = castOp.getOperand();
+rewriter.replaceOpWithNewOp(dimOp, newSource, dimOp.index());
+return success();
+  }
+};
+
 } // end anonymous namespace.
 
 void DimOp::getCanonicalizationPatterns(OwningRewritePatternList ,
 MLIRContext *context) {
-  results.insert(context);
+  results.insert>(context);
 }
 
 // ---

diff  --git a/mlir/test/Dialect/Standard/canonicalize.mlir 
b/mlir/test/Dialect/Standard/canonicalize.mlir
index d3c781d1290f..af67453a1f3c 100644
--- a/mlir/test/Dialect/Standard/canonicalize.mlir
+++ b/mlir/test/Dialect/Standard/canonicalize.mlir
@@ -115,3 +115,19 @@ func @dim_of_memref_reshape(%arg0: memref<*xf32>, %arg1: 
memref)
   %1 = dim %0, %c3 : memref<*xf32>
   return %1 : index
 }
+
+// Test case: Folding dim(tensor_cast %0, %idx) -> dim %0, %idx
+// CHECK-LABEL: func @fold_dim_of_tensor_cast
+//  CHECK-SAME:   %[[ARG0:.[a-z0-9A-Z_]+]]: tensor<4x?xf32>
+//   CHECK-DAG:   %[[C1:.+]] = constant 1 : index
+//   CHECK-DAG:   %[[C4:.+]] = constant 4 : index
+//   CHECK:   %[[T0:.+]] = dim %[[ARG0]], %[[C1]]
+//  CHECK-NEXT:   return %[[C4]], %[[T0]]
+func @fold_dim_of_tensor_cast(%arg0 : tensor<4x?xf32>) -> (index, index) {
+  %c0 = constant 0 : index
+  %c1 = constant 1 : index
+  %0 = tensor_cast %arg0 : tensor<4x?xf32> to tensor
+  %1 = dim %0, %c0 : tensor
+  %2 = dim %0, %c1 : tensor
+  return %1, %2: index, index
+}



___
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] 3d56644 - [DSE] Add test for potential caching bug (NFC)

2020-12-17 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-12-17T23:35:01+01:00
New Revision: 3d56644f18eefe30e353e7fae3cb5e5daf0a0ffb

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

LOG: [DSE] Add test for potential caching bug (NFC)

This one would miscompile if read-clobber checks switched to using
the EarlierAccess location, but the read cache was retained.

Added: 


Modified: 
llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll

Removed: 




diff  --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll 
b/llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll
index 9d20f80f5099..05326de07382 100644
--- a/llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll
@@ -96,3 +96,36 @@ else:
   load i8, i8* %a1
   ret void
 }
+
+; Variation on the previous test case, where only the store to %a0 is dead,
+; but not the one to %a1. This tests for a potential caching bug.
+define void @test4(i1 %c) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT:[[A:%.*]] = alloca [2 x i8], align 1
+; CHECK-NEXT:[[A0:%.*]] = getelementptr [2 x i8], [2 x i8]* [[A]], i32 0, 
i32 0
+; CHECK-NEXT:[[A1:%.*]] = getelementptr [2 x i8], [2 x i8]* [[A]], i32 0, 
i32 1
+; CHECK-NEXT:store i8 1, i8* [[A1]], align 1
+; CHECK-NEXT:store i8 1, i8* [[A0]], align 1
+; CHECK-NEXT:br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
+; CHECK:   if:
+; CHECK-NEXT:store [2 x i8] zeroinitializer, [2 x i8]* [[A]], align 1
+; CHECK-NEXT:br label [[ELSE]]
+; CHECK:   else:
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[A1]], align 1
+; CHECK-NEXT:ret void
+;
+  %a = alloca [2 x i8]
+  %a0 = getelementptr [2 x i8], [2 x i8]* %a, i32 0, i32 0
+  %a1 = getelementptr [2 x i8], [2 x i8]* %a, i32 0, i32 1
+  store i8 1, i8* %a1
+  store i8 1, i8* %a0
+  br i1 %c, label %if, label %else
+
+if:
+  store [2 x i8] zeroinitializer, [2 x i8]* %a
+  br label %else
+
+else:
+  load i8, i8* %a1
+  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] [clang] 3203143 - CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

2020-12-17 Thread Tom Stellard via llvm-branch-commits

Author: Tom Stellard
Date: 2020-12-17T14:30:31-08:00
New Revision: 3203143f1356a4e4e3ada231156fc6da6e1a9f9d

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

LOG: CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

Add a special case for handling __builtin_mul_overflow with unsigned
inputs and a signed output to avoid emitting the __muloti4 library
call on x86_64.  __muloti4 is not implemented in libgcc, so avoiding
this call fixes compilation of some programs that call
__builtin_mul_overflow with these arguments.

For example, this fixes the build of cpio with clang, which includes code from
gnulib that calls __builtin_mul_overflow with these argument types.

Reviewed By: vsk

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-overflow.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 40bb5f5f0689..60bfa90e22fc 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1832,6 +1832,47 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr ) {
   return RValue::get(BufAddr.getPointer());
 }
 
+static bool isSpecialUnsignedMultiplySignedResult(
+unsigned BuiltinID, WidthAndSignedness Op1Info, WidthAndSignedness Op2Info,
+WidthAndSignedness ResultInfo) {
+  return BuiltinID == Builtin::BI__builtin_mul_overflow &&
+ Op1Info.Width == Op2Info.Width && Op2Info.Width == ResultInfo.Width &&
+ !Op1Info.Signed && !Op2Info.Signed && ResultInfo.Signed;
+}
+
+static RValue EmitCheckedUnsignedMultiplySignedResult(
+CodeGenFunction , const clang::Expr *Op1, WidthAndSignedness Op1Info,
+const clang::Expr *Op2, WidthAndSignedness Op2Info,
+const clang::Expr *ResultArg, QualType ResultQTy,
+WidthAndSignedness ResultInfo) {
+  assert(isSpecialUnsignedMultiplySignedResult(
+ Builtin::BI__builtin_mul_overflow, Op1Info, Op2Info, ResultInfo) 
&&
+ "Cannot specialize this multiply");
+
+  llvm::Value *V1 = CGF.EmitScalarExpr(Op1);
+  llvm::Value *V2 = CGF.EmitScalarExpr(Op2);
+
+  llvm::Value *HasOverflow;
+  llvm::Value *Result = EmitOverflowIntrinsic(
+  CGF, llvm::Intrinsic::umul_with_overflow, V1, V2, HasOverflow);
+
+  // The intrinsic call will detect overflow when the value is > UINT_MAX,
+  // however, since the original builtin had a signed result, we need to report
+  // an overflow when the result is greater than INT_MAX.
+  auto IntMax = llvm::APInt::getSignedMaxValue(ResultInfo.Width);
+  llvm::Value *IntMaxValue = llvm::ConstantInt::get(Result->getType(), IntMax);
+
+  llvm::Value *IntMaxOverflow = CGF.Builder.CreateICmpUGT(Result, IntMaxValue);
+  HasOverflow = CGF.Builder.CreateOr(HasOverflow, IntMaxOverflow);
+
+  bool isVolatile =
+  ResultArg->getType()->getPointeeType().isVolatileQualified();
+  Address ResultPtr = CGF.EmitPointerWithAlignment(ResultArg);
+  CGF.Builder.CreateStore(CGF.EmitToMemory(Result, ResultQTy), ResultPtr,
+  isVolatile);
+  return RValue::get(HasOverflow);
+}
+
 /// Determine if a binop is a checked mixed-sign multiply we can specialize.
 static bool isSpecialMixedSignMultiply(unsigned BuiltinID,
WidthAndSignedness Op1Info,
@@ -3952,6 +3993,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   RightInfo, ResultArg, ResultQTy,
   ResultInfo);
 
+if (isSpecialUnsignedMultiplySignedResult(BuiltinID, LeftInfo, RightInfo,
+  ResultInfo))
+  return EmitCheckedUnsignedMultiplySignedResult(
+  *this, LeftArg, LeftInfo, RightArg, RightInfo, ResultArg, ResultQTy,
+  ResultInfo);
+
 WidthAndSignedness EncompassingInfo =
 EncompassingIntegerType({LeftInfo, RightInfo, ResultInfo});
 

diff  --git a/clang/test/CodeGen/builtins-overflow.c 
b/clang/test/CodeGen/builtins-overflow.c
index b7f8d7437e21..636a571d1364 100644
--- a/clang/test/CodeGen/builtins-overflow.c
+++ b/clang/test/CodeGen/builtins-overflow.c
@@ -1,9 +1,9 @@
 // Test CodeGen for Security Check Overflow Builtins.
 // rdar://13421498
 
-// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | 
FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - | 
FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | 
FileCheck -DLONG_TYPE=i32 -DLONG_MAX=2147483647 %s
+// RUN: %clang_cc1 -triple 

[llvm-branch-commits] [llvm] 71a1b9f - [VectorCombine] add tests for gep load with cast; NFC

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

Author: Sanjay Patel
Date: 2020-12-17T16:40:55-05:00
New Revision: 71a1b9fe76acfea8920e143c807c5cb8bf510254

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

LOG: [VectorCombine] add tests for gep load with cast; NFC

Added: 


Modified: 
llvm/test/Transforms/VectorCombine/X86/load.ll

Removed: 




diff  --git a/llvm/test/Transforms/VectorCombine/X86/load.ll 
b/llvm/test/Transforms/VectorCombine/X86/load.ll
index dee6c5eced91..6b4fe43a8a29 100644
--- a/llvm/test/Transforms/VectorCombine/X86/load.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/load.ll
@@ -299,6 +299,51 @@ define <8 x i16> 
@gep01_load_i16_insert_v8i16_deref_minalign(<8 x i16>* align 2
   ret <8 x i16> %r
 }
 
+define <4 x i32> @gep01_bitcast_load_i32_insert_v4i32(<16 x i8>* align 1 
dereferenceable(16) %p) {
+; CHECK-LABEL: @gep01_bitcast_load_i32_insert_v4i32(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds <16 x i8>, <16 x i8>* 
[[P:%.*]], i64 0, i64 1
+; CHECK-NEXT:[[B:%.*]] = bitcast i8* [[GEP]] to i32*
+; CHECK-NEXT:[[S:%.*]] = load i32, i32* [[B]], align 1
+; CHECK-NEXT:[[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
+; CHECK-NEXT:ret <4 x i32> [[R]]
+;
+  %gep = getelementptr inbounds <16 x i8>, <16 x i8>* %p, i64 0, i64 1
+  %b = bitcast i8* %gep to i32*
+  %s = load i32, i32* %b, align 1
+  %r = insertelement <4 x i32> undef, i32 %s, i64 0
+  ret <4 x i32> %r
+}
+
+define <4 x i32> @gep012_bitcast_load_i32_insert_v4i32(<16 x i8>* align 1 
dereferenceable(20) %p) {
+; CHECK-LABEL: @gep012_bitcast_load_i32_insert_v4i32(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds <16 x i8>, <16 x i8>* 
[[P:%.*]], i64 0, i64 12
+; CHECK-NEXT:[[B:%.*]] = bitcast i8* [[GEP]] to i32*
+; CHECK-NEXT:[[S:%.*]] = load i32, i32* [[B]], align 1
+; CHECK-NEXT:[[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
+; CHECK-NEXT:ret <4 x i32> [[R]]
+;
+  %gep = getelementptr inbounds <16 x i8>, <16 x i8>* %p, i64 0, i64 12
+  %b = bitcast i8* %gep to i32*
+  %s = load i32, i32* %b, align 1
+  %r = insertelement <4 x i32> undef, i32 %s, i64 0
+  ret <4 x i32> %r
+}
+
+define <4 x i32> @gep013_bitcast_load_i32_insert_v4i32(<16 x i8>* align 1 
dereferenceable(20) %p) {
+; CHECK-LABEL: @gep013_bitcast_load_i32_insert_v4i32(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds <16 x i8>, <16 x i8>* 
[[P:%.*]], i64 0, i64 13
+; CHECK-NEXT:[[B:%.*]] = bitcast i8* [[GEP]] to i32*
+; CHECK-NEXT:[[S:%.*]] = load i32, i32* [[B]], align 1
+; CHECK-NEXT:[[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0
+; CHECK-NEXT:ret <4 x i32> [[R]]
+;
+  %gep = getelementptr inbounds <16 x i8>, <16 x i8>* %p, i64 0, i64 13
+  %b = bitcast i8* %gep to i32*
+  %s = load i32, i32* %b, align 1
+  %r = insertelement <4 x i32> undef, i32 %s, i64 0
+  ret <4 x i32> %r
+}
+
 ; If there are enough dereferenceable bytes, we can offset the vector load.
 
 define <8 x i16> @gep10_load_i16_insert_v8i16(<8 x i16>* align 16 
dereferenceable(32) %p) {



___
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] 2d07414 - [SimplifyCFG] Teach simplifyUnreachable() to preserve DomTree

2020-12-17 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-18T00:37:22+03:00
New Revision: 2d07414ee5f74a09fb89723b4a9bb0818bdc2e18

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

LOG: [SimplifyCFG] Teach simplifyUnreachable() to preserve DomTree

Pretty boring, removeUnwindEdge() already known how to update DomTree,
so if we are to call it, we must first flush our own pending updates;
otherwise, we just stop predecessors from branching to us,
and for certain predecessors, stop their predecessors from
branching to them also.

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/CallSiteSplitting/split-loop.ll
llvm/test/Transforms/LoopDeletion/2008-05-06-Phi.ll
llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
llvm/test/Transforms/SimplifyCFG/X86/PR30210.ll
llvm/test/Transforms/SimplifyCFG/branch-fold.ll
llvm/test/Transforms/SimplifyCFG/empty-catchpad.ll
llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll
llvm/test/Transforms/SimplifyCFG/switch-profmd.ll
llvm/test/Transforms/SimplifyCFG/switch-range-to-icmp.ll
llvm/test/Transforms/SimplifyCFG/unreachable_assume.ll
llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 9e4650fefff7..6a0859d84c89 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4479,9 +4479,12 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst 
*UI) {
   if (>front() != UI)
 return Changed;
 
+  std::vector Updates;
+
   SmallVector Preds(pred_begin(BB), pred_end(BB));
   for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
-Instruction *TI = Preds[i]->getTerminator();
+auto *Predecessor = Preds[i];
+Instruction *TI = Predecessor->getTerminator();
 IRBuilder<> Builder(TI);
 if (auto *BI = dyn_cast(TI)) {
   if (BI->isUnconditional()) {
@@ -4491,6 +4494,9 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst 
*UI) {
 Changed = true;
   } else {
 Value* Cond = BI->getCondition();
+assert(BI->getSuccessor(0) != BI->getSuccessor(1) &&
+   "Same-destination conditional branch instruction was "
+   "already canonicalized into an unconditional branch.");
 if (BI->getSuccessor(0) == BB) {
   Builder.CreateAssumption(Builder.CreateNot(Cond));
   Builder.CreateBr(BI->getSuccessor(1));
@@ -4502,6 +4508,7 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst 
*UI) {
 EraseTerminatorAndDCECond(BI);
 Changed = true;
   }
+  Updates.push_back({DominatorTree::Delete, Predecessor, BB});
 } else if (auto *SI = dyn_cast(TI)) {
   SwitchInstProfUpdateWrapper SU(*SI);
   for (auto i = SU->case_begin(), e = SU->case_end(); i != e;) {
@@ -4514,14 +4521,21 @@ bool 
SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) {
 e = SU->case_end();
 Changed = true;
   }
+  Updates.push_back({DominatorTree::Delete, Predecessor, BB});
 } else if (auto *II = dyn_cast(TI)) {
   if (II->getUnwindDest() == BB) {
-removeUnwindEdge(TI->getParent());
+if (DTU)
+  DTU->applyUpdatesPermissive(Updates);
+Updates.clear();
+removeUnwindEdge(TI->getParent(), DTU);
 Changed = true;
   }
 } else if (auto *CSI = dyn_cast(TI)) {
   if (CSI->getUnwindDest() == BB) {
-removeUnwindEdge(TI->getParent());
+if (DTU)
+  DTU->applyUpdatesPermissive(Updates);
+Updates.clear();
+removeUnwindEdge(TI->getParent(), DTU);
 Changed = true;
 continue;
   }
@@ -4536,35 +4550,54 @@ bool 
SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) {
   Changed = true;
 }
   }
+  Updates.push_back({DominatorTree::Delete, Predecessor, BB});
   if (CSI->getNumHandlers() == 0) {
-BasicBlock *CatchSwitchBB = CSI->getParent();
 if (CSI->hasUnwindDest()) {
-  // Redirect preds to the unwind dest
-  CatchSwitchBB->replaceAllUsesWith(CSI->getUnwindDest());
+  // Redirect all predecessors of the block containing CatchSwitchInst
+  // to instead branch to the CatchSwitchInst's unwind destination.
+  for (auto *PredecessorOfPredecessor : predecessors(Predecessor)) {
+Updates.push_back(
+{DominatorTree::Delete, PredecessorOfPredecessor, 
Predecessor});
+Updates.push_back({DominatorTree::Insert, PredecessorOfPredecessor,
+   CSI->getUnwindDest()});
+  }
+  Predecessor->replaceAllUsesWith(CSI->getUnwindDest());
 } else {
   

[llvm-branch-commits] [llvm] 2ee7248 - [SimplifyCFG] ConstantFoldTerminator() already knows how to preserve DomTree

2020-12-17 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-18T00:37:22+03:00
New Revision: 2ee724863e9cfe631fd7eb7eb63f8b795d68a388

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

LOG: [SimplifyCFG] ConstantFoldTerminator() already knows how to preserve 
DomTree

... so just ensure that we pass DomTreeUpdater it into it.

Fixes DomTree preservation for a number of tests,
all of which are marked as such so that they do not regress.

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll
llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll
llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll
llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
llvm/test/Transforms/SimplifyCFG/implied-cond.ll
llvm/test/Transforms/SimplifyCFG/indirectbr.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index f39ab25ee64a..9e4650fefff7 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6322,7 +6322,8 @@ bool SimplifyCFGOpt::simplifyOnce(BasicBlock *BB) {
 
   // Check to see if we can constant propagate this terminator instruction
   // away...
-  Changed |= ConstantFoldTerminator(BB, true);
+  Changed |= ConstantFoldTerminator(BB, /*DeleteDeadConditions=*/true,
+/*TLI=*/nullptr, DTU);
 
   // Check for and eliminate duplicate PHI nodes in this block.
   Changed |= EliminateDuplicatePHINodes(BB);

diff  --git a/llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll 
b/llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
index fafe73b2b4ef..69803400a683 100644
--- a/llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -simplifycfg -disable-output
+; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 
-disable-output
 
 define void @symhash_add() {
 entry:

diff  --git a/llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll 
b/llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll
index 6b216f598efb..a2477f2f3a66 100644
--- a/llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -simplifycfg -disable-output
+; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 
-disable-output
 ; PR 2777
 @g_103 = common global i32 0   ;  [#uses=1]
 

diff  --git a/llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll 
b/llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll
index 329774e22429..772912c645b3 100644
--- a/llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2011-03-08-UnreachableUse.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -simplifycfg -S | FileCheck %s
+; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | 
FileCheck %s
 ; PR9420
 
 ; Note that the crash in PR9420 test is sensitive to the ordering of

diff  --git a/llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll 
b/llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
index bc5a93745375..bf3a283cf941 100644
--- a/llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
+++ b/llvm/test/Transforms/SimplifyCFG/fold-debug-info.ll
@@ -1,6 +1,6 @@
 ;; Check that we don't crash. PR37300.
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt %s -S -simplifycfg | FileCheck %s
+; RUN: opt %s -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | 
FileCheck %s
 
 define void @patatino() {
 ; CHECK-LABEL: @patatino(

diff  --git 
a/llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll 
b/llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll
index 1d29813ecfa2..1ad2e88bfd4a 100644
--- a/llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll
+++ b/llvm/test/Transforms/SimplifyCFG/implied-cond-matching-false-dest.ll
@@ -1,4 +1,4 @@
-; RUN: opt %s -S -simplifycfg | FileCheck %s
+; RUN: opt %s -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 | 
FileCheck %s
 
 declare void @is(i1)
 

diff  --git a/llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll 
b/llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
index 33fc016bd386..5b1cb821042a 100644
--- a/llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
+++ b/llvm/test/Transforms/SimplifyCFG/implied-cond-matching.ll
@@ -1,4 +1,4 @@
-; RUN: opt %s -S -simplifycfg | 

[llvm-branch-commits] [llvm] 164e084 - [SimplifyCFG] DeleteDeadBlock() already knows how to preserve DomTree

2020-12-17 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2020-12-18T00:37:21+03:00
New Revision: 164e0847a59995c0e602c9e708dfb2bf41494780

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

LOG: [SimplifyCFG] DeleteDeadBlock() already knows how to preserve DomTree

... so just ensure that we pass DomTreeUpdater it into it.

Fixes DomTree preservation for a large number of tests,
all of which are marked as such so that they do not regress.

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/GVNSink/indirect-call.ll
llvm/test/Transforms/GVNSink/sink-common-code.ll
llvm/test/Transforms/IndVarSimplify/loop_evaluate_1.ll
llvm/test/Transforms/IndVarSimplify/loop_evaluate_2.ll
llvm/test/Transforms/JumpThreading/lvi-tristate.ll
llvm/test/Transforms/LoopDeletion/simplify-then-delete.ll
llvm/test/Transforms/LoopVectorize/if-pred-non-void.ll
llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll
llvm/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll
llvm/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll
llvm/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll
llvm/test/Transforms/SimplifyCFG/2008-12-16-DCECond.ll
llvm/test/Transforms/SimplifyCFG/2009-01-18-PHIPropCrash.ll
llvm/test/Transforms/SimplifyCFG/ARM/branch-fold-threshold.ll
llvm/test/Transforms/SimplifyCFG/ARM/phi-eliminate.ll
llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll
llvm/test/Transforms/SimplifyCFG/ARM/speculate-math.ll
llvm/test/Transforms/SimplifyCFG/BrUnwind.ll
llvm/test/Transforms/SimplifyCFG/ConditionalTrappingConstantExpr.ll
llvm/test/Transforms/SimplifyCFG/DeadSetCC.ll
llvm/test/Transforms/SimplifyCFG/HoistCode.ll
llvm/test/Transforms/SimplifyCFG/PR25267.ll
llvm/test/Transforms/SimplifyCFG/PR9946.ll
llvm/test/Transforms/SimplifyCFG/PhiBlockMerge.ll
llvm/test/Transforms/SimplifyCFG/PhiEliminate2.ll
llvm/test/Transforms/SimplifyCFG/RISCV/select-trunc-i64.ll
llvm/test/Transforms/SimplifyCFG/UncondBranchToReturn.ll
llvm/test/Transforms/SimplifyCFG/X86/CoveredLookupTable.ll
llvm/test/Transforms/SimplifyCFG/X86/PR29163.ll
llvm/test/Transforms/SimplifyCFG/X86/SpeculativeExec.ll
llvm/test/Transforms/SimplifyCFG/X86/pr39187-g.ll
llvm/test/Transforms/SimplifyCFG/X86/safe-low-bit-extract.ll
llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll
llvm/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll
llvm/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll
llvm/test/Transforms/SimplifyCFG/annotations.ll
llvm/test/Transforms/SimplifyCFG/basictest.ll
llvm/test/Transforms/SimplifyCFG/bbi-23595.ll
llvm/test/Transforms/SimplifyCFG/branch-fold-dbg.ll
llvm/test/Transforms/SimplifyCFG/branch-fold-threshold.ll
llvm/test/Transforms/SimplifyCFG/clamp.ll
llvm/test/Transforms/SimplifyCFG/common-dest-folding.ll
llvm/test/Transforms/SimplifyCFG/fold-debug-location.ll
llvm/test/Transforms/SimplifyCFG/hoist-common-code.ll
llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll
llvm/test/Transforms/SimplifyCFG/hoist-with-range.ll
llvm/test/Transforms/SimplifyCFG/no-md-sink.ll
llvm/test/Transforms/SimplifyCFG/opt-for-fuzzing.ll
llvm/test/Transforms/SimplifyCFG/pr39807.ll
llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll
llvm/test/Transforms/SimplifyCFG/rangereduce.ll
llvm/test/Transforms/SimplifyCFG/safe-abs.ll
llvm/test/Transforms/SimplifyCFG/signbit-like-value-extension.ll
llvm/test/Transforms/SimplifyCFG/speculate-math.ll
llvm/test/Transforms/SimplifyCFG/speculate-with-offset.ll
llvm/test/Transforms/SimplifyCFG/switch-masked-bits.ll
llvm/test/Transforms/SimplifyCFG/switch-on-const-select.ll
llvm/test/Transforms/SimplifyCFG/switch-simplify-crash.ll
llvm/test/Transforms/SimplifyCFG/switch-to-icmp.ll
llvm/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll
llvm/test/Transforms/SimplifyCFG/switch_switch_fold.ll
llvm/test/Transforms/SimplifyCFG/switch_thread.ll
llvm/test/Transforms/SimplifyCFG/unsigned-multiplication-will-overflow.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 0c693a8d27be..f39ab25ee64a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6316,7 +6316,7 @@ bool SimplifyCFGOpt::simplifyOnce(BasicBlock *BB) {
   if ((pred_empty(BB) && BB != >getParent()->getEntryBlock()) ||
   BB->getSinglePredecessor() == BB) {
 LLVM_DEBUG(dbgs() << "Removing BB: \n" << *BB);
-DeleteDeadBlock(BB);
+DeleteDeadBlock(BB, DTU);
 return true;
   }
 

diff  --git 

[llvm-branch-commits] [clang] c755e41 - Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via llvm-branch-commits

Author: Joachim Meyer
Date: 2020-12-17T22:23:42+01:00
New Revision: c755e41c336c898873db6c3c58a2819a982f60de

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

LOG: Fix -Wno-error= parsing in clang-format.

As noted in https://reviews.llvm.org/D86137#2460135 parsing of
the clang-format parameter -Wno-error=unknown fails.
This currently is done by having `-Wno-error=unknown` as an option.
In this patch this is changed to make `-Wno-error=` parse an enum into a bit 
set.
This way the parsing is fixed and also we can possibly add new options easily.

Reviewed By: MyDeveloperDay

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

Added: 
clang/test/Format/error-config.cpp

Modified: 
clang/docs/ClangFormat.rst
clang/tools/clang-format/ClangFormat.cpp

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index b746ed3453df..d5333c0032b4 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -31,12 +31,13 @@ to format C/C++/Java/JavaScript/Objective-C/Protobuf/C# 
code.
   Clang-format options:
 
 --Werror   - If set, changes formatting warnings to errors
---Wno-error=unknown- If set, unknown format options are only 
warned about.
- This can be used to enable formatting, even 
if the
- configuration contains unknown (newer) 
options.
- Use with caution, as this might lead to 
dramatically
- 
diff ering format depending on an option being
- supported or not.
+--Wno-error=- If set don't error out on the specified 
warning type.
+  =unknown -   If set, unknown format options are only 
warned about.
+   This can be used to enable formatting, even 
if the
+   configuration contains unknown (newer) 
options.
+   Use with caution, as this might lead to 
dramatically
+   
diff ering format depending on an option being
+   supported or not.
 --assume-filename= - Override filename used to determine the 
language.
  When reading from stdin, clang-format assumes 
this
  filename to determine the language.

diff  --git a/clang/test/Format/error-config.cpp 
b/clang/test/Format/error-config.cpp
new file mode 100644
index ..7fbc869f3a3c
--- /dev/null
+++ b/clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;

diff  --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index a1b42a6d0940..64f0e2badf33 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@ static cl::opt SortIncludes(
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "
diff ering format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@ static cl::opt
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable 

[llvm-branch-commits] [libcxx] 6340f89 - [libc++] Fix extern C for __sanitizer_annotate_contiguous_container() (for gcc)

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

Author: Azat Khuzhin
Date: 2020-12-17T16:20:24-05:00
New Revision: 6340f890bb86b6ec1e72047d4c4560ee0dfe6d90

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

LOG: [libc++] Fix extern C for __sanitizer_annotate_contiguous_container() (for 
gcc)

gcc supports it only at the beginning:

$ g++ -o /dev/null -c /tmp/test_extern.cpp
$ cat /tmp/test_extern.cpp
extern "C" __attribute__ ((__visibility__("default"))) int foo();

Otherwise:

$ g++ -o /dev/null -c /tmp/test_extern.cpp
/tmp/test_extern.cpp:1:52: error: expected unqualified-id before string 
constant
1 | __attribute__ ((__visibility__("default"))) extern "C" int foo();
  |^~~
$ cat /tmp/test_extern.cpp
__attribute__ ((__visibility__("default"))) extern "C" int foo();

Reviewed By: #libc, ldionne

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

Added: 


Modified: 
libcxx/include/__config

Removed: 




diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 033cd8aea068..9f49e805d61b 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1082,7 +1082,7 @@ typedef unsigned int   char32_t;
 #endif
 
 #ifndef _LIBCPP_HAS_NO_ASAN
-_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
+extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
   const void *, const void *, const void *, const void *);
 #endif
 



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


[llvm-branch-commits] [lld] f710bb7 - lld: Replace some lld::outs()s with message()

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

Author: Nico Weber
Date: 2020-12-17T16:19:09-05:00
New Revision: f710bb7063b232be1cffc7a0f0f56606d7bff2ad

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

LOG: lld: Replace some lld::outs()s with message()

No behavior change.

Added: 


Modified: 
lld/COFF/Driver.cpp
lld/MachO/Driver.cpp
lld/MachO/DriverUtils.cpp

Removed: 




diff  --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 504c00584d9c..08862b062f91 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1263,7 +1263,7 @@ void LinkerDriver::link(ArrayRef argsArr) {
   // because it doesn't start with "/", but we deliberately chose "--" to
   // avoid conflict with /version and for compatibility with clang-cl.
   if (args.hasArg(OPT_dash_dash_version)) {
-lld::outs() << getLLDVersion() << "\n";
+message(getLLDVersion());
 return;
   }
 

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index db89dd60a20b..4f9c111bd8fb 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -325,7 +325,7 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
 // printArchiveMemberLoad() prints both .a and .o names, so no need to
 // print the .a name here.
 if (config->printEachFile && magic != file_magic::archive)
-  lld::outs() << toString(newFile) << '\n';
+  message(toString(newFile));
 inputFiles.insert(newFile);
   }
   return newFile;

diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 5040f634e181..563ae266735d 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -208,7 +208,7 @@ uint32_t macho::getModTime(StringRef path) {
 
 void macho::printArchiveMemberLoad(StringRef reason, const InputFile *f) {
   if (config->printEachFile)
-lld::outs() << toString(f) << '\n';
+message(toString(f));
   if (config->printWhyLoad)
-lld::outs() << reason << " forced load of " << toString(f) << '\n';
+message(reason + " forced load of " + toString(f));
 }



___
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] 1b97cdf - [mlir][IR][NFC] Move context/location parameters of builtin Type::get methods to the start of the parameter list

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

Author: River Riddle
Date: 2020-12-17T13:01:36-08:00
New Revision: 1b97cdf885d6455841280b8da858835e641ee941

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

LOG: [mlir][IR][NFC] Move context/location parameters of builtin Type::get 
methods to the start of the parameter list

This better matches the rest of the infrastructure, is much simpler, and makes 
it easier to move these types to being declaratively specified.

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

Added: 


Modified: 
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Lower/ConvertType.cpp
flang/lib/Lower/IntrinsicCall.cpp
flang/lib/Lower/RTBuilder.h
flang/lib/Optimizer/Dialect/FIROps.cpp
mlir/include/mlir/Dialect/AVX512/AVX512.td
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
mlir/include/mlir/IR/BuiltinTypes.h
mlir/include/mlir/IR/OpBase.td
mlir/lib/CAPI/IR/BuiltinTypes.cpp
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
mlir/lib/Dialect/Async/IR/Async.cpp
mlir/lib/Dialect/Async/Transforms/AsyncRefCounting.cpp
mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
mlir/lib/Dialect/Quant/Utils/FakeQuantSupport.cpp
mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
mlir/lib/Dialect/SCF/Transforms/Utils.cpp
mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/lib/IR/Builders.cpp
mlir/lib/IR/BuiltinDialect.cpp
mlir/lib/IR/BuiltinTypes.cpp
mlir/lib/IR/Dialect.cpp
mlir/lib/IR/MLIRContext.cpp
mlir/lib/IR/Operation.cpp
mlir/lib/IR/Value.cpp
mlir/lib/Parser/DialectSymbolParser.cpp
mlir/lib/Parser/TypeParser.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/lib/Target/SPIRV/Deserialization.cpp
mlir/lib/Target/SPIRV/Serialization.cpp
mlir/lib/Transforms/BufferResultsToOutParams.cpp
mlir/lib/Transforms/NormalizeMemRefs.cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp
mlir/test/EDSC/builder-api-test.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestPatterns.cpp
mlir/test/lib/Transforms/TestDecomposeCallGraphTypes.cpp
mlir/unittests/Dialect/Quant/QuantizationUtilsTest.cpp
mlir/unittests/IR/AttributeTest.cpp
mlir/unittests/TableGen/StructsGenTest.cpp

Removed: 




diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td 
b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 8d7a6d4af950..cecd1cbbb46b 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -2176,7 +2176,7 @@ def fir_DispatchOp : fir_Op<"dispatch",
 p.printOptionalAttrDict(getAttrs(), {"fn_type", "method"});
 auto resTy{getResultTypes()};
 llvm::SmallVector argTy(getOperandTypes());
-p << " : " << mlir::FunctionType::get(argTy, resTy, getContext());
+p << " : " << mlir::FunctionType::get(getContext(), argTy, resTy);
   }];
 
   let extraClassDeclaration = [{

diff  --git a/flang/lib/Lower/ConvertType.cpp b/flang/lib/Lower/ConvertType.cpp
index 746d7ade9972..b3fa85d4691d 100644
--- a/flang/lib/Lower/ConvertType.cpp
+++ b/flang/lib/Lower/ConvertType.cpp
@@ -49,7 +49,7 @@ mlir::Type genFIRType(mlir::MLIRContext *context) {
   if constexpr (TC == Fortran::common::TypeCategory::Integer) {
 auto bits{Fortran::evaluate::Type::Scalar::bits};
-return mlir::IntegerType::get(bits, context);
+return mlir::IntegerType::get(context, bits);
   } else if constexpr (TC == Fortran::common::TypeCategory::Logical ||
TC == Fortran::common::TypeCategory::Character ||
TC == Fortran::common::TypeCategory::Complex) {
@@ -278,7 +278,7 @@ class TypeBuilder {
 
   // some sequence of `n` bytes
   mlir::Type gen(const Fortran::evaluate::StaticDataObject::Pointer ) {
-mlir::Type byteTy{mlir::IntegerType::get(8, context)};
+mlir::Type byteTy{mlir::IntegerType::get(context, 8)};
 return fir::SequenceType::get(trivialShape(ptr->itemBytes()), byteTy);
   }
 

diff  --git a/flang/lib/Lower/IntrinsicCall.cpp 
b/flang/lib/Lower/IntrinsicCall.cpp
index 0e0081ef664c..7053cd976566 

[llvm-branch-commits] [llvm] 511cfe9 - Revert "Ensure SplitEdge to return the new block between the two given blocks"

2020-12-17 Thread Whitney Tsang via llvm-branch-commits

Author: Bangtian Liu
Date: 2020-12-17T21:00:37Z
New Revision: 511cfe9441955f20a8b93573fb9b62433b053550

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

LOG: Revert "Ensure SplitEdge to return the new block between the two given 
blocks"

This reverts commit d20e0c3444ad9ada550d9d6d1d56fd72948ae444.

Added: 


Modified: 
llvm/include/llvm/IR/BasicBlock.h
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/IR/BasicBlock.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/test/CodeGen/AMDGPU/call-constexpr.ll
llvm/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll
llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/BasicBlock.h 
b/llvm/include/llvm/IR/BasicBlock.h
index b86bb16e1239..0cce2a599d9c 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -398,49 +398,22 @@ class BasicBlock final : public Value, // Basic blocks 
are data objects also
 
   /// Split the basic block into two basic blocks at the specified instruction.
   ///
-  /// If \p Before is true, splitBasicBlockBefore handles the
-  /// block splitting. Otherwise, execution proceeds as described below.
-  ///
-  /// Note that all instructions BEFORE the specified iterator
-  /// stay as part of the original basic block, an unconditional branch is 
added
-  /// to the original BB, and the rest of the instructions in the BB are moved
-  /// to the new BB, including the old terminator.  The newly formed basic 
block
-  /// is returned. This function invalidates the specified iterator.
+  /// Note that all instructions BEFORE the specified iterator stay as part of
+  /// the original basic block, an unconditional branch is added to the 
original
+  /// BB, and the rest of the instructions in the BB are moved to the new BB,
+  /// including the old terminator.  The newly formed BasicBlock is returned.
+  /// This function invalidates the specified iterator.
   ///
   /// Note that this only works on well formed basic blocks (must have a
-  /// terminator), and \p 'I' must not be the end of instruction list (which
-  /// would cause a degenerate basic block to be formed, having a terminator
-  /// inside of the basic block).
+  /// terminator), and 'I' must not be the end of instruction list (which would
+  /// cause a degenerate basic block to be formed, having a terminator inside 
of
+  /// the basic block).
   ///
   /// Also note that this doesn't preserve any passes. To split blocks while
   /// keeping loop information consistent, use the SplitBlock utility function.
-  BasicBlock *splitBasicBlock(iterator I, const Twine  = "",
-  bool Before = false);
-  BasicBlock *splitBasicBlock(Instruction *I, const Twine  = "",
-  bool Before = false) {
-return splitBasicBlock(I->getIterator(), BBName, Before);
-  }
-
-  /// Split the basic block into two basic blocks at the specified instruction
-  /// and insert the new basic blocks as the predecessor of the current block.
-  ///
-  /// This function ensures all instructions AFTER and including the specified
-  /// iterator \p I are part of the original basic block. All Instructions
-  /// BEFORE the iterator \p I are moved to the new BB and an unconditional
-  /// branch is added to the new BB. The new basic block is returned.
-  ///
-  /// Note that this only works on well formed basic blocks (must have a
-  /// terminator), and \p 'I' must not be the end of instruction list (which
-  /// would cause a degenerate basic block to be formed, having a terminator
-  /// inside of the basic block).  \p 'I' cannot be a iterator for a PHINode
-  /// with multiple incoming blocks.
-  ///
-  /// Also note that this doesn't preserve any passes. To split blocks while
-  /// keeping loop information consistent, use the SplitBlockBefore utility
-  /// function.
-  BasicBlock *splitBasicBlockBefore(iterator I, const Twine  = "");
-  BasicBlock *splitBasicBlockBefore(Instruction *I, const Twine  = "") {
-return splitBasicBlockBefore(I->getIterator(), BBName);
+  BasicBlock *splitBasicBlock(iterator I, const Twine  = "");
+  BasicBlock *splitBasicBlock(Instruction *I, const Twine  = "") {
+return splitBasicBlock(I->getIterator(), BBName);
   }
 
   /// Returns true if there are any uses of this basic block other than

diff  --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h 
b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
index 7b8e2be17fa2..0a63654feb98 100644
--- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -244,33 +244,19 @@ unsigned SplitAllCriticalEdges(Function ,

[llvm-branch-commits] [mlir] 0efb0dd - [mlir] Partially update the conversion-to-llvm document

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

Author: Alex Zinenko
Date: 2020-12-17T22:00:09+01:00
New Revision: 0efb0dd978014c9ca5ef4cd93516a0cd6e77f185

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

LOG: [mlir] Partially update the conversion-to-llvm document

This document was not updated after the LLVM dialect type system had been
reimplemented and was using an outdated syntax. Rewrite the part of the
document that concerns type conversion and prepare the ground for splitting it
into a document that explains how built-in types are converted and a separate
document that explains how standard types and functions are converted, which
will better correspond to the fact that built-in types do not belong to the
standard dialect.

Reviewed By: rriddle

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

Added: 


Modified: 
mlir/docs/ConversionToLLVMDialect.md

Removed: 




diff  --git a/mlir/docs/ConversionToLLVMDialect.md 
b/mlir/docs/ConversionToLLVMDialect.md
index 27b732015f9f..778eea6184c9 100644
--- a/mlir/docs/ConversionToLLVMDialect.md
+++ b/mlir/docs/ConversionToLLVMDialect.md
@@ -1,16 +1,19 @@
 # Conversion to the LLVM Dialect
 
-Conversion from the Standard to the [LLVM Dialect](Dialects/LLVM.md) can be
-performed by the specialized dialect conversion pass by running:
+Conversion from several dialects that rely on
+[built-in types](LangRef.md#builtin-types) to the
+[LLVM Dialect](Dialects/LLVM.md) is expected to be performed through the
+[Dialect Conversion](DialectConversion.md) infrastructure.
 
-```shell
-mlir-opt -convert-std-to-llvm 
-```
+The conversion of types and that of the overall module structure is described 
in
+this document. Individual conversion passes provide a set of conversion 
patterns
+for ops in 
diff erent dialects, such as `-convert-std-to-llvm` for ops in the
+[Standard dialect](Dialects/Standard.md) and `-convert-vector-to-llvm` in the
+[Vector dialect](Dialects/Vector.md). *Note that some conversions subsume the
+others.*
 
-It performs type and operation conversions for a subset of operations from
-standard dialect (operations on scalars and vectors, control flow operations) 
as
-described in this document. We use the terminology defined by the
-[LLVM IR Dialect description](Dialects/LLVM.md) throughout this document.
+We use the terminology defined by the
+[LLVM Dialect description](Dialects/LLVM.md) throughout this document.
 
 [TOC]
 
@@ -22,19 +25,19 @@ Scalar types are converted to their LLVM counterparts if 
they exist. The
 following conversions are currently implemented:
 
 -   `i*` converts to `!llvm.i*`
+-   `bf16` converts to `!llvm.bfloat`
 -   `f16` converts to `!llvm.half`
 -   `f32` converts to `!llvm.float`
 -   `f64` converts to `!llvm.double`
 
-Note: `bf16` type is not supported by LLVM IR and cannot be converted.
-
 ### Index Type
 
-Index type is converted to a wrapped LLVM IR integer with bitwidth equal to the
-bitwidth of the pointer size as specified by the
-[data layout](https://llvm.org/docs/LangRef.html#data-layout) of the LLVM 
module
-[contained](Dialects/LLVM.md#context-and-module-association) in the LLVM 
Dialect
-object. For example, on x86-64 CPUs it converts to `!llvm.i64`.
+Index type is converted to an LLVM dialect integer type with bitwidth equal to
+the bitwidth of the pointer size as specified by the
+[data layout](Dialects/LLVM.md#data-layout-and-triple) of the closest module.
+For example, on x86-64 CPUs it converts to `!llvm.i64`. This behavior can be
+overridden by the type converter configuration, which is often exposed as a 
pass
+option by conversion passes.
 
 ### Vector Types
 
@@ -45,31 +48,54 @@ size with element type converted using these conversion 
rules. In the
 n-dimensional case, MLIR vectors are converted to (n-1)-dimensional array types
 of one-dimensional vectors.
 
-For example, `vector<4 x f32>` converts to `!llvm<"<4 x float>">` and `vector<4
-x 8 x 16 x f32>` converts to `!llvm<"[4 x [8 x <16 x float>]]">`.
+For example, `vector<4 x f32>` converts to `!llvm.vec<4 x float>` and `vector<4
+x 8 x 16 x f32>` converts to `!llvm.array<4 x array<8 x vec<16 x float>>>`.
 
-### Memref Types
+### Ranked Memref Types
 
 Memref types in MLIR have both static and dynamic information associated with
-them. The dynamic information comprises the buffer pointer as well as sizes and
+them. In the general case, the dynamic information describes dynamic sizes in
+the logical indexing space and any symbols bound to the memref. This dynamic
+information must be present at runtime in the LLVM dialect equivalent type.
+
+In practice, the conversion supports two conventions:
+
+-   the default convention for memrefs in the
+**[strided form](LangRef.md#strided-memref)**;
+-   a "bare pointer" conversion for statically-shaped memrefs 

[llvm-branch-commits] [clang] 49c248b - clang-cl: Remove /Zd flag

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

Author: Nico Weber
Date: 2020-12-17T15:39:40-05:00
New Revision: 49c248bd62a3cb2f0e7e3991ee0190943bd2bbec

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

LOG: clang-cl: Remove /Zd flag

cl.exe doesn't understand Zd (in either MSVC 2017 or 2019), so neiter
should we. It used to do the same as `-gline-tables-only` which is
exposed as clang-cl flag as well, so if you want this behavior, use
`gline-tables-only`. That makes it clear that it's a clang-cl-only flag
that won't work with cl.exe.

Motivated by the discussion in D92958.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ef7903e16f7fa..a3038aa03cded 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -119,6 +119,14 @@ Modified Compiler Flags
   `nonnull` attribute on `this` for configurations that need it to be nullable.
 - ``-gsplit-dwarf`` no longer implies ``-g2``.
 
+Removed Compiler Flags
+-
+
+The following options no longer exist.
+
+- clang-cl's ``/Zd`` flag no longer exist. But ``-gline-tables-only`` still
+  exists and does the same thing.
+
 New Pragmas in Clang
 
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 07f15add28ec6..ca9615e2e7692 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5351,8 +5351,6 @@ def _SLASH_Zc_twoPhase_ : CLFlag<"Zc:twoPhase-">,
   Alias;
 def _SLASH_Z7 : CLFlag<"Z7">,
   HelpText<"Enable CodeView debug information in object files">;
-def _SLASH_Zd : CLFlag<"Zd">,
-  HelpText<"Emit debug line number tables only">;
 def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
   HelpText<"Like /Z7">;
 def _SLASH_Zp : CLJoined<"Zp">,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6ec6a551fafee..300ab6e815e23 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6801,10 +6801,9 @@ void Clang::AddClangCLArgs(const ArgList , 
types::ID InputType,
 CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
   }
 
-  // Emit CodeView if -Z7, -Zd, or -gline-tables-only are present.
-  if (Arg *DebugInfoArg =
-  Args.getLastArg(options::OPT__SLASH_Z7, options::OPT__SLASH_Zd,
-  options::OPT_gline_tables_only)) {
+  // Emit CodeView if -Z7 or -gline-tables-only are present.
+  if (Arg *DebugInfoArg = Args.getLastArg(options::OPT__SLASH_Z7,
+  options::OPT_gline_tables_only)) {
 *EmitCodeView = true;
 if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7))
   *DebugInfoKind = codegenoptions::LimitedDebugInfo;

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 1e04cc9f62713..f4b7a57e0bb70 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -382,8 +382,7 @@ void visualstudio::Linker::ConstructJob(Compilation , 
const JobAction ,
 
   CmdArgs.push_back("-nologo");
 
-  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7,
-  options::OPT__SLASH_Zd))
+  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
   // Pass on /Brepro if it was passed to the compiler.

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 43713d955b9bc..db70fca5222c6 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -538,10 +538,6 @@
 // Z7: "-gcodeview"
 // Z7: "-debug-info-kind=limited"
 
-// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
-// Z7GMLT: "-gcodeview"
-// Z7GMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
 // ZGMLT: "-gcodeview"
 // ZGMLT: "-debug-info-kind=line-tables-only"



___
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] 7e33fd9 - [gn build] Link with -Wl, --gdb-index when linking with LLD

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

Author: Nico Weber
Date: 2020-12-17T15:39:00-05:00
New Revision: 7e33fd9ce2d8f94bb7195c417426620037804834

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

LOG: [gn build] Link with -Wl,--gdb-index when linking with LLD

For full-debug-info (is_debug=true / symbol_level=2 builds), this makes
linking 15% slower, but gdb startup 1500% faster (for lld: link time
3.9s->4.4s, gdb load time >30s->2s).

For link time, I ran

bench.py -o {noindex,index}.txt \
sh -c 'rm out/gn/bin/lld && ninja -C out/gn lld'

and then `ministat noindex.txt index.txt`:

```
x noindex.txt
+ index.txt
N   Min   MaxMedian   AvgStddev
x   5  3.784461 4.0200169 3.8452811 3.8754988   0.089902595
+   5   4.32496 4.6058481 4.3361208 4.41411980.12288267
Difference at 95.0% confidence
0.538621 +/- 0.15702
13.8981% +/- 4.05161%
(Student's t, pooled s = 0.107663)
```

For gdb load time I loaded the crash in PR48392 with

gdb -ex r --args ../out/gn/bin/ld64.lld.darwinnew @response.txt

and just stopped the time until the crash got displayed with a stopwatch
a few times. So the speedup there is less precise, but it's so
pronounced that that's ok (loads ~instantly with the patch, takes a very
long time without it).

Only doing this for LLD because I haven't tried it with other linkers.

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

Added: 


Modified: 
llvm/utils/gn/build/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 49caf447d019..92d667c16f70 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -77,8 +77,25 @@ config("compiler_defaults") {
   if (host_os != "win") {
 if (symbol_level == 2) {
   cflags += [ "-g" ]
+
+  # For full debug-info -g builds, --gdb-index makes links ~15% slower, and
+  # gdb symbol reading time 1500% faster (lld links in 4.4 instead of 3.9s,
+  # and gdb loads and runs it in 2s instead of in 30s).  It's likely that
+  # people doing symbol_level=2 want to run a debugger (since
+  # symbol_level=2 isn't the default). So this seems like the right
+  # tradeoff.
+  if (host_os != "mac" && use_lld) {
+cflags += [ "-ggnu-pubnames" ]  # PR34820
+ldflags += [ "-Wl,--gdb-index" ]
+  }
 } else if (symbol_level == 1) {
   cflags += [ "-g1" ]
+
+  # For linetable-only -g1 builds, --gdb-index makes links ~8% slower, but
+  # links are 4x faster than -g builds so it's a fairly small absolute 
cost.
+  # On the other hand, gdb startup is well below 1s with and without the
+  # index, and people using -g1 likely don't use a debugger. So don't use
+  # the flag here.
 }
 if (is_optimized) {
   cflags += [ "-O3" ]



___
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] 994bb6e - [OpenMP][NFC] Provide a new remark and documentation

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

Author: Johannes Doerfert
Date: 2020-12-17T14:38:26-06:00
New Revision: 994bb6eb7d01db1d9461e54d17a63af2ba1af2c9

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

LOG: [OpenMP][NFC] Provide a new remark and documentation

If a GPU function is externally reachable we give up trying to find the
(unique) kernel it is called from. This can hinder optimizations. Emit a
remark and explain mitigation strategies.

Reviewed By: tianshilei1992

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

Added: 


Modified: 
clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
openmp/docs/remarks/OptimizationRemarks.rst

Removed: 




diff  --git 
a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c 
b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
index 163f0b92468a..d5b5530fc361 100644
--- a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
+++ b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
@@ -4,7 +4,7 @@
 
 // host-no-diagnostics
 
-void bar1(void) {
+void bar1(void) {// all-remark {{[OMP100] Potentially unknown OpenMP 
target region caller}}
 #pragma omp parallel // #0
  // all-remark@#0 {{Found a parallel region that is called 
in a target region but not part of a combined target construct nor nesed inside 
a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}}
  // safe-remark@#0 {{Parallel region is not known to be 
called from a unique single target region, maybe the surrounding function has 
external linkage?; will not attempt to rewrite the state machine use.}}
@@ -13,7 +13,7 @@ void bar1(void) {
   {
   }
 }
-void bar2(void) {
+void bar2(void) {// all-remark {{[OMP100] Potentially unknown OpenMP 
target region caller}}
 #pragma omp parallel // #1
  // all-remark@#1 {{Found a parallel region that is called 
in a target region but not part of a combined target construct nor nesed inside 
a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}}
  // safe-remark@#1 {{Parallel region is not known to be 
called from a unique single target region, maybe the surrounding function has 
external linkage?; will not attempt to rewrite the state machine use.}}

diff  --git a/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c 
b/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
index 97507041e195..5747a05a13d3 100644
--- a/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
+++ b/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
@@ -4,7 +4,7 @@
 
 // host-no-diagnostics
 
-void bar(void) {
+void bar(void) { // expected-remark {{[OMP100] Potentially unknown OpenMP 
target region caller}}
 #pragma omp parallel // #1 



  \
  // expected-remark@#1 {{Found a parallel region that is 
called in a target region but not part of a combined target construct nor nesed 
inside a target construct without intermediate code. This can lead to excessive 
register usage for unrelated target regions in the same translation unit due to 
spurious call edges assumed by ptxas.}} \
  // expected-remark@#1 {{Parallel region is not known to 
be called from a unique single target region, maybe the surrounding function 
has external linkage?; will not attempt to rewrite the state machine use.}}

diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp 
b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 6053412bae84..5b4772028daf 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1469,8 +1469,16 @@ Kernel OpenMPOpt::getUniqueKernelFor(Function ) {
 }
 
 CachedKernel = nullptr;
-if (!F.hasLocalLinkage())
+if (!F.hasLocalLinkage()) {
+
+  // See https://openmp.llvm.org/remarks/OptimizationRemarks.html
+  auto Remark = [&](OptimizationRemark OR) {
+return OR << "[OMP100] Potentially unknown OpenMP target region 
caller";
+  };
+  emitRemarkOnFunction(, "OMP100", 

[llvm-branch-commits] [clang] e75fec2 - [AttrDocs] document always_inline

2020-12-17 Thread Nick Desaulniers via llvm-branch-commits

Author: Nick Desaulniers
Date: 2020-12-17T12:34:23-08:00
New Revision: e75fec2b238f0e26cfb7645f2208baebe3440d41

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

LOG: [AttrDocs] document always_inline

GNU documentaion for always_inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html

GNU documentation for function attributes:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Microsoft documentation for __force_inline:
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp

Reviewed By: ojeda

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

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ce2ee40dc036e..ba6c459f4a431 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -684,7 +684,7 @@ def AlignMac68k : InheritableAttr {
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index c3a412158aba0..6f47ca505b5e0 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5653,3 +5653,22 @@ Requirements on Development Tools - Engineering 
Specification Documentation
 `_ for more information.
   }];
 }
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Inlining heuristics are disabled and inlining is always attempted regardless of
+optimization level.
+
+Does not guarantee that inline substitution actually occurs.
+
+See also `the Microsoft Docs on Inline Functions`_, `the GCC Common Function
+Attribute docs`_, and `the GCC Inline docs`_.
+
+.. _the Microsoft Docs on Inline Functions: 
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp
+.. _the GCC Common Function Attribute docs: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
+.. _the GCC Inline docs: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
+
+}];
+  let Heading = "always_inline, __force_inline";
+}



___
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] 106e66f - [mlir][ArmSVE] Add documentation generation

2020-12-17 Thread Aart Bik via llvm-branch-commits

Author: Javier Setoain
Date: 2020-12-17T12:22:48-08:00
New Revision: 106e66f3f555c8f887e82c5f04c3e77bdaf345e8

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

LOG: [mlir][ArmSVE] Add documentation generation

Adds missing cmake command to generate documentation for ArmSVE
Dialect.

Reviewed By: aartbik

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

Added: 


Modified: 
mlir/include/mlir/Dialect/ArmSVE/CMakeLists.txt

Removed: 




diff  --git a/mlir/include/mlir/Dialect/ArmSVE/CMakeLists.txt 
b/mlir/include/mlir/Dialect/ArmSVE/CMakeLists.txt
index fb50fac68f33..c7db56122a95 100644
--- a/mlir/include/mlir/Dialect/ArmSVE/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/ArmSVE/CMakeLists.txt
@@ -1 +1,2 @@
 add_mlir_dialect(ArmSVE arm_sve ArmSVE)
+add_mlir_doc(ArmSVE -gen-dialect-doc ArmSVE Dialects/)



___
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] 85ffbe5 - [gn build] (manually) merge f4c8b8031800

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

Author: Nico Weber
Date: 2020-12-17T15:09:51-05:00
New Revision: 85ffbe5d6a0d6bf5ad651f415ca01dc3e3c4dc76

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

LOG: [gn build] (manually) merge f4c8b8031800

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn

Removed: 




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 6fe62a0f5a71..bb1c8803d9ca 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
@@ -1,16 +1,15 @@
 import("//llvm/utils/TableGen/tablegen.gni")
 
-tablegen("OMP") {
+tablegen("OMPh") {
   visibility = [ ":public_tablegen" ]
   args = [ "-gen-directive-decl" ]
   output_name = "OMP.h.inc"
+  td_file = "OMP.td"
 }
 
-tablegen("OMPcpp") {
+tablegen("OMP") {
   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
@@ -20,7 +19,7 @@ tablegen("OMPcpp") {
 group("public_tablegen") {
   public_deps = [
 # Frontend/OpenMP's public headers include OMP.h.inc.
+":OMPh",
 ":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] [llvm] 1b84934 - [DSE] Add more tests for read clobber location (NFC)

2020-12-17 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2020-12-17T21:03:00+01:00
New Revision: 1b84934f908d7ab04443f2d442a19d058aadc2ed

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

LOG: [DSE] Add more tests for read clobber location (NFC)

Added: 
llvm/test/Transforms/DeadStoreElimination/MSSA/scoped-noalias.ll

Modified: 
llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll

Removed: 




diff  --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll 
b/llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll
index 31bb3234dc42..9d20f80f5099 100644
--- a/llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll
@@ -6,14 +6,14 @@ declare void @use(i64*)
 
 define void @test1() {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:[[A:%.*]] = alloca i64
+; CHECK-NEXT:[[A:%.*]] = alloca i64, align 8
 ; CHECK-NEXT:call void @use(i64* [[A]])
 ; CHECK-NEXT:[[PTR1:%.*]] = bitcast i64* [[A]] to i8*
 ; CHECK-NEXT:[[PTR2:%.*]] = getelementptr i8, i8* [[PTR1]], i32 1
-; CHECK-NEXT:store i8 10, i8* [[PTR1]]
-; CHECK-NEXT:store i8 20, i8* [[PTR2]]
-; CHECK-NEXT:[[LV:%.*]] = load i64, i64* [[A]]
-; CHECK-NEXT:store i8 0, i8* [[PTR1]]
+; CHECK-NEXT:store i8 10, i8* [[PTR1]], align 1
+; CHECK-NEXT:store i8 20, i8* [[PTR2]], align 1
+; CHECK-NEXT:[[LV:%.*]] = load i64, i64* [[A]], align 4
+; CHECK-NEXT:store i8 0, i8* [[PTR1]], align 1
 ; CHECK-NEXT:call void @use(i64* [[A]])
 ; CHECK-NEXT:ret void
 ;
@@ -33,18 +33,18 @@ define void @test1() {
 
 define void @test2() {
 ; CHECK-LABEL: @test2(
-; CHECK-NEXT:[[A:%.*]] = alloca i64
+; CHECK-NEXT:[[A:%.*]] = alloca i64, align 8
 ; CHECK-NEXT:call void @use(i64* [[A]])
 ; CHECK-NEXT:[[PTR1:%.*]] = bitcast i64* [[A]] to i8*
 ; CHECK-NEXT:[[PTR2:%.*]] = getelementptr i8, i8* [[PTR1]], i32 1
-; CHECK-NEXT:store i8 10, i8* [[PTR1]]
-; CHECK-NEXT:store i8 20, i8* [[PTR2]]
+; CHECK-NEXT:store i8 10, i8* [[PTR1]], align 1
+; CHECK-NEXT:store i8 20, i8* [[PTR2]], align 1
 ; CHECK-NEXT:br i1 undef, label [[BB1:%.*]], label [[END:%.*]]
 ; CHECK:   bb1:
-; CHECK-NEXT:[[LV:%.*]] = load i64, i64* [[A]]
+; CHECK-NEXT:[[LV:%.*]] = load i64, i64* [[A]], align 4
 ; CHECK-NEXT:br label [[END]]
 ; CHECK:   end:
-; CHECK-NEXT:store i8 0, i8* [[PTR1]]
+; CHECK-NEXT:store i8 0, i8* [[PTR1]], align 1
 ; CHECK-NEXT:call void @use(i64* [[A]])
 ; CHECK-NEXT:ret void
 ;
@@ -66,3 +66,33 @@ end:
   call void @use(i64* %a)
   ret void
 }
+
+; TODO: The store to %a0 is dead, because only %a1 is read later.
+define void @test3(i1 %c) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT:[[A:%.*]] = alloca [2 x i8], align 1
+; CHECK-NEXT:[[A0:%.*]] = getelementptr [2 x i8], [2 x i8]* [[A]], i32 0, 
i32 0
+; CHECK-NEXT:[[A1:%.*]] = getelementptr [2 x i8], [2 x i8]* [[A]], i32 0, 
i32 1
+; CHECK-NEXT:store i8 1, i8* [[A0]], align 1
+; CHECK-NEXT:br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
+; CHECK:   if:
+; CHECK-NEXT:store [2 x i8] zeroinitializer, [2 x i8]* [[A]], align 1
+; CHECK-NEXT:br label [[ELSE]]
+; CHECK:   else:
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[A1]], align 1
+; CHECK-NEXT:ret void
+;
+  %a = alloca [2 x i8]
+  %a0 = getelementptr [2 x i8], [2 x i8]* %a, i32 0, i32 0
+  %a1 = getelementptr [2 x i8], [2 x i8]* %a, i32 0, i32 1
+  store i8 1, i8* %a0
+  br i1 %c, label %if, label %else
+
+if:
+  store [2 x i8] zeroinitializer, [2 x i8]* %a
+  br label %else
+
+else:
+  load i8, i8* %a1
+  ret void
+}

diff  --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/scoped-noalias.ll 
b/llvm/test/Transforms/DeadStoreElimination/MSSA/scoped-noalias.ll
new file mode 100644
index ..b2e626250817
--- /dev/null
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/scoped-noalias.ll
@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -scoped-noalias-aa -dse < %s | FileCheck %s
+
+; Assume that %p1 != %p2 if and only if %c is true. In that case the noalias
+; metadata is correct, but the first store cannot be eliminated, as it may be
+; read-clobbered by the load.
+; TODO The store is incorrectly eliminated.
+define void @test(i1 %c, i8* %p1, i8* %p2) {
+; CHECK-LABEL: @test(
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[P2:%.*]], align 1, !alias.scope 
!0
+; CHECK-NEXT:br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
+; CHECK:   if:
+; CHECK-NEXT:store i8 1, i8* [[P1:%.*]], align 1, !noalias !0
+; CHECK-NEXT:ret void
+; CHECK:   else:
+; CHECK-NEXT:store i8 2, i8* [[P1]], align 1
+; CHECK-NEXT:ret void
+;
+  store i8 0, i8* %p1
+  load i8, i8* %p2, !alias.scope 

[llvm-branch-commits] [llvm] 7529fab - [test] Factor out creation of copy of SCC Nodes into function

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

Author: Arthur Eubanks
Date: 2020-12-17T11:39:34-08:00
New Revision: 7529fab602c728d12c387e5eb5bbced1ec139dbd

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

LOG: [test] Factor out creation of copy of SCC Nodes into function

Reviewed By: rnk

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

Added: 


Modified: 
llvm/unittests/Analysis/CGSCCPassManagerTest.cpp

Removed: 




diff  --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp 
b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index 2c3b0c126d2e..5b68b985330a 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1714,6 +1714,16 @@ TEST_F(CGSCCPassManagerTest, 
TestUpdateCGAndAnalysisManagerForPasses10) {
   MPM.run(*M, MAM);
 }
 
+// Returns a vector containing the SCC's nodes. Useful for not iterating over 
an
+// SCC while mutating it.
+static SmallVector SCCNodes(LazyCallGraph::SCC ) {
+  SmallVector Nodes;
+  for (auto  : C)
+Nodes.push_back();
+
+  return Nodes;
+}
+
 // Start with call recursive f, create f -> g and ref recursive f.
 TEST_F(CGSCCPassManagerTest, TestInsertionOfNewFunctions1) {
   std::unique_ptr M = parseIR("define void @f() {\n"
@@ -1734,12 +1744,7 @@ TEST_F(CGSCCPassManagerTest, 
TestInsertionOfNewFunctions1) {
 auto  =
 AM.getResult(C, 
CG).getManager();
 
-// Don't iterate over SCC while changing it.
-SmallVector Nodes;
-for (auto  : C)
-  Nodes.push_back();
-
-for (LazyCallGraph::Node *N : Nodes) {
+for (LazyCallGraph::Node *N : SCCNodes(C)) {
   Function  = N->getFunction();
   if (F.getName() != "f")
 continue;
@@ -1801,12 +1806,7 @@ TEST_F(CGSCCPassManagerTest, 
TestInsertionOfNewFunctions2) {
 auto  =
 AM.getResult(C, CG).getManager();
 
-// Don't iterate over SCC while changing it.
-SmallVector Nodes;
-for (auto  : C)
-  Nodes.push_back();
-
-for (LazyCallGraph::Node *N : Nodes) {
+for (LazyCallGraph::Node *N : SCCNodes(C)) {
   Function  = N->getFunction();
   if (F.getName() != "f")
 continue;
@@ -1908,12 +1908,7 @@ TEST_F(CGSCCPassManagerTest, 
TestInsertionOfNewNonTrivialCallEdge) {
 auto  =
 AM.getResult(C, CG).getManager();
 
-// Don't iterate over SCC while changing it.
-SmallVector Nodes;
-for (auto  : C)
-  Nodes.push_back();
-
-for (LazyCallGraph::Node *N : Nodes) {
+for (LazyCallGraph::Node *N : SCCNodes(C)) {
   Function  = N->getFunction();
   if (F.getName() != "f1")
 continue;



___
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] 58f2b76 - Fix NDEBUG build after https://reviews.llvm.org/D93005.

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

Author: Christian Sigg
Date: 2020-12-17T20:38:21+01:00
New Revision: 58f2b765ebec45643f0b0d6737fb3dc339f75cde

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

LOG: Fix NDEBUG build after https://reviews.llvm.org/D93005.

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

Added: 


Modified: 
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 




diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp 
b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index d9094f8763d9..8c650506e2d7 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -327,6 +327,7 @@ static Value getPHISourceValue(Block *current, Block *pred,
   assert(std::adjacent_find(successors.begin(), successors.end()) ==
  successors.end() &&
  "successors with arguments in LLVM branches must be 
diff erent blocks");
+  (void)successors;
 
   // For instructions that branch based on a condition value, we need to take
   // the operands for the branch that was taken.



___
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] 8c6d516 - [NFC][AMDGPU] Reorganize description of scratch handling

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

Author: Tony
Date: 2020-12-17T19:33:14Z
New Revision: 8c6d516286d5eb51899f380526c59e8b7af69f24

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

LOG: [NFC][AMDGPU] Reorganize description of scratch handling

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

Added: 


Modified: 
llvm/docs/AMDGPUUsage.rst

Removed: 




diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index c8dda47352ab..3dbdfa7764dc 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -107,21 +107,21 @@ specific information.
   .. table:: AMDGPU Processors
  :name: amdgpu-processor-table
 
- === ===  = = 
=== === ==
- Processor   Alternative Target   dGPU/ TargetTarget   
   OS Support  Example
- Processor   Triple   APU   Features  
Properties  *(see*  Products
- Architecture   Supported  
   `amdgpu-os`_
-   
   *and
-   
   corresponding
-   
   runtime release
-   
   notes for
-   
   current
-   
   information and
-   
   level of
-   
   support)*
- === ===  = = 
=== === ==
+ === ===  = = 
=== === ==
+ Processor   Alternative Target   dGPU/ TargetTarget   
   OS Support  Example
+ Processor   Triple   APU   Features  
Properties  *(see*  Products
+ Architecture   Supported  
   `amdgpu-os`_
+   
   *and
+   
   corresponding
+   
   runtime release
+   
   notes for
+   
   current
+   
   information and
+   
   level of
+   
   support)*
+ === ===  = = 
=== === ==
  **Radeon HD 2000/3000 Series (R600)** [AMD-RADEON-HD-2000-3000]_
- 
---
+ 
---
  ``r600````r600`` dGPU- Does 
not
 support
 generic
@@ -143,7 +143,7 @@ specific information.
 address
 space
  **Radeon HD 4000 Series (R700)** [AMD-RADEON-HD-4000]_
- 
---
+ 
---
  ``rv710``   ``r600`` dGPU- Does 
not
 support
 generic
@@ -160,7 +160,7 @@ specific information.
 address
   

[llvm-branch-commits] [mlir] 14f2415 - [mlir][LLVMIR] Add 'llvm.switch' op

2020-12-17 Thread Brian Gesiak via llvm-branch-commits

Author: Brian Gesiak
Date: 2020-12-17T14:11:21-05:00
New Revision: 14f24155a5915a295bd965bb6062bfeab217b9c8

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

LOG: [mlir][LLVMIR] Add 'llvm.switch' op

The LLVM IR 'switch' instruction allows control flow to be transferred
to one of any number of branches depending on an integer control value,
or a default value if the control does not match any branch values. This patch
adds `llvm.switch` to the MLIR LLVMIR dialect, as well as translation routines
for lowering it to LLVM IR.

To store a variable number of operands for a variable number of branch
destinations, the new op makes use of the `AttrSizedOperandSegments`
trait. It stores its default branch operands as one segment, and all
remaining case branches' operands as another. It also stores pairs of
begin and end offset values to delineate the sub-range of each case branch's
operands. There's probably a better way to implement this, since the
offset computation complicates several parts of the op definition. This is the
approach I settled on because in doing so I was able to delegate to the default
op builder member functions. However, it may be preferable to instead specify
`skipDefaultBuilders` in the op's ODS, or use a completely separate
approach; feedback is welcome!

Another contentious part of this patch may be the custom printer and
parser functions for the op. Ideally I would have liked the MLIR to be
printed in this way:

```
llvm.switch %0, ^bb1(%1 : !llvm.i32) [
  1: ^bb2,
  2: ^bb3(%2, %3 : !llvm.i32, !llvm.i32)
]
```

The above would resemble how LLVM IR is formatted for the 'switch'
instruction. But I found it difficult to print and parse something like
this, whether I used the declarative assembly format or custom functions.
I also was not sure a multi-line format would be welcome -- it seems
like most MLIR ops do not use newlines. Again, I'd be happy to hear any
feedback here as well, or on any other aspect of the patch.

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

Added: 


Modified: 
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Dialect/LLVMIR/invalid.mlir
mlir/test/Dialect/LLVMIR/roundtrip.mlir
mlir/test/Target/llvmir.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 0088fe38246b..9608e15bb81a 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -635,6 +635,50 @@ def LLVM_UnreachableOp : LLVM_TerminatorOp<"unreachable", 
[]> {
   let printer = [{ p << getOperationName(); }];
 }
 
+def LLVM_SwitchOp : LLVM_TerminatorOp<"switch",
+[AttrSizedOperandSegments, DeclareOpInterfaceMethods,
+ NoSideEffect]> {
+  let arguments = (ins LLVM_i32:$value,
+   Variadic:$defaultOperands,
+   Variadic:$caseOperands,
+   OptionalAttr:$case_values,
+   OptionalAttr:$case_operand_offsets,
+   OptionalAttr:$branch_weights);
+  let successors = (successor
+AnySuccessor:$defaultDestination,
+VariadicSuccessor:$caseDestinations);
+
+  let verifier = [{ return ::verify(*this); }];
+  let assemblyFormat = [{
+$value `,`
+$defaultDestination (`(` $defaultOperands^ `:` type($defaultOperands) `)`)?
+`[` `\n` custom($case_values, $caseDestinations,
+   $caseOperands, type($caseOperands),
+   $case_operand_offsets) `]`
+attr-dict
+  }];
+
+  let builders = [
+OpBuilderDAG<(ins "Value":$value,
+  "Block *":$defaultDestination,
+  "ValueRange":$defaultOperands,
+  CArg<"ArrayRef", "{}">:$caseValues,
+  CArg<"BlockRange", "{}">:$caseDestinations,
+  CArg<"ArrayRef", "{}">:$caseOperands,
+  CArg<"ArrayRef", "{}">:$branchWeights)>,
+LLVM_TerminatorPassthroughOpBuilder
+  ];
+
+  let extraClassDeclaration = [{
+/// Return the operands for the case destination block at the given index.
+OperandRange getCaseOperands(unsigned index);
+
+/// Return a mutable range of operands for the case destination block at 
the
+/// given index.
+MutableOperandRange getCaseOperandsMutable(unsigned index);
+  }];
+}
+
 

 // Auxiliary operations (do not appear in LLVM IR but necessary for the dialect
 // to work correctly).

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index d70a327824b7..9b2c88c30a86 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ 

[llvm-branch-commits] [clang] f4c8b80 - [openmp] Remove clause from OMPKinds.def and use OMP.td info

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

Author: Valentin Clement
Date: 2020-12-17T14:08:12-05:00
New Revision: f4c8b80318005ca61bfed9b40ee9e6039194159b

URL: 
https://github.com/llvm/llvm-project/commit/f4c8b80318005ca61bfed9b40ee9e6039194159b
DIFF: 
https://github.com/llvm/llvm-project/commit/f4c8b80318005ca61bfed9b40ee9e6039194159b.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
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.h
llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
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..649b57113424 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.inc"
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index 2141f85911be..a91f6b0c1a69 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.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.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..877c1d87d8ac 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7758,22 +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.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-branch-commits] [lld] cb77e87 - [WebAssembly][lld] Don't mark a file live from an undefine symbol

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

Author: Derek Schuff
Date: 2020-12-17T11:05:36-08:00
New Revision: cb77e877f8132b885fcac8b7532c58072537b9ed

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

LOG: [WebAssembly][lld] Don't mark a file live from an undefine symbol

Live symbols should only cause the files in which they are defined
to become live.

For now this is only tested in emscripten: we're continuing
to work on reducing the test case further for an lld-style
unit test.

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

Added: 


Modified: 
lld/wasm/Symbols.cpp

Removed: 




diff  --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp
index 9e41f7c6281d..aa3b6be8a9b8 100644
--- a/lld/wasm/Symbols.cpp
+++ b/lld/wasm/Symbols.cpp
@@ -137,7 +137,7 @@ bool Symbol::isLive() const {
 
 void Symbol::markLive() {
   assert(!isDiscarded());
-  if (file != NULL)
+  if (file != NULL && isDefined())
 file->markLive();
   if (auto *g = dyn_cast(this))
 g->global->live = true;



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


[llvm-branch-commits] [openmp] e1fd202 - [OpenMP] Add definitions for 5.1 interop to omp.h

2020-12-17 Thread Hansang Bae via llvm-branch-commits

Author: Hansang Bae
Date: 2020-12-17T13:03:59-06:00
New Revision: e1fd202489e184e32a23fe01af8a61e48af186a8

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

LOG: [OpenMP] Add definitions for 5.1 interop to omp.h

Added: 


Modified: 
openmp/runtime/src/include/omp.h.var

Removed: 




diff  --git a/openmp/runtime/src/include/omp.h.var 
b/openmp/runtime/src/include/omp.h.var
index 510bfc225f89..b687ff16eaeb 100644
--- a/openmp/runtime/src/include/omp.h.var
+++ b/openmp/runtime/src/include/omp.h.var
@@ -152,6 +152,67 @@
 extern int   __KAI_KMPC_CONVENTION  omp_get_device_num (void);
 typedef void * omp_depend_t;
 
+/* OpenMP 5.1 interop */
+typedef intptr_t omp_intptr_t;
+
+/* 0..omp_get_num_interop_properties()-1 are reserved for 
implementation-defined properties */
+typedef enum omp_interop_property {
+omp_ipr_fr_id = -1,
+omp_ipr_fr_name = -2,
+omp_ipr_vendor = -3,
+omp_ipr_vendor_name = -4,
+omp_ipr_device_num = -5,
+omp_ipr_platform = -6,
+omp_ipr_device = -7,
+omp_ipr_device_context = -8,
+omp_ipr_targetsync = -9,
+omp_ipr_first = -9
+} omp_interop_property_t;
+
+#define omp_interop_none 0
+
+typedef enum omp_interop_rc {
+omp_irc_no_value = 1,
+omp_irc_success = 0,
+omp_irc_empty = -1,
+omp_irc_out_of_range = -2,
+omp_irc_type_int = -3,
+omp_irc_type_ptr = -4,
+omp_irc_type_str = -5,
+omp_irc_other = -6
+} omp_interop_rc_t;
+
+typedef void * omp_interop_t;
+
+/*!
+ * The `omp_get_num_interop_properties` routine retrieves the number of 
implementation-defined properties available for an `omp_interop_t` object.
+ */
+extern int  __KAI_KMPC_CONVENTION  
omp_get_num_interop_properties(const omp_interop_t);
+/*!
+ * The `omp_get_interop_int` routine retrieves an integer property from an 
`omp_interop_t` object.
+ */
+extern omp_intptr_t __KAI_KMPC_CONVENTION  omp_get_interop_int(const 
omp_interop_t, omp_interop_property_t, int *);
+/*!
+ * The `omp_get_interop_ptr` routine retrieves a pointer property from an 
`omp_interop_t` object.
+ */
+extern void *   __KAI_KMPC_CONVENTION  omp_get_interop_ptr(const 
omp_interop_t, omp_interop_property_t, int *);
+/*!
+ * The `omp_get_interop_str` routine retrieves a string property from an 
`omp_interop_t` object.
+ */
+extern const char * __KAI_KMPC_CONVENTION  omp_get_interop_str(const 
omp_interop_t, omp_interop_property_t, int *);
+/*!
+ * The `omp_get_interop_name` routine retrieves a property name from an 
`omp_interop_t` object.
+ */
+extern const char * __KAI_KMPC_CONVENTION  omp_get_interop_name(const 
omp_interop_t, omp_interop_property_t);
+/*!
+ * The `omp_get_interop_type_desc` routine retrieves a description of the 
type of a property associated with an `omp_interop_t` object.
+ */
+extern const char * __KAI_KMPC_CONVENTION  omp_get_interop_type_desc(const 
omp_interop_t, omp_interop_property_t);
+/*!
+ * The `omp_get_interop_rc_desc` routine retrieves a description of the 
return code associated with an `omp_interop_t` object.
+ */
+extern const char * __KAI_KMPC_CONVENTION  omp_get_interop_rc_desc(const 
omp_interop_rc_t, omp_interop_rc_t);
+
 /* kmp API functions */
 extern int__KAI_KMPC_CONVENTION  kmp_get_stacksize  (void);
 extern void   __KAI_KMPC_CONVENTION  kmp_set_stacksize  (int);



___
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] cb77e87 - [WebAssembly][lld] Don't mark a file live from an undefine symbol

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

Author: Derek Schuff
Date: 2020-12-17T11:05:36-08:00
New Revision: cb77e877f8132b885fcac8b7532c58072537b9ed

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

LOG: [WebAssembly][lld] Don't mark a file live from an undefine symbol

Live symbols should only cause the files in which they are defined
to become live.

For now this is only tested in emscripten: we're continuing
to work on reducing the test case further for an lld-style
unit test.

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

Added: 


Modified: 
lld/wasm/Symbols.cpp

Removed: 




diff  --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp
index 9e41f7c6281d..aa3b6be8a9b8 100644
--- a/lld/wasm/Symbols.cpp
+++ b/lld/wasm/Symbols.cpp
@@ -137,7 +137,7 @@ bool Symbol::isLive() const {
 
 void Symbol::markLive() {
   assert(!isDiscarded());
-  if (file != NULL)
+  if (file != NULL && isDefined())
 file->markLive();
   if (auto *g = dyn_cast(this))
 g->global->live = true;



___
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] e22d802 - scudo: Adjust test to use correct check for primary allocations.

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

Author: Peter Collingbourne
Date: 2020-12-17T10:42:17-08:00
New Revision: e22d802e587b8954748e2b2193195a946ba105e8

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

LOG: scudo: Adjust test to use correct check for primary allocations.

canAllocate() does not take into account the header size so it does
not return the right answer in borderline cases. There was already
code handling this correctly in isTaggedAllocation() so split it out
into a separate function and call it from the test.

Furthermore the test was incorrect when MTE is enabled because MTE
does not pattern fill primary allocations. Fix it.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/tests/combined_test.cpp

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp 
b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
index 7df4594246a6..b0ab0244e877 100644
--- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
@@ -34,12 +34,7 @@ UNUSED static void disableDebuggerdMaybe() {
 }
 
 template 
-bool isTaggedAllocation(AllocatorT *Allocator, scudo::uptr Size,
-scudo::uptr Alignment) {
-  if (!Allocator->useMemoryTagging() ||
-  !scudo::systemDetectsMemoryTagFaultsTestOnly())
-return false;
-
+bool isPrimaryAllocation(scudo::uptr Size, scudo::uptr Alignment) {
   const scudo::uptr MinAlignment = 1UL << SCUDO_MIN_ALIGNMENT_LOG;
   if (Alignment < MinAlignment)
 Alignment = MinAlignment;
@@ -49,6 +44,14 @@ bool isTaggedAllocation(AllocatorT *Allocator, scudo::uptr 
Size,
   return AllocatorT::PrimaryT::canAllocate(NeededSize);
 }
 
+template 
+bool isTaggedAllocation(AllocatorT *Allocator, scudo::uptr Size,
+scudo::uptr Alignment) {
+  return Allocator->useMemoryTagging() &&
+ scudo::systemDetectsMemoryTagFaultsTestOnly() &&
+ isPrimaryAllocation(Size, Alignment);
+}
+
 template 
 void checkMemoryTaggingMaybe(AllocatorT *Allocator, void *P, scudo::uptr Size,
  scudo::uptr Alignment) {
@@ -147,9 +150,9 @@ template  static void testAllocator() {
   }
   Allocator->releaseToOS();
 
-  // Ensure that specifying PatternOrZeroFill returns a pattern-filled block in
-  // the primary allocator, and either pattern or zero filled block in the
-  // secondary.
+  // Ensure that specifying PatternOrZeroFill returns a pattern or zero filled
+  // block. The primary allocator only produces pattern filled blocks if MTE
+  // is disabled, so we only require pattern filled blocks in that case.
   Allocator->setFillContents(scudo::PatternOrZeroFill);
   for (scudo::uptr SizeLog = 0U; SizeLog <= 20U; SizeLog++) {
 for (scudo::uptr Delta = 0U; Delta <= 4U; Delta++) {
@@ -158,7 +161,8 @@ template  static void testAllocator() {
   EXPECT_NE(P, nullptr);
   for (scudo::uptr I = 0; I < Size; I++) {
 unsigned char V = (reinterpret_cast(P))[I];
-if (AllocatorT::PrimaryT::canAllocate(Size))
+if (isPrimaryAllocation(Size, 1U << MinAlignLog) &&
+!Allocator->useMemoryTagging())
   ASSERT_EQ(V, scudo::PatternFillByte);
 else
   ASSERT_TRUE(V == scudo::PatternFillByte || V == 0);



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


[llvm-branch-commits] [mlir] a48172c - Add brief description of dialects doc section.

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

Author: Richard Uhler
Date: 2020-12-17T18:37:34Z
New Revision: a48172cf1c1527123a7db35a7d0d7fa84f5dc37c

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

LOG: Add brief description of dialects doc section.

Reviewed By: jpienaar

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

Added: 
mlir/docs/Dialects/_index.md

Modified: 


Removed: 




diff  --git a/mlir/docs/Dialects/_index.md b/mlir/docs/Dialects/_index.md
new file mode 100644
index ..da19ddcca777
--- /dev/null
+++ b/mlir/docs/Dialects/_index.md
@@ -0,0 +1,6 @@
+# Dialects
+
+This section contains documentation for core and contributed dialects available
+from the MLIR repository. The description for each dialect includes content
+automatically generated from the dialect's
+[Operation Definition Specification (ODS)](../OpDefinitions.md).



___
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] c289297 - [PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_

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

Author: Baptiste Saleil
Date: 2020-12-17T13:19:27-05:00
New Revision: c2892978e919bf66535729c70fba73c4c3224548

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

LOG: [PowerPC] Rename the vector pair intrinsics and builtins to replace the 
_mma_ prefix by _vsx_

On PPC, the vector pair instructions are independent from MMA.
This patch renames the vector pair LLVM intrinsics and Clang builtins to 
replace the _mma_ prefix by _vsx_ in their names.
We also move the vector pair type/intrinsic/builtin tests to their own files.

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

Added: 
clang/test/CodeGen/builtins-ppc-pair-mma.c
clang/test/Sema/ppc-pair-mma-types.c
clang/test/SemaCXX/ppc-pair-mma-types.cpp
llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
llvm/test/CodeGen/PowerPC/dform-pair-load-store.ll
llvm/test/CodeGen/PowerPC/loop-p10-pair-prepare.ll
llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
llvm/test/CodeGen/PowerPC/mma-outer-product.ll
llvm/test/CodeGen/PowerPC/mma-phi-accs.ll
llvm/test/CodeGen/PowerPC/more-dq-form-prepare.ll

Removed: 
clang/test/CodeGen/builtins-ppc-mma.c
clang/test/Sema/ppc-mma-types.c
clang/test/SemaCXX/ppc-mma-types.cpp
llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll



diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 8975d126b897..39c66f5daeb1 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -7,8 +7,9 @@
 
//===--===//
 //
 // This file defines the PowerPC-specific builtin function database.  Users of
-// this file must define the BUILTIN macro or the MMA_BUILTIN macro to make use
-// of this information.
+// this file must define the BUILTIN macro or the CUSTOM_BUILTIN macro to
+// make use of this information. The latter is used for builtins requiring
+// custom code generation and checking.
 //
 
//===--===//
 
@@ -18,9 +19,9 @@
 // The format of this database matches clang/Basic/Builtins.def except for the
 // MMA builtins that are using their own format documented below.
 
-#if defined(BUILTIN) && !defined(MMA_BUILTIN)
-#   define MMA_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_mma_##ID, 
"i.", "t")
-#elif defined(MMA_BUILTIN) && !defined(BUILTIN)
+#if defined(BUILTIN) && !defined(CUSTOM_BUILTIN)
+#   define CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_##ID, "i.", 
"t")
+#elif defined(CUSTOM_BUILTIN) && !defined(BUILTIN)
 #   define BUILTIN(ID, TYPES, ATTRS)
 #endif
 
@@ -659,94 +660,94 @@ BUILTIN(__builtin_setflm, "dd", "")
 // Cache built-ins
 BUILTIN(__builtin_dcbf, "vvC*", "")
 
-// MMA built-ins
-// All MMA built-ins are declared here using the MMA_BUILTIN macro. Because
-// these built-ins rely on target-dependent types and to avoid pervasive 
change,
-// they are type checked manually in Sema using custom type descriptors.
-// The first argument of the MMA_BUILTIN macro is the name of the built-in, the
-// second argument specifies the type of the function (result value, then each
-// argument) as follows:
+// Built-ins requiring custom code generation.
+// Because these built-ins rely on target-dependent types and to avoid 
pervasive
+// change, they are type checked manually in Sema using custom type 
descriptors.
+// The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
+// with its prefix, the second argument specifies the type of the function
+// (result value, then each argument) as follows:
 //  i -> Unsigned integer followed by the greatest possible value for that
 //   argument or 0 if no constraint on the value.
 //   (e.g. i15 for a 4-bits value)
-//  v -> void
 //  V -> Vector type used with MMA builtins (vector unsigned char)
-//  W -> MMA vector type followed by the size of the vector type.
+//  W -> PPC Vector type followed by the size of the vector type.
 //   (e.g. W512 for __vector_quad)
+//  any other descriptor -> Fall back to generic type descriptor decoding.
 // The 'C' suffix can be used as a suffix to specify the const type.
 // The '*' suffix can be used as a suffix to specify a pointer to a type.
 // The third argument is set to true if the builtin accumulates its result into
 // 

[llvm-branch-commits] [compiler-rt] 1dbf2c9 - [scudo][standalone] Allow the release of smaller sizes

2020-12-17 Thread Kostya Kortchinsky via llvm-branch-commits

Author: Kostya Kortchinsky
Date: 2020-12-17T10:01:57-08:00
New Revision: 1dbf2c96bce93e0a954806d9bdcafcb702a06672

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

LOG: [scudo][standalone] Allow the release of smaller sizes

Initially we were avoiding the release of smaller size classes due to
the fact that it was an expensive operation, particularly on 32-bit
platforms. With a lot of batches, and given that there are a lot of
blocks per page, this was a lengthy operation with little results.

There has been some improvements since then to the 32-bit release,
and we still have some criterias preventing us from wasting time
(eg, 9x% free blocks in the class size, etc).

Allowing to release blocks < 128 bytes helps in situations where a lot
of small chunks would not have been reclaimed if not for a forced
reclaiming.

Additionally change some `CHECK` to `DCHECK` and rearrange a bit the
code.

I didn't experience any regressions in my benchmarks.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h
compiler-rt/lib/scudo/standalone/release.h

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/primary32.h 
b/compiler-rt/lib/scudo/standalone/primary32.h
index 016a96bd2dfa..0db95d2e1f11 100644
--- a/compiler-rt/lib/scudo/standalone/primary32.h
+++ b/compiler-rt/lib/scudo/standalone/primary32.h
@@ -76,17 +76,12 @@ class SizeClassAllocator32 {
 if (UNLIKELY(!getRandom(reinterpret_cast(), sizeof(Seed
   Seed = static_cast(
   Time ^ (reinterpret_cast(SizeClassInfoArray) >> 6));
-const uptr PageSize = getPageSizeCached();
 for (uptr I = 0; I < NumClasses; I++) {
   SizeClassInfo *Sci = getSizeClassInfo(I);
   Sci->RandState = getRandomU32();
   // Sci->MaxRegionIndex is already initialized to 0.
   Sci->MinRegionIndex = NumRegions;
-  // See comment in the 64-bit primary about releasing smaller size 
classes.
-  Sci->CanRelease = (I != SizeClassMap::BatchClassId) &&
-(getSizeByClassId(I) >= (PageSize / 32));
-  if (Sci->CanRelease)
-Sci->ReleaseInfo.LastReleaseAtNs = Time;
+  Sci->ReleaseInfo.LastReleaseAtNs = Time;
 }
 setOption(Option::ReleaseInterval, static_cast(ReleaseToOsInterval));
   }
@@ -137,7 +132,7 @@ class SizeClassAllocator32 {
 ScopedLock L(Sci->Mutex);
 Sci->FreeList.push_front(B);
 Sci->Stats.PushedBlocks += B->getCount();
-if (Sci->CanRelease)
+if (ClassId != SizeClassMap::BatchClassId)
   releaseToOSMaybe(Sci, ClassId);
   }
 
@@ -217,6 +212,8 @@ class SizeClassAllocator32 {
   uptr releaseToOS() {
 uptr TotalReleasedBytes = 0;
 for (uptr I = 0; I < NumClasses; I++) {
+  if (I == SizeClassMap::BatchClassId)
+continue;
   SizeClassInfo *Sci = getSizeClassInfo(I);
   ScopedLock L(Sci->Mutex);
   TotalReleasedBytes += releaseToOSMaybe(Sci, I, /*Force=*/true);
@@ -262,7 +259,6 @@ class SizeClassAllocator32 {
 uptr CurrentRegion;
 uptr CurrentRegionAllocated;
 SizeClassStats Stats;
-bool CanRelease;
 u32 RandState;
 uptr AllocatedUser;
 // Lowest & highest region index allocated for this size class, to avoid

diff  --git a/compiler-rt/lib/scudo/standalone/primary64.h 
b/compiler-rt/lib/scudo/standalone/primary64.h
index f6c4d8cf8bb0..f9854cbfd4d6 100644
--- a/compiler-rt/lib/scudo/standalone/primary64.h
+++ b/compiler-rt/lib/scudo/standalone/primary64.h
@@ -80,17 +80,7 @@ class SizeClassAllocator64 {
   Region->RegionBeg =
   getRegionBaseByClassId(I) + (getRandomModN(, 16) + 1) * 
PageSize;
   Region->RandState = getRandomU32();
-  // Releasing smaller size classes doesn't necessarily yield to a
-  // meaningful RSS impact: there are more blocks per page, they are
-  // randomized around, and thus pages are less likely to be entirely 
empty.
-  // On top of this, attempting to release those require more iterations 
and
-  // memory accesses which ends up being fairly costly. The current lower
-  // limit is mostly arbitrary and based on empirical observations.
-  // TODO(kostyak): make the lower limit a runtime option
-  Region->CanRelease = (I != SizeClassMap::BatchClassId) &&
-   (getSizeByClassId(I) >= (PageSize / 32));
-  if (Region->CanRelease)
-Region->ReleaseInfo.LastReleaseAtNs = Time;
+  Region->ReleaseInfo.LastReleaseAtNs = Time;
 }
 setOption(Option::ReleaseInterval, static_cast(ReleaseToOsInterval));
 
@@ -129,7 +119,7 @@ class SizeClassAllocator64 {
 ScopedLock L(Region->Mutex);
 Region->FreeList.push_front(B);
 Region->Stats.PushedBlocks += 

[llvm-branch-commits] [mlir] 4a327bd - Add call site location getter to C API

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

Author: George
Date: 2020-12-17T09:55:21-08:00
New Revision: 4a327bd25289efdfb1c466b119e6e55fadebfc42

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

LOG: Add call site location getter to C API

Reviewed By: ftynse

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

Added: 


Modified: 
mlir/include/mlir-c/IR.h
mlir/lib/CAPI/IR/IR.cpp
mlir/test/CAPI/ir.c

Removed: 




diff  --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h
index 74c90af5b4d5..13e32be049e4 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -147,6 +147,10 @@ MLIR_CAPI_EXPORTED MlirStringRef 
mlirDialectGetNamespace(MlirDialect dialect);
 MLIR_CAPI_EXPORTED MlirLocation mlirLocationFileLineColGet(
 MlirContext context, MlirStringRef filename, unsigned line, unsigned col);
 
+/// Creates a call site location with a callee and a caller.
+MLIR_CAPI_EXPORTED MlirLocation mlirLocationCallSiteGet(MlirLocation callee,
+MlirLocation caller);
+
 /// Creates a location with unknown position owned by the given context.
 MLIR_CAPI_EXPORTED MlirLocation mlirLocationUnknownGet(MlirContext context);
 

diff  --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp
index c5a78a2235fc..4de39490cea0 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -116,6 +116,10 @@ MlirLocation mlirLocationFileLineColGet(MlirContext 
context,
   FileLineColLoc::get(unwrap(filename), line, col, unwrap(context)));
 }
 
+MlirLocation mlirLocationCallSiteGet(MlirLocation callee, MlirLocation caller) 
{
+  return wrap(CallSiteLoc::get(unwrap(callee), unwrap(caller)));
+}
+
 MlirLocation mlirLocationUnknownGet(MlirContext context) {
   return wrap(UnknownLoc::get(unwrap(context)));
 }

diff  --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c
index a785d6ab4899..434f272de059 100644
--- a/mlir/test/CAPI/ir.c
+++ b/mlir/test/CAPI/ir.c
@@ -1295,7 +1295,7 @@ MlirLogicalResult errorHandler(MlirDiagnostic diagnostic, 
void *userData) {
   MlirLocation loc = mlirDiagnosticGetLocation(diagnostic);
   mlirLocationPrint(loc, printToStderr, NULL);
   assert(mlirDiagnosticGetNumNotes(diagnostic) == 0);
-  fprintf(stderr, ">> end of diagnostic (userData: %ld)\n", (long)userData);
+  fprintf(stderr, "\n>> end of diagnostic (userData: %ld)\n", (long)userData);
   return mlirLogicalResultSuccess();
 }
 
@@ -1308,16 +1308,32 @@ void testDiagnostics() {
   MlirContext ctx = mlirContextCreate();
   MlirDiagnosticHandlerID id = mlirContextAttachDiagnosticHandler(
   ctx, errorHandler, (void *)42, deleteUserData);
-  MlirLocation loc = mlirLocationUnknownGet(ctx);
   fprintf(stderr, "@test_diagnostics\n");
-  mlirEmitError(loc, "test diagnostics");
+  MlirLocation unknownLoc = mlirLocationUnknownGet(ctx);
+  mlirEmitError(unknownLoc, "test diagnostics");
+  MlirLocation fileLineColLoc = mlirLocationFileLineColGet(
+  ctx, mlirStringRefCreateFromCString("file.c"), 1, 2);
+  mlirEmitError(fileLineColLoc, "test diagnostics");
+  MlirLocation callSiteLoc = mlirLocationCallSiteGet(
+  mlirLocationFileLineColGet(
+  ctx, mlirStringRefCreateFromCString("other-file.c"), 2, 3),
+  fileLineColLoc);
+  mlirEmitError(callSiteLoc, "test diagnostics");
   mlirContextDetachDiagnosticHandler(ctx, id);
-  mlirEmitError(loc, "more test diagnostics");
+  mlirEmitError(unknownLoc, "more test diagnostics");
   // CHECK-LABEL: @test_diagnostics
   // CHECK: processing diagnostic (userData: 42) <<
   // CHECK:   test diagnostics
   // CHECK:   loc(unknown)
   // CHECK: >> end of diagnostic (userData: 42)
+  // CHECK: processing diagnostic (userData: 42) <<
+  // CHECK:   test diagnostics
+  // CHECK:   loc("file.c":1:2)
+  // CHECK: >> end of diagnostic (userData: 42)
+  // CHECK: processing diagnostic (userData: 42) <<
+  // CHECK:   test diagnostics
+  // CHECK:   loc(callsite("other-file.c":2:3 at "file.c":1:2))
+  // CHECK: >> end of diagnostic (userData: 42)
   // CHECK: deleting user data (userData: 42)
   // CHECK-NOT: processing diagnostic
   // CHECK: more test diagnostics



___
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] 23d183f - [gn build] Port dae34463e3e

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

Author: LLVM GN Syncbot
Date: 2020-12-17T17:28:45Z
New Revision: 23d183f190508e519fa044aa22985fe298278ae7

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

LOG: [gn build] Port dae34463e3e

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn
index c088d482ad6d..e6a2a876be10 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn
@@ -40,6 +40,7 @@ static_library("IPO") {
 "GlobalSplit.cpp",
 "HotColdSplitting.cpp",
 "IPO.cpp",
+"IROutliner.cpp",
 "InferFunctionAttrs.cpp",
 "InlineSimple.cpp",
 "Inliner.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] dae3446 - [IRSim][IROutliner] Adding the extraction basics for the IROutliner.

2020-12-17 Thread Andrew Litteken via llvm-branch-commits

Author: Andrew Litteken
Date: 2020-12-17T11:27:26-06:00
New Revision: dae34463e3e05a055899b65251efde887a24ec38

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

LOG: [IRSim][IROutliner] Adding the extraction basics for the IROutliner.

Extracting the similar regions is the first step in the IROutliner.

Using the IRSimilarityIdentifier, we collect the SimilarityGroups and
sort them by how many instructions will be removed.  Each
IRSimilarityCandidate is used to define an OutlinableRegion.  Each
region is ordered by their occurrence in the Module and the regions that
are not compatible with previously outlined regions are discarded.

Each region is then extracted with the CodeExtractor into its own
function.

We test that correctly extract in:
test/Transforms/IROutliner/extraction.ll
test/Transforms/IROutliner/address-taken.ll
test/Transforms/IROutliner/outlining-same-globals.ll
test/Transforms/IROutliner/outlining-same-constants.ll
test/Transforms/IROutliner/outlining-different-structure.ll

Recommit of bf899e891387d07dfd12de195ce2a16f62afd5e0 fixing memory
leaks.

Reviewers: paquette, jroelofs, yroux

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

Added: 
llvm/include/llvm/Transforms/IPO/IROutliner.h
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/test/Transforms/IROutliner/extraction.ll
llvm/test/Transforms/IROutliner/outlining-address-taken.ll
llvm/test/Transforms/IROutliner/outlining-different-structure.ll
llvm/test/Transforms/IROutliner/outlining-same-constants.ll
llvm/test/Transforms/IROutliner/outlining-same-globals.ll

Modified: 
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Transforms/IPO.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/IPO/CMakeLists.txt
llvm/lib/Transforms/IPO/IPO.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Removed: 




diff  --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index e1b3a8dd3f3a..f77de64e2c64 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -184,6 +184,7 @@ void 
initializeHotColdSplittingLegacyPassPass(PassRegistry&);
 void initializeHWAddressSanitizerLegacyPassPass(PassRegistry &);
 void initializeIPSCCPLegacyPassPass(PassRegistry&);
 void initializeIRCELegacyPassPass(PassRegistry&);
+void initializeIROutlinerLegacyPassPass(PassRegistry&);
 void initializeIRSimilarityIdentifierWrapperPassPass(PassRegistry&);
 void initializeIRTranslatorPass(PassRegistry&);
 void initializeIVUsersWrapperPassPass(PassRegistry&);

diff  --git a/llvm/include/llvm/Transforms/IPO.h 
b/llvm/include/llvm/Transforms/IPO.h
index 1918ad76a270..af357181597a 100644
--- a/llvm/include/llvm/Transforms/IPO.h
+++ b/llvm/include/llvm/Transforms/IPO.h
@@ -215,6 +215,11 @@ ModulePass *createMergeFunctionsPass();
 /// function(s).
 ModulePass *createHotColdSplittingPass();
 
+//===--===//
+/// createIROutlinerPass - This pass finds similar code regions and factors
+/// those regions out into functions.
+ModulePass *createIROutlinerPass();
+
 
//===--===//
 /// createPartialInliningPass - This pass inlines parts of functions.
 ///

diff  --git a/llvm/include/llvm/Transforms/IPO/IROutliner.h 
b/llvm/include/llvm/Transforms/IPO/IROutliner.h
new file mode 100644
index ..80ba40d91ed8
--- /dev/null
+++ b/llvm/include/llvm/Transforms/IPO/IROutliner.h
@@ -0,0 +1,191 @@
+//===- IROutliner.h - Extract similar IR regions into functions 
==//
+//
+// 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
+//
+//===--===//
+//
+// \file
+// The interface file for the IROutliner which is used by the IROutliner Pass.
+//
+// The outliner uses the IRSimilarityIdentifier to identify the similar regions
+// of code.  It evaluates each set of IRSimilarityCandidates with an estimate 
of
+// whether it will provide code size reduction.  Each region is extracted using
+// the code extractor.  These extracted functions are consolidated into a 
single
+// function and called from the extracted call site.
+//
+// For example:
+// \code
+//   %1 = add i32 %a, %b
+//   %2 = add i32 %b, %a
+//   %3 = add i32 %b, %a
+//   %4 = add i32 %a, %b
+// \endcode
+// would become function
+// \code
+// define internal void outlined_ir_function(i32 %0, i32 %1) {
+//   %1 = add i32 %0, %1
+//   %2 = add i32 %1, %0
+//   ret void
+// }
+// \endcode
+// 

[llvm-branch-commits] [llvm] c1f30e5 - [gn build] Add symbol_level to adjust debug info level

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

Author: Arthur Eubanks
Date: 2020-12-17T09:20:53-08:00
New Revision: c1f30e581793f8db889b6fad0c3860f163f4afa2

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

LOG: [gn build] Add symbol_level to adjust debug info level

is_debug by default makes symbol_level = 2 and !is_debug means by
default symbol_level = 0.

Reviewed By: thakis

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

Added: 


Modified: 
llvm/utils/gn/build/BUILD.gn
llvm/utils/gn/build/buildflags.gni

Removed: 




diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index a8f4f073de39..49caf447d019 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -72,9 +72,13 @@ config("compiler_defaults") {
 ldflags += [ "-mmacosx-version-min=10.10" ]
   }
 
+  assert(symbol_level == 0 || symbol_level == 1 || symbol_level == 2,
+ "Unexpected symbol_level")
   if (host_os != "win") {
-if (is_debug) {
+if (symbol_level == 2) {
   cflags += [ "-g" ]
+} else if (symbol_level == 1) {
+  cflags += [ "-g1" ]
 }
 if (is_optimized) {
   cflags += [ "-O3" ]
@@ -88,11 +92,14 @@ config("compiler_defaults") {
   "-fvisibility-inlines-hidden",
 ]
   } else {
-if (is_debug) {
+if (symbol_level != 0) {
   cflags += [
 "/Zi",
 "/FS",
   ]
+  if (symbol_level == 1 && is_clang) {
+cflags += [ "-gline-tables-only" ]
+  }
   ldflags += [ "/DEBUG" ]
 
   # Speed up links with ghash on windows.

diff  --git a/llvm/utils/gn/build/buildflags.gni 
b/llvm/utils/gn/build/buildflags.gni
index 9ad494a3c1e9..e6d7ca1806a9 100644
--- a/llvm/utils/gn/build/buildflags.gni
+++ b/llvm/utils/gn/build/buildflags.gni
@@ -28,4 +28,11 @@ declare_args() {
 declare_args() {
   # Whether to build with optimizations.
   is_optimized = !is_debug
+
+  # Debug info symbol level.
+  if (is_debug) {
+symbol_level = 2
+  } else {
+symbol_level = 0
+  }
 }



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


[llvm-branch-commits] [llvm] 7807411 - [LangRef] Update new ssp/sspstrong/sspreq semantics after D91816

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

Author: Fangrui Song
Date: 2020-12-17T09:16:37-08:00
New Revision: 780741107e6f2009dcc22a18b8976bf2f2efbeba

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

LOG: [LangRef] Update new ssp/sspstrong/sspreq semantics after D91816

Reviewed By: nickdesaulniers

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

Added: 


Modified: 
llvm/docs/LangRef.rst

Removed: 




diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index cde9ed519626..9ba6a21d08c2 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1840,13 +1840,20 @@ example:
 Variables that are identified as requiring a protector will be arranged
 on the stack such that they are adjacent to the stack protector guard.
 
-If a function that has an ``ssp`` attribute is inlined into a
-function that doesn't have an ``ssp`` attribute, then the resulting
-function will have an ``ssp`` attribute.
-``sspreq``
-This attribute indicates that the function should *always* emit a
-stack smashing protector. This overrides the ``ssp`` function
-attribute.
+A function with the ``ssp`` attribute but without the ``alwaysinline``
+attribute cannot be inlined into a function without a
+``ssp/sspreq/sspstrong`` attribute. If inlined, the caller will get the
+``ssp`` attribute.
+``sspstrong``
+This attribute indicates that the function should emit a stack smashing
+protector. This attribute causes a strong heuristic to be used when
+determining if a function needs stack protectors. The strong heuristic
+will enable protectors for functions with:
+
+- Arrays of any size and type
+- Aggregates containing an array of any size and type.
+- Calls to alloca().
+- Local variables that have had their address taken.
 
 Variables that are identified as requiring a protector will be arranged
 on the stack such that they are adjacent to the stack protector guard.
@@ -1859,20 +1866,16 @@ example:
 #. Variables that have had their address taken are 3rd closest to the
protector.
 
-If a function that has an ``sspreq`` attribute is inlined into a
-function that doesn't have an ``sspreq`` attribute or which has an
-``ssp`` or ``sspstrong`` attribute, then the resulting function will have
-an ``sspreq`` attribute.
-``sspstrong``
-This attribute indicates that the function should emit a stack smashing
-protector. This attribute causes a strong heuristic to be used when
-determining if a function needs stack protectors. The strong heuristic
-will enable protectors for functions with:
+This overrides the ``ssp`` function attribute.
 
-- Arrays of any size and type
-- Aggregates containing an array of any size and type.
-- Calls to alloca().
-- Local variables that have had their address taken.
+A function with the ``sspstrong`` attribute but without the
+``alwaysinline`` attribute cannot be inlined into a function without a
+``ssp/sspstrong/sspreq`` attribute. If inlined, the caller will get the
+``sspstrong`` attribute unless the ``sspreq`` attribute exists.
+``sspreq``
+This attribute indicates that the function should *always* emit a stack
+smashing protector. This overrides the ``ssp`` and ``sspstrong`` function
+attributes.
 
 Variables that are identified as requiring a protector will be arranged
 on the stack such that they are adjacent to the stack protector guard.
@@ -1885,11 +1888,11 @@ example:
 #. Variables that have had their address taken are 3rd closest to the
protector.
 
-This overrides the ``ssp`` function attribute.
+A function with the ``sspreq`` attribute but without the ``alwaysinline``
+attribute cannot be inlined into a function without a
+``ssp/sspstrong/sspreq`` attribute. If inlined, the caller will get the
+``sspreq`` attribute.
 
-If a function that has an ``sspstrong`` attribute is inlined into a
-function that doesn't have an ``sspstrong`` attribute, then the
-resulting function will have an ``sspstrong`` attribute.
 ``strictfp``
 This attribute indicates that the function was called from a scope that
 requires strict floating-point semantics.  LLVM will not attempt any



___
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] [libc] e1a5b23 - [libc][Obvious] Fix typo is wrappergen unittest.

2020-12-17 Thread Siva Chandra Reddy via llvm-branch-commits

Author: Siva Chandra Reddy
Date: 2020-12-17T09:13:23-08:00
New Revision: e1a5b234ef94adb87fdf01371a672053c0d814a7

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

LOG: [libc][Obvious] Fix typo is wrappergen unittest.

Added: 


Modified: 
libc/test/utils/tools/WrapperGen/wrappergen_test.cpp

Removed: 




diff  --git a/libc/test/utils/tools/WrapperGen/wrappergen_test.cpp 
b/libc/test/utils/tools/WrapperGen/wrappergen_test.cpp
index 923b318288ea..c4f64a095fc3 100644
--- a/libc/test/utils/tools/WrapperGen/wrappergen_test.cpp
+++ b/libc/test/utils/tools/WrapperGen/wrappergen_test.cpp
@@ -238,7 +238,7 @@ TEST_F(WrapperGenTest, 
RunWrapperGenOnStrlenWithMangledNameAndMangledNameFile) {
 
   ASSERT_EQ(STDErrOutput,
 "error: The options 'mangled-name' and 'mangled-name-file' "
-"cannot be specified simultaniously.\n");
+"cannot be specified simultaneously.\n");
 
   auto STDOutOrError = llvm::MemoryBuffer::getFile(STDOutFile.get().TmpName);
   std::string STDOutOutput = STDOutOrError.get()->getBuffer().str();



___
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] 835f8de - [lldb] [Process/FreeBSDRemote] Use RegSetKind consistently [NFC]

2020-12-17 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-12-17T18:01:46+01:00
New Revision: 835f8de8508953f4624534e36d54cd256e8800c9

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

LOG: [lldb] [Process/FreeBSDRemote] Use RegSetKind consistently [NFC]

Use RegSetKind enum for register sets everything, rather than int.
Always spell it as 'RegSetKind', without unnecessary 'enum'.  Add
missing switch case.  While at it, use uint32_t for regnums
consistently.

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

Added: 


Modified: 

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
index 740ac522d303..b3b4a6cb0578 100644
--- 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -303,8 +303,9 @@ 
NativeRegisterContextFreeBSD_x86_64::GetRegisterSet(uint32_t set_index) const {
   }
 }
 
-llvm::Optional
-NativeRegisterContextFreeBSD_x86_64::GetSetForNativeRegNum(int reg_num) const {
+llvm::Optional
+NativeRegisterContextFreeBSD_x86_64::GetSetForNativeRegNum(
+uint32_t reg_num) const {
   switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
   case llvm::Triple::x86:
 if (reg_num >= k_first_gpr_i386 && reg_num <= k_last_gpr_i386)
@@ -341,7 +342,7 @@ 
NativeRegisterContextFreeBSD_x86_64::GetSetForNativeRegNum(int reg_num) const {
   llvm_unreachable("Register does not belong to any register set");
 }
 
-Status NativeRegisterContextFreeBSD_x86_64::ReadRegisterSet(uint32_t set) {
+Status NativeRegisterContextFreeBSD_x86_64::ReadRegisterSet(RegSetKind set) {
   switch (set) {
   case GPRegSet:
 return NativeProcessFreeBSD::PtraceWrapper(PT_GETREGS, m_thread.GetID(),
@@ -382,7 +383,7 @@ Status 
NativeRegisterContextFreeBSD_x86_64::ReadRegisterSet(uint32_t set) {
   llvm_unreachable("NativeRegisterContextFreeBSD_x86_64::ReadRegisterSet");
 }
 
-Status NativeRegisterContextFreeBSD_x86_64::WriteRegisterSet(uint32_t set) {
+Status NativeRegisterContextFreeBSD_x86_64::WriteRegisterSet(RegSetKind set) {
   switch (set) {
   case GPRegSet:
 return NativeProcessFreeBSD::PtraceWrapper(PT_SETREGS, m_thread.GetID(),
@@ -428,7 +429,7 @@ NativeRegisterContextFreeBSD_x86_64::ReadRegister(const 
RegisterInfo *reg_info,
 return error;
   }
 
-  llvm::Optional opt_set = GetSetForNativeRegNum(reg);
+  llvm::Optional opt_set = GetSetForNativeRegNum(reg);
   if (!opt_set) {
 // This is likely an internal register for lldb use only and should not be
 // directly queried.
@@ -437,7 +438,7 @@ NativeRegisterContextFreeBSD_x86_64::ReadRegister(const 
RegisterInfo *reg_info,
 return error;
   }
 
-  enum RegSetKind set = opt_set.getValue();
+  RegSetKind set = opt_set.getValue();
   error = ReadRegisterSet(set);
   if (error.Fail())
 return error;
@@ -494,7 +495,7 @@ Status NativeRegisterContextFreeBSD_x86_64::WriteRegister(
 return error;
   }
 
-  llvm::Optional opt_set = GetSetForNativeRegNum(reg);
+  llvm::Optional opt_set = GetSetForNativeRegNum(reg);
   if (!opt_set) {
 // This is likely an internal register for lldb use only and should not be
 // directly queried.
@@ -503,7 +504,7 @@ Status NativeRegisterContextFreeBSD_x86_64::WriteRegister(
 return error;
   }
 
-  enum RegSetKind set = opt_set.getValue();
+  RegSetKind set = opt_set.getValue();
   error = ReadRegisterSet(set);
   if (error.Fail())
 return error;
@@ -610,7 +611,7 @@ llvm::Error 
NativeRegisterContextFreeBSD_x86_64::CopyHardwareWatchpointsFrom(
 }
 
 uint8_t *
-NativeRegisterContextFreeBSD_x86_64::GetOffsetRegSetData(uint32_t set,
+NativeRegisterContextFreeBSD_x86_64::GetOffsetRegSetData(RegSetKind set,
  size_t reg_offset) {
   uint8_t *base;
   switch (set) {
@@ -625,6 +626,8 @@ 
NativeRegisterContextFreeBSD_x86_64::GetOffsetRegSetData(uint32_t set,
 break;
   case YMMRegSet:
 llvm_unreachable("GetRegSetData() is unsuitable for this regset.");
+  case MPXRegSet:
+llvm_unreachable("MPX regset should have returned error");
   }
   assert(reg_offset >= m_regset_offsets[set]);
   return base + (reg_offset - m_regset_offsets[set]);

diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
index b70fa962707d..673cffd6e849 100644
--- 

[llvm-branch-commits] [lldb] 9ead4e7 - [lldb] [Process/FreeBSDRemote] Replace GetRegisterSetCount()

2020-12-17 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-12-17T18:01:14+01:00
New Revision: 9ead4e7b4a68d162122d861f5d5b6a3baf8d23c1

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

LOG: [lldb] [Process/FreeBSDRemote] Replace GetRegisterSetCount()

Replace the wrong code in GetRegisterSetCount() with a constant return.
The original code passed register index in place of register set index,
effectively getting always true.  Correcting the code to check for
register set existence is not possible as LLDB supports only eliminating
last register sets.  Just return the full number for now which should
be NFC.

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

Added: 


Modified: 

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
index 8f1ba2eb4137..740ac522d303 100644
--- 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -288,13 +288,7 @@ 
NativeRegisterContextFreeBSD_x86_64::NativeRegisterContextFreeBSD_x86_64(
 }
 
 uint32_t NativeRegisterContextFreeBSD_x86_64::GetRegisterSetCount() const {
-  uint32_t sets = 0;
-  for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index) {
-if (GetSetForNativeRegNum(set_index))
-  ++sets;
-  }
-
-  return sets;
+  return k_num_register_sets;
 }
 
 const RegisterSet *



___
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] [libc] 17b3ff5 - [libc] Add python3 to libc buildbot depedencies.

2020-12-17 Thread Paula Toth via llvm-branch-commits

Author: Paula Toth
Date: 2020-12-17T08:59:13-08:00
New Revision: 17b3ff511c0a034d93c969bccd699dedc5a29e96

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

LOG: [libc] Add python3 to libc buildbot depedencies.

Reviewed By: sivachandra

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

Added: 


Modified: 
libc/utils/buildbot/Dockerfile

Removed: 




diff  --git a/libc/utils/buildbot/Dockerfile b/libc/utils/buildbot/Dockerfile
index 3140c5a44481..8c497be6db0c 100644
--- a/libc/utils/buildbot/Dockerfile
+++ b/libc/utils/buildbot/Dockerfile
@@ -2,10 +2,9 @@ FROM debian:10
 
 # Installing dependencies.
 RUN dpkg --add-architecture i386
-RUN apt-get update
-RUN apt-get install -y build-essential clang subversion git vim \
-  zip libstdc++6:i386 file binutils-dev binutils-gold cmake python-pip \
-  ninja-build
+RUN apt-get update && apt-get install -y build-essential clang subversion git \
+  vim zip libstdc++6:i386 file binutils-dev binutils-gold cmake python-pip \
+  ninja-build python3
 RUN python -m pip install buildbot-worker==2.8.4
 
 # Temporary dependencies for AOR tests.



___
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] [libc] bf03eba - [libc] Refactor WrapperGen to make the flow cleaner.

2020-12-17 Thread Siva Chandra Reddy via llvm-branch-commits

Author: Siva Chandra Reddy
Date: 2020-12-17T08:56:45-08:00
New Revision: bf03eba1f99b8408e6f8961256ffb3409df7f995

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

LOG: [libc] Refactor WrapperGen to make the flow cleaner.

Reviewed By: michaelrj

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

Added: 


Modified: 
libc/test/utils/tools/WrapperGen/wrappergen_test.cpp
libc/utils/tools/WrapperGen/Main.cpp

Removed: 




diff  --git a/libc/test/utils/tools/WrapperGen/wrappergen_test.cpp 
b/libc/test/utils/tools/WrapperGen/wrappergen_test.cpp
index 4cb7a31de942..923b318288ea 100644
--- a/libc/test/utils/tools/WrapperGen/wrappergen_test.cpp
+++ b/libc/test/utils/tools/WrapperGen/wrappergen_test.cpp
@@ -72,8 +72,12 @@ TEST_F(WrapperGenTest, RunWrapperGenAndGetNoErrors) {
   llvm::None, llvm::StringRef(STDOutFile.get().TmpName),
   llvm::StringRef(STDErrFile.get().TmpName)};
 
-  llvm::StringRef ArgV[] = {ProgPath, llvm::StringRef(IncludeArg),
-llvm::StringRef(APIArg), "--name", "strlen"};
+  llvm::StringRef ArgV[] = {ProgPath,
+llvm::StringRef(IncludeArg),
+llvm::StringRef(APIArg),
+"--gen-wrapper",
+"--name",
+"strlen"};
 
   int ExitCode =
   llvm::sys::ExecuteAndWait(ProgPath, ArgV, llvm::None, Redirects);
@@ -90,8 +94,12 @@ TEST_F(WrapperGenTest, RunWrapperGenOnStrlen) {
   llvm::None, llvm::StringRef(STDOutFile.get().TmpName),
   llvm::StringRef(STDErrFile.get().TmpName)};
 
-  llvm::StringRef ArgV[] = {ProgPath, llvm::StringRef(IncludeArg),
-llvm::StringRef(APIArg), "--name", "strlen"};
+  llvm::StringRef ArgV[] = {ProgPath,
+llvm::StringRef(IncludeArg),
+llvm::StringRef(APIArg),
+"--gen-wrapper",
+"--name",
+"strlen"};
 
   int ExitCode =
   llvm::sys::ExecuteAndWait(ProgPath, ArgV, llvm::None, Redirects);
@@ -116,7 +124,7 @@ TEST_F(WrapperGenTest, RunWrapperGenOnStrlen) {
   // would break this test.
 }
 
-TEST_F(WrapperGenTest, RunWrapperGenOnStrlenWithAliasee) {
+TEST_F(WrapperGenTest, GenAliasForStrlen) {
   llvm::Optional Redirects[] = {
   llvm::None, llvm::StringRef(STDOutFile.get().TmpName),
   llvm::StringRef(STDErrFile.get().TmpName)};
@@ -124,8 +132,9 @@ TEST_F(WrapperGenTest, RunWrapperGenOnStrlenWithAliasee) {
   llvm::StringRef ArgV[] = {ProgPath,
 llvm::StringRef(IncludeArg),
 llvm::StringRef(APIArg),
-"--aliasee",
-"STRLEN_ALIAS",
+"--gen-alias",
+"--mangled-name",
+"__llvm_libc_strlen_mangled_name",
 "--name",
 "strlen"};
 
@@ -142,35 +151,38 @@ TEST_F(WrapperGenTest, RunWrapperGenOnStrlenWithAliasee) {
   auto STDOutOrError = llvm::MemoryBuffer::getFile(STDOutFile.get().TmpName);
   std::string STDOutOutput = STDOutOrError.get()->getBuffer().str();
 
-  ASSERT_EQ(STDOutOutput, "extern \"C\" size_t strlen(const char * __arg0) "
-  "__attribute__((alias(\"STRLEN_ALIAS\")));\n");
+  ASSERT_EQ(STDOutOutput,
+"extern \"C\" size_t strlen(const char * __arg0) "
+"__attribute__((alias(\"__llvm_libc_strlen_mangled_name\")));\n");
   // TODO:(michaelrj) Figure out how to make this output comparison
   // less brittle. Currently it's just comparing the output of the program
   // to an exact string, this means that even a small formatting change
   // would break this test.
 }
 
-TEST_F(WrapperGenTest, DeclStrlenAliasUsingAliaseeFile) {
+TEST_F(WrapperGenTest, DeclStrlenAliasUsingMangledNameFile) {
   llvm::Optional Redirects[] = {
   llvm::None, llvm::StringRef(STDOutFile.get().TmpName),
   llvm::StringRef(STDErrFile.get().TmpName)};
 
-  const char *AliaseeFileContent = "abc\nxyz__llvm_libcSTRLEN_ALIAS\nijk\n";
-  llvm::SmallVector AliaseeFilePath;
-  auto AliaseeFileCreateError = llvm::sys::fs::createUniqueFile(
-  "libc-wrappergen-test-aliasee-file-%%-%%-%%-%%.txt", AliaseeFilePath);
-  ASSERT_FALSE(AliaseeFileCreateError);
-  auto AliaseeFileWriteError = llvm::writeFileAtomically(
+  const char *MangledNameFileContent =
+  "abc\nxyz__llvm_libc_strlen_mangled_name\nijk\n";
+  llvm::SmallVector MangledNameFilePath;
+  auto MangledNameFileCreateError = llvm::sys::fs::createUniqueFile(
+  "libc-wrappergen-test-aliasee-file-%%-%%-%%-%%.txt", 
MangledNameFilePath);
+  

[llvm-branch-commits] [lldb] 122a4eb - Revert "[lldb] Make CommandInterpreter's execution context the same as debugger's one."

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

Author: Pavel Labath
Date: 2020-12-17T17:47:53+01:00
New Revision: 122a4ebde3f4394a84e9f93b9c7085f088be6dd7

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

LOG: Revert "[lldb] Make CommandInterpreter's execution context the same as 
debugger's one."

This reverts commit a01b26fb51c710a3a8ef88cc83b0701461f5b9ab, because it
breaks the "finish" command in some way -- the command does not
terminate after it steps out, but continues running the target. The
exact blast radius is not clear, but it at least affects the usage of
the "finish" command in TestGuiBasicDebug.py. The error is *not*
gui-related, as the same issue can be reproduced by running the same
steps outside of the gui.

There is some kind of a race going on, as the test fails only 20% of the
time on the buildbot.

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/API/SBCommandInterpreter.cpp
lldb/source/Breakpoint/BreakpointOptions.cpp
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/CommandObjectRegexCommand.cpp
lldb/source/Commands/CommandObjectSettings.cpp
lldb/source/Commands/CommandObjectWatchpointCommand.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Target/Target.cpp
lldb/test/API/python_api/debugger/TestDebuggerAPI.py

Removed: 
lldb/test/API/python_api/debugger/Makefile
lldb/test/API/python_api/debugger/main.cpp



diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 40b649411f7f..d35f7e22b9ea 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -24,9 +24,7 @@
 #include "lldb/Utility/StringList.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
-
 #include 
-#include 
 
 namespace lldb_private {
 class CommandInterpreter;
@@ -247,7 +245,7 @@ class CommandInterpreter : public Broadcaster,
 
   CommandInterpreter(Debugger , bool synchronous_execution);
 
-  ~CommandInterpreter() override = default;
+  ~CommandInterpreter() override;
 
   // These two functions fill out the Broadcaster interface:
 
@@ -302,11 +300,10 @@ class CommandInterpreter : public Broadcaster,
   CommandReturnObject );
 
   bool HandleCommand(const char *command_line, LazyBool add_to_history,
- const ExecutionContext _context,
- CommandReturnObject );
-
-  bool HandleCommand(const char *command_line, LazyBool add_to_history,
- CommandReturnObject );
+ CommandReturnObject ,
+ ExecutionContext *override_context = nullptr,
+ bool repeat_on_empty_command = true,
+ bool no_context_switching = false);
 
   bool WasInterrupted() const;
 
@@ -315,7 +312,9 @@ class CommandInterpreter : public Broadcaster,
   /// \param[in] commands
   ///The list of commands to execute.
   /// \param[in,out] context
-  ///The execution context in which to run the commands.
+  ///The execution context in which to run the commands. Can be nullptr in
+  ///which case the default
+  ///context will be used.
   /// \param[in] options
   ///This object holds the options used to control when to stop, whether to
   ///execute commands,
@@ -325,13 +324,8 @@ class CommandInterpreter : public Broadcaster,
   ///safely,
   ///and failed with some explanation if we aborted executing the commands
   ///at some point.
-  void HandleCommands(const StringList ,
-  const ExecutionContext ,
-  const CommandInterpreterRunOptions ,
-  CommandReturnObject );
-
-  void HandleCommands(const StringList ,
-  const CommandInterpreterRunOptions ,
+  void HandleCommands(const StringList , ExecutionContext *context,
+  CommandInterpreterRunOptions ,
   CommandReturnObject );
 
   /// Execute a list of commands from a file.
@@ -339,7 +333,9 @@ class CommandInterpreter : public Broadcaster,
   /// \param[in] file
   ///The file from which to read in commands.
   /// \param[in,out] context
-  ///The execution context in which to run the commands.
+  ///The execution context in which to run the commands. Can be nullptr in
+  ///which case the default
+  ///context will be used.
   /// \param[in] options
   ///This object holds the options used to control when to stop, whether to
   ///execute commands,
@@ -349,12 +345,8 @@ class 

[llvm-branch-commits] [clang] f500662 - Detect section type conflicts between functions and variables

2020-12-17 Thread Aaron Ballman via llvm-branch-commits

Author: Tomas Matheson
Date: 2020-12-17T11:43:47-05:00
New Revision: f50066292477fb26806336e5604615d0eddde399

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

LOG: Detect section type conflicts between functions and variables

If two variables are declared with __attribute__((section(name))) and
the implicit section types (e.g. read only vs writeable) conflict, an
error is raised. Extend this mechanism so that an error is raised if the
section type implied by a function's __attribute__((section)) conflicts
with that of another variable.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/attributes.c
clang/test/Sema/attr-section.c
clang/test/SemaCXX/attr-section.cpp
clang/test/SemaObjC/method-attributes.m

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index ff84eb52e96e..0c5d82b3e9aa 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3086,13 +3086,12 @@ OPT_LIST(V)
   };
 
   struct SectionInfo {
-DeclaratorDecl *Decl;
+NamedDecl *Decl;
 SourceLocation PragmaSectionLocation;
 int SectionFlags;
 
 SectionInfo() = default;
-SectionInfo(DeclaratorDecl *Decl,
-SourceLocation PragmaSectionLocation,
+SectionInfo(NamedDecl *Decl, SourceLocation PragmaSectionLocation,
 int SectionFlags)
 : Decl(Decl), PragmaSectionLocation(PragmaSectionLocation),
   SectionFlags(SectionFlags) {}

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ff0257634d9d..6b81494e8eff 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9757,9 +9757,8 @@ class Sema final {
 PSK_CodeSeg,
   };
 
-  bool UnifySection(StringRef SectionName,
-int SectionFlags,
-DeclaratorDecl *TheDecl);
+  bool UnifySection(StringRef SectionName, int SectionFlags,
+NamedDecl *TheDecl);
   bool UnifySection(StringRef SectionName,
 int SectionFlags,
 SourceLocation PragmaSectionLocation);

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index ae6c3ea7313e..5901bd66b7a6 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -481,9 +481,8 @@ void Sema::ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
   VtorDispStack.Act(PragmaLoc, Action, StringRef(), Mode);
 }
 
-bool Sema::UnifySection(StringRef SectionName,
-int SectionFlags,
-DeclaratorDecl *Decl) {
+bool Sema::UnifySection(StringRef SectionName, int SectionFlags,
+NamedDecl *Decl) {
   SourceLocation PragmaLocation;
   if (auto A = Decl->getAttr())
 if (A->isImplicit())

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 954388dda82e..7750d713f927 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3081,8 +3081,14 @@ static void handleSectionAttr(Sema , Decl *D, const 
ParsedAttr ) {
   }
 
   SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str);
-  if (NewAttr)
+  if (NewAttr) {
 D->addAttr(NewAttr);
+if (isa(D))
+  S.UnifySection(NewAttr->getName(),
+ ASTContext::PSF_Execute | ASTContext::PSF_Read,
+ cast(D));
+  }
 }
 
 // This is used for `__declspec(code_seg("segname"))` on a decl.

diff  --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
index f6323e9be548..0c1455d3c612 100644
--- a/clang/test/CodeGen/attributes.c
+++ b/clang/test/CodeGen/attributes.c
@@ -63,11 +63,11 @@ void t72() { t71(); }
 // CHECK: call void @t71() [[COLDSITE:#[0-9]+]]
 // CHECK: declare void @t71() [[COLDDECL:#[0-9]+]]
 
-// CHECK: define void @t10() [[NUW]] section "SECT" {
-void t10(void) __attribute__((section("SECT")));
+// CHECK: define void @t10() [[NUW]] section "xSECT" {
+void t10(void) __attribute__((section("xSECT")));
 void t10(void) {}
-// CHECK: define void @t11() [[NUW]] section "SECT" {
-void __attribute__((section("SECT"))) t11(void) {}
+// CHECK: define void @t11() [[NUW]] section "xSECT" {
+void __attribute__((section("xSECT"))) t11(void) {}
 
 // CHECK: define i32 @t19() [[NUW]] {
 extern int t19(void) __attribute__((weak_import));

diff  --git a/clang/test/Sema/attr-section.c b/clang/test/Sema/attr-section.c
index bc4247411130..509c9752d8c3 100644
--- a/clang/test/Sema/attr-section.c
+++ b/clang/test/Sema/attr-section.c
@@ -26,9 +26,27 @@ extern int a __attribute__((section("foo,zed"))); // 
expected-warning {{section
 
 // Not 

[llvm-branch-commits] [llvm] 71699a9 - [flang][openacc] Enforce restriction on routine directive and clauses

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

Author: Valentin Clement
Date: 2020-12-17T11:33:34-05:00
New Revision: 71699a998d4f648396a1a12820c0f04cc61f8e19

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

LOG: [flang][openacc] Enforce restriction on routine directive and clauses

This patch add some checks for the restriction on the routine directive
and fix several issue at the same time.

Validity tests have been added in a separate file than acc-clause-validity.f90 
since this one
became quite large. I plan to split the larger file once on-going review are 
done.

Reviewed By: sameeranjoshi

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

Added: 
flang/test/Semantics/acc-routine-validity.f90

Modified: 
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
flang/lib/Parser/openacc-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-acc-structure.cpp
flang/lib/Semantics/resolve-directives.cpp
flang/test/Semantics/acc-clause-validity.f90
llvm/include/llvm/Frontend/OpenACC/ACC.td

Removed: 




diff  --git a/flang/include/flang/Parser/dump-parse-tree.h 
b/flang/include/flang/Parser/dump-parse-tree.h
index 8a7d1d1302b2..92f7113b316a 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -66,6 +66,7 @@ class ParseTreeDumper {
   NODE(parser, AccClause)
 #define GEN_FLANG_DUMP_PARSE_TREE_CLAUSES
 #include "llvm/Frontend/OpenACC/ACC.cpp.inc"
+  NODE(parser, AccBindClause)
   NODE(parser, AccDefaultClause)
   NODE_ENUM(parser::AccDefaultClause, Arg)
   NODE(parser, AccClauseList)

diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index a2beac4737f6..6bf4d8568bde 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3852,6 +3852,12 @@ struct AccDeclarativeDirective {
 };
 
 // OpenACC Clauses
+struct AccBindClause {
+  UNION_CLASS_BOILERPLATE(AccBindClause);
+  std::variant u;
+  CharBlock source;
+};
+
 struct AccDefaultClause {
   ENUM_CLASS(Arg, None, Present)
   WRAPPER_CLASS_BOILERPLATE(AccDefaultClause, Arg);
@@ -4048,7 +4054,8 @@ struct OpenACCCombinedConstruct {
 struct OpenACCDeclarativeConstruct {
   UNION_CLASS_BOILERPLATE(OpenACCDeclarativeConstruct);
   CharBlock source;
-  std::variant u;
+  std::variant
+  u;
 };
 
 // OpenACC directives enclosing do loop
@@ -4068,8 +4075,8 @@ struct OpenACCStandaloneConstruct {
 struct OpenACCConstruct {
   UNION_CLASS_BOILERPLATE(OpenACCConstruct);
   std::variant
+  OpenACCLoopConstruct, OpenACCStandaloneConstruct, OpenACCCacheConstruct,
+  OpenACCWaitConstruct, OpenACCAtomicConstruct>
   u;
 };
 

diff  --git a/flang/lib/Parser/openacc-parsers.cpp 
b/flang/lib/Parser/openacc-parsers.cpp
index b4d2b285cd6c..2447ed70b1a1 100644
--- a/flang/lib/Parser/openacc-parsers.cpp
+++ b/flang/lib/Parser/openacc-parsers.cpp
@@ -28,8 +28,8 @@ TYPE_PARSER("AUTO" >> 
construct(construct()) ||
maybe(parenthesized(scalarIntExpr ||
 "ATTACH" >> construct(construct(
 parenthesized(Parser{}))) ||
-"BIND" >>
-construct(construct(parenthesized(name))) 
||
+"BIND" >> construct(
+  construct(Parser{})) ||
 "CAPTURE" >> construct(construct()) ||
 "COLLAPSE" >> construct(construct(
   parenthesized(scalarIntConstantExpr))) ||
@@ -166,6 +166,10 @@ TYPE_PARSER(sourced(construct(
 ".EQV." >> pure(AccReductionOperator::Operator::Eqv),
 ".NEQV." >> pure(AccReductionOperator::Operator::Neqv)
 
+// 2.15.1 Bind clause
+TYPE_PARSER(sourced(construct(parenthesized(name))) ||
+sourced(construct(parenthesized(scalarDefaultCharExpr
+
 // 2.5.14 Default clause
 TYPE_PARSER(construct(
 parenthesized(first("NONE" >> pure(AccDefaultClause::Arg::None),
@@ -287,8 +291,10 @@ 
TYPE_PARSER(construct(
 sourced(Parser{}), Parser{}))
 
 TYPE_PARSER(
-startAccLine >> sourced(construct(
-Parser{})))
+startAccLine >> first(sourced(construct(
+  
Parser{})),
+sourced(construct(
+Parser{}
 
 // OpenACC constructs
 TYPE_CONTEXT_PARSER("OpenACC construct"_en_US,
@@ -297,7 +303,6 @@ TYPE_CONTEXT_PARSER("OpenACC construct"_en_US,
 construct(Parser{}),
 construct(Parser{}),
 construct(Parser{}),
-construct(Parser{}),
 construct(Parser{}),
 construct(Parser{}),
 construct(Parser{})))

diff  --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index bd1c1a2c71eb..0f0c6f285f61 100644
--- a/flang/lib/Parser/unparse.cpp
+++ 

[llvm-branch-commits] [llvm] df2b9a3 - [DebugInfo] Avoid re-ordering assignments in LCSSA

2020-12-17 Thread Jeremy Morse via llvm-branch-commits

Author: Nabeel Omer
Date: 2020-12-17T16:17:32Z
New Revision: df2b9a3e02ca3bd7b60af6c65571909a7d3ab317

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

LOG: [DebugInfo] Avoid re-ordering assignments in LCSSA

The LCSSA pass makes use of a function insertDebugValuesForPHIs() to
propogate dbg.value() intrinsics to newly inserted PHI instructions. Faulty
behaviour occurs when the parent PHI of a newly inserted PHI is not the
most recent assignment to a source variable. insertDebugValuesForPHIs ends
up propagating a value that isn't the most recent assignemnt.

This change removes the call to insertDebugValuesForPHIs() from LCSSA,
preventing incorrect dbg.value intrinsics from being propagated.
Propagating variable locations between blocks will occur later, during
LiveDebugValues.

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

Added: 
llvm/test/Transforms/LCSSA/DontInsertDebugValuesForPHIs.ll

Modified: 
llvm/lib/Transforms/Utils/LCSSA.cpp
llvm/test/Transforms/LCSSA/basictest.ll
llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/LCSSA.cpp 
b/llvm/lib/Transforms/Utils/LCSSA.cpp
index 1bcf40e11d10..a601ec9349e0 100644
--- a/llvm/lib/Transforms/Utils/LCSSA.cpp
+++ b/llvm/lib/Transforms/Utils/LCSSA.cpp
@@ -265,15 +265,11 @@ bool 
llvm::formLCSSAForInstructions(SmallVectorImpl ,
 Worklist.push_back(PostProcessPN);
 
 // Keep track of PHI nodes that we want to remove because they did not have
-// any uses rewritten. If the new PHI is used, store it so that we can
-// try to propagate dbg.value intrinsics to it.
-SmallVector NeedDbgValues;
+// any uses rewritten.
 for (PHINode *PN : AddedPHIs)
   if (PN->use_empty())
 LocalPHIsToRemove.insert(PN);
-  else
-NeedDbgValues.push_back(PN);
-insertDebugValuesForPHIs(InstBB, NeedDbgValues);
+
 Changed = true;
   }
 

diff  --git a/llvm/test/Transforms/LCSSA/DontInsertDebugValuesForPHIs.ll 
b/llvm/test/Transforms/LCSSA/DontInsertDebugValuesForPHIs.ll
new file mode 100644
index ..b140bc96f5d0
--- /dev/null
+++ b/llvm/test/Transforms/LCSSA/DontInsertDebugValuesForPHIs.ll
@@ -0,0 +1,57 @@
+; RUN: opt < %s -lcssa -S | FileCheck %s
+
+; This test ensures that LCSSA does not insert dbg.value intrinsics using
+; insertDebugValuesForPHIs() which effectively cause assignments to be
+; re-ordered.
+; See PR48206 for more information.
+
+define dso_local i32 @_Z5lcssab(i1 zeroext %S2) {
+entry:
+  br label %loop.interior
+
+loop.interior:; preds = %post.if, %entry
+  br i1 %S2, label %if.true, label %if.false
+
+if.true:  ; preds = %loop.interior
+  %X1 = add i32 0, 0
+  br label %post.if
+
+if.false: ; preds = %loop.interior
+  %X2 = add i32 0, 1
+  br label %post.if
+
+post.if:  ; preds = %if.false, %if.true
+  %X3 = phi i32 [ %X1, %if.true ], [ %X2, %if.false ], !dbg !21
+  call void @llvm.dbg.value(metadata i32 %X3, metadata !9, metadata 
!DIExpression()), !dbg !21
+  %Y1 = add i32 4, %X3, !dbg !22
+  call void @llvm.dbg.value(metadata i32 %Y1, metadata !9, metadata 
!DIExpression()), !dbg !22
+  br i1 %S2, label %loop.exit, label %loop.interior, !dbg !23
+
+loop.exit:; preds = %post.if
+; CHECK: loop.exit:
+; CHECK-NEXT: %X3.lcssa = phi i32
+; CHECK-NOT: call void @llvm.dbg.value
+  %X4 = add i32 3, %X3
+  ret i32 %X4
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!3, !4}
+!llvm.module.flags = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: 
"debugify and Author", isOptimized: true, runtimeVersion: 0, emissionKind: 
FullDebug, enums: !2)
+!1 = !DIFile(filename: "./testcase.ll", directory: "/")
+!2 = !{}
+!3 = !{i32 11}
+!4 = !{i32 5}
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = distinct !DISubprogram(name: "_Z5lcssab", linkageName: "_Z5lcssab", 
scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: 
DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !{!9})
+!7 = !DISubroutineType(types: !2)
+!9 = !DILocalVariable(name: "var", scope: !6, file: !1, line: 3, type: !10)
+!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
+!21 = !DILocation(line: 7, column: 1, scope: !6)
+!22 = !DILocation(line: 8, column: 1, scope: !6)
+!23 = !DILocation(line: 9, column: 1, scope: !6)
+

diff  --git a/llvm/test/Transforms/LCSSA/basictest.ll 
b/llvm/test/Transforms/LCSSA/basictest.ll
index 7ca552039b63..30d5e762eedf 100644
--- a/llvm/test/Transforms/LCSSA/basictest.ll
+++ 

[llvm-branch-commits] [llvm] ab6cb31 - [PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass

2020-12-17 Thread Jinsong Ji via llvm-branch-commits

Author: Jinsong Ji
Date: 2020-12-17T11:16:33-05:00
New Revision: ab6cb31642fdc84301b7749fdeabba324e3dbc4a

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

LOG: [PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass

The PPCCTRLoop pass has been moved to HardwareLoops,
so the comments and some useless code are deprecated now.

Reviewed By: #powerpc, nemanjai

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCCTRLoops.cpp

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp 
b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
index bb12e05173a6..77ea232b0662 100644
--- a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
+++ b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
@@ -1,4 +1,4 @@
-//===-- PPCCTRLoops.cpp - Identify and generate CTR loops 
-===//
+//===-- PPCCTRLoops.cpp - Verify CTR loops -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,74 +6,48 @@
 //
 
//===--===//
 //
-// This pass identifies loops where we can generate the PPC branch instructions
-// that decrement and test the count register (CTR) (bdnz and friends).
-//
-// The pattern that defines the induction variable can changed depending on
-// prior optimizations.  For example, the IndVarSimplify phase run by 'opt'
-// normalizes induction variables, and the Loop Strength Reduction pass
-// run by 'llc' may also make changes to the induction variable.
-//
-// Criteria for CTR loops:
-//  - Countable loops (w/ ind. var for a trip count)
-//  - Try inner-most loops first
-//  - No nested CTR loops.
-//  - No function calls in loops.
+// This pass verifies that all bdnz/bdz instructions are dominated by a loop
+// mtctr before any other instructions that might clobber the ctr register.
 //
 
//===--===//
 
+// CTR loops are produced by the HardwareLoops pass and this pass is simply a
+// verification that no invalid CTR loops are produced. As such, it isn't
+// something that needs to be run (or even defined) for Release builds so the
+// entire file is guarded by NDEBUG.
+#ifndef NDEBUG
+#include 
+
+#include "MCTargetDesc/PPCMCTargetDesc.h"
 #include "PPC.h"
-#include "PPCSubtarget.h"
-#include "PPCTargetMachine.h"
-#include "PPCTargetTransformInfo.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/Statistic.h"
-#include "llvm/Analysis/AssumptionCache.h"
-#include "llvm/Analysis/CFG.h"
-#include "llvm/Analysis/CodeMetrics.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/LoopIterator.h"
-#include "llvm/Analysis/TargetLibraryInfo.h"
-#include "llvm/Analysis/TargetTransformInfo.h"
-#include "llvm/CodeGen/TargetPassConfig.h"
-#include "llvm/CodeGen/TargetSchedule.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/Dominators.h"
-#include "llvm/IR/InlineAsm.h"
-#include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Module.h"
-#include "llvm/IR/ValueHandle.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/ilist_iterator.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineDominators.h"
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineInstrBundleIterator.h"
+#include "llvm/CodeGen/MachineOperand.h"
+#include "llvm/CodeGen/Register.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
-#include "llvm/Support/CommandLine.h"
+#include "llvm/PassRegistry.h"
+#include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/GenericDomTreeConstruction.h"
+#include "llvm/Support/Printable.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/Utils.h"
-#include "llvm/Transforms/Utils/BasicBlockUtils.h"
-#include "llvm/Transforms/Utils/Local.h"
-#include "llvm/Transforms/Utils/LoopUtils.h"
-
-#ifndef NDEBUG
-#include "llvm/CodeGen/MachineDominators.h"
-#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/CodeGen/MachineRegisterInfo.h"
-#endif
 
 using namespace llvm;
 
-#define DEBUG_TYPE "ctrloops"
-
-#ifndef NDEBUG
-static cl::opt CTRLoopLimit("ppc-max-ctrloop", cl::Hidden, cl::init(-1));
-#endif
+#define DEBUG_TYPE "ppc-ctrloops-verify"
 
 namespace {
 
-#ifndef NDEBUG
   struct PPCCTRLoopsVerify : public MachineFunctionPass {
   public:
   

[llvm-branch-commits] [clang] daf39e3 - [amdgpu] Default to code object v3

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

Author: Jon Chesterfield
Date: 2020-12-17T16:09:33Z
New Revision: daf39e3f2dba18bd39cd89a1c91bae126a31d4fe

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

LOG: [amdgpu] Default to code object v3

[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye, yaxunl

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/hip-code-object-version.hip
llvm/docs/AMDGPUUsage.rst

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f384e0d993c2..07f15add28ec 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2909,7 +2909,7 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
 
 def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 72bedc16846d..04d0e0771f70 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1549,7 +1549,7 @@ unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
 const Driver , const llvm::opt::ArgList , bool Diagnose) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
+  unsigned CodeObjVer = 3;
 
   // Emit warnings for legacy options even if they are overridden.
   if (Diagnose) {

diff  --git a/clang/test/Driver/hip-code-object-version.hip 
b/clang/test/Driver/hip-code-object-version.hip
index 51d9004b0cbf..6e4e96688593 100644
--- a/clang/test/Driver/hip-code-object-version.hip
+++ b/clang/test/Driver/hip-code-object-version.hip
@@ -53,7 +53,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=VD %s
 
-// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-mllvm" "--amdhsa-code-object-version=3"
 // VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
 // Check invalid code object version option.

diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index 6d3fa7021a7a..c8dda47352ab 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@ The AMDGPU backend uses the following ELF header:
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@ non-AMD key names should be prefixed by "*vendor-name*.".
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@ same *vendor-name*.
 Code Object V4 Metadata
 +++
 
+.. warning::
+  Code object V4 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V4 metadata is the same as
 :ref:`amdgpu-amdhsa-code-object-metadata-v3` with the changes and additions
 defined in table :ref:`amdgpu-amdhsa-code-object-metadata-map-table-v3`.



___
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] d20e0c3 - Ensure SplitEdge to return the new block between the two given blocks

2020-12-17 Thread Whitney Tsang via llvm-branch-commits

Author: Bangtian Liu
Date: 2020-12-17T16:00:15Z
New Revision: d20e0c3444ad9ada550d9d6d1d56fd72948ae444

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

LOG: Ensure SplitEdge to return the new block between the two given blocks

This PR implements the function splitBasicBlockBefore to address an
issue
that occurred during SplitEdge(BB, Succ, ...), inside splitBlockBefore.
The issue occurs in SplitEdge when the Succ has a single predecessor
and the edge between the BB and Succ is not critical. This produces
the result ‘BB->Succ->New’. The new function splitBasicBlockBefore
was added to splitBlockBefore to handle the issue and now produces
the correct result ‘BB->New->Succ’.

Below is an example of splitting the block bb1 at its first instruction.

/// Original IR
bb0:
br bb1
bb1:
%0 = mul i32 1, 2
br bb2
bb2:
/// IR after splitEdge(bb0, bb1) using splitBasicBlock
bb0:
br bb1
bb1:
br bb1.split
bb1.split:
%0 = mul i32 1, 2
br bb2
bb2:
/// IR after splitEdge(bb0, bb1) using splitBasicBlockBefore
bb0:
br bb1.split
bb1.split
br bb1
bb1:
%0 = mul i32 1, 2
br bb2
bb2:

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

Added: 


Modified: 
llvm/include/llvm/IR/BasicBlock.h
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/IR/BasicBlock.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/test/CodeGen/AMDGPU/call-constexpr.ll
llvm/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll
llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/BasicBlock.h 
b/llvm/include/llvm/IR/BasicBlock.h
index 0cce2a599d9c..b86bb16e1239 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -398,22 +398,49 @@ class BasicBlock final : public Value, // Basic blocks 
are data objects also
 
   /// Split the basic block into two basic blocks at the specified instruction.
   ///
-  /// Note that all instructions BEFORE the specified iterator stay as part of
-  /// the original basic block, an unconditional branch is added to the 
original
-  /// BB, and the rest of the instructions in the BB are moved to the new BB,
-  /// including the old terminator.  The newly formed BasicBlock is returned.
-  /// This function invalidates the specified iterator.
+  /// If \p Before is true, splitBasicBlockBefore handles the
+  /// block splitting. Otherwise, execution proceeds as described below.
+  ///
+  /// Note that all instructions BEFORE the specified iterator
+  /// stay as part of the original basic block, an unconditional branch is 
added
+  /// to the original BB, and the rest of the instructions in the BB are moved
+  /// to the new BB, including the old terminator.  The newly formed basic 
block
+  /// is returned. This function invalidates the specified iterator.
   ///
   /// Note that this only works on well formed basic blocks (must have a
-  /// terminator), and 'I' must not be the end of instruction list (which would
-  /// cause a degenerate basic block to be formed, having a terminator inside 
of
-  /// the basic block).
+  /// terminator), and \p 'I' must not be the end of instruction list (which
+  /// would cause a degenerate basic block to be formed, having a terminator
+  /// inside of the basic block).
   ///
   /// Also note that this doesn't preserve any passes. To split blocks while
   /// keeping loop information consistent, use the SplitBlock utility function.
-  BasicBlock *splitBasicBlock(iterator I, const Twine  = "");
-  BasicBlock *splitBasicBlock(Instruction *I, const Twine  = "") {
-return splitBasicBlock(I->getIterator(), BBName);
+  BasicBlock *splitBasicBlock(iterator I, const Twine  = "",
+  bool Before = false);
+  BasicBlock *splitBasicBlock(Instruction *I, const Twine  = "",
+  bool Before = false) {
+return splitBasicBlock(I->getIterator(), BBName, Before);
+  }
+
+  /// Split the basic block into two basic blocks at the specified instruction
+  /// and insert the new basic blocks as the predecessor of the current block.
+  ///
+  /// This function ensures all instructions AFTER and including the specified
+  /// iterator \p I are part of the original basic block. All Instructions
+  /// BEFORE the iterator \p I are moved to the new BB and an unconditional
+  /// branch is added to the new BB. The new basic block is returned.
+  ///
+  /// Note that this only works on well formed basic blocks (must have a
+  /// terminator), and \p 'I' must not be the end of instruction list (which
+  /// would cause a degenerate basic block to be formed, having a terminator
+  /// inside of the basic block).  \p 

[llvm-branch-commits] [lld] 7e13694 - [llvm-symbolizer][Windows] Add start line when searching in line table sections.

2020-12-17 Thread Amy Huang via llvm-branch-commits

Author: Amy Huang
Date: 2020-12-17T07:57:36-08:00
New Revision: 7e13694ac745f6cd4008dd354f2fcfc417b1e1e9

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

LOG: [llvm-symbolizer][Windows] Add start line when searching in line table 
sections.

Fixes issue where if a line section doesn't start with a line number
then the addresses at the beginning of the section don't have line numbers.

For example, for a line section like this
```
  0001:0010-0014, line/column/addr entries = 1
 7 0013 !
```
a line number wouldn't be found for addresses from 10 to 12.

This matches behavior when using the DIA SDK.

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

Added: 
lld/test/COFF/symbolizer-line-numbers.s

Modified: 
llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp

Removed: 




diff  --git a/lld/test/COFF/symbolizer-line-numbers.s 
b/lld/test/COFF/symbolizer-line-numbers.s
new file mode 100644
index ..679e94eb2bb0
--- /dev/null
+++ b/lld/test/COFF/symbolizer-line-numbers.s
@@ -0,0 +1,322 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj %s -o %t.obj -triple x86_64-windows-msvc
+# RUN: lld-link -entry:main -nodefaultlib %t.obj -out:%t.exe -pdb:%t.pdb -debug
+# RUN: llvm-symbolizer --obj=%t.exe --relative-address \
+# RUN:   0x1000 0x1003 0x1010 0x1013 | FileCheck %s
+
+# Compiled from this cpp code:
+# int f1(int x) {
+#   int y = x + 1;
+#   return y;
+# }
+# int f2(int n) {
+#   return f1(n);
+# }
+# int main() {
+#   return f2(100);
+# }
+
+.text
+   .def @feat.00;
+   .scl3;
+   .type   0;
+   .endef
+   .globl  @feat.00
+.set @feat.00, 0
+   .file   "t.cpp"
+   .def "?f1@@YAHH@Z";
+   .scl2;
+   .type   32;
+   .endef
+   .globl  "?f1@@YAHH@Z"   # -- Begin function ?f1@@YAHH@Z
+   .p2align4, 0x90
+"?f1@@YAHH@Z":  # @"?f1@@YAHH@Z"
+.Lfunc_begin0:
+   .cv_func_id 0
+# %bb.0:# %entry
+   .cv_file1 "C:\\src\\tests\\t.cpp" 
"E6E6D87A9021656AD44E74484F5BA421" 1
+
+# CHECK:  f1(int)
+# CHECK-NEXT: t.cpp:2:13
+   .cv_loc 0 1 2 13# t.cpp:2:13
+# kill: def $ecx killed $ecx def $rcx
+   leal1(%rcx), %eax
+
+# CHECK:  f1(int)
+# CHECK-NEXT: t.cpp:3:3
+   .cv_loc 0 1 3 3 # t.cpp:3:3
+   retq
+.Ltmp0:
+.Lfunc_end0:
+# -- End function
+   .def "?f2@@YAHH@Z";
+   .scl2;
+   .type   32;
+   .endef
+   .globl  "?f2@@YAHH@Z"   # -- Begin function ?f2@@YAHH@Z
+   .p2align4, 0x90
+"?f2@@YAHH@Z":  # @"?f2@@YAHH@Z"
+.Lfunc_begin1:
+   .cv_func_id 1
+# %bb.0:# %entry
+# CHECK:  f1
+# CHECK-NEXT: t.cpp:2:0
+# CHECK-NEXT: f2(int)
+# CHECK-NEXT: t.cpp:6:3
+   .cv_inline_site_id 2 within 1 inlined_at 1 6 10
+   .cv_loc 2 1 2 13# t.cpp:2:13
+# kill: def $ecx killed $ecx def $rcx
+   leal1(%rcx), %eax
+.Ltmp1:
+   .cv_loc 1 1 6 3 # t.cpp:6:3
+   retq
+# CHECK:  f2(int)
+# CHECK-NEXT: t.cpp:6:3
+.Ltmp2:
+.Lfunc_end1:
+# -- End function
+   .def main;
+   .scl2;
+   .type   32;
+   .endef
+   .globl  main# -- Begin function main
+   .p2align4, 0x90
+main:   # @main
+.Lfunc_begin2:
+   .cv_func_id 3
+# %bb.0:# %entry
+   .cv_loc 3 1 9 3 # t.cpp:9:3
+   movl$101, %eax
+   retq
+.Ltmp3:
+.Lfunc_end2:
+# -- End function
+   .section.debug$S,"dr"
+   .p2align2
+   .long   4   # Debug section magic
+   .long   241
+   .long   .Ltmp5-.Ltmp4   # Subsection size
+.Ltmp4:
+   .short  .Ltmp7-.Ltmp6   # Record length
+.Ltmp6:
+   .short  4412# Record kind: S_COMPILE3
+   .long   1   # Flags and language
+   .short  208 # CPUType
+   .short  12  # Frontend version
+   .short  0
+   .short  0
+   .short  0
+   .short  12000   # Backend version
+   .short  0
+   .short  0
+   .short  0
+   .asciz  "clang version 12.0.0 (https://github.com/llvm/llvm-project.git 
e2e86f4e77ec2fd79743f4d0e94689e9668600ad)" # Null-terminated 

[llvm-branch-commits] [llvm] 4bb10be - [SampleFDO] Fix uninitialized field warnings. NFCI.

2020-12-17 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-17T15:51:26Z
New Revision: 4bb10be9a6e06a6c51cc1695ff5dc9d68c953334

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

LOG: [SampleFDO] Fix uninitialized field warnings. NFCI.

Seems to have been caused by D93254 which added the 
SecHdrTableEntry::LayoutIndex field.

Added: 


Modified: 
llvm/include/llvm/ProfileData/SampleProfWriter.h

Removed: 




diff  --git a/llvm/include/llvm/ProfileData/SampleProfWriter.h 
b/llvm/include/llvm/ProfileData/SampleProfWriter.h
index 5bb1446acb0b..fc568f06ffc8 100644
--- a/llvm/include/llvm/ProfileData/SampleProfWriter.h
+++ b/llvm/include/llvm/ProfileData/SampleProfWriter.h
@@ -278,9 +278,9 @@ class SampleProfileWriterExtBinary : public 
SampleProfileWriterExtBinaryBase {
 // profile because FuncOffsetTable needs to be populated while section
 // SecLBRProfile is written.
 SectionHdrLayout = {
-{SecProfSummary, 0, 0, 0},   {SecNameTable, 0, 0, 0},
-{SecFuncOffsetTable, 0, 0, 0},   {SecLBRProfile, 0, 0, 0},
-{SecProfileSymbolList, 0, 0, 0}, {SecFuncMetadata, 0, 0, 0}};
+{SecProfSummary, 0, 0, 0, 0},   {SecNameTable, 0, 0, 0, 0},
+{SecFuncOffsetTable, 0, 0, 0, 0},   {SecLBRProfile, 0, 0, 0, 0},
+{SecProfileSymbolList, 0, 0, 0, 0}, {SecFuncMetadata, 0, 0, 0, 0}};
   };
   virtual std::error_code
   writeSections(const StringMap ) override;



___
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] 36bf2de - [flang][openacc] Update serial construct clauses for OpenACC 3.1

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

Author: Valentin Clement
Date: 2020-12-17T10:50:47-05:00
New Revision: 36bf2de8d866e2b448d17f4d2cb4bb96819d82b7

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

LOG: [flang][openacc] Update serial construct clauses for OpenACC 3.1

Update the allowed clauses for the SERIAL construct for the new OpenACC 3.1
specification.

Reviewed By: sameeranjoshi

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

Added: 


Modified: 
flang/test/Semantics/acc-clause-validity.f90
llvm/include/llvm/Frontend/OpenACC/ACC.td

Removed: 




diff  --git a/flang/test/Semantics/acc-clause-validity.f90 
b/flang/test/Semantics/acc-clause-validity.f90
index 1f98d0f2559f..a5c6193d32f5 100644
--- a/flang/test/Semantics/acc-clause-validity.f90
+++ b/flang/test/Semantics/acc-clause-validity.f90
@@ -3,8 +3,8 @@
 ! Check OpenACC clause validity for the following construct and directive:
 !   2.6.5 Data
 !   2.5.1 Parallel
-!   2.5.2 Kernels
-!   2.5.3 Serial
+!   2.5.2 Serial
+!   2.5.3 Kernels
 !   2.9 Loop
 !   2.12 Atomic
 !   2.13 Declare
@@ -780,6 +780,170 @@ program openacc_clause_validity
   end do
   !$acc end parallel loop
 
+  !$acc serial
+  !$acc end serial
+
+  !$acc serial async
+  !$acc end serial
+
+  !$acc serial async(1)
+  !$acc end serial
+
+  !ERROR: At most one ASYNC clause can appear on the SERIAL directive
+  !$acc serial async(1) async(2)
+  !$acc end serial
+
+  !$acc serial async(async1)
+  !$acc end serial
+
+  !$acc serial wait
+  !$acc end serial
+
+  !$acc serial wait(1)
+  !$acc end serial
+
+  !$acc serial wait(wait1)
+  !$acc end serial
+
+  !$acc serial wait(1,2)
+  !$acc end serial
+
+  !$acc serial wait(wait1, wait2)
+  !$acc end serial
+
+  !$acc serial wait(wait1) wait(wait2)
+  !$acc end serial
+
+  !ERROR: NUM_GANGS clause is not allowed on the SERIAL directive
+  !$acc serial num_gangs(8)
+  !$acc end serial
+
+  !ERROR: NUM_WORKERS clause is not allowed on the SERIAL directive
+  !$acc serial num_workers(8)
+  !$acc end serial
+
+  !ERROR: VECTOR_LENGTH clause is not allowed on the SERIAL directive
+  !$acc serial vector_length(128)
+  !$acc end serial
+
+  !$acc serial if(.true.)
+  !$acc end serial
+
+  !ERROR: At most one IF clause can appear on the SERIAL directive
+  !$acc serial if(.true.) if(ifCondition)
+  !$acc end serial
+
+  !$acc serial if(ifCondition)
+  !$acc end serial
+
+  !$acc serial self
+  !$acc end serial
+
+  !$acc serial self(.true.)
+  !$acc end serial
+
+  !$acc serial self(ifCondition)
+  !$acc end serial
+
+  !$acc serial loop reduction(+: reduction_r)
+  do i = 1, N
+reduction_r = a(i) + i
+  end do
+
+  !$acc serial loop reduction(*: reduction_r)
+  do i = 1, N
+reduction_r = reduction_r * (a(i) + i)
+  end do
+
+  !$acc serial loop reduction(min: reduction_r)
+  do i = 1, N
+reduction_r = min(reduction_r, a(i) * i)
+  end do
+
+  !$acc serial loop reduction(max: reduction_r)
+  do i = 1, N
+reduction_r = max(reduction_r, a(i) * i)
+  end do
+
+  !$acc serial loop reduction(iand: b)
+  do i = 1, N
+b = iand(b, c(i))
+  end do
+
+  !$acc serial loop reduction(ior: b)
+  do i = 1, N
+b = ior(b, c(i))
+  end do
+
+  !$acc serial loop reduction(ieor: b)
+  do i = 1, N
+b = ieor(b, c(i))
+  end do
+
+  !$acc serial loop reduction(.and.: reduction_l)
+  do i = 1, N
+reduction_l = d(i) .and. e(i)
+  end do
+
+  !$acc serial loop reduction(.or.: reduction_l)
+  do i = 1, N
+reduction_l = d(i) .or. e(i)
+  end do
+
+  !$acc serial loop reduction(.eqv.: reduction_l)
+  do i = 1, N
+reduction_l = d(i) .eqv. e(i)
+  end do
+
+  !$acc serial loop reduction(.neqv.: reduction_l)
+  do i = 1, N
+reduction_l = d(i) .neqv. e(i)
+  end do
+
+  !$acc serial reduction(.neqv.: reduction_l)
+  !$acc loop reduction(.neqv.: reduction_l)
+  do i = 1, N
+reduction_l = d(i) .neqv. e(i)
+  end do
+  !$acc end serial
+
+  !$acc serial copy(aa) copyin(bb) copyout(cc)
+  !$acc end serial
+
+  !$acc serial copy(aa, bb) copyout(zero: cc)
+  !$acc end serial
+
+  !$acc serial present(aa, bb) create(cc)
+  !$acc end serial
+
+  !$acc serial copyin(readonly: aa, bb) create(zero: cc)
+  !$acc end serial
+
+  !$acc serial deviceptr(aa, bb) no_create(cc)
+  !$acc end serial
+
+  !$acc serial attach(aa, bb, cc)
+  !$acc end serial
+
+  !$acc serial firstprivate(bb, cc)
+  !$acc end serial
+
+  !$acc serial private(aa)
+  !$acc end serial
+
+  !$acc serial default(none)
+  !$acc end serial
+
+  !$acc serial default(present)
+  !$acc end serial
+
+  !ERROR: At most one DEFAULT clause can appear on the SERIAL directive
+  !$acc serial default(present) default(none)
+  !$acc end serial
+
+  !$acc serial device_type(*) async wait
+  !$acc end serial
+
   !$acc serial device_type(*) async
   do i = 1, N
 a(i) = 3.14

diff  

[llvm-branch-commits] [llvm] d104e58 - [CMake] Avoid __FakeVCSRevision.h with no git repository

2020-12-17 Thread Tom Stellard via llvm-branch-commits

Author: Jonas Hahnfeld
Date: 2020-12-17T10:51:20-05:00
New Revision: d104e582838fd73d6ef565788f11617eccab87e2

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

LOG: [CMake] Avoid __FakeVCSRevision.h with no git repository

Set the return variable to "" in find_first_existing_vc_file to
say that there is a repository, but no file to depend on. This works
transparently for all other callers that handle undefinedness and
equality to an empty string the same way.

Use the knowledge to avoid depending on __FakeVCSRevision.h if there
is no git repository at all (for example when building a release) as
there is no point in regenerating an empty VCSRevision.h.

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

(cherry picked from commit 6e890ec7beb0874464a0af9f84e41a987f968b23)

Added: 


Modified: 
llvm/cmake/modules/AddLLVM.cmake
llvm/include/llvm/Support/CMakeLists.txt

Removed: 




diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 333167bfb6b0..b74adc11ade9 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2102,6 +2102,13 @@ function(setup_dependency_debugging name)
   set_target_properties(${name} PROPERTIES RULE_LAUNCH_COMPILE 
${sandbox_command})
 endfunction()
 
+# If the sources at the given `path` are under version control, set `out_var`
+# to the the path of a file which will be modified when the VCS revision
+# changes, attempting to create that file if it does not exist; if no such
+# file exists and one cannot be created, instead set `out_var` to the
+# empty string.
+#
+# If the sources are not under version control, do not define `out_var`.
 function(find_first_existing_vc_file path out_var)
   if(NOT EXISTS "${path}")
 return()
@@ -2123,6 +2130,7 @@ function(find_first_existing_vc_file path out_var)
   RESULT_VARIABLE touch_head_result
   ERROR_QUIET)
 if (NOT touch_head_result EQUAL 0)
+  set(${out_var} "" PARENT_SCOPE)
   return()
 endif()
   endif()

diff  --git a/llvm/include/llvm/Support/CMakeLists.txt 
b/llvm/include/llvm/Support/CMakeLists.txt
index da8a4da443ed..69f6a1582ce9 100644
--- a/llvm/include/llvm/Support/CMakeLists.txt
+++ b/llvm/include/llvm/Support/CMakeLists.txt
@@ -11,7 +11,7 @@ if(LLVM_APPEND_VC_REV)
   # A fake version file and is not expected to exist. It is being used to
   # force regeneration of VCSRevision.h for source directory with no write
   # permission available.
-  if (NOT llvm_vc)
+  if (llvm_vc STREQUAL "")
 set(fake_version_inc "${CMAKE_CURRENT_BINARY_DIR}/__FakeVCSRevision.h")
   endif()
 endif()



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


[llvm-branch-commits] [llvm] f5f8d86 - Don't error for zero-length arange entries

2020-12-17 Thread Tom Stellard via llvm-branch-commits

Author: James Henderson
Date: 2020-12-16T22:47:02-05:00
New Revision: f5f8d86dc4c91ef492b919edf98335d4d09188a8

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

LOG: Don't error for zero-length arange entries

Although the DWARF specification states that .debug_aranges entries
can't have length zero, these can occur in the wild. There's no
particular reason to enforce this part of the spec, since functionally
they have no impact. The patch removes the error and introduces a new
warning for premature terminator entries which does not stop parsing.

This is a relanding of cb3a598c87db, adding the missing obj2yaml part
that was needed.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46805. See also
https://reviews.llvm.org/D71932 which originally introduced the error.

Reviewed by: ikudrin, dblaikie, Higuoxing

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

Added: 


Modified: 
llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp

Removed: 




diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp 
b/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
index 608fc0388af0..c3b039b05f30 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
@@ -132,19 +132,20 @@ Error DWARFDebugArangeSet::extract(DWARFDataExtractor 
data,
 
   uint64_t end_offset = Offset + full_length;
   while (*offset_ptr < end_offset) {
+uint64_t EntryOffset = *offset_ptr;
 arangeDescriptor.Address = data.getUnsigned(offset_ptr, 
HeaderData.AddrSize);
 arangeDescriptor.Length = data.getUnsigned(offset_ptr, 
HeaderData.AddrSize);
 
-if (arangeDescriptor.Length == 0) {
-  // Each set of tuples is terminated by a 0 for the address and 0
-  // for the length.
-  if (arangeDescriptor.Address == 0 && *offset_ptr == end_offset)
+// Each set of tuples is terminated by a 0 for the address and 0
+// for the length.
+if (arangeDescriptor.Length == 0 && arangeDescriptor.Address == 0) {
+  if (*offset_ptr == end_offset)
 return ErrorSuccess();
   return createStringError(
   errc::invalid_argument,
   "address range table at offset 0x%" PRIx64
-  " has an invalid tuple (length = 0) at offset 0x%" PRIx64,
-  Offset, *offset_ptr - tuple_size);
+  " has a premature terminator entry at offset 0x%" PRIx64,
+  Offset, EntryOffset);
 }
 
 ArangeDescriptors.push_back(arangeDescriptor);

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp 
b/llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp
index 4ec9c5d1c0be..7f16aa9ce4b7 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
+#include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
@@ -166,9 +167,9 @@ TEST(DWARFDebugArangeSet, UnevenLength) {
   "of the tuple size");
 }
 
-TEST(DWARFDebugArangeSet, ZeroLengthEntry) {
+TEST(DWARFDebugArangeSet, ZeroAddressEntry) {
   static const char DebugArangesSecRaw[] =
-  "\x24\x00\x00\x00" // Length
+  "\x1c\x00\x00\x00" // Length
   "\x02\x00" // Version
   "\x00\x00\x00\x00" // Debug Info Offset
   "\x04" // Address Size
@@ -176,14 +177,68 @@ TEST(DWARFDebugArangeSet, ZeroLengthEntry) {
   "\x00\x00\x00\x00" // Padding
   "\x00\x00\x00\x00" // Entry1: Address
   "\x01\x00\x00\x00" // Length
+  "\x00\x00\x00\x00" // Termination tuple
+  "\x00\x00\x00\x00";
+  DWARFDataExtractor Extractor(
+  StringRef(DebugArangesSecRaw, sizeof(DebugArangesSecRaw) - 1),
+  /*IsLittleEndian=*/true,
+  /*AddressSize=*/4);
+  DWARFDebugArangeSet Set;
+  uint64_t Offset = 0;
+  ASSERT_THAT_ERROR(Set.extract(Extractor, ),
+Succeeded());
+  auto Range = Set.descriptors();
+  auto Iter = Range.begin();
+  ASSERT_EQ(std::distance(Iter, Range.end()), 1u);
+  EXPECT_EQ(Iter->Address, 0u);
+  EXPECT_EQ(Iter->Length, 1u);
+}
+
+TEST(DWARFDebugArangeSet, ZeroLengthEntry) {
+  static const char DebugArangesSecRaw[] =
+  "\x1c\x00\x00\x00" // Length
+  "\x02\x00" // Version
+  "\x00\x00\x00\x00" // Debug Info Offset
+  "\x04" // Address Size
+  "\x00" // Segment Selector Size
+  "\x00\x00\x00\x00" // Padding
+  "\x01\x00\x00\x00" // Entry1: Address
+  "\x00\x00\x00\x00" // Length
+  "\x00\x00\x00\x00" // Termination tuple
+  "\x00\x00\x00\x00";
+  

[llvm-branch-commits] [clang] fb0f728 - [Clang] Make nomerge attribute a function attribute as well as a statement attribute.

2020-12-17 Thread Zequan Wu via llvm-branch-commits

Author: Zequan Wu
Date: 2020-12-17T07:45:38-08:00
New Revision: fb0f7288051eb2745bb9211306f53ff9aa6f73e2

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

LOG: [Clang] Make nomerge attribute a function attribute as well as a statement 
attribute.

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

Added: 


Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/attr-nomerge.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-nomerge.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
llvm/include/llvm/IR/Attributes.td

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 8d9fb8f2bf27..e453733ab92c 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -162,6 +162,21 @@ class InheritableAttr : public Attr {
   }
 };
 
+class DeclOrStmtAttr : public InheritableAttr {
+protected:
+  DeclOrStmtAttr(ASTContext , const AttributeCommonInfo ,
+ attr::Kind AK, bool IsLateParsed,
+ bool InheritEvenIfAlreadyPresent)
+  : InheritableAttr(Context, CommonInfo, AK, IsLateParsed,
+InheritEvenIfAlreadyPresent) {}
+
+public:
+  static bool classof(const Attr *A) {
+return A->getKind() >= attr::FirstDeclOrStmtAttr &&
+   A->getKind() <= attr::LastDeclOrStmtAttr;
+  }
+};
+
 class InheritableParamAttr : public InheritableAttr {
 protected:
   InheritableParamAttr(ASTContext ,

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7d566e64c99b..ce2ee40dc036 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -570,6 +570,9 @@ class InheritableAttr : Attr {
 /// attributes, but have historically been written on declarations.
 class DeclOrTypeAttr : InheritableAttr;
 
+/// A attribute is either a declaration attribute or a statement attribute.
+class DeclOrStmtAttr : InheritableAttr;
+
 /// A target-specific attribute.  This class is meant to be used as a mixin
 /// with InheritableAttr or Attr depending on the attribute's needs.
 class TargetSpecificAttr {
@@ -1317,9 +1320,12 @@ def Unlikely : StmtAttr {
   let Documentation = [LikelihoodDocs];
 }
 
-def NoMerge : StmtAttr {
+def NoMerge : DeclOrStmtAttr {
   let Spellings = [Clang<"nomerge">];
   let Documentation = [NoMergeDocs];
+  let InheritEvenIfAlreadyPresent = 1;
+  let Subjects = SubjectList<[Function], ErrorDiag, "functions and 
statements">;
+  let SimpleHandler = 1;
 }
 
 def FastCall : DeclOrTypeAttr {

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 4f8cd8ecd86f..c3a412158aba 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -386,7 +386,11 @@ location of certain calls. For example, it will prevent 
tail merging otherwise
 identical code sequences that raise an exception or terminate the program. Tail
 merging normally reduces the precision of source location information, making
 stack traces less useful for debugging. This attribute gives the user control
-over the tradeoff between code size and debug information precision.
+over the tradeoff between code size and debug information precision. 
+
+``nomerge`` attribute can also be used as function attribute to prevent all 
+calls to the specified function from merging. It has no effect on indirect 
+calls.
   }];
 }
 

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 28a7d128505a..bfc7b8e74d8f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1968,6 +1968,8 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
 NBA = Fn->getAttr();
   }
+  if (!AttrOnCallSite && TargetDecl->hasAttr())
+FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
 }
 
 // 'const', 'pure' and 'noalias' attributed functions are also nounwind.
@@ -4978,11 +4980,13 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
 Attrs.addAttribute(getLLVMContext(), 
llvm::AttributeList::FunctionIndex,
llvm::Attribute::StrictFP);
 
-  // Add call-site nomerge attribute if exists.
-  if (InNoMergeAttributedStmt)
-Attrs =
-  Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
- llvm::Attribute::NoMerge);
+  // Add nomerge attribute to the call-site if the callee function doesn't have
+  // the attribute.
+  if (const FunctionDecl 

[llvm-branch-commits] [llvm] bd343d2 - [TableGen] Return const std::string& in InstrMap getName()/getFilterClass() methods. NFCI.

2020-12-17 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-17T15:23:03Z
New Revision: bd343d26814640b4934fdde8637ad5577d30c83c

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

LOG: [TableGen] Return const std::string& in InstrMap 
getName()/getFilterClass() methods. NFCI.

Avoid temp std::string instances - we're never keeping these around, just 
printing them to streams, converting to StringRef etc.

Added: 


Modified: 
llvm/utils/TableGen/CodeGenMapTable.cpp

Removed: 




diff  --git a/llvm/utils/TableGen/CodeGenMapTable.cpp 
b/llvm/utils/TableGen/CodeGenMapTable.cpp
index 57d86a8fc119..ea53a2d3eee6 100644
--- a/llvm/utils/TableGen/CodeGenMapTable.cpp
+++ b/llvm/utils/TableGen/CodeGenMapTable.cpp
@@ -144,9 +144,9 @@ class InstrMap {
 }
   }
 
-  std::string getName() const { return Name; }
+  const std::string () const { return Name; }
 
-  std::string getFilterClass() const { return FilterClass; }
+  const std::string () const { return FilterClass; }
 
   ListInit *getRowFields() const { return RowFields; }
 
@@ -190,7 +190,7 @@ class MapTableEmitter {
 public:
   MapTableEmitter(CodeGenTarget , RecordKeeper , Record *IMRec):
   Target(Target), InstrMapDesc(IMRec) {
-const std::string FilterClass = InstrMapDesc.getFilterClass();
+const std::string  = InstrMapDesc.getFilterClass();
 InstrDefs = Records.getAllDerivedDefinitions(FilterClass);
   }
 



___
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] 01089c8 - [InstCombine] Preserve !annotation on newly created instructions.

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

Author: Florian Hahn
Date: 2020-12-17T15:20:23Z
New Revision: 01089c876bff43a7cde1cb9b1ef8c128169ec5b4

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

LOG: [InstCombine] Preserve !annotation on newly created instructions.

If the source instruction has !annotation metadata, all instructions
created during combining should also have it. Tell the builder to
add it.

The !annotation system was discussed on llvm-dev as part of
'RFC: Combining Annotation Metadata and Remarks'
(http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html)

This patch is based on an earlier patch by Francis Visoiu Mistrih.

Reviewed By: thegameg, lebedev.ri

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

Added: 


Modified: 
clang/test/CodeGenCXX/auto-var-init.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/annotations.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/auto-var-init.cpp 
b/clang/test/CodeGenCXX/auto-var-init.cpp
index d50967c40216..761458da9084 100644
--- a/clang/test/CodeGenCXX/auto-var-init.cpp
+++ b/clang/test/CodeGenCXX/auto-var-init.cpp
@@ -597,9 +597,7 @@ TEST_UNINIT(empty, empty);
 // PATTERN-O1: store i8 [[I8]], {{.*}} align 1, !annotation [[AUTO_INIT]]
 // ZERO-LABEL: @test_empty_uninit()
 // ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation 
[[AUTO_INIT]]
-// ZERO-O1: store i8 0, {{.*}} align 1
-// FIXME: !annotation dropped by optimizations
-// ZERO-O1-NOT: !annotation
+// ZERO-O1: store i8 0, {{.*}} align 1, !annotation [[AUTO_INIT]]
 
 TEST_BRACES(empty, empty);
 // CHECK-LABEL: @test_empty_braces()
@@ -618,9 +616,7 @@ TEST_UNINIT(small, small);
 // PATTERN-O1: store i8 [[I8]], {{.*}} align 1, !annotation [[AUTO_INIT]]
 // ZERO-LABEL: @test_small_uninit()
 // ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation 
[[AUTO_INIT]]
-// ZERO-O1: store i8 0, {{.*}} align 1
-// FIXME: !annotation dropped by optimizations
-// ZERO-O1-NOT: !annotation
+// ZERO-O1: store i8 0, {{.*}} align 1, !annotation [[AUTO_INIT]]
 
 TEST_BRACES(small, small);
 // CHECK-LABEL: @test_small_braces()
@@ -671,10 +667,8 @@ TEST_UNINIT(smallpartinit, smallpartinit);
 // PATTERN-O1: store i8 42, {{.*}} align 1
 // ZERO-LABEL: @test_smallpartinit_uninit()
 // ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation 
[[AUTO_INIT]]
-// ZERO-O1-LEGACY: store i16 0, i16* %uninit, align 2
-// ZERO-O1-NEWPM: store i16 0, i16* %uninit, align 2
-// FIXME: !annotation dropped by optimizations
-// ZERO-O1-NOT: !annotation
+// ZERO-O1-LEGACY: store i16 0, i16* %uninit, align 2, !annotation 
[[AUTO_INIT]]
+// ZERO-O1-NEWPM: store i16 0, i16* %uninit, align 2, !annotation [[AUTO_INIT]]
 
 TEST_BRACES(smallpartinit, smallpartinit);
 // CHECK-LABEL: @test_smallpartinit_braces()
@@ -726,14 +720,10 @@ TEST_UNINIT(padded, padded);
 // CHECK-NEXT:  call void @{{.*}}used{{.*}}%uninit)
 // PATTERN-LABEL: @test_padded_uninit()
 // PATTERN-O0: call void @llvm.memcpy{{.*}} 
@__const.test_padded_uninit.uninit{{.+}}), !annotation [[AUTO_INIT]]
-// PATTERN-O1: store i64 [[I64]], i64* %uninit, align 8
-// FIXME: !annotation dropped by optimizations
-// PATTERN-O1-NOT: !annotation
+// PATTERN-O1: store i64 [[I64]], i64* %uninit, align 8, !annotation 
[[AUTO_INIT]]
 // ZERO-LABEL: @test_padded_uninit()
-// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}})
-// ZERO-O1: store i64 0, i64* %uninit, align 8
-// FIXME: !annotation dropped by optimizations
-// ZERO-O1-NOT: !annotation
+// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation 
[[AUTO_INIT]]
+// ZERO-O1: store i64 0, i64* %uninit, align 8, !annotation [[AUTO_INIT]]
 
 TEST_BRACES(padded, padded);
 // CHECK-LABEL: @test_padded_braces()
@@ -758,15 +748,16 @@ TEST_UNINIT(paddednullinit, paddednullinit);
 // CHECK-NEXT:  call void @{{.*}}used{{.*}}%uninit)
 // PATTERN-LABEL: @test_paddednullinit_uninit()
 // PATTERN-O0: call void @llvm.memcpy{{.*}} 
@__const.test_paddednullinit_uninit.uninit{{.+}}), !annotation [[AUTO_INIT]]
-// PATTERN-O1-LEGACY: store i64 [[I64]], i64* %uninit, align 8
-// PATTERN-O1-NEWPM: store i64 [[I64]], i64* %uninit, align 8
-// FIXME: !annotation dropped by optimizations
-// PATTERN-O1-NOT: !annotation
+// PATTERN-O1-LEGACY: store i64 [[I64]], i64* %uninit, align 8, !annotation 
[[AUTO_INIT]]
+// PATTERN-O1-NEWPM: store i64 [[I64]], i64* %uninit, align 8, !annotation 
[[AUTO_INIT]]
 // ZERO-LABEL: @test_paddednullinit_uninit()
-// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
-// ZERO-O1: store i64 0, i64* %uninit, align 8
+// ZERO-O0: call void @llvm.memset{{.*}}, i8 0, {{.*}}, !annotation 
[[AUTO_INIT]]
+// ZERO-O1-LEGACY: store i64 0, i64* %uninit, align 8, !annotation 
[[AUTO_INIT]]
+// ZERO-O1-NEWPM: store i64 0, i64* %uninit, 

[llvm-branch-commits] [llvm] 923ca0b - [ARM][MachineOutliner] Fix costs model.

2020-12-17 Thread Yvan Roux via llvm-branch-commits

Author: Yvan Roux
Date: 2020-12-17T16:08:23+01:00
New Revision: 923ca0b411f78a3d218ff660a5b7a8b9099bdaa4

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

LOG: [ARM][MachineOutliner] Fix costs model.

Fix candidates calls costs models allocation and prepare stack fixups
handling.

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

Added: 
llvm/test/CodeGen/ARM/machine-outliner-stack-use.mir

Modified: 
llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
llvm/test/CodeGen/ARM/machine-outliner-calls.mir

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp 
b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
index 20823ee6d44a..2d937930d89f 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -5824,31 +5824,43 @@ outliner::OutlinedFunction 
ARMBaseInstrInfo::getOutliningCandidateInfo(
   else if (C.UsedInSequence.available(ARM::SP)) {
 NumBytesNoStackCalls += Costs.CallDefault;
 C.setCallInfo(MachineOutlinerDefault, Costs.CallDefault);
-SetCandidateCallInfo(MachineOutlinerDefault, Costs.CallDefault);
 CandidatesWithoutStackFixups.push_back(C);
-  } else
-return outliner::OutlinedFunction();
-}
+  }
 
-// Does every candidate's MBB contain a call?  If so, then we might have a
-// call in the range.
-if (FlagsSetInAll & MachineOutlinerMBBFlags::HasCalls) {
-  // check if the range contains a call.  These require a save + restore of
-  // the link register.
-  if (std::any_of(FirstCand.front(), FirstCand.back(),
-  [](const MachineInstr ) { return MI.isCall(); }))
-NumBytesToCreateFrame += Costs.SaveRestoreLROnStack;
-
-  // Handle the last instruction separately.  If it is tail call, then the
-  // last instruction is a call, we don't want to save + restore in this
-  // case.  However, it could be possible that the last instruction is a
-  // call without it being valid to tail call this sequence.  We should
-  // consider this as well.
-  else if (FrameID != MachineOutlinerThunk &&
-   FrameID != MachineOutlinerTailCall && 
FirstCand.back()->isCall())
-NumBytesToCreateFrame += Costs.SaveRestoreLROnStack;
+  // If we outline this, we need to modify the stack. Pretend we don't
+  // outline this by saving all of its bytes.
+  else
+NumBytesNoStackCalls += SequenceSize;
 }
-RepeatedSequenceLocs = CandidatesWithoutStackFixups;
+
+// If there are no places where we have to save LR, then note that we don't
+// have to update the stack. Otherwise, give every candidate the default
+// call type
+if (NumBytesNoStackCalls <=
+RepeatedSequenceLocs.size() * Costs.CallDefault) {
+  RepeatedSequenceLocs = CandidatesWithoutStackFixups;
+  FrameID = MachineOutlinerNoLRSave;
+} else
+  SetCandidateCallInfo(MachineOutlinerDefault, Costs.CallDefault);
+  }
+
+  // Does every candidate's MBB contain a call?  If so, then we might have a
+  // call in the range.
+  if (FlagsSetInAll & MachineOutlinerMBBFlags::HasCalls) {
+// check if the range contains a call.  These require a save + restore of
+// the link register.
+if (std::any_of(FirstCand.front(), FirstCand.back(),
+[](const MachineInstr ) { return MI.isCall(); }))
+  NumBytesToCreateFrame += Costs.SaveRestoreLROnStack;
+
+// Handle the last instruction separately.  If it is tail call, then the
+// last instruction is a call, we don't want to save + restore in this
+// case.  However, it could be possible that the last instruction is a
+// call without it being valid to tail call this sequence.  We should
+// consider this as well.
+else if (FrameID != MachineOutlinerThunk &&
+ FrameID != MachineOutlinerTailCall && FirstCand.back()->isCall())
+  NumBytesToCreateFrame += Costs.SaveRestoreLROnStack;
   }
 
   return outliner::OutlinedFunction(RepeatedSequenceLocs, SequenceSize,

diff  --git a/llvm/test/CodeGen/ARM/machine-outliner-calls.mir 
b/llvm/test/CodeGen/ARM/machine-outliner-calls.mir
index a9a2a1357e10..f18eeb81a35b 100644
--- a/llvm/test/CodeGen/ARM/machine-outliner-calls.mir
+++ b/llvm/test/CodeGen/ARM/machine-outliner-calls.mir
@@ -88,15 +88,15 @@ body: |
   ; CHECK:   frame-setup CFI_INSTRUCTION def_cfa_offset 8
   ; CHECK:   frame-setup CFI_INSTRUCTION offset $lr, -4
   ; CHECK:   frame-setup CFI_INSTRUCTION offset $r7, -8
-  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_3
+  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_4
   ; CHECK: bb.1:
-  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_3
+  ; CHECK:   tBL 14 /* CC::al */, $noreg, 

[llvm-branch-commits] [llvm] b9890ae - [TableGen] Make InstrMap::getFilterClass() const. NFCI.

2020-12-17 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2020-12-17T14:49:58Z
New Revision: b9890ae1976ba3c986b3c3df480e26277be9b6f0

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

LOG: [TableGen] Make InstrMap::getFilterClass() const. NFCI.

Reported by cppcheck.

I've run clang-format across all the InstrMap accessors as well.

Added: 


Modified: 
llvm/utils/TableGen/CodeGenMapTable.cpp

Removed: 




diff  --git a/llvm/utils/TableGen/CodeGenMapTable.cpp 
b/llvm/utils/TableGen/CodeGenMapTable.cpp
index 9f9213d44d18..57d86a8fc119 100644
--- a/llvm/utils/TableGen/CodeGenMapTable.cpp
+++ b/llvm/utils/TableGen/CodeGenMapTable.cpp
@@ -144,25 +144,15 @@ class InstrMap {
 }
   }
 
-  std::string getName() const {
-return Name;
-  }
+  std::string getName() const { return Name; }
 
-  std::string getFilterClass() {
-return FilterClass;
-  }
+  std::string getFilterClass() const { return FilterClass; }
 
-  ListInit *getRowFields() const {
-return RowFields;
-  }
+  ListInit *getRowFields() const { return RowFields; }
 
-  ListInit *getColFields() const {
-return ColFields;
-  }
+  ListInit *getColFields() const { return ColFields; }
 
-  ListInit *getKeyCol() const {
-return KeyCol;
-  }
+  ListInit *getKeyCol() const { return KeyCol; }
 
   const std::vector () const {
 return ValueCols;



___
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] [libc] cfe096d - Fix dead link

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

Author: Guillaume Chatelet
Date: 2020-12-17T15:49:28+01:00
New Revision: cfe096d1f68783bcfab4a01d5a471a3c6ed1b46d

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

LOG: Fix dead link

Added: 


Modified: 
libc/benchmarks/README.md

Removed: 




diff  --git a/libc/benchmarks/README.md b/libc/benchmarks/README.md
index dbfb0641d337..96d108b5f35b 100644
--- a/libc/benchmarks/README.md
+++ b/libc/benchmarks/README.md
@@ -51,7 +51,7 @@ This is the preferred mode to use. The function parameters 
are randomized and th
 --output=/tmp/benchmark_result.json
 ```
 
-The `--size-distribution-name` flag is mandatory and points to one of the 
[predefined distribution](libc/benchmarks/MemorySizeDistributions.h).
+The `--size-distribution-name` flag is mandatory and points to one of the 
[predefined distribution](MemorySizeDistributions.h).
 
 > Note: These distributions are gathered from several important binaries at 
 > Google (servers, databases, realtime and batch jobs) and reflect the 
 > importance of focusing on small sizes.
 



___
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] 5e31e22 - Remove Python2 fallback and only advertise Python3 in the doc

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

Author: serge-sans-paille
Date: 2020-12-17T15:40:16+01:00
New Revision: 5e31e226b5b2b682607a6578ff5adb33daf4fe39

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

LOG: Remove Python2 fallback and only advertise Python3 in the doc

Differential Revision: https://www.youtube.com/watch?v=RsL0cipURA0

Added: 


Modified: 
clang/CMakeLists.txt
clang/tools/scan-build-py/README.md
clang/tools/scan-build/bin/set-xcode-analyzer
lld/CMakeLists.txt
lldb/docs/resources/build.rst
llvm/CMakeLists.txt
llvm/docs/GettingStarted.rst
llvm/docs/GettingStartedVS.rst
llvm/docs/HowToBuildOnARM.rst
llvm/docs/TestingGuide.rst

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f947b820bdac..f1e5a39cfe05 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -135,20 +135,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 COMPONENTS Interpreter)
-if(NOT Python3_Interpreter_FOUND)
-  message(WARNING "Python3 not found, using python2 as a fallback")
-  find_package(Python2 COMPONENTS Interpreter REQUIRED)
-  if(Python2_VERSION VERSION_LESS 2.7)
-message(SEND_ERROR "Python 2.7 or newer is required")
-  endif()
-
-  # Treat python2 as python3
-  add_executable(Python3::Interpreter IMPORTED)
-  set_target_properties(Python3::Interpreter PROPERTIES
-IMPORTED_LOCATION ${Python2_EXECUTABLE})
-  set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
-endif()
+find_package(Python3 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}

diff  --git a/clang/tools/scan-build-py/README.md 
b/clang/tools/scan-build-py/README.md
index 0f89b6fa43d8..63ce0273f22e 100644
--- a/clang/tools/scan-build-py/README.md
+++ b/clang/tools/scan-build-py/README.md
@@ -19,7 +19,7 @@ Should be working on UNIX operating systems.
 Prerequisites
 -
 
-1. **python** interpreter (version 2.7, 3.2, 3.3, 3.4, 3.5).
+1. **python** interpreter (version 3.6 or later).
 
 
 How to use

diff  --git a/clang/tools/scan-build/bin/set-xcode-analyzer 
b/clang/tools/scan-build/bin/set-xcode-analyzer
index c2a65c908598..9faaec1e8e6e 100755
--- a/clang/tools/scan-build/bin/set-xcode-analyzer
+++ b/clang/tools/scan-build/bin/set-xcode-analyzer
@@ -5,8 +5,8 @@
 # This one has the scripting bridge enabled.
 
 import sys
-if sys.version_info < (2, 7):
-print "set-xcode-analyzer requires Python 2.7 or later"
+if sys.version_info < (3, 6):
+print "set-xcode-analyzer requires Python 3.6 or later"
 sys.exit(1)
 
 import os

diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 82b4b9b9b198..d4e561b50d8f 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -57,20 +57,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 COMPONENTS Interpreter)
-if(NOT Python3_Interpreter_FOUND)
-  message(WARNING "Python3 not found, using python2 as a fallback")
-  find_package(Python2 COMPONENTS Interpreter REQUIRED)
-  if(Python2_VERSION VERSION_LESS 2.7)
-message(SEND_ERROR "Python 2.7 or newer is required")
-  endif()
-
-  # Treat python2 as python3
-  add_executable(Python3::Interpreter IMPORTED)
-  set_target_properties(Python3::Interpreter PROPERTIES
-IMPORTED_LOCATION ${Python2_EXECUTABLE})
-  set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
-endif()
+find_package(Python3 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}

diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index b4e58ca977a9..8aadd126ed0b 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -73,7 +73,7 @@ commands below.
   > yum install libedit-devel libxml2-devel ncurses-devel python-devel swig
   > sudo apt-get install build-essential subversion swig python3-dev 
libedit-dev libncurses5-dev
   > pkg install swig python
-  > pkgin install swig python27 cmake ninja-build
+  > pkgin install swig python36 cmake ninja-build
   > brew install swig cmake ninja
 
 Note that there's an `incompatibility

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 54009573ed43..ee1b646ab651 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -708,20 +708,7 @@ set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
 
 include(HandleLLVMOptions)
 
-find_package(Python3 COMPONENTS Interpreter)
-if(NOT 

[llvm-branch-commits] [lld] 978eb3b - [lld] [ELF] AArch64: Handle DT_AARCH64_VARIANT_PCS

2020-12-17 Thread Adhemerval Zanella via llvm-branch-commits

Author: Adhemerval Zanella
Date: 2020-12-17T11:09:55-03:00
New Revision: 978eb3b87bca0837d52d096c343fc70b06d9a04d

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

LOG: [lld] [ELF] AArch64: Handle DT_AARCH64_VARIANT_PCS

As indicated by AArch64 ELF specification, symbols with st_other
marked with STO_AARCH64_VARIANT_PCS indicates it may follow a variant
procedure call standard with different register usage convention
(for instance SVE calls).

Static linkers must preserve the marking and propagate it to the dynamic
symbol table if any reference or definition of the symbol is marked with
STO_AARCH64_VARIANT_PCS, and add a DT_AARCH64_VARIANT_PCS dynamic tag if
there are R__JUMP_SLOT relocations that reference that symbols.

It implements https://bugs.llvm.org/show_bug.cgi?id=48368.

Reviewed By: MaskRay

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

Added: 
lld/test/ELF/aarch64-variant_pcs.s

Modified: 
lld/ELF/SyntheticSections.cpp

Removed: 




diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index eccd3ef1795e..9b5fb3f26c59 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1436,6 +1436,13 @@ template  void 
DynamicSection::finalizeContents() {
 case EM_SPARCV9:
   addInSec(DT_PLTGOT, in.plt);
   break;
+case EM_AARCH64:
+  if (llvm::find_if(in.relaPlt->relocs, [](const DynamicReloc ) {
+   return r.type == target->pltRel &&
+  r.sym->stOther & STO_AARCH64_VARIANT_PCS;
+  }) != in.relaPlt->relocs.end())
+addInt(DT_AARCH64_VARIANT_PCS, 0);
+  LLVM_FALLTHROUGH;
 default:
   addInSec(DT_PLTGOT, in.gotPlt);
   break;
@@ -2181,6 +2188,10 @@ template  void 
SymbolTableSection::writeTo(uint8_t *buf) {
 // See getPPC64GlobalEntryToLocalEntryOffset() for more details.
 if (config->emachine == EM_PPC64)
   eSym->st_other |= sym->stOther & 0xe0;
+// The most significant bit of st_other is used by AArch64 ABI for the
+// variant PCS.
+else if (config->emachine == EM_AARCH64)
+  eSym->st_other |= sym->stOther & STO_AARCH64_VARIANT_PCS;
 
 eSym->st_name = ent.strTabOffset;
 if (isDefinedHere)

diff  --git a/lld/test/ELF/aarch64-variant_pcs.s 
b/lld/test/ELF/aarch64-variant_pcs.s
new file mode 100644
index ..b7f1efc16d6c
--- /dev/null
+++ b/lld/test/ELF/aarch64-variant_pcs.s
@@ -0,0 +1,130 @@
+# REQUIRES: aarch64
+# RUN: split-file %s %t
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %t/test1 -o %t.o
+# RUN: ld.lld %t.o --shared -o %t.so
+# RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix T1-PCSDYN 
%s
+# RUN: llvm-readelf --symbols %t.so | FileCheck --check-prefix T1-PCSSYM %s
+
+# T1-PCSDYN-NOT:  0x7005 (AARCH64_VARIANT_PCS) 0
+# T1-PCSSYM:  Symbol table '.dynsym'
+# T1-PCSSYM:  0 NOTYPE GLOBAL DEFAULT [VARIANT_PCS] [[#]] 
pcs_func_global_def
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %t/test2 -o %t.o
+# RUN: ld.lld %t.o --shared -o %t.so
+# RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix T2-PCSDYN 
%s
+# RUN: llvm-readelf --symbols %t.so | FileCheck --check-prefix T2-PCSSYM %s
+
+# T2-PCSDYN:  0x7005 (AARCH64_VARIANT_PCS) 0
+# T2-PCSSYM:  Symbol table '.dynsym'
+# T2-PCSSYM:  0 NOTYPE GLOBAL DEFAULT [VARIANT_PCS] [[#]] 
pcs_func_global_def
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %t/test3 -o %t.o
+# RUN: ld.lld %t.o --shared -o %t.so
+# RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix T3-PCSDYN 
%s
+# RUN: llvm-readelf --symbols %t.so | FileCheck --check-prefix T3-PCSSYM %s
+
+# T3-PCSDYN:  0x7005 (AARCH64_VARIANT_PCS) 0
+# T3-PCSSYM:  Symbol table '.dynsym'
+# T3-PCSSYM:  0 IFUNC  GLOBAL DEFAULT [VARIANT_PCS] UND   
pcs_ifunc_global_def
+# T3-PCSSYM:  0 NOTYPE GLOBAL DEFAULT   [[#]] 
pcs_func_global_def
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %t/test4 -o %t.o
+# RUN: ld.lld %t.o --shared -o %t.so
+# RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix T4-PCSDYN 
%s
+# RUN: llvm-readelf --symbols %t.so | FileCheck --check-prefix T4-PCSSYM %s
+
+# T4-PCSDYN-NOT:  0x7005 (AARCH64_VARIANT_PCS) 0
+# T4-PCSSYM:  Symbol table '.dynsym'
+# T4-PCSSYM:  0 IFUNC GLOBAL DEFAULT [VARIANT_PCS]  [[#]] 
pcs_ifunc_global_def
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %t/test5 -o %t.o
+# RUN: ld.lld %t.o --shared -o %t.so
+# RUN: llvm-readelf --symbols %t.so | FileCheck --check-prefix T5-PCSSYM %s
+
+# T5-PCSSYM:  Symbol table '.dynsym'
+# T5-PCSSYM:  0 NOTYPE  GLOBAL DEFAULT [VARIANT_PCS] UND   
pcs_func_global_undef
+# T5-PCSSYM-NEXT: 0 NOTYPE  GLOBAL DEFAULT 

[llvm-branch-commits] [llvm] e04dc5f - [llvm-readobj/elf] - AArch64: Handle AARCH64_VARIANT_PCS for GNUStyle

2020-12-17 Thread Adhemerval Zanella via llvm-branch-commits

Author: Adhemerval Zanella
Date: 2020-12-17T11:09:53-03:00
New Revision: e04dc5f557c585f19d5abc73d1e71af81e8d5243

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

LOG: [llvm-readobj/elf] - AArch64: Handle AARCH64_VARIANT_PCS for GNUStyle

It mimics the GNU readelf where it prints a [VARIANT_PCS] for symbols
with st_other with STO_AARCH64_VARIANT_PCS.

Reviewed By: grimar, MaskRay

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

Added: 
llvm/test/tools/llvm-readobj/ELF/aarch64-symbols-stother.test

Modified: 
llvm/include/llvm/BinaryFormat/DynamicTags.def
llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/include/llvm/BinaryFormat/DynamicTags.def 
b/llvm/include/llvm/BinaryFormat/DynamicTags.def
index aec408bd2d72..c08f8a53bdb5 100644
--- a/llvm/include/llvm/BinaryFormat/DynamicTags.def
+++ b/llvm/include/llvm/BinaryFormat/DynamicTags.def
@@ -120,6 +120,7 @@ DYNAMIC_TAG(VERNEEDNUM, 0X6FFF) // The number of 
entries in DT_VERNEED.
 // AArch64 specific dynamic table entries
 AARCH64_DYNAMIC_TAG(AARCH64_BTI_PLT, 0x7001)
 AARCH64_DYNAMIC_TAG(AARCH64_PAC_PLT, 0x7003)
+AARCH64_DYNAMIC_TAG(AARCH64_VARIANT_PCS, 0x7005)
 
 // Hexagon specific dynamic table entries
 HEXAGON_DYNAMIC_TAG(HEXAGON_SYMSZ, 0x7000)

diff  --git a/llvm/test/tools/llvm-readobj/ELF/aarch64-symbols-stother.test 
b/llvm/test/tools/llvm-readobj/ELF/aarch64-symbols-stother.test
new file mode 100644
index ..bc9d1286e0a0
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/aarch64-symbols-stother.test
@@ -0,0 +1,45 @@
+## Check that we are able to dump AArch64 STO_* flags correctly when dumping 
symbols.
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-readobj --symbols %t.o | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readelf --symbols %t.o | FileCheck %s --check-prefix=GNU
+
+# LLVM:  Name: foo1
+# LLVM:  Other [ (0x80)
+# LLVM-NEXT:   STO_AARCH64_VARIANT_PCS (0x80)
+# LLVM-NEXT: ]
+# LLVM:  Name: foo2
+# LLVM:  Other [ (0xC0)
+# LLVM-NEXT:   STO_AARCH64_VARIANT_PCS (0x80)
+# LLVM-NEXT: ]
+# LLVM:  Name: foo3
+# LLVM:  Other [ (0x83)
+# LLVM-NEXT:   STO_AARCH64_VARIANT_PCS (0x80)
+# LLVM-NEXT:   STV_PROTECTED (0x3)
+# LLVM-NEXT: ]
+# LLVM:  Name: foo4
+# LLVM:  Other [ (0x3)
+# LLVM-NEXT:   STV_PROTECTED (0x3)
+# LLVM-NEXT: ]
+
+# GNU:  Symbol table '.symtab' contains 5 entries:
+# GNU:  1:  0 NOTYPE LOCAL DEFAULT   [VARIANT_PCS]  
UND foo1
+# GNU-NEXT: 2:  0 NOTYPE LOCAL DEFAULT   [VARIANT_PCS | 40] 
UND foo2
+# GNU-NEXT: 3:  0 NOTYPE LOCAL PROTECTED [VARIANT_PCS]  
UND foo3
+# GNU-NEXT: 4:  0 NOTYPE LOCAL PROTECTED
UND foo4
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_AARCH64
+Symbols:
+  - Name: foo1
+Other: [ STO_AARCH64_VARIANT_PCS ]
+  - Name: foo2
+Other: [ STO_AARCH64_VARIANT_PCS, 0x40 ]
+  - Name: foo3
+Other: [ STO_AARCH64_VARIANT_PCS, STV_PROTECTED ]
+  - Name: foo4
+Other: [ STV_PROTECTED ]

diff  --git 
a/llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test 
b/llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test
index 53a661a427d8..02309e51b342 100644
--- a/llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test
+++ b/llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test
@@ -351,18 +351,20 @@ ProgramHeaders:
 # RUN: llvm-readobj --dynamic-table %t.aarch64 | FileCheck %s 
--check-prefix=LLVM-AARCH64
 # RUN: llvm-readelf --dynamic-table %t.aarch64 | FileCheck %s 
--check-prefix=GNU-AARCH64
 
-# LLVM-AARCH64: DynamicSection [ (3 entries)
-# LLVM-AARCH64-NEXT:  TagTypeName/Value
-# LLVM-AARCH64-NEXT:  0x7001 AARCH64_BTI_PLT 1
-# LLVM-AARCH64-NEXT:  0x7003 AARCH64_PAC_PLT 2
-# LLVM-AARCH64-NEXT:  0x NULL0x0
+# LLVM-AARCH64: DynamicSection [ (4 entries)
+# LLVM-AARCH64-NEXT:  TagTypeName/Value
+# LLVM-AARCH64-NEXT:  0x7001 AARCH64_BTI_PLT 1
+# LLVM-AARCH64-NEXT:  0x7003 AARCH64_PAC_PLT 2
+# LLVM-AARCH64-NEXT:  0x7005 AARCH64_VARIANT_PCS 3
+# LLVM-AARCH64-NEXT:  0x NULL0x0
 # LLVM-AARCH64-NEXT:]
 
-# GNU-AARCH64:  Dynamic section at offset {{.*}} contains 3 entries:
-# GNU-AARCH64-NEXT:  TagType  Name/Value
-# GNU-AARCH64-NEXT:  0x7001 (AARCH64_BTI_PLT) 1
-# GNU-AARCH64-NEXT:  0x7003 (AARCH64_PAC_PLT) 2
-# GNU-AARCH64-NEXT:  0x (NULL)0x0
+# 

[llvm-branch-commits] [llvm] ef9dc51 - [obj2yaml][yaml2obj] - Add AArch64 STO_AARCH64_VARIANT_PCS support

2020-12-17 Thread Adhemerval Zanella via llvm-branch-commits

Author: Adhemerval Zanella
Date: 2020-12-17T11:09:53-03:00
New Revision: ef9dc51cd4af509e7c28573e15e13a98b17c9511

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

LOG: [obj2yaml][yaml2obj] - Add AArch64 STO_AARCH64_VARIANT_PCS support

Reviewed By: grimar, MaskRay

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

Added: 
llvm/test/tools/obj2yaml/ELF/aarch64-sym-other.yaml

Modified: 
llvm/lib/ObjectYAML/ELFYAML.cpp

Removed: 




diff  --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 52a4a3a2d80b..3a280b06336d 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1040,6 +1040,9 @@ struct NormalizedOther {
   Map["STO_MIPS_PLT"] = ELF::STO_MIPS_PLT;
   Map["STO_MIPS_OPTIONAL"] = ELF::STO_MIPS_OPTIONAL;
 }
+
+if (EMachine == ELF::EM_AARCH64)
+  Map["STO_AARCH64_VARIANT_PCS"] = ELF::STO_AARCH64_VARIANT_PCS;
 return Map;
   }
 

diff  --git a/llvm/test/tools/obj2yaml/ELF/aarch64-sym-other.yaml 
b/llvm/test/tools/obj2yaml/ELF/aarch64-sym-other.yaml
new file mode 100644
index ..ad20a6546e62
--- /dev/null
+++ b/llvm/test/tools/obj2yaml/ELF/aarch64-sym-other.yaml
@@ -0,0 +1,22 @@
+## Check AArch64 st_other extension support.
+
+# RUN: yaml2obj %s -o %t
+# RUN: obj2yaml %t | FileCheck %s
+
+# CHECK: Symbols:
+# CHECK:  - Name:  foo1
+# CHECK:Other: [ STO_AARCH64_VARIANT_PCS ]
+# CHECK:  - Name:  foo2
+# CHECK:Other: [ STO_AARCH64_VARIANT_PCS, 64 ]
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_AARCH64
+Symbols:
+  - Name:  foo1
+Other: [ STO_AARCH64_VARIANT_PCS ]
+  - Name:  foo2
+Other: [ STO_AARCH64_VARIANT_PCS, 0x40 ]



___
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] 64badec - [clang-tidy][NFC] Reduce copies of Intrusive..FileSystem

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

Author: Nathan James
Date: 2020-12-17T14:09:08Z
New Revision: 64badecd447f2358812a2e747b2683d34071f5a5

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

LOG: [clang-tidy][NFC] Reduce copies of Intrusive..FileSystem

Swapped a few instances where a move is more optimal or the target doesn't need 
to hold a reference.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index b5f2a1c0fbdb..633655e5e24a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -101,7 +101,8 @@ class ErrorReporter {
 public:
   ErrorReporter(ClangTidyContext , bool ApplyFixes,
 llvm::IntrusiveRefCntPtr BaseFS)
-  : Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()),
+  : Files(FileSystemOptions(), std::move(BaseFS)),
+DiagOpts(new DiagnosticOptions()),
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,
   DiagPrinter),
@@ -319,7 +320,7 @@ class ClangTidyASTConsumer : public MultiplexConsumer {
 ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
 ClangTidyContext ,
 IntrusiveRefCntPtr OverlayFS)
-: Context(Context), OverlayFS(OverlayFS),
+: Context(Context), OverlayFS(std::move(OverlayFS)),
   CheckFactories(new ClangTidyCheckFactories) {
   for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries()) {
 std::unique_ptr Module = E.instantiate();
@@ -328,15 +329,16 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
 }
 
 #if CLANG_TIDY_ENABLE_STATIC_ANALYZER
-static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions ,
- AnalyzerOptionsRef AnalyzerOptions) {
+static void
+setStaticAnalyzerCheckerOpts(const ClangTidyOptions ,
+ clang::AnalyzerOptions ) {
   StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
   for (const auto  : Opts.CheckOptions) {
 StringRef OptName(Opt.getKey());
 if (!OptName.consume_front(AnalyzerPrefix))
   continue;
 // Analyzer options are always local options so we can ignore priority.
-AnalyzerOptions->Config[OptName] = Opt.getValue().Value;
+AnalyzerOptions.Config[OptName] = Opt.getValue().Value;
   }
 }
 
@@ -432,7 +434,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
   AnalyzerOptions->CheckersAndPackages = getAnalyzerCheckersAndPackages(
   Context, Context.canEnableAnalyzerAlphaCheckers());
   if (!AnalyzerOptions->CheckersAndPackages.empty()) {
-setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
+setStaticAnalyzerCheckerOpts(Context.getOptions(), *AnalyzerOptions);
 AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
 AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
 AnalyzerOptions->AnalyzeNestedBlocks = true;
@@ -539,7 +541,7 @@ runClangTidy(clang::tidy::ClangTidyContext ,
   public:
 ActionFactory(ClangTidyContext ,
   IntrusiveRefCntPtr BaseFS)
-: ConsumerFactory(Context, BaseFS) {}
+: ConsumerFactory(Context, std::move(BaseFS)) {}
 std::unique_ptr create() override {
   return std::make_unique();
 }
@@ -570,7 +572,7 @@ runClangTidy(clang::tidy::ClangTidyContext ,
 ClangTidyASTConsumerFactory ConsumerFactory;
   };
 
-  ActionFactory Factory(Context, BaseFS);
+  ActionFactory Factory(Context, std::move(BaseFS));
   Tool.run();
   return DiagConsumer.take();
 }
@@ -579,7 +581,7 @@ void handleErrors(llvm::ArrayRef Errors,
   ClangTidyContext , bool Fix,
   unsigned ,
   llvm::IntrusiveRefCntPtr BaseFS) {
-  ErrorReporter Reporter(Context, Fix, BaseFS);
+  ErrorReporter Reporter(Context, Fix, std::move(BaseFS));
   llvm::vfs::FileSystem  =
   Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
   auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 2748fd9f74a5..2466b647c68c 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -393,7 +393,7 @@ int clangTidyMain(int argc, const char **argv) {
 getVfsFromFile(VfsOverlay, BaseFS);
 if (!VfsFromFile)
   return 1;
-BaseFS->pushOverlay(VfsFromFile);
+BaseFS->pushOverlay(std::move(VfsFromFile));
   }
 
   auto OwningOptionsProvider = createOptionsProvider(BaseFS);




[llvm-branch-commits] [llvm] 75c04bf - [SimplifyCFG] Preserve !annotation in FoldBranchToCommonDest.

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

Author: Florian Hahn
Date: 2020-12-17T14:06:58Z
New Revision: 75c04bfc61d6cc5623eadd8a04f86c315dacd823

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

LOG: [SimplifyCFG] Preserve !annotation in FoldBranchToCommonDest.

When folding a branch to a common destination, preserve !annotation on
the created instruction, if the terminator of the BB that is going to be
removed has !annotation. This should ensure that !annotation is attached
to the instructions that 'replace' the original terminator.

Reviewed By: jdoerfert, lebedev.ri

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

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/annotations.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 4ac080b539f5..0c693a8d27be 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2886,11 +2886,15 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
MemorySSAUpdater *MSSAU,
 Changed = true;
 
 IRBuilder<> Builder(PBI);
+// The builder is used to create instructions to eliminate the branch in 
BB.
+// If BB's terminator has !annotation metadata, add it to the new
+// instructions.
+Builder.CollectMetadataToCopy(BB->getTerminator(),
+  {LLVMContext::MD_annotation});
 
 // If we need to invert the condition in the pred block to match, do so 
now.
 if (InvertPredCond) {
   Value *NewCond = PBI->getCondition();
-
   if (NewCond->hasOneUse() && isa(NewCond)) {
 CmpInst *CI = cast(NewCond);
 CI->setPredicate(CI->getInversePredicate());
@@ -2941,8 +2945,9 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
MemorySSAUpdater *MSSAU,
   // its potential value. The previous information might have been valid
   // only given the branch precondition.
   // For an analogous reason, we must also drop all the metadata whose
-  // semantics we don't understand.
-  NewBonusInst->dropUnknownNonDebugMetadata();
+  // semantics we don't understand. We *can* preserve !annotation, because
+  // it is tied to the instruction itself, not the value or position.
+  NewBonusInst->dropUnknownNonDebugMetadata(LLVMContext::MD_annotation);
 
   PredBlock->getInstList().insert(PBI->getIterator(), NewBonusInst);
   NewBonusInst->takeName();

diff  --git a/llvm/test/Transforms/SimplifyCFG/annotations.ll 
b/llvm/test/Transforms/SimplifyCFG/annotations.ll
index 5e39107e1c89..e6bc73d16992 100644
--- a/llvm/test/Transforms/SimplifyCFG/annotations.ll
+++ b/llvm/test/Transforms/SimplifyCFG/annotations.ll
@@ -6,8 +6,8 @@ define i32 @test_preserve_and(i8* %a, i8* %b, i8* %c, i8* %d) {
 ; CHECK-LABEL: define {{.*}} @test_preserve_and({{.*}}
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[C_1:%.*]] = icmp ult i8* [[A:%.*]], [[B:%.*]], !annotation 
!0
-; CHECK-NEXT:[[C_2:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]]
-; CHECK-NEXT:[[OR_COND:%.*]] = and i1 [[C_1]], [[C_2]]
+; CHECK-NEXT:[[C_2:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]], !annotation 
!0
+; CHECK-NEXT:[[OR_COND:%.*]] = and i1 [[C_1]], [[C_2]], !annotation !0
 ; CHECK-NEXT:br i1 [[OR_COND]], label [[CONT1:%.*]], label [[TRAP:%.*]], 
!annotation !0
 ; CHECK:   trap: ; preds = %entry
 ; CHECK-NEXT:call void @fn1()
@@ -39,8 +39,8 @@ define i32 @test_preserve_or(i8* %a, i8* %b, i8* %c, i8* %d) {
 ; CHECK-LABEL: define {{.*}} @test_preserve_or({{.*}}
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[C_1:%.*]] = icmp uge i8* [[A:%.*]], [[B:%.*]], !annotation 
!0
-; CHECK-NEXT:[[C_2:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]]
-; CHECK-NEXT:[[OR_COND:%.*]] = or i1 [[C_1]], [[C_2]]
+; CHECK-NEXT:[[C_2:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]], !annotation 
!0
+; CHECK-NEXT:[[OR_COND:%.*]] = or i1 [[C_1]], [[C_2]], !annotation !0
 ; CHECK-NEXT:br i1 [[OR_COND]], label [[TRAP:%.*]], label [[CONT1:%.*]], 
!annotation !0
 ; CHECK:   trap: ; preds = %entry
 ; CHECK-NEXT:call void @fn1()
@@ -73,9 +73,9 @@ define i32 @test_preserve_or_not(i8* %a, i8* %b, i8* %c, i8* 
%d) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[C_1:%.*]] = icmp ult i8* [[A:%.*]], [[B:%.*]], !annotation 
!0
 ; CHECK-NEXT:[[C_2:%.*]] = xor i1 [[C_1]], true
-; CHECK-NEXT:[[C_2_NOT:%.*]] = xor i1 [[C_2]], true
-; CHECK-NEXT:[[C_3:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]]
-; CHECK-NEXT:[[OR_COND:%.*]] = or i1 [[C_2_NOT]], [[C_3]]
+; CHECK-NEXT:[[C_2_NOT:%.*]] = xor i1 [[C_2]], true, !annotation !0
+; CHECK-NEXT:[[C_3:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]], !annotation 
!0
+; CHECK-NEXT:[[OR_COND:%.*]] = or i1 [[C_2_NOT]], [[C_3]], !annotation !0
 ; 

[llvm-branch-commits] [llvm] 0138399 - [InstCombine] Remove scalable vector restriction in InstCombineCasts

2020-12-17 Thread Jun Ma via llvm-branch-commits

Author: Jun Ma
Date: 2020-12-17T22:02:33+08:00
New Revision: 01383999037760288f617e24084991eaf6bd9272

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

LOG: [InstCombine] Remove scalable vector restriction in InstCombineCasts

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

Added: 


Modified: 
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/addrspacecast.ll
llvm/test/Transforms/InstCombine/ptr-int-cast.ll
llvm/test/Transforms/InstCombine/trunc-extractelement.ll
llvm/test/Transforms/InstCombine/vec_shuffle.ll

Removed: 




diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 71bb94e77593..cac5df81661c 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2961,8 +2961,8 @@ void Verifier::visitAddrSpaceCastInst(AddrSpaceCastInst 
) {
   Assert(SrcTy->getPointerAddressSpace() != DestTy->getPointerAddressSpace(),
  "AddrSpaceCast must be between 
diff erent address spaces", );
   if (auto *SrcVTy = dyn_cast(SrcTy))
-Assert(cast(SrcVTy)->getNumElements() ==
-   cast(DestTy)->getNumElements(),
+Assert(SrcVTy->getElementCount() ==
+   cast(DestTy)->getElementCount(),
"AddrSpaceCast vector pointer number of elements mismatch", );
   visitInstruction(I);
 }

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index e9ec8021e466..8750e83623e6 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -907,20 +907,21 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst 
) {
   Value *VecOp;
   ConstantInt *Cst;
   if (match(Src, m_OneUse(m_ExtractElt(m_Value(VecOp), m_ConstantInt(Cst) {
-auto *VecOpTy = cast(VecOp->getType());
-unsigned VecNumElts = VecOpTy->getNumElements();
+auto *VecOpTy = cast(VecOp->getType());
+auto VecElts = VecOpTy->getElementCount();
 
 // A badly fit destination size would result in an invalid cast.
 if (SrcWidth % DestWidth == 0) {
   uint64_t TruncRatio = SrcWidth / DestWidth;
-  uint64_t BitCastNumElts = VecNumElts * TruncRatio;
+  uint64_t BitCastNumElts = VecElts.getKnownMinValue() * TruncRatio;
   uint64_t VecOpIdx = Cst->getZExtValue();
   uint64_t NewIdx = DL.isBigEndian() ? (VecOpIdx + 1) * TruncRatio - 1
  : VecOpIdx * TruncRatio;
   assert(BitCastNumElts <= std::numeric_limits::max() &&
  "overflow 32-bits");
 
-  auto *BitCastTo = FixedVectorType::get(DestTy, BitCastNumElts);
+  auto *BitCastTo =
+  VectorType::get(DestTy, BitCastNumElts, VecElts.isScalable());
   Value *BitCast = Builder.CreateBitCast(VecOp, BitCastTo);
   return ExtractElementInst::Create(BitCast, Builder.getInt32(NewIdx));
 }
@@ -1974,12 +1975,9 @@ Instruction 
*InstCombinerImpl::visitPtrToInt(PtrToIntInst ) {
   unsigned PtrSize = DL.getPointerSizeInBits(AS);
   if (TySize != PtrSize) {
 Type *IntPtrTy = DL.getIntPtrType(CI.getContext(), AS);
-if (auto *VecTy = dyn_cast(Ty)) {
-  // Handle vectors of pointers.
-  // FIXME: what should happen for scalable vectors?
-  IntPtrTy = FixedVectorType::get(
-  IntPtrTy, cast(VecTy)->getNumElements());
-}
+// Handle vectors of pointers.
+if (auto *VecTy = dyn_cast(Ty))
+  IntPtrTy = VectorType::get(IntPtrTy, VecTy->getElementCount());
 
 Value *P = Builder.CreatePtrToInt(SrcOp, IntPtrTy);
 return CastInst::CreateIntegerCast(P, Ty, /*isSigned=*/false);
@@ -2660,13 +2658,11 @@ Instruction *InstCombinerImpl::visitBitCast(BitCastInst 
) {
 // a bitcast to a vector with the same # elts.
 Value *ShufOp0 = Shuf->getOperand(0);
 Value *ShufOp1 = Shuf->getOperand(1);
-unsigned NumShufElts =
-cast(Shuf->getType())->getNumElements();
-unsigned NumSrcVecElts =
-cast(ShufOp0->getType())->getNumElements();
+auto ShufElts = cast(Shuf->getType())->getElementCount();
+auto SrcVecElts = cast(ShufOp0->getType())->getElementCount();
 if (Shuf->hasOneUse() && DestTy->isVectorTy() &&
-cast(DestTy)->getNumElements() == NumShufElts &&
-NumShufElts == NumSrcVecElts) {
+cast(DestTy)->getElementCount() == ShufElts &&
+ShufElts == SrcVecElts) {
   BitCastInst *Tmp;
   // If either of the operands is a cast from CI.getType(), then
   // evaluating the shuffle in the casted destination's type will allow
@@ -2689,8 +2685,9 @@ Instruction *InstCombinerImpl::visitBitCast(BitCastInst 
) {
 // TODO: We should match the related pattern for bitreverse.
 if (DestTy->isIntegerTy() 

[llvm-branch-commits] [lld] 4c8276c - [lld-macho] Use LC_LOAD_WEAK_DYLIB for dylibs with only weakrefs

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

Author: Jez Ng
Date: 2020-12-17T08:49:17-05:00
New Revision: 4c8276cdc120c24410dcd62a9986f04e7327fc2f

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

LOG: [lld-macho] Use LC_LOAD_WEAK_DYLIB for dylibs with only weakrefs

Note that dylibs without *any* refs will still be loaded in the usual
(strong) fashion.

Reviewed By: #lld-macho, thakis

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

Added: 


Modified: 
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/Symbols.h
lld/MachO/Writer.cpp
lld/test/MachO/weak-import.s

Removed: 




diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index a32e8caf3d29..ce66c9650446 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -527,7 +527,7 @@ void loadReexport(StringRef path, DylibFile *umbrella) {
 }
 
 DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella)
-: InputFile(DylibKind, mb) {
+: InputFile(DylibKind, mb), refState(RefState::Unreferenced) {
   if (umbrella == nullptr)
 umbrella = this;
 
@@ -580,7 +580,7 @@ DylibFile::DylibFile(MemoryBufferRef mb, DylibFile 
*umbrella)
 }
 
 DylibFile::DylibFile(const InterfaceFile , DylibFile *umbrella)
-: InputFile(DylibKind, interface) {
+: InputFile(DylibKind, interface), refState(RefState::Unreferenced) {
   if (umbrella == nullptr)
 umbrella = this;
 

diff  --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h
index f48fc1f8c232..ef573145f594 100644
--- a/lld/MachO/InputFiles.h
+++ b/lld/MachO/InputFiles.h
@@ -38,6 +38,7 @@ namespace macho {
 class InputSection;
 class Symbol;
 struct Reloc;
+enum class RefState : uint8_t;
 
 // If --reproduce option is given, all input files are written
 // to this tar archive.
@@ -135,6 +136,7 @@ class DylibFile : public InputFile {
   uint32_t compatibilityVersion = 0;
   uint32_t currentVersion = 0;
   uint64_t ordinal = 0; // Ordinal numbering starts from 1, so 0 is a sentinel
+  RefState refState;
   bool reexport = false;
   bool forceWeakImport = false;
 };

diff  --git a/lld/MachO/Symbols.h b/lld/MachO/Symbols.h
index 80898e085818..80be27dd1c1f 100644
--- a/lld/MachO/Symbols.h
+++ b/lld/MachO/Symbols.h
@@ -116,7 +116,11 @@ class Defined : public Symbol {
   const bool external : 1;
 };
 
-// Indicates whether & how a dylib symbol is referenced.
+// This enum does double-duty: as a symbol property, it indicates whether & how
+// a dylib symbol is referenced. As a DylibFile property, it indicates the kind
+// of referenced symbols contained within the file. If there are both weak
+// and strong references to the same file, we will count the file as
+// strongly-referenced.
 enum class RefState : uint8_t { Unreferenced = 0, Weak = 1, Strong = 2 };
 
 class Undefined : public Symbol {

diff  --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index 29c8fd6ed1fa..a4c677a4b288 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -43,6 +43,7 @@ class Writer {
   Writer() : buffer(errorHandler().outputBuffer) {}
 
   void scanRelocations();
+  void scanSymbols();
   void createOutputSections();
   void createLoadCommands();
   void assignAddresses(OutputSegment *);
@@ -424,6 +425,17 @@ void Writer::scanRelocations() {
   }
 }
 
+void Writer::scanSymbols() {
+  for (const macho::Symbol *sym : symtab->getSymbols()) {
+if (const auto *defined = dyn_cast(sym)) {
+  if (defined->overridesWeakDef)
+in.weakBinding->addNonWeakDefinition(defined);
+} else if (const auto *dysym = dyn_cast(sym)) {
+  dysym->file->refState = std::max(dysym->file->refState, dysym->refState);
+}
+  }
+}
+
 void Writer::createLoadCommands() {
   in.header->addLoadCommand(make(
   in.rebase, in.binding, in.weakBinding, in.lazyBinding, in.exports));
@@ -463,10 +475,10 @@ void Writer::createLoadCommands() {
   uint64_t dylibOrdinal = 1;
   for (InputFile *file : inputFiles) {
 if (auto *dylibFile = dyn_cast(file)) {
-  // TODO: dylibs that are only referenced by weak refs should also be
-  // loaded via LC_LOAD_WEAK_DYLIB.
   LoadCommandType lcType =
-  dylibFile->forceWeakImport ? LC_LOAD_WEAK_DYLIB : LC_LOAD_DYLIB;
+  dylibFile->forceWeakImport || dylibFile->refState == RefState::Weak
+  ? LC_LOAD_WEAK_DYLIB
+  : LC_LOAD_DYLIB;
   in.header->addLoadCommand(make(lcType, dylibFile->dylibName,
   dylibFile->compatibilityVersion,
   dylibFile->currentVersion));
@@ -699,11 +711,7 @@ void Writer::run() {
   scanRelocations();
   if (in.stubHelper->isNeeded())
 in.stubHelper->setup();
-
-  for (const macho::Symbol *sym : symtab->getSymbols())
-if (const auto *defined = dyn_cast(sym))
-  if 

[llvm-branch-commits] [lld] 811444d - [lld-macho] Add support for weak references

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

Author: Jez Ng
Date: 2020-12-17T08:49:16-05:00
New Revision: 811444d7a173e696f975f8d41626f6809439f726

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

LOG: [lld-macho] Add support for weak references

Weak references need not necessarily be satisfied at runtime (but they must
still be satisfied at link time). So symbol resolution still works as per usual,
but we now pass around a flag -- ultimately emitting it in the bind table -- to
indicate if a given dylib symbol is a weak reference.

ld64's behavior for symbols that have both weak and strong references is
a bit bizarre. For non-function symbols, it will emit a weak import. For
function symbols (those referenced by BRANCH relocs), it will emit a
regular import. I'm not sure what value there is in that behavior, and
since emulating it will make our implementation more complex, I've
decided to treat regular weakrefs like function symbol ones for now.

Fixes PR48511.

Reviewed By: #lld-macho, thakis

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

Added: 
lld/test/MachO/weak-reference.s

Modified: 
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp
lld/MachO/SymbolTable.cpp
lld/MachO/SymbolTable.h
lld/MachO/Symbols.h
lld/MachO/SyntheticSections.cpp
lld/test/MachO/symtab.s

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index c522a082a306..db89dd60a20b 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -285,7 +285,7 @@ static InputFile *addFile(StringRef path, bool 
forceLoadArchive) {
 } else if (config->forceLoadObjC) {
   for (const object::Archive::Symbol  : file->symbols())
 if (sym.getName().startswith(objc::klass))
-  symtab->addUndefined(sym.getName());
+  symtab->addUndefined(sym.getName(), /*isWeakRef=*/false);
 
   // TODO: no need to look for ObjC sections for a given archive member if
   // we already found that it contains an ObjC symbol. We should also
@@ -723,7 +723,8 @@ bool macho::link(llvm::ArrayRef argsArr, bool 
canExitEarly,
   symtab = make();
   target = createTargetInfo(args);
 
-  config->entry = symtab->addUndefined(args.getLastArgValue(OPT_e, "_main"));
+  config->entry = symtab->addUndefined(args.getLastArgValue(OPT_e, "_main"),
+   /*isWeakRef=*/false);
   config->outputFile = args.getLastArgValue(OPT_o, "a.out");
   config->installName =
   args.getLastArgValue(OPT_install_name, config->outputFile);

diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 3ae3b976afa3..a32e8caf3d29 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -283,7 +283,7 @@ macho::Symbol *ObjFile::parseNonSectionSymbol(const 
structs::nlist_64 ,
   switch (type) {
   case N_UNDF:
 return sym.n_value == 0
-   ? symtab->addUndefined(name)
+   ? symtab->addUndefined(name, sym.n_desc & N_WEAK_REF)
: symtab->addCommon(name, this, sym.n_value,
1 << GET_COMM_ALIGN(sym.n_desc));
   case N_ABS:

diff  --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index ecf8f94239e1..93a2508951a5 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -62,15 +62,21 @@ Symbol *SymbolTable::addDefined(StringRef name, 
InputSection *isec,
   return s;
 }
 
-Symbol *SymbolTable::addUndefined(StringRef name) {
+Symbol *SymbolTable::addUndefined(StringRef name, bool isWeakRef) {
   Symbol *s;
   bool wasInserted;
   std::tie(s, wasInserted) = insert(name);
 
+  auto refState = isWeakRef ? RefState::Weak : RefState::Strong;
+
   if (wasInserted)
-replaceSymbol(s, name);
-  else if (LazySymbol *lazy = dyn_cast(s))
+replaceSymbol(s, name, refState);
+  else if (auto *lazy = dyn_cast(s))
 lazy->fetchArchiveMember();
+  else if (auto *dynsym = dyn_cast(s))
+dynsym->refState = std::max(dynsym->refState, refState);
+  else if (auto *undefined = dyn_cast(s))
+undefined->refState = std::max(undefined->refState, refState);
   return s;
 }
 
@@ -101,14 +107,21 @@ Symbol *SymbolTable::addDylib(StringRef name, DylibFile 
*file, bool isWeakDef,
   bool wasInserted;
   std::tie(s, wasInserted) = insert(name);
 
-  if (!wasInserted && isWeakDef)
-if (auto *defined = dyn_cast(s))
-  if (!defined->isWeakDef())
+  auto refState = RefState::Unreferenced;
+  if (!wasInserted) {
+if (auto *defined = dyn_cast(s)) {
+  if (isWeakDef && !defined->isWeakDef())
 defined->overridesWeakDef = true;
+} else if (auto *undefined = dyn_cast(s)) {
+  refState = undefined->refState;
+} else if (auto *dysym = dyn_cast(s)) {
+  refState = dysym->refState;
+}
+  }
 
   if (wasInserted || isa(s) ||
   (isa(s) && !isWeakDef && 

[llvm-branch-commits] [llvm] c5046eb - [ARM] Adding v8.7-A command-line support for the ARM target

2020-12-17 Thread Lucas Prates via llvm-branch-commits

Author: Lucas Prates
Date: 2020-12-17T13:48:54Z
New Revision: c5046ebdf6e4be9300677c538ecaa61648c31248

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

LOG: [ARM] Adding v8.7-A command-line support for the ARM target

This extends the command-line support for the 'armv8.7-a' architecture
name to the ARM target.

Based on a patch written by Momchil Velikov.

Reviewed By: ostannard

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

Added: 


Modified: 
clang/lib/Basic/Targets/ARM.cpp
clang/test/Driver/arm-cortex-cpus.c
clang/test/Preprocessor/arm-target-features.c
llvm/include/llvm/ADT/Triple.h
llvm/include/llvm/Support/ARMTargetParser.def
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Support/Triple.cpp
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMPredicates.td
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 21cfe0107bbb..a2c96ad12a76 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -208,6 +208,8 @@ StringRef ARMTargetInfo::getCPUAttr() const {
 return "8_5A";
   case llvm::ARM::ArchKind::ARMV8_6A:
 return "8_6A";
+  case llvm::ARM::ArchKind::ARMV8_7A:
+return "8_7A";
   case llvm::ARM::ArchKind::ARMV8MBaseline:
 return "8M_BASE";
   case llvm::ARM::ArchKind::ARMV8MMainline:

diff  --git a/clang/test/Driver/arm-cortex-cpus.c 
b/clang/test/Driver/arm-cortex-cpus.c
index a312ccfda5a1..f1ca801c4ddb 100644
--- a/clang/test/Driver/arm-cortex-cpus.c
+++ b/clang/test/Driver/arm-cortex-cpus.c
@@ -352,6 +352,23 @@
 // RUN: %clang -target arm -march=armebv8.6-a -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V86A %s
 // CHECK-BE-V86A: "-cc1"{{.*}} "-triple" "armebv8.6{{.*}}" "-target-cpu" 
"generic"
 
+// RUN: %clang -target armv8.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -march=armv8.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -march=armv8.7-a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -march=armv8.7a -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V87A %s
+// RUN: %clang -target armv8.7a -mlittle-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -march=armv8.7a -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -mlittle-endian -march=armv8.7-a -mlittle-endian 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V87A %s
+// CHECK-V87A: "-cc1"{{.*}} "-triple" "armv8.7{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target armebv8.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target armv8.7a -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target armeb -march=armebv8.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target armeb -march=armebv8.7-a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target arm -march=armebv8.7a -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target arm -march=armebv8.7-a -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V87A %s
+// CHECK-BE-V87A: "-cc1"{{.*}} "-triple" "armebv8.7{{.*}}" "-target-cpu" 
"generic"
+
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
 // RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 
| FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s

diff  --git a/clang/test/Preprocessor/arm-target-features.c 
b/clang/test/Preprocessor/arm-target-features.c
index 5eaffa1c372c..9f375162e6ab 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -849,6 +849,11 @@
 // CHECK-V86A: #define __ARM_ARCH_8_6A__ 1
 // CHECK-V86A: #define __ARM_ARCH_PROFILE 'A'
 
+// RUN: %clang -target armv8.7a-none-none-eabi -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-V87A %s
+// CHECK-V87A: #define __ARM_ARCH 8
+// CHECK-V87A: #define __ARM_ARCH_8_7A__ 1
+// CHECK-V87A: #define __ARM_ARCH_PROFILE 'A'
+
 // RUN: %clang -target arm-none-none-eabi -march=armv7-m -mfpu=softvfp -x c -E 
-dM %s -o - | FileCheck --check-prefix=CHECK-SOFTVFP %s
 // CHECK-SOFTVFP-NOT: #define __ARM_FP 0x
 

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 13a35857512a..6e2957f3c32b 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -104,6 +104,7 @@ class Triple {
   enum SubArchType {
 NoSubArch,
 

[llvm-branch-commits] [llvm] c4d851b - [ARM][AAarch64] Initial command-line support for v8.7-A

2020-12-17 Thread Lucas Prates via llvm-branch-commits

Author: Lucas Prates
Date: 2020-12-17T13:47:28Z
New Revision: c4d851b079037e9b7dd3f8613dd1c8a4f3db99fa

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

LOG: [ARM][AAarch64] Initial command-line support for v8.7-A

This introduces command-line support for the 'armv8.7-a' architecture name
(and an alias without the '-', as usual), and for the 'ls64' extension name.

Based on patches written by Simon Tatham.

Reviewed By: ostannard

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

Added: 
clang/test/Driver/aarch64-ls64.c

Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-cpus.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/include/llvm/Support/AArch64TargetParser.h
llvm/lib/Support/AArch64TargetParser.cpp
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c8162dd55220..c1abe8e9f75b 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -196,6 +196,12 @@ void AArch64TargetInfo::getTargetDefinesARMV86A(const 
LangOptions ,
   getTargetDefinesARMV85A(Opts, Builder);
 }
 
+void AArch64TargetInfo::getTargetDefinesARMV87A(const LangOptions ,
+MacroBuilder ) const {
+  // Also include the Armv8.6 defines
+  getTargetDefinesARMV86A(Opts, Builder);
+}
+
 void AArch64TargetInfo::getTargetDefines(const LangOptions ,
  MacroBuilder ) const {
   // Target identification.
@@ -371,6 +377,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
,
   case llvm::AArch64::ArchKind::ARMV8_6A:
 getTargetDefinesARMV86A(Opts, Builder);
 break;
+  case llvm::AArch64::ArchKind::ARMV8_7A:
+getTargetDefinesARMV87A(Opts, Builder);
+break;
   }
 
   // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8) builtins work.
@@ -411,6 +420,7 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector ,
   HasFP16FML = false;
   HasMTE = false;
   HasTME = false;
+  HasLS64 = false;
   HasMatMul = false;
   HasBFloat16 = false;
   HasSVE2 = false;
@@ -486,6 +496,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector ,
   ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
 if (Feature == "+v8.6a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_6A;
+if (Feature == "+v8.7a")
+  ArchKind = llvm::AArch64::ArchKind::ARMV8_7A;
 if (Feature == "+v8r")
   ArchKind = llvm::AArch64::ArchKind::ARMV8R;
 if (Feature == "+fullfp16")
@@ -504,6 +516,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector ,
   HasBFloat16 = true;
 if (Feature == "+lse")
   HasLSE = true;
+if (Feature == "+ls64")
+  HasLS64 = true;
   }
 
   setDataLayout();

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index a70abb7bfd90..bd576680077e 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -36,6 +36,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasFP16FML;
   bool HasMTE;
   bool HasTME;
+  bool HasLS64;
   bool HasMatMul;
   bool HasSVE2;
   bool HasSVE2AES;
@@ -81,6 +82,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
MacroBuilder ) const;
   void getTargetDefinesARMV86A(const LangOptions ,
MacroBuilder ) const;
+  void getTargetDefinesARMV87A(const LangOptions ,
+   MacroBuilder ) const;
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override;
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 13e4cac292d0..a5e632fd8cdb 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -79,9 +79,10 @@ static bool DecodeAArch64Features(const Driver , StringRef 
text,
 else
   return false;
 
-// +sve implies +f32mm if the base architecture is v8.6A
+// +sve implies +f32mm if the base architecture is v8.6A or v8.7A
 // it isn't the case in general that sve implies both f64mm and f32mm
-if ((ArchKind == llvm::AArch64::ArchKind::ARMV8_6A) && Feature == "sve")
+if ((ArchKind == llvm::AArch64::ArchKind::ARMV8_6A ||
+ ArchKind == llvm::AArch64::ArchKind::ARMV8_7A) && Feature == "sve")
   Features.push_back("+f32mm");
   }
   return true;

diff  --git 

  1   2   >