[llvm-branch-commits] [libcxx] ba3adfa - [libc++] Mark LWG3200 as Nothing To Do. NFC.

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

Author: Marek Kurdej
Date: 2020-12-08T09:00:45+01:00
New Revision: ba3adfad6e00cf53dd12a021182ab6c179457574

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

LOG: [libc++] Mark LWG3200 as Nothing To Do. NFC.

This is only a wording change, because it is currently impossible to constrain 
the overload set on whether the type is complete or not.

Added: 


Modified: 
libcxx/docs/Cxx2aStatusIssuesStatus.csv

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusIssuesStatus.csv 
b/libcxx/docs/Cxx2aStatusIssuesStatus.csv
index 2d0af44a259e..3f371812eda7 100644
--- a/libcxx/docs/Cxx2aStatusIssuesStatus.csv
+++ b/libcxx/docs/Cxx2aStatusIssuesStatus.csv
@@ -196,7 +196,7 @@
 "`3150 `__","``UniformRandomBitGenerator``\  should 
validate ``min``\  and ``max``\ ","Prague","",""
 "`3175 `__","The ``CommonReference``\  requirement 
of concept ``SwappableWith``\  is not satisfied in the example","Prague","",""
 "`3194 `__","``ConvertibleTo``\  prose does not 
match code","Prague","",""
-"`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","",""
+"`3200 `__","``midpoint``\  should not constrain 
``T``\  is complete","Prague","|Nothing To Do|",""
 "`3201 `__","``lerp``\  should be marked as 
``noexcept``\ ","Prague","|Complete|",""
 "`3226 `__","``zoned_time``\  constructor from 
``string_view``\  should accept ``zoned_time``\ 
","Prague","",""
 "`3233 `__","Broken requirements for 
``shared_ptr``\  converting constructors","Prague","",""



___
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] 4415678 - Fix shtest-timeout test harder

2020-12-08 Thread David Blaikie via llvm-branch-commits

Author: David Blaikie
Date: 2020-12-08T00:23:33-08:00
New Revision: 4415678718ad471c84f024e20ce864ae1e79348a

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

LOG: Fix shtest-timeout test harder

Don't produce or expect any output from the infinite looping test -
doing so is a recipe for racey flakyness without a longer timeout to
ensure the output is received first, even though that doesn't seem
integral/important to the test. Instead have a plain, no output infinite
loop and check that that is caught and handled.

If for some reason the output is valuable for test coverage - the
timeout should be increased from 1 second to give the process time to
output the text, flush, and for that text to be received and buffered
before the test is timed out.

Added: 


Modified: 
llvm/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py
llvm/utils/lit/tests/shtest-timeout.py

Removed: 




diff  --git a/llvm/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py 
b/llvm/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py
index c8ced24f29c5..079f3595e175 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py
+++ b/llvm/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py
@@ -1,9 +1,3 @@
 # RUN: %{python} %s
-from __future__ import print_function
-
-import sys
-
-print("Running infinite loop")
-sys.stdout.flush() # Make sure the print gets flushed so it appears in lit 
output.
 while True:
 pass

diff  --git a/llvm/utils/lit/tests/shtest-timeout.py 
b/llvm/utils/lit/tests/shtest-timeout.py
index f229c286088b..1576b89ea182 100644
--- a/llvm/utils/lit/tests/shtest-timeout.py
+++ b/llvm/utils/lit/tests/shtest-timeout.py
@@ -25,7 +25,6 @@
 # RUN: FileCheck --check-prefix=CHECK-INTSH-ERR < %t.intsh.err %s
 
 # CHECK-INTSH-OUT: TIMEOUT: per_test_timeout :: infinite_loop.py
-# CHECK-INTSH-OUT: command output:
 # CHECK-INTSH-OUT: command reached timeout: True
 
 # CHECK-INTSH-ERR: Using internal shell



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


[llvm-branch-commits] [libcxx] a134477 - Revert "Add new 'preferred_name' attribute."

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

Author: Richard Smith
Date: 2020-12-08T00:42:48-08:00
New Revision: a1344779ab019a6bcd29842c1499343e15efbe87

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

LOG: Revert "Add new 'preferred_name' attribute."

This change exposed a pre-existing issue with deserialization cycles
caused by a combination of attributes and template instantiations
violating the deserialization ordering restrictions; see PR48434 for
details.

A previous commit attempted to work around PR48434, but appears to have
only been a partial fix, and fixing this properly seems non-trivial.
Backing out for now to unblock things.

This reverts commit 98f76adf4e941738c0b9fe3b9965fa63603e9c89 and
commit a64c26a47a81b1b44e36d235ff3bc6a74a0bad9f.

Added: 


Modified: 
clang/include/clang/AST/TypeProperties.td
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/TypePrinter.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/attributes.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
libcxx/include/__config
libcxx/include/iosfwd
libcxx/include/regex
libcxx/include/string
libcxx/include/string_view

Removed: 
clang/test/PCH/decl-attrs.cpp



diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index b582395c44a6..a183ac0479c6 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -484,12 +484,8 @@ let Class = TagType in {
 let Read = [{ node->isDependentType() }];
   }
   def : Property<"declaration", DeclRef> {
-// We don't know which declaration was originally referenced here, and we
-// cannot reference a declaration that follows the use (because that can
-// introduce deserialization cycles), so conservatively generate a
-// reference to the first declaration.
-// FIXME: If this is a reference to a class template specialization, that
-// can still introduce a deserialization cycle.
+// Serializing a reference to the canonical declaration is apparently
+// necessary to make module-merging work.
 let Read = [{ node->getDecl()->getCanonicalDecl() }];
   }
 }

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 51f654fc7613..52041201d22f 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -126,9 +126,6 @@ def FunctionTmpl
  FunctionDecl::TK_FunctionTemplate}],
 "function templates">;
 
-def ClassTmpl : SubsetSubjectgetDescribedClassTemplate()}],
-  "class templates">;
-
 // FIXME: this hack is needed because DeclNodes.td defines the base Decl node
 // type to be a class, not a definition. This makes it impossible to create an
 // attribute subject which accepts a Decl. Normally, this is not a problem,
@@ -2394,16 +2391,6 @@ def Pascal : DeclOrTypeAttr {
   let Documentation = [Undocumented];
 }
 
-def PreferredName : InheritableAttr {
-  let Spellings = [Clang<"preferred_name", /*AllowInC*/0>];
-  let Subjects = SubjectList<[ClassTmpl]>;
-  let Args = [TypeArgument<"TypedefType">];
-  let Documentation = [PreferredNameDocs];
-  let InheritEvenIfAlreadyPresent = 1;
-  let MeaningfulToClassTemplateDefinition = 1;
-  let TemplateDependent = 1;
-}
-
 def PreserveMost : DeclOrTypeAttr {
   let Spellings = [Clang<"preserve_most">];
   let Documentation = [PreserveMostDocs];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 28f35cf2c0c7..e7e2805a9608 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4471,30 +4471,6 @@ the old mangled name and the new code will use the new 
mangled name with tags.
   }];
 }
 
-def PreferredNameDocs : Documentation {
-  let Category = DocCatDecl;
-  let Content = [{
-The ``preferred_name`` attribute can be applied to a class template, and
-specifies a preferred way of naming a specialization of the template. The
-preferred name will be used whenever the corresponding template specialization
-would otherwise be printed in a diagnostic or similar context.
-
-The preferred name must be a typedef or type alias declaration that refers to a
-specialization of the class template (not including any type qualifiers). In
-general this requires the template to be declared at least twice. For example:
-
-.. code-block:: c++
-
-  template struct basic_string;
-  using string = basic_string;
-  using wstring = basic_string;
-  template struct [[clang::preferred_name(string),
- 

[llvm-branch-commits] [llvm] 6c3f56e - [SLP][Test] Differentiate SSE/AVX512 test coverage (NFC)

2020-12-08 Thread Anton Afanasyev via llvm-branch-commits

Author: Anton Afanasyev
Date: 2020-12-08T12:00:52+03:00
New Revision: 6c3f56efa6e6ca746ba3dafae43251105f16e5fb

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

LOG: [SLP][Test] Differentiate SSE/AVX512 test coverage (NFC)

Add test coverage for SSE/AVX512 for insert-after-bundle.ll test.
Prepare this test for accurate showing of PR46983 fix.

Added: 


Modified: 
llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll

Removed: 




diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll
index 2a4d457f1063..fa1183400cb0 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/insert-after-bundle.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -slp-vectorizer < %s | FileCheck %s
+; RUN: opt -S -slp-vectorizer -mattr=+sse  < %s | FileCheck %s 
--check-prefixes=CHECK,SSE
+; RUN: opt -S -slp-vectorizer -mattr=+avx512f < %s | FileCheck %s 
--check-prefixes=CHECK,AVX512
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
@@ -410,75 +411,109 @@ for.end:  ; 
preds = %for.body
 @ia = common local_unnamed_addr global [64 x i32] zeroinitializer, align 16
 
 define i32 @foo1() local_unnamed_addr #0 {
-; CHECK-LABEL: @foo1(
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[TMP0:%.*]] = load <4 x i32>, <4 x i32>* bitcast ([64 x 
i32]* @ib to <4 x i32>*), align 16
-; CHECK-NEXT:[[TMP1:%.*]] = xor <4 x i32> [[TMP0]], 
-; CHECK-NEXT:store <4 x i32> [[TMP1]], <4 x i32>* bitcast ([64 x i32]* @ia 
to <4 x i32>*), align 16
-; CHECK-NEXT:[[TMP2:%.*]] = load <4 x i32>, <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ib, i64 0, i64 4) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP3:%.*]] = xor <4 x i32> [[TMP2]], 
-; CHECK-NEXT:store <4 x i32> [[TMP3]], <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ia, i64 0, i64 4) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP4:%.*]] = load <4 x i32>, <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ib, i64 0, i64 8) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP5:%.*]] = xor <4 x i32> [[TMP4]], 
-; CHECK-NEXT:store <4 x i32> [[TMP5]], <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ia, i64 0, i64 8) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP6:%.*]] = load <4 x i32>, <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ib, i64 0, i64 12) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP7:%.*]] = xor <4 x i32> [[TMP6]], 
-; CHECK-NEXT:store <4 x i32> [[TMP7]], <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ia, i64 0, i64 12) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP8:%.*]] = load <4 x i32>, <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ib, i64 0, i64 16) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP9:%.*]] = xor <4 x i32> [[TMP8]], 
-; CHECK-NEXT:store <4 x i32> [[TMP9]], <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ia, i64 0, i64 16) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP10:%.*]] = load <4 x i32>, <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ib, i64 0, i64 20) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP11:%.*]] = xor <4 x i32> [[TMP10]], 
-; CHECK-NEXT:store <4 x i32> [[TMP11]], <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ia, i64 0, i64 20) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP12:%.*]] = load <4 x i32>, <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ib, i64 0, i64 24) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP13:%.*]] = xor <4 x i32> [[TMP12]], 
-; CHECK-NEXT:store <4 x i32> [[TMP13]], <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ia, i64 0, i64 24) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP14:%.*]] = load <4 x i32>, <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ib, i64 0, i64 28) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP15:%.*]] = xor <4 x i32> [[TMP14]], 
-; CHECK-NEXT:store <4 x i32> [[TMP15]], <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ia, i64 0, i64 28) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP16:%.*]] = load <4 x i32>, <4 x i32>* bitcast (i32* 
getelementptr inbounds ([64 x i32], [64 x i32]* @ib, i64 0, i64 32) to <4 x 
i32>*), align 16
-; CHECK-NEXT:[[TMP17:%.*]] = xor <4 x i32> [[TMP16]], 
-; CHECK-NEXT:store <4 x i32> [[TMP17]], <4 x i32

[llvm-branch-commits] [clang] ca93f9a - [Clang][CodeGen][RISCV] Add hard float ABI tests with empty struct

2020-12-08 Thread Luís Marques via llvm-branch-commits

Author: Luís Marques
Date: 2020-12-08T09:19:05Z
New Revision: ca93f9abdc0abc96ca8fb7999549a50aadd95caf

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

LOG: [Clang][CodeGen][RISCV] Add hard float ABI tests with empty struct

This patch adds tests that showcase a behavior that is currently buggy.
Fix in a follow-up patch.

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

Added: 
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
new file mode 100644
index ..ffebb057e230
--- /dev/null
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d \
+// RUN: -Wno-missing-declarations -emit-llvm %s -o - | FileCheck %s
+
+struct empty_float2 { struct {}; float f; float g; };
+
+// CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
+// FIXME: Extraneous padding before the second float
+// CHECK: { [4 x i8], float, [4 x i8], float }
+float f_empty_float2(empty_float2 a) {
+return a.g;
+}
+
+struct empty_double2 { struct {}; double f; double g; };
+
+// CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double 
%1)
+// FIXME: Extraneous padding before the second double
+// CHECK: { [8 x i8], double, [8 x i8], double }
+double f_empty_double2(empty_double2 a) {
+return a.g;
+}
+
+struct empty_float_double { struct {}; float f; double g; };
+
+// CHECK: define double @_Z20f_empty_float_double18empty_float_double(float 
%0, double %1)
+// CHECK: { [4 x i8], float, double }
+double f_empty_float_double(empty_float_double a) {
+return a.g;
+}
+
+struct empty_double_float { struct {}; double f; float g; };
+
+// CHECK: define double @_Z20f_empty_double_float18empty_double_float(double 
%0, float %1)
+// FIXME: Extraneous padding before the float
+// CHECK: { [8 x i8], double, [8 x i8], float }
+double f_empty_double_float(empty_double_float a) {
+return a.g;
+}



___
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] fa8f5bf - [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

2020-12-08 Thread Luís Marques via llvm-branch-commits

Author: Luís Marques
Date: 2020-12-08T09:19:05Z
New Revision: fa8f5bfa4e8cff042c9730320c74e97fab152ae1

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

LOG: [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

The code seemed not to account for the field 1 offset.

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 7213f7864d43..05c12dfe0458 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10520,7 +10520,7 @@ bool RISCVABIInfo::detectFPCCEligibleStruct(QualType 
Ty, llvm::Type *&Field1Ty,
 NeededArgFPRs++;
   else if (Field2Ty)
 NeededArgGPRs++;
-  return IsCandidate;
+  return true;
 }
 
 // Call getCoerceAndExpand for the two-element flattened struct described by
@@ -10546,15 +10546,15 @@ ABIArgInfo 
RISCVABIInfo::coerceAndExpandFPCCEligibleStruct(
 
   CharUnits Field2Align =
   CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(Field2Ty));
-  CharUnits Field1Size =
+  CharUnits Field1End = Field1Off +
   CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty));
-  CharUnits Field2OffNoPadNoPack = Field1Size.alignTo(Field2Align);
+  CharUnits Field2OffNoPadNoPack = Field1End.alignTo(Field2Align);
 
   CharUnits Padding = CharUnits::Zero();
   if (Field2Off > Field2OffNoPadNoPack)
 Padding = Field2Off - Field2OffNoPadNoPack;
-  else if (Field2Off != Field2Align && Field2Off > Field1Size)
-Padding = Field2Off - Field1Size;
+  else if (Field2Off != Field2Align && Field2Off > Field1End)
+Padding = Field2Off - Field1End;
 
   bool IsPacked = !Field2Off.isMultipleOf(Field2Align);
 

diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
index ffebb057e230..1018c78e168b 100644
--- a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -4,8 +4,7 @@
 struct empty_float2 { struct {}; float f; float g; };
 
 // CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
-// FIXME: Extraneous padding before the second float
-// CHECK: { [4 x i8], float, [4 x i8], float }
+// CHECK: { [4 x i8], float, float }
 float f_empty_float2(empty_float2 a) {
 return a.g;
 }
@@ -13,8 +12,7 @@ float f_empty_float2(empty_float2 a) {
 struct empty_double2 { struct {}; double f; double g; };
 
 // CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double 
%1)
-// FIXME: Extraneous padding before the second double
-// CHECK: { [8 x i8], double, [8 x i8], double }
+// CHECK: { [8 x i8], double, double }
 double f_empty_double2(empty_double2 a) {
 return a.g;
 }
@@ -30,8 +28,7 @@ double f_empty_float_double(empty_float_double a) {
 struct empty_double_float { struct {}; double f; float g; };
 
 // CHECK: define double @_Z20f_empty_double_float18empty_double_float(double 
%0, float %1)
-// FIXME: Extraneous padding before the float
-// CHECK: { [8 x i8], double, [8 x i8], float }
+// CHECK: { [8 x i8], double, float }
 double f_empty_double_float(empty_double_float a) {
 return a.g;
 }



___
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] 3af354e - [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct and complex

2020-12-08 Thread Luís Marques via llvm-branch-commits

Author: Luís Marques
Date: 2020-12-08T09:19:05Z
New Revision: 3af354e863f553ef727967dfc091a64a11500aa5

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

LOG: [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct 
and complex

Fixes bug 44904.

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 05c12dfe0458..d4191b943ef5 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10425,7 +10425,6 @@ bool 
RISCVABIInfo::detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff,
   return false;
 Field1Ty = CGT.ConvertType(EltTy);
 Field1Off = CurOff;
-assert(CurOff.isZero() && "Unexpected offset for first field");
 Field2Ty = Field1Ty;
 Field2Off = Field1Off + getContext().getTypeSizeInChars(EltTy);
 return true;

diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
index 1018c78e168b..26d968be97df 100644
--- a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -32,3 +32,19 @@ struct empty_double_float { struct {}; double f; float g; };
 double f_empty_double_float(empty_double_float a) {
 return a.g;
 }
+
+struct empty_complex_f { struct {}; float _Complex fc; };
+
+// CHECK: define float @_Z17f_empty_complex_f15empty_complex_f(float %0, float 
%1)
+// CHECK: { [4 x i8], float, float }
+float f_empty_complex_f(empty_complex_f a) {
+return __imag__ a.fc;
+}
+
+struct empty_complex_d { struct {}; double _Complex fc; };
+
+// CHECK: define double @_Z17f_empty_complex_d15empty_complex_d(double %0, 
double %1)
+// CHECK: { [8 x i8], double, double }
+double f_empty_complex_d(empty_complex_d a) {
+return __imag__ a.fc;
+}



___
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] ca93f9a - [Clang][CodeGen][RISCV] Add hard float ABI tests with empty struct

2020-12-08 Thread Luís Marques via llvm-branch-commits

Author: Luís Marques
Date: 2020-12-08T09:19:05Z
New Revision: ca93f9abdc0abc96ca8fb7999549a50aadd95caf

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

LOG: [Clang][CodeGen][RISCV] Add hard float ABI tests with empty struct

This patch adds tests that showcase a behavior that is currently buggy.
Fix in a follow-up patch.

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

Added: 
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
new file mode 100644
index ..ffebb057e230
--- /dev/null
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d \
+// RUN: -Wno-missing-declarations -emit-llvm %s -o - | FileCheck %s
+
+struct empty_float2 { struct {}; float f; float g; };
+
+// CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
+// FIXME: Extraneous padding before the second float
+// CHECK: { [4 x i8], float, [4 x i8], float }
+float f_empty_float2(empty_float2 a) {
+return a.g;
+}
+
+struct empty_double2 { struct {}; double f; double g; };
+
+// CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double 
%1)
+// FIXME: Extraneous padding before the second double
+// CHECK: { [8 x i8], double, [8 x i8], double }
+double f_empty_double2(empty_double2 a) {
+return a.g;
+}
+
+struct empty_float_double { struct {}; float f; double g; };
+
+// CHECK: define double @_Z20f_empty_float_double18empty_float_double(float 
%0, double %1)
+// CHECK: { [4 x i8], float, double }
+double f_empty_float_double(empty_float_double a) {
+return a.g;
+}
+
+struct empty_double_float { struct {}; double f; float g; };
+
+// CHECK: define double @_Z20f_empty_double_float18empty_double_float(double 
%0, float %1)
+// FIXME: Extraneous padding before the float
+// CHECK: { [8 x i8], double, [8 x i8], float }
+double f_empty_double_float(empty_double_float a) {
+return a.g;
+}



___
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] 3af354e - [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct and complex

2020-12-08 Thread Luís Marques via llvm-branch-commits

Author: Luís Marques
Date: 2020-12-08T09:19:05Z
New Revision: 3af354e863f553ef727967dfc091a64a11500aa5

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

LOG: [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct 
and complex

Fixes bug 44904.

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 05c12dfe0458..d4191b943ef5 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10425,7 +10425,6 @@ bool 
RISCVABIInfo::detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff,
   return false;
 Field1Ty = CGT.ConvertType(EltTy);
 Field1Off = CurOff;
-assert(CurOff.isZero() && "Unexpected offset for first field");
 Field2Ty = Field1Ty;
 Field2Off = Field1Off + getContext().getTypeSizeInChars(EltTy);
 return true;

diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
index 1018c78e168b..26d968be97df 100644
--- a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -32,3 +32,19 @@ struct empty_double_float { struct {}; double f; float g; };
 double f_empty_double_float(empty_double_float a) {
 return a.g;
 }
+
+struct empty_complex_f { struct {}; float _Complex fc; };
+
+// CHECK: define float @_Z17f_empty_complex_f15empty_complex_f(float %0, float 
%1)
+// CHECK: { [4 x i8], float, float }
+float f_empty_complex_f(empty_complex_f a) {
+return __imag__ a.fc;
+}
+
+struct empty_complex_d { struct {}; double _Complex fc; };
+
+// CHECK: define double @_Z17f_empty_complex_d15empty_complex_d(double %0, 
double %1)
+// CHECK: { [8 x i8], double, double }
+double f_empty_complex_d(empty_complex_d a) {
+return __imag__ a.fc;
+}



___
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] fa8f5bf - [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

2020-12-08 Thread Luís Marques via llvm-branch-commits

Author: Luís Marques
Date: 2020-12-08T09:19:05Z
New Revision: fa8f5bfa4e8cff042c9730320c74e97fab152ae1

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

LOG: [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

The code seemed not to account for the field 1 offset.

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 7213f7864d43..05c12dfe0458 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10520,7 +10520,7 @@ bool RISCVABIInfo::detectFPCCEligibleStruct(QualType 
Ty, llvm::Type *&Field1Ty,
 NeededArgFPRs++;
   else if (Field2Ty)
 NeededArgGPRs++;
-  return IsCandidate;
+  return true;
 }
 
 // Call getCoerceAndExpand for the two-element flattened struct described by
@@ -10546,15 +10546,15 @@ ABIArgInfo 
RISCVABIInfo::coerceAndExpandFPCCEligibleStruct(
 
   CharUnits Field2Align =
   CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(Field2Ty));
-  CharUnits Field1Size =
+  CharUnits Field1End = Field1Off +
   CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty));
-  CharUnits Field2OffNoPadNoPack = Field1Size.alignTo(Field2Align);
+  CharUnits Field2OffNoPadNoPack = Field1End.alignTo(Field2Align);
 
   CharUnits Padding = CharUnits::Zero();
   if (Field2Off > Field2OffNoPadNoPack)
 Padding = Field2Off - Field2OffNoPadNoPack;
-  else if (Field2Off != Field2Align && Field2Off > Field1Size)
-Padding = Field2Off - Field1Size;
+  else if (Field2Off != Field2Align && Field2Off > Field1End)
+Padding = Field2Off - Field1End;
 
   bool IsPacked = !Field2Off.isMultipleOf(Field2Align);
 

diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp 
b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
index ffebb057e230..1018c78e168b 100644
--- a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -4,8 +4,7 @@
 struct empty_float2 { struct {}; float f; float g; };
 
 // CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
-// FIXME: Extraneous padding before the second float
-// CHECK: { [4 x i8], float, [4 x i8], float }
+// CHECK: { [4 x i8], float, float }
 float f_empty_float2(empty_float2 a) {
 return a.g;
 }
@@ -13,8 +12,7 @@ float f_empty_float2(empty_float2 a) {
 struct empty_double2 { struct {}; double f; double g; };
 
 // CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double 
%1)
-// FIXME: Extraneous padding before the second double
-// CHECK: { [8 x i8], double, [8 x i8], double }
+// CHECK: { [8 x i8], double, double }
 double f_empty_double2(empty_double2 a) {
 return a.g;
 }
@@ -30,8 +28,7 @@ double f_empty_float_double(empty_float_double a) {
 struct empty_double_float { struct {}; double f; float g; };
 
 // CHECK: define double @_Z20f_empty_double_float18empty_double_float(double 
%0, float %1)
-// FIXME: Extraneous padding before the float
-// CHECK: { [8 x i8], double, [8 x i8], float }
+// CHECK: { [8 x i8], double, float }
 double f_empty_double_float(empty_double_float a) {
 return a.g;
 }



___
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] 2fe30a3 - [mlir] properly support min/max in affine parallelization

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

Author: Alex Zinenko
Date: 2020-12-08T10:43:35+01:00
New Revision: 2fe30a3534dad9f982a3d840b4bfa4870b2ba5bc

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

LOG: [mlir] properly support min/max in affine parallelization

The existing implementation of the affine parallelization silently copies over
the lower and upper bound maps from affine.for to affine.parallel. However, the
semantics of these maps differ between these two ops: in affine.for, a max(min)
of results is taken for the lower(upper) bound; in affine.parallel, multiple
induction variables can be defined an each result corresponds to one induction
variable. Thus the existing implementation could generate invalid IR or IR that
passes the verifier but has different semantics than the original code. Fix the
parallelization utility to emit dedicated min/max operations before the
affine.parallel in such cases. Disallow parallelization if min/max would have
been in an operation without the AffineScope trait, e.g., in another loop,
since the result of these operations is not considered a valid affine dimension
identifier and may not be properly handled by the affine analyses.

Reviewed By: wsmoses

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

Added: 


Modified: 
mlir/lib/Dialect/Affine/Utils/Utils.cpp
mlir/test/Dialect/Affine/parallelize.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp 
b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
index 7892dfbc7a48..e5f5a6d8998f 100644
--- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
@@ -134,11 +134,43 @@ static AffineIfOp hoistAffineIfOp(AffineIfOp ifOp, 
Operation *hoistOverOp) {
 void mlir::affineParallelize(AffineForOp forOp) {
   Location loc = forOp.getLoc();
   OpBuilder outsideBuilder(forOp);
+
+  // If a loop has a 'max' in the lower bound, emit it outside the parallel 
loop
+  // as it does not have implicit 'max' behavior.
+  AffineMap lowerBoundMap = forOp.getLowerBoundMap();
+  ValueRange lowerBoundOperands = forOp.getLowerBoundOperands();
+  AffineMap upperBoundMap = forOp.getUpperBoundMap();
+  ValueRange upperBoundOperands = forOp.getUpperBoundOperands();
+
+  bool needsMax = lowerBoundMap.getNumResults() > 1;
+  bool needsMin = upperBoundMap.getNumResults() > 1;
+  AffineMap identityMap;
+  if (needsMax || needsMin) {
+if (forOp->getParentOp() &&
+!forOp->getParentOp()->hasTrait())
+  return;
+
+identityMap = AffineMap::getMultiDimIdentityMap(1, loc->getContext());
+  }
+  if (needsMax) {
+auto maxOp = outsideBuilder.create(loc, lowerBoundMap,
+lowerBoundOperands);
+lowerBoundMap = identityMap;
+lowerBoundOperands = maxOp->getResults();
+  }
+
+  // Same for the upper bound.
+  if (needsMin) {
+auto minOp = outsideBuilder.create(loc, upperBoundMap,
+upperBoundOperands);
+upperBoundMap = identityMap;
+upperBoundOperands = minOp->getResults();
+  }
+
   // Creating empty 1-D affine.parallel op.
   AffineParallelOp newPloop = outsideBuilder.create(
-  loc, llvm::None, llvm::None, forOp.getLowerBoundMap(),
-  forOp.getLowerBoundOperands(), forOp.getUpperBoundMap(),
-  forOp.getUpperBoundOperands());
+  loc, llvm::None, llvm::None, lowerBoundMap, lowerBoundOperands,
+  upperBoundMap, upperBoundOperands);
   // Steal the body of the old affine for op and erase it.
   newPloop.region().takeBody(forOp.region());
   forOp.erase();

diff  --git a/mlir/test/Dialect/Affine/parallelize.mlir 
b/mlir/test/Dialect/Affine/parallelize.mlir
index 8e6cb05f46a0..cbc80a092e76 100644
--- a/mlir/test/Dialect/Affine/parallelize.mlir
+++ b/mlir/test/Dialect/Affine/parallelize.mlir
@@ -114,3 +114,33 @@ func @non_affine_load() {
   }
   return
 }
+
+// CHECK-LABEL: for_with_minmax
+func @for_with_minmax(%m: memref, %lb0: index, %lb1: index,
+  %ub0: index, %ub1: index) {
+  // CHECK: %[[lb:.*]] = affine.max
+  // CHECK: %[[ub:.*]] = affine.min
+  // CHECK: affine.parallel (%{{.*}}) = (%[[lb]]) to (%[[ub]])
+  affine.for %i = max affine_map<(d0, d1) -> (d0, d1)>(%lb0, %lb1)
+  to min affine_map<(d0, d1) -> (d0, d1)>(%ub0, %ub1) {
+affine.load %m[%i] : memref
+  }
+  return
+}
+
+// CHECK-LABEL: nested_for_with_minmax
+func @nested_for_with_minmax(%m: memref, %lb0: index,
+ %ub0: index, %ub1: index) {
+  // CHECK: affine.parallel
+  affine.for %j = 0 to 10 {
+// Cannot parallelize the inner loop because we would need to compute
+// affine.max for its lower bound inside the loop, and that is not (yet)
+// considered as a valid affine dimension.
+// CHECK: affine.for
+affine.for %

[llvm-branch-commits] [mlir] 80766ec - [mlir] Add an option to control the number of loops in affine parallelizer

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

Author: Alex Zinenko
Date: 2020-12-08T10:44:37+01:00
New Revision: 80766ecc65096deeb4ff6f03562dcad94c54b862

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

LOG: [mlir] Add an option to control the number of loops in affine parallelizer

Add a pass option to control the number of nested parallel loops produced by
the parallelization passes. This is useful to build end-to-end passes targeting
systems that don't need multiple parallel dimensions (e.g., CPUs typically need
only one).

Reviewed By: wsmoses, chelini

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Affine/Passes.td
mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp
mlir/test/Dialect/Affine/parallelize.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Affine/Passes.td 
b/mlir/include/mlir/Dialect/Affine/Passes.td
index ace272692d66..9f2aac7b685a 100644
--- a/mlir/include/mlir/Dialect/Affine/Passes.td
+++ b/mlir/include/mlir/Dialect/Affine/Passes.td
@@ -118,6 +118,11 @@ def AffineVectorize : 
FunctionPass<"affine-super-vectorize"> {
 def AffineParallelize : FunctionPass<"affine-parallelize"> {
   let summary = "Convert affine.for ops into 1-D affine.parallel";
   let constructor = "mlir::createAffineParallelizePass()";
+  let options = [
+Option<"maxNested", "max-nested", "unsigned", /*default=*/"-1u",
+   "Maximum number of nested parallel loops to produce. "
+   "Defaults to unlimited (UINT_MAX).">,
+  ];
 }
 
 def AffineLoopNormalize : FunctionPass<"affine-loop-normalize"> {

diff  --git a/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp 
b/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp
index b3651e202245..d8511be326dd 100644
--- a/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/AffineParallelize.cpp
@@ -36,13 +36,28 @@ struct AffineParallelize : public 
AffineParallelizeBase {
 
 void AffineParallelize::runOnFunction() {
   FuncOp f = getFunction();
-  SmallVector parallelizableLoops;
+
+  // The walker proceeds in post-order, but we need to process outer loops 
first
+  // to control the number of outer parallel loops, so push candidate loops to
+  // the front of a deque.
+  std::deque parallelizableLoops;
   f.walk([&](AffineForOp loop) {
 if (isLoopParallel(loop))
-  parallelizableLoops.push_back(loop);
+  parallelizableLoops.push_front(loop);
   });
-  for (AffineForOp loop : parallelizableLoops)
-affineParallelize(loop);
+
+  for (AffineForOp loop : parallelizableLoops) {
+unsigned numParentParallelOps = 0;
+for (Operation *op = loop->getParentOp();
+ op != nullptr && !op->hasTrait();
+ op = op->getParentOp()) {
+  if (isa(op))
+++numParentParallelOps;
+}
+
+if (numParentParallelOps < maxNested)
+  affineParallelize(loop);
+  }
 }
 
 std::unique_ptr> mlir::createAffineParallelizePass() {

diff  --git a/mlir/test/Dialect/Affine/parallelize.mlir 
b/mlir/test/Dialect/Affine/parallelize.mlir
index cbc80a092e76..08aaa7f32fc8 100644
--- a/mlir/test/Dialect/Affine/parallelize.mlir
+++ b/mlir/test/Dialect/Affine/parallelize.mlir
@@ -1,4 +1,5 @@
 // RUN: mlir-opt %s -allow-unregistered-dialect -affine-parallelize| FileCheck 
%s
+// RUN: mlir-opt %s -allow-unregistered-dialect 
-affine-parallelize='max-nested=1' | FileCheck --check-prefix=MAX-NESTED %s
 
 // CHECK-LABEL:func @reduce_window_max() {
 func @reduce_window_max() {
@@ -144,3 +145,18 @@ func @nested_for_with_minmax(%m: memref, %lb0: 
index,
   }
   return
 }
+
+// MAX-NESTED-LABEL: @max_nested
+func @max_nested(%m: memref, %lb0: index, %lb1: index,
+ %ub0: index, %ub1: index) {
+  // MAX-NESTED: affine.parallel
+  affine.for %i = affine_map<(d0) -> (d0)>(%lb0) to affine_map<(d0) -> 
(d0)>(%ub0) {
+// MAX-NESTED: affine.for
+affine.for %j = affine_map<(d0) -> (d0)>(%lb1) to affine_map<(d0) -> 
(d0)>(%ub1) {
+  affine.load %m[%i, %j] : memref
+}
+  }
+  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] [llvm] 2d1b024 - [DSE][NFC] Need to be carefull mixing signed and unsigned types

2020-12-08 Thread Evgeniy Brevnov via llvm-branch-commits

Author: Evgeniy Brevnov
Date: 2020-12-08T16:53:37+07:00
New Revision: 2d1b024d06b2a81f1c35193a998a864be09e2ae8

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

LOG: [DSE][NFC] Need to be carefull mixing signed and unsigned types

Currently in some places we use signed type to represent size of an access and 
put explicit casts from unsigned to signed.
For example: int64_t EarlierSize = int64_t(Loc.Size.getValue());

Even though it doesn't loos bits (immidiatly) it may overflow and we end up 
with negative size. Potentially that cause later code to work incorrectly. A 
simple expample is a check that size is not negative.

I think it would be safer and clearer if we use unsigned type for the size and 
handle it appropriately.

Reviewed By: fhahn

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp 
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 9499e892871f..e4b8980b01e8 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1071,8 +1071,8 @@ static bool handleEndBlock(BasicBlock &BB, AliasAnalysis 
*AA,
 }
 
 static bool tryToShorten(Instruction *EarlierWrite, int64_t &EarlierOffset,
- int64_t &EarlierSize, int64_t LaterOffset,
- int64_t LaterSize, bool IsOverwriteEnd) {
+ uint64_t &EarlierSize, int64_t LaterOffset,
+ uint64_t LaterSize, bool IsOverwriteEnd) {
   // TODO: base this on the target vector size so that if the earlier
   // store was too small to get vector writes anyway then its likely
   // a good idea to shorten it
@@ -1127,16 +1127,23 @@ static bool tryToShorten(Instruction *EarlierWrite, 
int64_t &EarlierOffset,
 
 static bool tryToShortenEnd(Instruction *EarlierWrite,
 OverlapIntervalsTy &IntervalMap,
-int64_t &EarlierStart, int64_t &EarlierSize) {
+int64_t &EarlierStart, uint64_t &EarlierSize) {
   if (IntervalMap.empty() || !isShortenableAtTheEnd(EarlierWrite))
 return false;
 
   OverlapIntervalsTy::iterator OII = --IntervalMap.end();
   int64_t LaterStart = OII->second;
-  int64_t LaterSize = OII->first - LaterStart;
+  uint64_t LaterSize = OII->first - LaterStart;
 
-  if (LaterStart > EarlierStart && LaterStart < EarlierStart + EarlierSize &&
-  LaterStart + LaterSize >= EarlierStart + EarlierSize) {
+  assert(OII->first - LaterStart >= 0 && "Size expected to be positive");
+
+  if (LaterStart > EarlierStart &&
+  // Note: "LaterStart - EarlierStart" is known to be positive due to
+  // preceding check.
+  (uint64_t)(LaterStart - EarlierStart) < EarlierSize &&
+  // Note: "EarlierSize - (uint64_t)(LaterStart - EarlierStart)" is known 
to
+  // be non negative due to preceding checks.
+  LaterSize >= EarlierSize - (uint64_t)(LaterStart - EarlierStart)) {
 if (tryToShorten(EarlierWrite, EarlierStart, EarlierSize, LaterStart,
  LaterSize, true)) {
   IntervalMap.erase(OII);
@@ -1148,16 +1155,23 @@ static bool tryToShortenEnd(Instruction *EarlierWrite,
 
 static bool tryToShortenBegin(Instruction *EarlierWrite,
   OverlapIntervalsTy &IntervalMap,
-  int64_t &EarlierStart, int64_t &EarlierSize) {
+  int64_t &EarlierStart, uint64_t &EarlierSize) {
   if (IntervalMap.empty() || !isShortenableAtTheBeginning(EarlierWrite))
 return false;
 
   OverlapIntervalsTy::iterator OII = IntervalMap.begin();
   int64_t LaterStart = OII->second;
-  int64_t LaterSize = OII->first - LaterStart;
+  uint64_t LaterSize = OII->first - LaterStart;
+
+  assert(OII->first - LaterStart >= 0 && "Size expected to be positive");
 
-  if (LaterStart <= EarlierStart && LaterStart + LaterSize > EarlierStart) {
-assert(LaterStart + LaterSize < EarlierStart + EarlierSize &&
+  if (LaterStart <= EarlierStart &&
+  // Note: "EarlierStart - LaterStart" is known to be non negative due to
+  // preceding check.
+  LaterSize > (uint64_t)(EarlierStart - LaterStart)) {
+// Note: "LaterSize - (uint64_t)(EarlierStart - LaterStart)" is known to be
+// positive due to preceding checks.
+assert(LaterSize - (uint64_t)(EarlierStart - LaterStart) < EarlierSize &&
"Should have been handled as OW_Complete");
 if (tryToShorten(EarlierWrite, EarlierStart, EarlierSize, LaterStart,
  LaterSize, false)) {
@@ -1179,7 +1193,7 @@ static bool removePartiallyOverlappedStores(const 
DataLayout &DL

[llvm-branch-commits] [llvm] 83b52b5 - [JITLink][ELF] Route objects to their matching linker backends based on header info

2020-12-08 Thread Stefan Gränitz via llvm-branch-commits

Author: Stefan Gränitz
Date: 2020-12-08T10:56:01+01:00
New Revision: 83b52b5ba27815200e76343f2a2f1614bb1960d9

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

LOG: [JITLink][ELF] Route objects to their matching linker backends based on 
header info

Distinguish objects by target properties address size, endian and machine 
architecture. So far we only
support x86-64 (ELFCLASS64, ELFDATA2LSB, EM_X86_64).

Reviewed By: lhames

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

Added: 


Modified: 
llvm/lib/ExecutionEngine/JITLink/ELF.cpp

Removed: 




diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF.cpp 
b/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
index 6160583b13fe5..19b8782577097 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
@@ -15,6 +15,7 @@
 
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/ExecutionEngine/JITLink/ELF_x86_64.h"
+#include "llvm/Object/ELF.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -27,24 +28,56 @@ using namespace llvm;
 namespace llvm {
 namespace jitlink {
 
-void jitLink_ELF(std::unique_ptr Ctx) {
+Expected readTargetMachineArch(StringRef Buffer) {
+  const char *Data = Buffer.data();
 
-  // We don't want to do full ELF validation here. We just verify it is 
elf'ish.
-  // Probably should parse into an elf header when we support more than x86 :)
+  if (Data[ELF::EI_DATA] == ELF::ELFDATA2LSB) {
+if (Data[ELF::EI_CLASS] == ELF::ELFCLASS64) {
+  if (auto File = llvm::object::ELF64LEFile::create(Buffer)) {
+return File->getHeader().e_machine;
+  } else {
+return File.takeError();
+  }
+} else if (Data[ELF::EI_CLASS] == ELF::ELFCLASS32) {
+  if (auto File = llvm::object::ELF32LEFile::create(Buffer)) {
+return File->getHeader().e_machine;
+  } else {
+return File.takeError();
+  }
+}
+  }
 
-  StringRef Data = Ctx->getObjectBuffer().getBuffer();
-  if (Data.size() < llvm::ELF::EI_MAG3 + 1) {
+  return ELF::EM_NONE;
+}
+
+void jitLink_ELF(std::unique_ptr Ctx) {
+  StringRef Buffer = Ctx->getObjectBuffer().getBuffer();
+  if (Buffer.size() < ELF::EI_MAG3 + 1) {
 Ctx->notifyFailed(make_error("Truncated ELF buffer"));
 return;
   }
 
-  if (!memcmp(Data.data(), llvm::ELF::ElfMagic, strlen(llvm::ELF::ElfMagic))) {
-if (Data.data()[llvm::ELF::EI_CLASS] == ELF::ELFCLASS64) {
-  return jitLink_ELF_x86_64(std::move(Ctx));
-}
+  if (memcmp(Buffer.data(), ELF::ElfMagic, strlen(ELF::ElfMagic)) != 0) {
+Ctx->notifyFailed(make_error("ELF magic not valid"));
+return;
+  }
+
+  Expected TargetMachineArch = readTargetMachineArch(Buffer);
+  if (!TargetMachineArch) {
+Ctx->notifyFailed(TargetMachineArch.takeError());
+return;
   }
 
-  Ctx->notifyFailed(make_error("ELF magic not valid"));
+  switch (*TargetMachineArch) {
+  case ELF::EM_X86_64:
+jitLink_ELF_x86_64(std::move(Ctx));
+return;
+  default:
+Ctx->notifyFailed(make_error(
+"Unsupported target machine architecture in ELF object " +
+Ctx->getObjectBuffer().getBufferIdentifier()));
+return;
+  }
 }
 
 } // end namespace jitlink



___
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] c54d827 - [Orc] Two small fixes in TPCDynamicLibrarySearchGenerator

2020-12-08 Thread Stefan Gränitz via llvm-branch-commits

Author: Stefan Gränitz
Date: 2020-12-08T10:58:20+01:00
New Revision: c54d827fdb12d033dca2155c416f02791fc86786

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

LOG: [Orc] Two small fixes in TPCDynamicLibrarySearchGenerator

There is one result per lookup symbol, so we have to advance the result 
iterator no matter whether it's NULL or not.
MissingSymbols variable is unused.

Reviewed By: lhames

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

Added: 


Modified: 
llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp

Removed: 




diff  --git a/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp 
b/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp
index f275c634a6d5..80d8f34ea447 100644
--- a/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp
@@ -50,12 +50,13 @@ Error TPCDynamicLibrarySearchGenerator::tryToGenerate(
   assert(Result->front().size() == LookupSymbols.size() &&
  "Result has incorrect number of elements");
 
-  SymbolNameVector MissingSymbols;
   auto ResultI = Result->front().begin();
-  for (auto &KV : LookupSymbols)
+  for (auto &KV : LookupSymbols) {
 if (*ResultI)
   NewSymbols[KV.first] =
-  JITEvaluatedSymbol(*ResultI++, JITSymbolFlags::Exported);
+  JITEvaluatedSymbol(*ResultI, JITSymbolFlags::Exported);
+ResultI++;
+  }
 
   // If there were no resolved symbols bail out.
   if (NewSymbols.empty())



___
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] 2cfbdaf - [IR] Remove CastInst::isCastable since it is not used

2020-12-08 Thread Cullen Rhodes via llvm-branch-commits

Author: Cullen Rhodes
Date: 2020-12-08T10:31:53Z
New Revision: 2cfbdaf601049faafb2f1b40f63a3b2bef74a464

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

LOG: [IR] Remove CastInst::isCastable since it is not used

It was removed back in 2013 (f63dfbb) by Matt Arsenault but then
reverted since DragonEgg used it, but that project is no longer
maintained.

Reviewed By: ldionne, dexonsmith

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

Added: 


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

Removed: 




diff  --git a/llvm/include/llvm/IR/InstrTypes.h 
b/llvm/include/llvm/IR/InstrTypes.h
index 1091c4b0dc0f..23e030e94953 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -599,12 +599,6 @@ class CastInst : public UnaryInstruction {
 BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
   );
 
-  /// Check whether it is valid to call getCastOpcode for these types.
-  static bool isCastable(
-Type *SrcTy, ///< The Type from which the value should be cast.
-Type *DestTy ///< The Type to which the value should be cast.
-  );
-
   /// Check whether a bitcast between these types is valid
   static bool isBitCastable(
 Type *SrcTy, ///< The Type from which the value should be cast.

diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 5de1addabbe2..cfc6d05ecaba 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -3142,64 +3142,6 @@ CastInst *CastInst::CreateFPCast(Value *C, Type *Ty,
   return Create(opcode, C, Ty, Name, InsertAtEnd);
 }
 
-// Check whether it is valid to call getCastOpcode for these types.
-// This routine must be kept in sync with getCastOpcode.
-bool CastInst::isCastable(Type *SrcTy, Type *DestTy) {
-  if (!SrcTy->isFirstClassType() || !DestTy->isFirstClassType())
-return false;
-
-  if (SrcTy == DestTy)
-return true;
-
-  if (VectorType *SrcVecTy = dyn_cast(SrcTy))
-if (VectorType *DestVecTy = dyn_cast(DestTy))
-  if (cast(SrcVecTy)->getNumElements() ==
-  cast(DestVecTy)->getNumElements()) {
-// An element by element cast.  Valid if casting the elements is valid.
-SrcTy = SrcVecTy->getElementType();
-DestTy = DestVecTy->getElementType();
-  }
-
-  // Get the bit sizes, we'll need these
-  TypeSize SrcBits = SrcTy->getPrimitiveSizeInBits();   // 0 for ptr
-  TypeSize DestBits = DestTy->getPrimitiveSizeInBits(); // 0 for ptr
-
-  // Run through the possibilities ...
-  if (DestTy->isIntegerTy()) {   // Casting to integral
-if (SrcTy->isIntegerTy())// Casting from integral
-return true;
-if (SrcTy->isFloatingPointTy())   // Casting from floating pt
-  return true;
-if (SrcTy->isVectorTy())  // Casting from vector
-  return DestBits == SrcBits;
-  // Casting from something else
-return SrcTy->isPointerTy();
-  }
-  if (DestTy->isFloatingPointTy()) {  // Casting to floating pt
-if (SrcTy->isIntegerTy())// Casting from integral
-  return true;
-if (SrcTy->isFloatingPointTy())   // Casting from floating pt
-  return true;
-if (SrcTy->isVectorTy())  // Casting from vector
-  return DestBits == SrcBits;
-// Casting from something else
-return false;
-  }
-  if (DestTy->isVectorTy()) // Casting to vector
-return DestBits == SrcBits;
-  if (DestTy->isPointerTy()) {// Casting to pointer
-if (SrcTy->isPointerTy())// Casting from pointer
-  return true;
-return SrcTy->isIntegerTy(); // Casting from integral
-  }
-  if (DestTy->isX86_MMXTy()) {
-if (SrcTy->isVectorTy())
-  return DestBits == SrcBits;   // 64-bit vector to MMX
-return false;
-  }// Casting to something else
-  return false;
-}
-
 bool CastInst::isBitCastable(Type *SrcTy, Type *DestTy) {
   if (!SrcTy->isFirstClassType() || !DestTy->isFirstClassType())
 return false;
@@ -3261,7 +3203,6 @@ bool CastInst::isBitOrNoopPointerCastable(Type *SrcTy, 
Type *DestTy,
 //   castIsValid( getCastOpcode(Val, Ty), Val, Ty)
 // should not assert in castIsValid. In other words, this produces a "correct"
 // casting opcode for the arguments passed to it.
-// This routine must be kept in sync with isCastable.
 Instruction::CastOps
 CastInst::getCastOpcode(
   const Value *Src, bool SrcIsSigned, Type *DestTy, bool DestIsSigned) {

diff  --git a/llvm/unittests/IR/InstructionsTest.cpp 
b/llvm/unittests/IR/InstructionsTest.cpp
index 2c67ff4286e7..7a4dad21ecc9 100644
--- a/llvm/u

[llvm-branch-commits] [llvm] 7af8029 - [CodeGen] Add text section prefix for COFF object file

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

Author: Pan, Tao
Date: 2020-12-08T18:56:21+08:00
New Revision: 7af802994eb0521e1b00eda95303f21e874d9f22

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

LOG: [CodeGen] Add text section prefix for COFF object file

Text section prefix is created in CodeGenPrepare, it's file format independent 
implementation,  text section name is written into object file in 
TargetLoweringObjectFile, it's file format dependent implementation, port code 
of adding text section prefix to text section name from ELF to COFF.
Different with ELF that use '.' as concatenation character, COFF use '$' as 
concatenation character. That is, concatenation character is variable, so split 
concatenation character from text section prefix.
Text section prefix is existing feature of ELF, it can help to reduce icache 
and itlb misses, it's also make possible aggregate other compilers e.g. v8 
created same prefix sections. Furthermore, the recent feature Machine Function 
Splitter (basic block level text prefix section) is based on text section 
prefix.

Reviewed By: pengfei, rnk

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

Added: 
llvm/test/CodeGen/X86/text-section-prefix.ll

Modified: 
llvm/include/llvm/ProfileData/ProfileCommon.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachineFunctionSplitter.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/CodeGen/X86/machine-function-splitter.ll
llvm/test/CodeGen/X86/mingw-comdats.ll
llvm/test/Transforms/CodeGenPrepare/X86/section-samplepgo.ll
llvm/test/Transforms/CodeGenPrepare/X86/section.ll
llvm/test/Transforms/HotColdSplit/coldentrycount.ll
llvm/test/Transforms/SampleProfile/section-accurate-samplepgo.ll

Removed: 




diff  --git a/llvm/include/llvm/ProfileData/ProfileCommon.h 
b/llvm/include/llvm/ProfileData/ProfileCommon.h
index 14c305b3d0c0..6bb5825339ae 100644
--- a/llvm/include/llvm/ProfileData/ProfileCommon.h
+++ b/llvm/include/llvm/ProfileData/ProfileCommon.h
@@ -33,8 +33,8 @@ class FunctionSamples;
 
 } // end namespace sampleprof
 
-inline const char *getHotSectionPrefix() { return ".hot"; }
-inline const char *getUnlikelySectionPrefix() { return ".unlikely"; }
+inline const char *getHotSectionPrefix() { return "hot"; }
+inline const char *getUnlikelySectionPrefix() { return "unlikely"; }
 
 class ProfileSummaryBuilder {
 private:

diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp 
b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 40e92b9e0a4a..9b44b30e7a1b 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -473,12 +473,12 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
   OptSize = F.hasOptSize();
   if (ProfileGuidedSectionPrefix) {
 if (PSI->isFunctionHotInCallGraph(&F, *BFI))
-  F.setSectionPrefix(".hot");
+  F.setSectionPrefix("hot");
 else if (PSI->isFunctionColdInCallGraph(&F, *BFI))
-  F.setSectionPrefix(".unlikely");
+  F.setSectionPrefix("unlikely");
 else if (ProfileUnknownInSpecialSection && PSI->hasPartialSampleProfile() 
&&
  PSI->isFunctionHotnessUnknown(F))
-  F.setSectionPrefix(".unknown");
+  F.setSectionPrefix("unknown");
   }
 
   /// This optimization identifies DIV instructions that can be

diff  --git a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp 
b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp
index b2f474afea99..483809a8ed96 100644
--- a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp
+++ b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp
@@ -107,8 +107,8 @@ bool 
MachineFunctionSplitter::runOnMachineFunction(MachineFunction &MF) {
   // or functions of unknown hotness. Lukewarm functions have no prefix.
   Optional SectionPrefix = MF.getFunction().getSectionPrefix();
   if (SectionPrefix.hasValue() &&
-  (SectionPrefix.getValue().equals(".unlikely") ||
-   SectionPrefix.getValue().equals(".unknown"))) {
+  (SectionPrefix.getValue().equals("unlikely") ||
+   SectionPrefix.getValue().equals("unknown"))) {
 return false;
   }
 

diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp 
b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 4c8caa0497e4..2e32eabba53d 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -621,7 +621,7 @@ getELFSectionNameForGlobal(const GlobalObject *GO, 
SectionKind Kind,
   bool HasPrefix = false;
   if (const auto *F = dyn_cast(GO)) {
 if (Optional Prefix = F->getSectionPrefix()) {
-  Name += *Prefix;
+  raw_svector_ostream(Name) << '.' << *Prefix;
   HasPrefix = true;
 }
   }
@@ -1573,6 +1573,10 @@ MCSection 
*TargetLoweringObjectFileCOFF::SelectSectionForGlobal(
   MCSymbol *Sym = TM.getSymbol(ComdatGV);
   StringRef COM

[llvm-branch-commits] [llvm] cda32ab - [DebugInfo][Docs] Document MIR language debug-info constructs

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

Author: Jeremy Morse
Date: 2020-12-08T11:01:55Z
New Revision: cda32aba4f46033eea4eea6eda703459dc3c7a1e

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

LOG: [DebugInfo][Docs] Document MIR language debug-info constructs

This patch documents the MIR syntax for a number of things relevant to
debugging information:
 * Trailing 'debug-location' metadata that becomes a DebugLoc,
 * Variable location metadata for stack slots,
 * Syntax for DBG_VALUE metainstructions,
 * Syntax for DBG_INSTR_REF, including trailing instruction numbers
   attached to MIR instructions.

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

Added: 


Modified: 
llvm/docs/MIRLangRef.rst

Removed: 




diff  --git a/llvm/docs/MIRLangRef.rst b/llvm/docs/MIRLangRef.rst
index 0380bcced5fc..ff8029c5c646 100644
--- a/llvm/docs/MIRLangRef.rst
+++ b/llvm/docs/MIRLangRef.rst
@@ -790,3 +790,105 @@ For an int eq predicate ``ICMP_EQ``, the syntax is:
instructions debug location attribute.
 .. TODO: Describe the syntax of the register live out machine operands.
 .. TODO: Describe the syntax of the machine memory operands.
+
+Debug-Info constructs
+-
+
+Most of the debugging information in a MIR file is to be found in the metadata
+of the embedded module. Within a machine function, that metadata is referred to
+by various constructs to describe source locations and variable locations.
+
+Source locations
+
+
+Every MIR instruction may optionally have a trailing reference to a
+``DILocation`` metadata node, after all operands and symbols, but before
+memory operands:
+
+.. code-block:: text
+
+   $rbp = MOV64rr $rdi, debug-location !12
+
+The source location attachment is synonymous with the ``!dbg`` metadata
+attachment in LLVM-IR. The absence of a source location attachment will be
+represented by an empty ``DebugLoc`` object in the machine instruction.
+
+Fixed variable locations
+
+
+There are several ways of specifying variable locations. The simpliest is
+describing a variable that is permanently located on the stack. In the stack
+or fixedStack attribute of the machine function, the variable, scope, and
+any qualifying location modifier are provided:
+
+.. code-block:: text
+
+- { id: 0, name: offset.addr, offset: -24, size: 8, alignment: 8, 
stack-id: default,
+ 4  debug-info-variable: '!1', debug-info-expression: '!DIExpression()',
+debug-info-location: '!2' }
+
+Where:
+
+- ``debug-info-variable`` identifies a DILocalVariable metadata node,
+
+- ``debug-info-expression`` adds qualifiers to the variable location,
+
+- ``debug-info-location`` identifies a DILocation metadata node.
+
+These metadata attributes correspond to the operands of a ``llvm.dbg.declare``
+IR intrinsic, see the :ref:`source level debugging`
+documentation.
+
+Varying variable locations
+^^
+
+Variables that are not always on the stack or change location are specified
+with the ``DBG_VALUE``  meta machine instruction. It is synonymous with the
+``llvm.dbg.value`` IR intrinsic, and is written:
+
+.. code-block:: text
+
+DBG_VALUE $rax, $noreg, !123, !DIExpression(), debug-location !456
+
+The operands to which respectively:
+
+1. Identifies a machine location such as a register, immediate, or frame index,
+
+2. Is either $noreg, or immediate value zero if an extra level of indirection 
is to be added to the first operand,
+
+3. Identifies a ``DILocalVariable`` metadata node,
+
+4. Specifies an expression qualifying the variable location, either inline or 
as a metadata node reference,
+
+While the source location identifies the ``DILocation`` for the scope of the
+variable. The second operand (``IsIndirect``) is deprecated and to be deleted.
+All additional qualifiers for the variable location should be made through the
+expression metadata.
+
+Instruction referencing locations
+^
+
+This experimental feature aims to separate the specification of variable
+*values* from the program point where a variable takes on that value. Changes
+in variable value occur in the same manner as ``DBG_VALUE`` meta instructions
+but using ``DBG_INSTR_REF``. Variable values are identified by a pair of
+instruction number and operand number. Consider the example below:
+
+.. code-block:: text
+
+$rbp = MOV64ri 0, debug-instr-number 1, debug-location !12
+DBG_INSTR_REF 1, 0, !123, !DIExpression(), debug-location !456
+
+Instruction numbers are directly attached to machine instructions with an
+optional ``debug-instr-number`` attachment, before the optional
+``debug-location`` attachment. The value defined in ``$rbp`` in the code
+above would be identified by the pair ``<1, 0>``.
+
+The first two operands of the ``

[llvm-branch-commits] [compiler-rt] deec343 - [compiler-rt] Allow appending to 'target_cflags' value from lit_config.

2020-12-08 Thread Hafiz Abid Qadeer via llvm-branch-commits

Author: Hafiz Abid Qadeer
Date: 2020-12-08T11:46:36Z
New Revision: deec343bfd85d7c78fb0d8e251e63f372767297d

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

LOG: [compiler-rt] Allow appending to 'target_cflags' value from lit_config.

This patch is similar to D84708. When testing compiler-rt on different
baremetal targets, it helps to have the ability to pass some more parameters
at test time that allows you to build the test executable for a
given target. For an example, you may need a different linker command
file for different targets.

This patch will allows to do things like

$ llvm-lit --param=append_target_cflags="-T simulator.ld"
or
$ llvm-lit --param=append_target_cflags="-T hardware.ld"

In this way, you can run tests on different targets without having to run
cmake again.

Reviewed By: delcypher

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

Added: 


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

Removed: 




diff  --git a/compiler-rt/test/lit.common.cfg.py 
b/compiler-rt/test/lit.common.cfg.py
index 889e29341ee2..e2de463f85c0 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -582,5 +582,11 @@ def is_windows_lto_supported():
 elif config.use_lld and (not config.has_lld):
   config.unsupported = True
 
+# Append any extra flags passed in lit_config
+append_target_cflags = lit_config.params.get('append_target_cflags', None)
+if append_target_cflags:
+  lit_config.note('Appending to extra_cflags: 
"{}"'.format(append_target_cflags))
+  extra_cflags += [append_target_cflags]
+
 config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, 
config.clang]) + " "
 config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "



___
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] c100d7b - [NFC] Chec[^k] -> Check

2020-12-08 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-08T11:54:39Z
New Revision: c100d7ba36a5501bba6f7107a531323a51498bf6

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

LOG: [NFC] Chec[^k] -> Check

Some test updates all appearing to use the wrong spelling of CHECK.

Added: 


Modified: 
llvm/test/CodeGen/AArch64/arm64-fold-lsl.ll
llvm/test/CodeGen/ARM/ParallelDSP/inner-full-unroll.ll
llvm/test/CodeGen/ARM/fold-stack-adjust.ll
llvm/test/CodeGen/ARM/v7k-abi-align.ll
llvm/test/CodeGen/ARM/vminmaxnm-safe.ll
llvm/test/DebugInfo/COFF/retained-types.ll
llvm/test/MC/ARM/thumb_set-diagnostics.s
llvm/test/MC/Mips/macro-ddiv.s
llvm/test/Transforms/IRCE/pre_post_loops.ll
llvm/test/tools/llvm-readobj/ELF/groups.test
llvm/utils/llvm-compilers-check

Removed: 




diff  --git a/llvm/test/CodeGen/AArch64/arm64-fold-lsl.ll 
b/llvm/test/CodeGen/AArch64/arm64-fold-lsl.ll
index 0790e4c58c46..5e4aae3df836 100644
--- a/llvm/test/CodeGen/AArch64/arm64-fold-lsl.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-fold-lsl.ll
@@ -298,7 +298,7 @@ define i32 @load_doubleword_trunc_word_reuse_shift(i64* 
%ptr, i64 %off) {
 ; CHECK-LABEL: load_doubleword_trunc_word_reuse_shift:
 ; CHECK: lsl x[[REG1:[0-9]+]], x1, #3
 ; CHECK: ldr w[[REG2:[0-9]+]], [x0, x[[REG1]]]
-; CHECL: add w0, w[[REG2]], w[[REG1]]
+; CHECK: add w0, w[[REG2]], w[[REG1]]
 entry:
   %idx = getelementptr inbounds i64, i64* %ptr, i64 %off
   %x = load i64, i64* %idx, align 8

diff  --git a/llvm/test/CodeGen/ARM/ParallelDSP/inner-full-unroll.ll 
b/llvm/test/CodeGen/ARM/ParallelDSP/inner-full-unroll.ll
index a75dd591dfce..542202ced703 100644
--- a/llvm/test/CodeGen/ARM/ParallelDSP/inner-full-unroll.ll
+++ b/llvm/test/CodeGen/ARM/ParallelDSP/inner-full-unroll.ll
@@ -72,7 +72,7 @@ for.body: ; preds = 
%entry, %for.body
 }
 
 ; CHECK-LABEL: full_unroll_sub
-; CHEC: [[IV:%[^ ]+]] = phi i32
+; CHECK: [[IV:%[^ ]+]] = phi i32
 ; CHECK: [[AI:%[^ ]+]] = getelementptr inbounds i32, i32* %a, i32 [[IV]]
 ; CHECK: [[BI:%[^ ]+]] = getelementptr inbounds i16*, i16** %b, i32 [[IV]]
 ; CHECK: [[BIJ:%[^ ]+]] = load i16*, i16** [[BI]], align 4

diff  --git a/llvm/test/CodeGen/ARM/fold-stack-adjust.ll 
b/llvm/test/CodeGen/ARM/fold-stack-adjust.ll
index 6256138e9a02..e22aa882404b 100644
--- a/llvm/test/CodeGen/ARM/fold-stack-adjust.ll
+++ b/llvm/test/CodeGen/ARM/fold-stack-adjust.ll
@@ -1,5 +1,5 @@
 ; Disable shrink-wrapping on the first test otherwise we wouldn't
-; exerce the path for PR18136.
+; exercise the path for PR18136.
 ; RUN: llc -mtriple=thumbv7-apple-none-macho < %s -enable-shrink-wrap=false 
-verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-FNSTART,CHECK
 ; RUN: llc -mtriple=thumbv6m-apple-none-macho -frame-pointer=all < %s 
-verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-FNSTART,CHECK-T1
 ; RUN: llc -mtriple=thumbv6m-apple-none-macho < %s -verify-machineinstrs | 
FileCheck %s --check-prefixes=CHECK-FNSTART,CHECK-T1-NOFP
@@ -30,12 +30,12 @@ define void @check_simple() minsize {
   ; iOS always has a frame pointer and messing with the push affects
   ; how it's set in the prologue. Make sure we get that right.
 ; CHECK-IOS: push {r3, r4, r5, r6, r7, lr}
-; CHECK-NOT: sub sp,
+; CHECK-IOS-NOT: sub sp,
 ; CHECK-IOS: add r7, sp, #16
-; CHECK-NOT: sub sp,
+; CHECK-IOS-NOT: sub sp,
 ; ...
-; CHECK-NOT: add sp,
-; CHEC: pop {r3, r4, r5, r6, r7, pc}
+; CHECK-IOS-NOT: add sp,
+; CHECK-IOS: pop {r0, r1, r2, r3, r7, pc}
 
   %var = alloca i8, i32 16
   call void @bar(i8* %var)

diff  --git a/llvm/test/CodeGen/ARM/v7k-abi-align.ll 
b/llvm/test/CodeGen/ARM/v7k-abi-align.ll
index d7a95c0faa17..be4d876a59ec 100644
--- a/llvm/test/CodeGen/ARM/v7k-abi-align.ll
+++ b/llvm/test/CodeGen/ARM/v7k-abi-align.ll
@@ -4,25 +4,25 @@
 
 define i32 @test_i64_align() "frame-pointer"="all" {
 ; CHECK-LABEL: test_i64_align:
-; CHECL: movs r0, #8
+; CHECK: movs r0, #8
   ret i32 ptrtoint(i64* getelementptr(%struct, %struct* null, i32 0, i32 1) to 
i32)
 }
 
 define i32 @test_f64_align() "frame-pointer"="all" {
 ; CHECK-LABEL: test_f64_align:
-; CHECL: movs r0, #24
+; CHECK: movs r0, #24
   ret i32 ptrtoint(double* getelementptr(%struct, %struct* null, i32 0, i32 3) 
to i32)
 }
 
 define i32 @test_v2f32_align() "frame-pointer"="all" {
 ; CHECK-LABEL: test_v2f32_align:
-; CHECL: movs r0, #40
+; CHECK: movs r0, #40
   ret i32 ptrtoint(<2 x float>* getelementptr(%struct, %struct* null, i32 0, 
i32 5) to i32)
 }
 
 define i32 @test_v4f32_align() "frame-pointer"="all" {
 ; CHECK-LABEL: test_v4f32_align:
-; CHECL: movs r0, #64
+; CHECK: movs r0, #64
   ret i32 ptrtoint(<4 x float>* getelementptr(%struct, %struct* null, i32 0, 
i32 7) to i32)
 }
 

diff  --git a/llvm/test/CodeGen/ARM/vminmaxnm-safe.ll 
b/llvm/test/Cod

[llvm-branch-commits] [llvm] 1e260f9 - [LICM][docs] Document that LICM is also a canonicalization transform. NFC.

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

Author: Sjoerd Meijer
Date: 2020-12-08T11:56:35Z
New Revision: 1e260f955d3123351fc68de8c2dde02b1be6d14f

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

LOG: [LICM][docs] Document that LICM is also a canonicalization transform. NFC.

This documents that LICM is a canonicalization transform, which we discussed
recently in:

http://lists.llvm.org/pipermail/llvm-dev/2020-December/147184.html

but which was also discused earlier, e.g. in:

http://lists.llvm.org/pipermail/llvm-dev/2019-September/135058.html

Added: 


Modified: 
llvm/docs/Passes.rst
llvm/lib/Transforms/Scalar/LICM.cpp

Removed: 




diff  --git a/llvm/docs/Passes.rst b/llvm/docs/Passes.rst
index 202e3ab223d6..d146ce745282 100644
--- a/llvm/docs/Passes.rst
+++ b/llvm/docs/Passes.rst
@@ -720,6 +720,12 @@ into the preheader block, or by sinking code to the exit 
blocks if it is safe.
 This pass also promotes must-aliased memory locations in the loop to live in
 registers, thus hoisting and sinking "invariant" loads and stores.
 
+Hoisting operations out of loops is a canonicalization transform. It enables
+and simplifies subsequent optimizations in the middle-end. Rematerialization
+of hoisted instructions to reduce register pressure is the responsibility of
+the back-end, which has more accurate information about register pressure and
+also handles other optimizations than LICM that increase live-ranges.
+
 This pass uses alias analysis for two purposes:
 
 #. Moving loop invariant loads and calls out of loops.  If we can determine

diff  --git a/llvm/lib/Transforms/Scalar/LICM.cpp 
b/llvm/lib/Transforms/Scalar/LICM.cpp
index 9d90986c54ad..1b14bc972a9e 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -12,6 +12,13 @@
 // safe.  This pass also promotes must-aliased memory locations in the loop to
 // live in registers, thus hoisting and sinking "invariant" loads and stores.
 //
+// Hoisting operations out of loops is a canonicalization transform.  It
+// enables and simplifies subsequent optimizations in the middle-end.
+// Rematerialization of hoisted instructions to reduce register pressure is the
+// responsibility of the back-end, which has more accurate information about
+// register pressure and also handles other optimizations than LICM that
+// increase live-ranges.
+//
 // This pass uses alias analysis for two purposes:
 //
 //  1. Moving loop invariant loads and calls out of loops.  If we can determine



___
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] 776bb71 - [XCore][docs] Fix XCore compiler writer documentation links.

2020-12-08 Thread J. Ryan Stinnett via llvm-branch-commits

Author: Nigel Perks
Date: 2020-12-08T12:21:09Z
New Revision: 776bb71d88e48a77fc6788324d30bbc63581d6a9

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

LOG: [XCore][docs] Fix XCore compiler writer documentation links.

Fix links to XMOS website. Add link for XS2 architecture.

Reviewed By: jryans

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

Added: 


Modified: 
llvm/docs/CompilerWriterInfo.rst

Removed: 




diff  --git a/llvm/docs/CompilerWriterInfo.rst 
b/llvm/docs/CompilerWriterInfo.rst
index 55c2b92e4931..9184b852539d 100644
--- a/llvm/docs/CompilerWriterInfo.rst
+++ b/llvm/docs/CompilerWriterInfo.rst
@@ -131,8 +131,9 @@ X86
 XCore
 -
 
-* `The XMOS XS1 Architecture (ISA) 
`_
-* `Tools Development Guide (includes ABI) 
`_
+* `The XMOS XS1 Architecture (ISA) 
`_
+* `The XMOS XS2 Architecture (ISA) 
`_
+* `Tools Development Guide (includes ABI) 
`_
 
 Hexagon
 ---



___
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] 6face91 - [lldb][import-std-module] Add a test for typedef'd std types

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

Author: Raphael Isemann
Date: 2020-12-08T13:36:13+01:00
New Revision: 6face9119c811e06cfb284755953ba6cdbdaa22b

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

LOG: [lldb][import-std-module] Add a test for typedef'd std types

Added: 


Modified: 

lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
lldb/test/API/commands/expression/import-std-module/vector/main.cpp

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
index 9a186e7a2243..a03c347a728f 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
@@ -87,3 +87,13 @@ def test(self):
  ValueCheck(value="4"),
  ValueCheck(value="5")
  ])
+
+# Test that the typedef'd vector type can be substituted.
+self.expect("expr b.emplace_back(6)")
+self.expect_expr("b", result_type="vector_long",
+ result_children=[
+ ValueCheck(value="3"),
+ ValueCheck(value="1"),
+ ValueCheck(value="2"),
+ ValueCheck(value="6"),
+ ])

diff  --git 
a/lldb/test/API/commands/expression/import-std-module/vector/main.cpp 
b/lldb/test/API/commands/expression/import-std-module/vector/main.cpp
index edf130d47488..668b59181d42 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector/main.cpp
+++ b/lldb/test/API/commands/expression/import-std-module/vector/main.cpp
@@ -1,6 +1,8 @@
 #include 
 
+typedef std::vector vector_long;
 int main(int argc, char **argv) {
   std::vector a = {3, 1, 2};
+  vector_long b = {3, 1, 2};
   return 0; // Set break point at this line.
 }



___
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] 41d0666 - [SLP][X86] Extend PR46983 tests to include SSE2, SSE42, AVX512BW test coverage

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

Author: Simon Pilgrim
Date: 2020-12-08T12:41:47Z
New Revision: 41d0666391131ddee451085c72ba6513872e7f6c

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

LOG: [SLP][X86] Extend PR46983 tests to include SSE2,SSE42,AVX512BW test 
coverage

Noticed while reviewing D92824

Added: 


Modified: 
llvm/test/Transforms/SLPVectorizer/X86/pr46983.ll

Removed: 




diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/pr46983.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/pr46983.ll
index 7df32e665805..ca74d9d71631 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/pr46983.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/pr46983.ll
@@ -1,6 +1,9 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -slp-vectorizer -instcombine -S 
-mtriple=x86_64-unknown-linux-gnu -mattr=+avx | FileCheck %s 
--check-prefixes=CHECK,AVX
-; RUN: opt < %s -slp-vectorizer -instcombine -S 
-mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 | FileCheck %s 
--check-prefixes=CHECK,AVX2
+; RUN: opt < %s -slp-vectorizer -instcombine -S 
-mtriple=x86_64-unknown-linux-gnu -mattr=+sse2   | FileCheck %s 
--check-prefixes=CHECK,SSE
+; RUN: opt < %s -slp-vectorizer -instcombine -S 
-mtriple=x86_64-unknown-linux-gnu -mattr=+sse4.2 | FileCheck %s 
--check-prefixes=CHECK,SSE
+; RUN: opt < %s -slp-vectorizer -instcombine -S 
-mtriple=x86_64-unknown-linux-gnu -mattr=+avx| FileCheck %s 
--check-prefixes=CHECK,AVX1
+; RUN: opt < %s -slp-vectorizer -instcombine -S 
-mtriple=x86_64-unknown-linux-gnu -mattr=+avx2   | FileCheck %s 
--check-prefixes=CHECK,AVX2
+; RUN: opt < %s -slp-vectorizer -instcombine -S 
-mtriple=x86_64-unknown-linux-gnu -mattr=+avx512bw,+avx512vl | FileCheck %s 
--check-prefixes=CHECK,AVX2
 
 define void @store_i32(i32* nocapture %0, i32 %1, i32 %2) {
 ; CHECK-LABEL: @store_i32(
@@ -124,44 +127,83 @@ define void @store_i8(i8* nocapture %0, i32 %1, i32 %2) {
 }
 
 define void @store_i64(i64* nocapture %0, i32 %1, i32 %2) {
-; AVX-LABEL: @store_i64(
-; AVX-NEXT:[[TMP4:%.*]] = zext i32 [[TMP1:%.*]] to i64
-; AVX-NEXT:[[TMP5:%.*]] = load i64, i64* [[TMP0:%.*]], align 8, 
[[TBAA5:!tbaa !.*]]
-; AVX-NEXT:[[TMP6:%.*]] = mul i64 [[TMP5]], [[TMP4]]
-; AVX-NEXT:[[TMP7:%.*]] = lshr i64 [[TMP6]], 15
-; AVX-NEXT:[[TMP8:%.*]] = trunc i64 [[TMP7]] to i32
-; AVX-NEXT:[[TMP9:%.*]] = icmp ult i32 [[TMP8]], 255
-; AVX-NEXT:[[TMP10:%.*]] = and i64 [[TMP7]], 4294967295
-; AVX-NEXT:[[TMP11:%.*]] = select i1 [[TMP9]], i64 [[TMP10]], i64 255
-; AVX-NEXT:store i64 [[TMP11]], i64* [[TMP0]], align 8, [[TBAA5]]
-; AVX-NEXT:[[TMP12:%.*]] = getelementptr inbounds i64, i64* [[TMP0]], i64 1
-; AVX-NEXT:[[TMP13:%.*]] = load i64, i64* [[TMP12]], align 8, [[TBAA5]]
-; AVX-NEXT:[[TMP14:%.*]] = mul i64 [[TMP13]], [[TMP4]]
-; AVX-NEXT:[[TMP15:%.*]] = lshr i64 [[TMP14]], 15
-; AVX-NEXT:[[TMP16:%.*]] = trunc i64 [[TMP15]] to i32
-; AVX-NEXT:[[TMP17:%.*]] = icmp ult i32 [[TMP16]], 255
-; AVX-NEXT:[[TMP18:%.*]] = and i64 [[TMP15]], 4294967295
-; AVX-NEXT:[[TMP19:%.*]] = select i1 [[TMP17]], i64 [[TMP18]], i64 255
-; AVX-NEXT:store i64 [[TMP19]], i64* [[TMP12]], align 8, [[TBAA5]]
-; AVX-NEXT:[[TMP20:%.*]] = getelementptr inbounds i64, i64* [[TMP0]], i64 2
-; AVX-NEXT:[[TMP21:%.*]] = load i64, i64* [[TMP20]], align 8, [[TBAA5]]
-; AVX-NEXT:[[TMP22:%.*]] = mul i64 [[TMP21]], [[TMP4]]
-; AVX-NEXT:[[TMP23:%.*]] = lshr i64 [[TMP22]], 15
-; AVX-NEXT:[[TMP24:%.*]] = trunc i64 [[TMP23]] to i32
-; AVX-NEXT:[[TMP25:%.*]] = icmp ult i32 [[TMP24]], 255
-; AVX-NEXT:[[TMP26:%.*]] = and i64 [[TMP23]], 4294967295
-; AVX-NEXT:[[TMP27:%.*]] = select i1 [[TMP25]], i64 [[TMP26]], i64 255
-; AVX-NEXT:store i64 [[TMP27]], i64* [[TMP20]], align 8, [[TBAA5]]
-; AVX-NEXT:[[TMP28:%.*]] = getelementptr inbounds i64, i64* [[TMP0]], i64 3
-; AVX-NEXT:[[TMP29:%.*]] = load i64, i64* [[TMP28]], align 8, [[TBAA5]]
-; AVX-NEXT:[[TMP30:%.*]] = mul i64 [[TMP29]], [[TMP4]]
-; AVX-NEXT:[[TMP31:%.*]] = lshr i64 [[TMP30]], 15
-; AVX-NEXT:[[TMP32:%.*]] = trunc i64 [[TMP31]] to i32
-; AVX-NEXT:[[TMP33:%.*]] = icmp ult i32 [[TMP32]], 255
-; AVX-NEXT:[[TMP34:%.*]] = and i64 [[TMP31]], 4294967295
-; AVX-NEXT:[[TMP35:%.*]] = select i1 [[TMP33]], i64 [[TMP34]], i64 255
-; AVX-NEXT:store i64 [[TMP35]], i64* [[TMP28]], align 8, [[TBAA5]]
-; AVX-NEXT:ret void
+; SSE-LABEL: @store_i64(
+; SSE-NEXT:[[TMP4:%.*]] = zext i32 [[TMP1:%.*]] to i64
+; SSE-NEXT:[[TMP5:%.*]] = load i64, i64* [[TMP0:%.*]], align 8, 
[[TBAA5:!tbaa !.*]]
+; SSE-NEXT:[[TMP6:%.*]] = mul i64 [[TMP5]], [[TMP4]]
+; SSE-NEXT:[[TMP7:%.*]] = lshr i64 [[TMP6]], 15
+; SSE-NEXT:[[TMP8:%.*]] = trunc i64 [[TMP7]] to i32
+; SSE-NEXT:[[TMP9:%

[llvm-branch-commits] [llvm] 083e035 - [clang][cli] Unify boolean marshalling

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

Author: Jan Svoboda
Date: 2020-12-08T13:47:30+01:00
New Revision: 083e035c47f6c73084ecf5ab7f41cddca19ce332

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

LOG: [clang][cli] Unify boolean marshalling

Use lambdas with captures to replace the redundant infrastructure for 
marshalling of two boolean flags that control the same keypath.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c6159f50b781..794aa24f997d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -271,7 +271,7 @@ multiclass OptOutFFlag {
   def fno_#NAME : Flag<["-"], "fno-"#name>, HelpText;
   def f#NAME : Flag<["-"], "f"#name>, HelpText,
-MarshallingInfoBooleanFlag("fno_"#NAME)>;
+MarshallingInfoBooleanFlag;
 }
 
 /

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index e31f6aa34b36..547dadd37931 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -185,25 +185,21 @@ static FlagToValueNormalizer 
makeFlagToValueNormalizer(T Value) {
   return FlagToValueNormalizer{std::move(Value)};
 }
 
-static Optional normalizeBooleanFlag(OptSpecifier PosOpt,
-   OptSpecifier NegOpt,
-   unsigned TableIndex,
-   const ArgList &Args,
-   DiagnosticsEngine &Diags) {
-  if (const Arg *A = Args.getLastArg(PosOpt, NegOpt))
-return A->getOption().matches(PosOpt);
-  return None;
+static auto makeBooleanFlagNormalizer(OptSpecifier NegOpt) {
+  return [NegOpt](OptSpecifier PosOpt, unsigned, const ArgList &Args,
+  DiagnosticsEngine &) -> Optional {
+if (const Arg *A = Args.getLastArg(PosOpt, NegOpt))
+  return A->getOption().matches(PosOpt);
+return None;
+  };
 }
 
-static void denormalizeBooleanFlag(SmallVectorImpl &Args,
-   const char *Spelling,
-   const char *NegSpelling,
-   CompilerInvocation::StringAllocator SA,
-   unsigned TableIndex, unsigned Value) {
-  if (Value)
-Args.push_back(Spelling);
-  else
-Args.push_back(NegSpelling);
+static auto makeBooleanFlagDenormalizer(const char *NegSpelling) {
+  return [NegSpelling](
+ SmallVectorImpl &Args, const char *PosSpelling,
+ CompilerInvocation::StringAllocator, unsigned, unsigned Value) {
+Args.push_back(Value ? PosSpelling : NegSpelling);
+  };
 }
 
 static Optional
@@ -3779,23 +3775,7 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList 
&Args,
   this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
   }
 
-#define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
-IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
-TABLE_INDEX, NEG_ID, NEG_SPELLING) 
\
-  {
\
-this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
-if (IMPLIED_CHECK) 
\
-  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (auto MaybeValue =  
\
-NORMALIZER(OPT_##ID, OPT_##NEG_ID, TABLE_INDEX, Args, Diags))  
\
-  this->KEYPATH = MERGER(  
\
-  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
-  }
-
 #include "clang/Driver/Options.inc"
-#undef OPTION_WITH_MARSHALLING_BOOLEAN
 #undef OPTION_WITH_MARSHALLING
   return true;
 }
@@ -4060,20 +4040,7 @@ void CompilerInvocation::generateCC1CommandLine(
 }(EXTRACTOR(this->KEYPATH));   
\
   }
 
-#define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
-IMPLIED_CHECK, IMPLIED_

[llvm-branch-commits] [mlir] bb7d43e - Add rsqrt lowering from standard to NVVM

2020-12-08 Thread Frederik Gossen via llvm-branch-commits

Author: Frederik Gossen
Date: 2020-12-08T14:33:58+01:00
New Revision: bb7d43e7d5f683fc3e7109072610dc8d176a3bf8

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

LOG: Add rsqrt lowering from standard to NVVM

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

Added: 


Modified: 
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp 
b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index 61f97d44e125..4b7bb6e193a4 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -183,6 +183,8 @@ void mlir::populateGpuToNVVMConversionPatterns(
  "__nv_log10");
   patterns.insert>(converter, "__nv_log2f",
 "__nv_log2");
+  patterns.insert>(converter, "__nv_rsqrtf",
+ "__nv_rsqrt");
   patterns.insert>(converter, "__nv_sinf",
"__nv_sin");
   patterns.insert>(converter, "__nv_tanhf",

diff  --git a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir 
b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
index 8e4e4515c638..347cc48daa20 100644
--- a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
+++ b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
@@ -295,6 +295,26 @@ gpu.module @test_module {
 
 // -
 
+gpu.module @test_module {
+  // CHECK: llvm.func @__nv_rsqrtf(!llvm.float) -> !llvm.float
+  // CHECK: llvm.func @__nv_rsqrt(!llvm.double) -> !llvm.double
+  // CHECK-LABEL: func @gpu_rsqrt
+  func @gpu_rsqrt(%arg_f16 : f16, %arg_f32 : f32, %arg_f64 : f64)
+  -> (f16, f32, f64) {
+%result16 = std.rsqrt %arg_f16 : f16
+// CHECK: llvm.fpext %{{.*}} : !llvm.half to !llvm.float
+// CHECK-NEXT: llvm.call @__nv_rsqrtf(%{{.*}}) : (!llvm.float) -> 
!llvm.float
+// CHECK-NEXT: llvm.fptrunc %{{.*}} : !llvm.float to !llvm.half
+%result32 = std.rsqrt %arg_f32 : f32
+// CHECK: llvm.call @__nv_rsqrtf(%{{.*}}) : (!llvm.float) -> !llvm.float
+%result64 = std.rsqrt %arg_f64 : f64
+// CHECK: llvm.call @__nv_rsqrt(%{{.*}}) : (!llvm.double) -> !llvm.double
+std.return %result16, %result32, %result64 : f16, f32, f64
+  }
+}
+
+// -
+
 // Test that we handled properly operation with SymbolTable other than module 
op
 gpu.module @test_module {
   "test.symbol_scope"() ({



___
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] 59f17b5 - [SVE] Fix crashes with inline assembly

2020-12-08 Thread David Sherwood via llvm-branch-commits

Author: David Sherwood
Date: 2020-12-08T13:48:43Z
New Revision: 59f17b57d9c9abf86d8dcc05c49d3bbd807e29c7

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

LOG: [SVE] Fix crashes with inline assembly

All the crashes found compiling inline assembly are fixed in this
patch by changing AArch64TargetLowering::getRegForInlineAsmConstraint
to be more resilient to mismatched value and register types. For
example, it makes no sense to request a predicate register for
a nxv2i64 type and so on.

Tests have been added here:

  test/CodeGen/AArch64/inline-asm-constraints-bad-sve.ll

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

Added: 
llvm/test/CodeGen/AArch64/inline-asm-constraints-bad-sve.ll

Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index cca31a701d56..700c281cdaa9 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -7511,23 +7511,30 @@ AArch64TargetLowering::getRegForInlineAsmConstraint(
   if (Constraint.size() == 1) {
 switch (Constraint[0]) {
 case 'r':
-  if (VT.getSizeInBits() == 64)
+  if (VT.isScalableVector())
+return std::make_pair(0U, nullptr);
+  if (VT.getFixedSizeInBits() == 64)
 return std::make_pair(0U, &AArch64::GPR64commonRegClass);
   return std::make_pair(0U, &AArch64::GPR32commonRegClass);
-case 'w':
+case 'w': {
   if (!Subtarget->hasFPARMv8())
 break;
-  if (VT.isScalableVector())
-return std::make_pair(0U, &AArch64::ZPRRegClass);
-  if (VT.getSizeInBits() == 16)
+  if (VT.isScalableVector()) {
+if (VT.getVectorElementType() != MVT::i1)
+  return std::make_pair(0U, &AArch64::ZPRRegClass);
+return std::make_pair(0U, nullptr);
+  }
+  uint64_t VTSize = VT.getFixedSizeInBits();
+  if (VTSize == 16)
 return std::make_pair(0U, &AArch64::FPR16RegClass);
-  if (VT.getSizeInBits() == 32)
+  if (VTSize == 32)
 return std::make_pair(0U, &AArch64::FPR32RegClass);
-  if (VT.getSizeInBits() == 64)
+  if (VTSize == 64)
 return std::make_pair(0U, &AArch64::FPR64RegClass);
-  if (VT.getSizeInBits() == 128)
+  if (VTSize == 128)
 return std::make_pair(0U, &AArch64::FPR128RegClass);
   break;
+}
 // The instructions that this constraint is designed for can
 // only take 128-bit registers so just use that regclass.
 case 'x':
@@ -7548,10 +7555,11 @@ AArch64TargetLowering::getRegForInlineAsmConstraint(
   } else {
 PredicateConstraint PC = parsePredicateConstraint(Constraint);
 if (PC != PredicateConstraint::Invalid) {
-  assert(VT.isScalableVector());
+  if (!VT.isScalableVector() || VT.getVectorElementType() != MVT::i1)
+return std::make_pair(0U, nullptr);
   bool restricted = (PC == PredicateConstraint::Upl);
   return restricted ? std::make_pair(0U, &AArch64::PPR_3bRegClass)
-  : std::make_pair(0U, &AArch64::PPRRegClass);
+: std::make_pair(0U, &AArch64::PPRRegClass);
 }
   }
   if (StringRef("{cc}").equals_lower(Constraint))

diff  --git a/llvm/test/CodeGen/AArch64/inline-asm-constraints-bad-sve.ll 
b/llvm/test/CodeGen/AArch64/inline-asm-constraints-bad-sve.ll
new file mode 100644
index ..5a2f4746af87
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/inline-asm-constraints-bad-sve.ll
@@ -0,0 +1,29 @@
+; RUN: not llc -mtriple=aarch64-none-linux-gnu -mattr=+sve -o - %s 2>&1 | 
FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+; CHECK: error: couldn't allocate input reg for constraint 'Upa'
+; CHECK: error: couldn't allocate input reg for constraint 'r'
+; CHECK: error: couldn't allocate output register for constraint 'w'
+
+define  @foo1(i32 *%in) {
+entry:
+  %0 = load i32, i32* %in, align 4
+  %1 = call  asm sideeffect "mov $0.b, $1.b \0A", 
"=@3Upa,@3Upa"(i32 %0)
+  ret  %1
+}
+
+define  @foo2( *%in) {
+entry:
+  %0 = load , * %in, align 16
+  %1 = call  asm sideeffect "ptrue p0.s, #1 \0Afabs $0.s, 
p0/m, $1.s \0A", "=w,r"( %0)
+  ret  %1
+}
+
+define  @foo3( *%in) {
+entry:
+  %0 = load , * %in, align 2
+  %1 = call  asm sideeffect "mov $0.b, $1.b \0A", 
"=&w,w"( %0)
+  ret  %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] 91fb9ea - [ARM] Remove dead instructions before creating VPT block bundles

2020-12-08 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-08T14:05:07Z
New Revision: 91fb9eac0b562cdfdc6b677f8ab2ee67f1ae1a77

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

LOG: [ARM] Remove dead instructions before creating VPT block bundles

We remove VPNOT instructions in VPT blocks as we create them, turning
them into else predicates. We don't remove the dead instructions until
after the block has been created though. Because the VPNOT will have
killed the vpr register it used, this makes finalizeBundle add internal
flags to the vpr uses of any instructions after the VPNOT. These
incorrect flags can then confuse what is alive and what is not, leading
to machine verifier problems.

This patch removes them earlier instead, before the bundle is finalized
so that kill flags remain valid.

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

Added: 


Modified: 
llvm/lib/Target/ARM/MVEVPTBlockPass.cpp
llvm/test/CodeGen/Thumb2/mve-vpt-3-blocks-kill-vpr.mir

Removed: 




diff  --git a/llvm/lib/Target/ARM/MVEVPTBlockPass.cpp 
b/llvm/lib/Target/ARM/MVEVPTBlockPass.cpp
index 7b8a33d046fa..9a710b784fd1 100644
--- a/llvm/lib/Target/ARM/MVEVPTBlockPass.cpp
+++ b/llvm/lib/Target/ARM/MVEVPTBlockPass.cpp
@@ -285,20 +285,18 @@ bool MVEVPTBlock::InsertVPTBlocks(MachineBasicBlock 
&Block) {
   MIBuilder.addImm((uint64_t)BlockMask);
 }
 
+// Erase all dead instructions (VPNOT's). Do that now so that they do not
+// mess with the bundle creation.
+for (MachineInstr *DeadMI : DeadInstructions)
+  DeadMI->eraseFromParent();
+DeadInstructions.clear();
+
 finalizeBundle(
 Block, MachineBasicBlock::instr_iterator(MIBuilder.getInstr()), 
MBIter);
 
 Modified = true;
   }
 
-  // Erase all dead instructions
-  for (MachineInstr *DeadMI : DeadInstructions) {
-if (DeadMI->isInsideBundle())
-  DeadMI->eraseFromBundle();
-else
-  DeadMI->eraseFromParent();
-  }
-
   return Modified;
 }
 

diff  --git a/llvm/test/CodeGen/Thumb2/mve-vpt-3-blocks-kill-vpr.mir 
b/llvm/test/CodeGen/Thumb2/mve-vpt-3-blocks-kill-vpr.mir
index a60c217404be..03cd4ee690bf 100644
--- a/llvm/test/CodeGen/Thumb2/mve-vpt-3-blocks-kill-vpr.mir
+++ b/llvm/test/CodeGen/Thumb2/mve-vpt-3-blocks-kill-vpr.mir
@@ -68,10 +68,10 @@ body: |
 ; CHECK: liveins: $q0, $q1, $q2, $r0
 ; CHECK: $vpr = VMSR_P0 killed $r0, 14 /* CC::al */, $noreg
 ; CHECK: $q3 = MVE_VORR $q0, $q0, 0, $noreg, undef $q3
-; CHECK: BUNDLE implicit-def dead $q3, implicit-def $d6, implicit-def 
$s12, implicit-def $s13, implicit-def $d7, implicit-def $s14, implicit-def 
$s15, implicit-def $vpr, implicit-def $q1, implicit-def $d2, implicit-def $s4, 
implicit-def $s5, implicit-def $d3, implicit-def $s6, implicit-def $s7, 
implicit killed $vpr, implicit killed $q1, implicit $q2, implicit killed $q3 {
+; CHECK: BUNDLE implicit-def dead $q3, implicit-def $d6, implicit-def 
$s12, implicit-def $s13, implicit-def $d7, implicit-def $s14, implicit-def 
$s15, implicit-def $q1, implicit-def $d2, implicit-def $s4, implicit-def $s5, 
implicit-def $d3, implicit-def $s6, implicit-def $s7, implicit $vpr, implicit 
killed $q1, implicit $q2, implicit killed $q3 {
 ; CHECK:   MVE_VPST 12, implicit $vpr
 ; CHECK:   renamable $q3 = nnan ninf nsz MVE_VMINNMf32 killed renamable 
$q1, renamable $q2, 1, renamable $vpr, killed renamable $q3
-; CHECK:   renamable $q1 = nnan ninf nsz MVE_VMINNMf32 internal killed 
renamable $q3, internal renamable $q3, 2, internal renamable $vpr, undef 
renamable $q1
+; CHECK:   renamable $q1 = nnan ninf nsz MVE_VMINNMf32 internal killed 
renamable $q3, internal renamable $q3, 2, renamable $vpr, undef renamable $q1
 ; CHECK: }
 ; CHECK: $q3 = MVE_VORR $q0, $q0, 0, $noreg, undef $q3
 ; CHECK: BUNDLE implicit-def dead $q3, implicit-def $d6, implicit-def 
$s12, implicit-def $s13, implicit-def $d7, implicit-def $s14, implicit-def 
$s15, implicit-def $q0, implicit-def $d0, implicit-def $s0, implicit-def $s1, 
implicit-def $d1, implicit-def $s2, implicit-def $s3, implicit killed $vpr, 
implicit killed $q1, implicit killed $q2, implicit killed $q3, implicit killed 
$q0 {



___
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] 6c69d3d - [MLIR][SPIRV] Add initial support for OpSpecConstantOp.

2020-12-08 Thread Lei Zhang via llvm-branch-commits

Author: ergawy
Date: 2020-12-08T09:07:52-05:00
New Revision: 6c69d3d68e9a4438b47422e49c0f2d69e2b8e1b7

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

LOG: [MLIR][SPIRV] Add initial support for OpSpecConstantOp.

This commit adds initial support for SPIR-V OpSpecConstantOp
instruction. The following is introdcued:

- A new `spv.specConstantOperation` operation consisting of a single
region and of 2 operations within that regions (more details in the
docs of the op itself).
- A new `spv.yield` instruction that acts a terminator for
`spv.specConstantOperation`.

For now, the generic form of the new op is supported (i.e. no custom
parsing or printing). This will be done in a follow up patch.

Reviewed By: antiagainst

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

Added: 


Modified: 
mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
mlir/test/Dialect/SPIRV/structure-ops.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td 
b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td
index 0b1f6d294ac0..b8e76c3662ec 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td
@@ -607,6 +607,130 @@ def SPV_SpecConstantCompositeOp : 
SPV_Op<"specConstantComposite", [InModuleScope
 
   let autogenSerialization = 0;
 }
+
+def SPV_YieldOp : SPV_Op<"mlir.yield", [NoSideEffect, Terminator]> {
+  let summary = "Yields the result computed in `spv.SpecConstantOperation`'s"
+"region back to the parent op.";
+
+  let description = [{
+This op is a special terminator whose only purpose is to terminate
+an `spv.SpecConstantOperation`'s enclosed region. It accepts a
+single operand produced by the preceeding (and only other) instruction
+in its parent block (see SPV_SpecConstantOperation for further
+details). This op has no corresponding SPIR-V instruction.
+
+```
+spv.mlir.yield ::= `spv.mlir.yield` ssa-id : spirv-type
+```
+
+ Example:
+```mlir
+%0 = ... (some op supported by SPIR-V OpSpecConstantOp)
+spv.mlir.yield %0
+```
+  }];
+
+  let arguments = (ins AnyType:$operand);
+
+  let results = (outs);
+
+  let hasOpcode = 0;
+
+  let autogenSerialization = 0;
+
+  let assemblyFormat = "attr-dict $operand `:` type($operand)";
+}
+
+def SPV_SpecConstantOperationOp : SPV_Op<"SpecConstantOperation", [
+ InFunctionScope, NoSideEffect,
+ IsolatedFromAbove]> {
+  let summary = "Declare a new specialization constant that results from doing 
an operation.";
+
+  let description = [{
+This op declares a SPIR-V specialization constant that results from
+doing an operation on other constants (specialization or otherwise).
+
+In the `spv` dialect, this op is modelled as follows:
+
+```
+spv-spec-constant-operation-op ::= `"spv.SpecConstantOperation"`
+ `(`ssa-id (`, ` ssa-id)`)`
+   `({`
+ ssa-id = spirv-op
+ `spv.mlir.yield` ssa-id
+   `})` `:` function-type
+```
+
+In particular, an `spv.SpecConstantOperation` contains exactly one
+region. In turn, that region, contains exactly 2 instructions:
+- One of SPIR-V's instructions that are allowed within an
+OpSpecConstantOp.
+- An `spv.mlir.yield` instruction as the terminator.
+
+The following SPIR-V instructions are valid:
+- OpSConvert,
+- OpUConvert,
+- OpFConvert,
+- OpSNegate,
+- OpNot,
+- OpIAdd,
+- OpISub,
+- OpIMul,
+- OpUDiv,
+- OpSDiv,
+- OpUMod,
+- OpSRem,
+- OpSMod
+- OpShiftRightLogical,
+- OpShiftRightArithmetic,
+- OpShiftLeftLogical
+- OpBitwiseOr,
+- OpBitwiseXor,
+- OpBitwiseAnd
+- OpVectorShuffle,
+- OpCompositeExtract,
+- OpCompositeInsert
+- OpLogicalOr,
+- OpLogicalAnd,
+- OpLogicalNot,
+- OpLogicalEqual,
+- OpLogicalNotEqual
+- OpSelect
+- OpIEqual,
+- OpINotEqual
+- OpULessThan,
+- OpSLessThan
+- OpUGreaterThan,
+- OpSGreaterThan
+- OpULessThanEqual,
+- OpSLessThanEqual
+- OpUGreaterThanEqual,
+- OpSGreaterThanEqual
+
+TODO Add capability-specific ops when supported.
+
+ Example:
+```mlir
+%0 = spv.constant 1: i32
+
+%1 = "spv.SpecConstantOperation"(%0) ({
+  %ret = spv.IAdd %0, %0 : i32
+  spv.mlir.yield %ret : i32
+}) : (i32) -> i32
+```
+  }];
+
+  let arguments = (ins Variadic:$operands);
+
+  let results = (ou

[llvm-branch-commits] [llvm] 03663e4 - [AMDGPU] Add occupancy level tests for GFX10.3. NFC.

2020-12-08 Thread Jay Foad via llvm-branch-commits

Author: Jay Foad
Date: 2020-12-08T14:15:01Z
New Revision: 03663e4130d700c6c8ea28b357fcac4d31b617f7

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

LOG: [AMDGPU] Add occupancy level tests for GFX10.3. NFC.

getMaxWavesPerEU and getVGPRAllocGranule both changed in GFX10.3 and
they both affect the occupancy calculation.

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

Added: 


Modified: 
llvm/test/CodeGen/AMDGPU/occupancy-levels.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AMDGPU/occupancy-levels.ll 
b/llvm/test/CodeGen/AMDGPU/occupancy-levels.ll
index db70c3d9387d..25e0376dd7ee 100644
--- a/llvm/test/CodeGen/AMDGPU/occupancy-levels.ll
+++ b/llvm/test/CodeGen/AMDGPU/occupancy-levels.ll
@@ -1,18 +1,21 @@
 ; RUN: llc -march=amdgcn -mcpu=gfx900 < %s | FileCheck 
--check-prefixes=GCN,GFX9 %s
-; RUN: llc -march=amdgcn -mcpu=gfx1010 < %s | FileCheck 
--check-prefixes=GCN,GFX1010,GFX1010W32 %s
-; RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=+wavefrontsize64 < %s | 
FileCheck --check-prefixes=GCN,GFX1010,GFX1010W64 %s
+; RUN: llc -march=amdgcn -mcpu=gfx1010 < %s | FileCheck 
--check-prefixes=GCN,GFX10,GFX10W32,GFX1010,GFX1010W32 %s
+; RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=+wavefrontsize64 < %s | 
FileCheck --check-prefixes=GCN,GFX10,GFX10W64,GFX1010,GFX1010W64 %s
+; RUN: llc -march=amdgcn -mcpu=gfx1030 < %s | FileCheck 
--check-prefixes=GCN,GFX10,GFX10W32,GFX1030,GFX1030W32 %s
+; RUN: llc -march=amdgcn -mcpu=gfx1030 -mattr=+wavefrontsize64 < %s | 
FileCheck --check-prefixes=GCN,GFX10,GFX10W64,GFX1030,GFX1030W64 %s
 
 ; GCN-LABEL: {{^}}max_occupancy:
 ; GFX9:   ; Occupancy: 10
 ; GFX1010:; Occupancy: 20
+; GFX1030:; Occupancy: 16
 define amdgpu_kernel void @max_occupancy() {
   ret void
 }
 
 ; GCN-LABEL: {{^}}limited_occupancy_3:
 ; GFX9:   ; Occupancy: 3
-; GFX1010W64: ; Occupancy: 3
-; GFX1010W32: ; Occupancy: 4
+; GFX10W64:   ; Occupancy: 3
+; GFX10W32:   ; Occupancy: 4
 define amdgpu_kernel void @limited_occupancy_3() #0 {
   ret void
 }
@@ -20,6 +23,7 @@ define amdgpu_kernel void @limited_occupancy_3() #0 {
 ; GCN-LABEL: {{^}}limited_occupancy_18:
 ; GFX9:   ; Occupancy: 10
 ; GFX1010:; Occupancy: 18
+; GFX1030:; Occupancy: 16
 define amdgpu_kernel void @limited_occupancy_18() #1 {
   ret void
 }
@@ -27,6 +31,7 @@ define amdgpu_kernel void @limited_occupancy_18() #1 {
 ; GCN-LABEL: {{^}}limited_occupancy_19:
 ; GFX9:   ; Occupancy: 10
 ; GFX1010:; Occupancy: 18
+; GFX1030:; Occupancy: 16
 define amdgpu_kernel void @limited_occupancy_19() #2 {
   ret void
 }
@@ -34,6 +39,7 @@ define amdgpu_kernel void @limited_occupancy_19() #2 {
 ; GCN-LABEL: {{^}}used_24_vgprs:
 ; GFX9:   ; Occupancy: 10
 ; GFX1010:; Occupancy: 20
+; GFX1030:; Occupancy: 16
 define amdgpu_kernel void @used_24_vgprs() {
   call void asm sideeffect "", "~{v23}" ()
   ret void
@@ -43,6 +49,7 @@ define amdgpu_kernel void @used_24_vgprs() {
 ; GFX9:   ; Occupancy: 9
 ; GFX1010W64: ; Occupancy: 18
 ; GFX1010W32: ; Occupancy: 20
+; GFX1030:; Occupancy: 16
 define amdgpu_kernel void @used_28_vgprs() {
   call void asm sideeffect "", "~{v27}" ()
   ret void
@@ -50,8 +57,9 @@ define amdgpu_kernel void @used_28_vgprs() {
 
 ; GCN-LABEL: {{^}}used_32_vgprs:
 ; GFX9:   ; Occupancy: 8
-; GFX1010W64: ; Occupancy: 16
+; GFX10W64:   ; Occupancy: 16
 ; GFX1010W32: ; Occupancy: 20
+; GFX1030W32: ; Occupancy: 16
 define amdgpu_kernel void @used_32_vgprs() {
   call void asm sideeffect "", "~{v31}" ()
   ret void
@@ -61,6 +69,8 @@ define amdgpu_kernel void @used_32_vgprs() {
 ; GFX9:   ; Occupancy: 7
 ; GFX1010W64: ; Occupancy: 14
 ; GFX1010W32: ; Occupancy: 20
+; GFX1030W64: ; Occupancy: 12
+; GFX1030W32: ; Occupancy: 16
 define amdgpu_kernel void @used_36_vgprs() {
   call void asm sideeffect "", "~{v35}" ()
   ret void
@@ -68,8 +78,9 @@ define amdgpu_kernel void @used_36_vgprs() {
 
 ; GCN-LABEL: {{^}}used_40_vgprs:
 ; GFX9:   ; Occupancy: 6
-; GFX1010W64: ; Occupancy: 12
+; GFX10W64:   ; Occupancy: 12
 ; GFX1010W32: ; Occupancy: 20
+; GFX1030W32: ; Occupancy: 16
 define amdgpu_kernel void @used_40_vgprs() {
   call void asm sideeffect "", "~{v39}" ()
   ret void
@@ -79,6 +90,8 @@ define amdgpu_kernel void @used_40_vgprs() {
 ; GFX9:   ; Occupancy: 5
 ; GFX1010W64: ; Occupancy: 11
 ; GFX1010W32: ; Occupancy: 20
+; GFX1030W64: ; Occupancy: 10
+; GFX1030W32: ; Occupancy: 16
 define amdgpu_kernel void @used_44_vgprs() {
   call void asm sideeffect "", "~{v43}" ()
   ret void
@@ -86,8 +99,9 @@ define amdgpu_kernel void @used_44_vgprs() {
 
 ; GCN-LABEL: {{^}}used_48_vgprs:
 ; GFX9:   ; Occupancy: 5
-; GFX1010W64: ; Occupancy: 10
+; GFX10W64:   ; Occupancy: 10
 ; GFX1010W32: ; Occupancy: 20
+; GFX1030W32: ; Occupancy: 16
 define amdgpu_ker

[llvm-branch-commits] [llvm] e22259f - [SVE] Remove duplicate assert in DAGTypeLegalizer::SplitVecOp_EXTRACT_SUBVECTOR

2020-12-08 Thread David Sherwood via llvm-branch-commits

Author: David Sherwood
Date: 2020-12-08T14:41:14Z
New Revision: e22259fafe5e2f5e0219366ff92bba15ec70ff56

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

LOG: [SVE] Remove duplicate assert in 
DAGTypeLegalizer::SplitVecOp_EXTRACT_SUBVECTOR

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 9a0925061105..1525543a60b6 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -2281,10 +2281,6 @@ SDValue 
DAGTypeLegalizer::SplitVecOp_EXTRACT_SUBVECTOR(SDNode *N) {
   // We know that the extracted result type is legal.
   EVT SubVT = N->getValueType(0);
 
-  if (SubVT.isScalableVector() !=
-  N->getOperand(0).getValueType().isScalableVector())
-report_fatal_error("Extracting fixed from scalable not implemented");
-
   SDValue Idx = N->getOperand(1);
   SDLoc dl(N);
   SDValue Lo, Hi;



___
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] db61b18 - [compiler-rt] [builtins] Support conversion between fp16 and fp128

2020-12-08 Thread Adhemerval Zanella via llvm-branch-commits

Author: Adhemerval Zanella
Date: 2020-12-08T11:51:55-03:00
New Revision: db61b1844e11f29a06d6dc4aab87ebb4f0aabfdd

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

LOG: [compiler-rt] [builtins] Support conversion between fp16 and fp128

This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are built iff the compiler supports _Float16.

Some notes on ARM plaforms: while fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst). Also,
fp16 is a storage format and 64-bit ARM supports floating-point
convert precision to half as base armv8-a instruction.

This patch does not change the ABI for 32-bit ARM, it will continue
to pass _Float16 as uint16.

This re-enabled revert done by 
https://reviews.llvm.org/rGb534beabeed3ba1777cd0ff9ce552d077e496726

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

Added: 
compiler-rt/lib/builtins/extendhftf2.c
compiler-rt/lib/builtins/trunctfhf2.c
compiler-rt/test/builtins/Unit/extendhftf2_test.c
compiler-rt/test/builtins/Unit/trunctfhf2_test.c

Modified: 
compiler-rt/lib/builtins/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index 8bb367e6ce41f..d84f4d09e53e5 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -179,6 +179,7 @@ set(GENERIC_TF_SOURCES
   divtc3.c
   divtf3.c
   extenddftf2.c
+  extendhftf2.c
   extendsftf2.c
   fixtfdi.c
   fixtfsi.c
@@ -197,6 +198,7 @@ set(GENERIC_TF_SOURCES
   powitf2.c
   subtf3.c
   trunctfdf2.c
+  trunctfhf2.c
   trunctfsf2.c
 )
 

diff  --git a/compiler-rt/lib/builtins/extendhftf2.c 
b/compiler-rt/lib/builtins/extendhftf2.c
new file mode 100644
index 0..aefe9737d34f9
--- /dev/null
+++ b/compiler-rt/lib/builtins/extendhftf2.c
@@ -0,0 +1,23 @@
+//===-- lib/extendhftf2.c - half -> quad conversion ---*- C 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && 
\
+defined(COMPILER_RT_HAS_FLOAT16)
+#define SRC_HALF
+#define DST_QUAD
+#include "fp_extend_impl.inc"
+
+COMPILER_RT_ABI long double __extendhftf2(_Float16 a) {
+  return __extendXfYf2__(a);
+}
+
+#endif

diff  --git a/compiler-rt/lib/builtins/trunctfhf2.c 
b/compiler-rt/lib/builtins/trunctfhf2.c
new file mode 100644
index 0..e3a2309d954bc
--- /dev/null
+++ b/compiler-rt/lib/builtins/trunctfhf2.c
@@ -0,0 +1,23 @@
+//===-- lib/trunctfhf2.c - quad -> half conversion *- C 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && 
\
+defined(COMPILER_RT_HAS_FLOAT16)
+#define SRC_QUAD
+#define DST_HALF
+#include "fp_trunc_impl.inc"
+
+COMPILER_RT_ABI _Float16 __trunctfhf2(long double a) {
+  return __truncXfYf2__(a);
+}
+
+#endif

diff  --git a/compiler-rt/test/builtins/Unit/extendhftf2_test.c 
b/compiler-rt/test/builtins/Unit/extendhftf2_test.c
new file mode 100644
index 0..7d3ea3049e8a1
--- /dev/null
+++ b/compiler-rt/test/builtins/Unit/extendhftf2_test.c
@@ -0,0 +1,95 @@
+// RUN: %clang_builtins %s %librt -o %t && %run %t
+// REQUIRES: librt_has_extendhftf2
+
+#include "int_lib.h"
+#include 
+
+#if __LDBL_MANT_DIG__ == 113 && defined(COMPILER_RT_HAS_FLOAT16)
+
+#include "fp_test.h"
+
+COMPILER_RT_ABI long double __extendhftf2(TYPE_FP16 a);
+
+int test__extendhftf2(TYPE_FP16 a, uint64_t expectedHi, uint64_t expectedLo) {
+  long double x = __extendhftf2(a);
+  int ret = compareResultLD(x, expectedHi, expectedLo);
+
+  if (ret) {
+printf("error in test__extendhftf2(%#.4x) = %.20Lf, "
+   "expected %.20Lf\n",
+   toRep16(a), x,
+   fromRep128(expectedHi, expectedLo));
+  }
+  return ret;
+}
+
+char assumption_1[sizeof(TYPE_FP16) * CHAR_BIT == 16] = {0};
+
+#endif
+
+int main() {
+#if __LDBL_MANT_DIG__ == 113 && defined(COMPILER_RT_HAS_FLOAT16)
+  // qNaN
+  if (test__extendhftf2(makeQNaN16(),
+UINT6

[llvm-branch-commits] [clang-tools-extra] f6b205d - [clangd] ExtractFunction: disable on regions that sometimes, but not always return.

2020-12-08 Thread Adam Czachorowski via llvm-branch-commits

Author: Adam Czachorowski
Date: 2020-12-08T15:55:32+01:00
New Revision: f6b205dae16392382324fbca676ef6afe3920642

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

LOG: [clangd] ExtractFunction: disable on regions that sometimes, but not 
always return.

apply() will fail in those cases, so it's better to detect it in
prepare() already and hide code action from the user.

This was especially annoying on code bases that use a lot of
RETURN_IF_ERROR-like macros.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 18fe7bf39160..8eec42876d6b 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -708,6 +708,27 @@ tooling::Replacement createFunctionDefinition(const 
NewFunction &ExtractedFunc,
   return tooling::Replacement(SM, ExtractedFunc.InsertionPoint, 0, 
FunctionDef);
 }
 
+// Returns true if ExtZone contains any ReturnStmts.
+bool hasReturnStmt(const ExtractionZone &ExtZone) {
+  class ReturnStmtVisitor
+  : public clang::RecursiveASTVisitor {
+  public:
+bool VisitReturnStmt(ReturnStmt *Return) {
+  Found = true;
+  return false; // We found the answer, abort the scan.
+}
+bool Found = false;
+  };
+
+  ReturnStmtVisitor V;
+  for (const Stmt *RootStmt : ExtZone.RootStmts) {
+V.TraverseStmt(const_cast(RootStmt));
+if (V.Found)
+  break;
+  }
+  return V.Found;
+}
+
 bool ExtractFunction::prepare(const Selection &Inputs) {
   const LangOptions &LangOpts = Inputs.AST->getLangOpts();
   if (!LangOpts.CPlusPlus)
@@ -715,8 +736,12 @@ bool ExtractFunction::prepare(const Selection &Inputs) {
   const Node *CommonAnc = Inputs.ASTSelection.commonAncestor();
   const SourceManager &SM = Inputs.AST->getSourceManager();
   auto MaybeExtZone = findExtractionZone(CommonAnc, SM, LangOpts);
+  if (!MaybeExtZone ||
+  (hasReturnStmt(*MaybeExtZone) && !alwaysReturns(*MaybeExtZone)))
+return false;
+
   // FIXME: Get rid of this check once we support hoisting.
-  if (!MaybeExtZone || MaybeExtZone->requiresHoisting(SM))
+  if (MaybeExtZone->requiresHoisting(SM))
 return false;
 
   ExtZone = std::move(*MaybeExtZone);

diff  --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp 
b/clang-tools-extra/clangd/unittests/TweakTests.cpp
index 07f061b3f2e3..85edd92d27da 100644
--- a/clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -607,7 +607,11 @@ TEST_F(ExtractFunctionTest, FunctionTest) {
   // Extract certain return
   EXPECT_THAT(apply(" if(true) [[{ return; }]] "), HasSubstr("extracted"));
   // Don't extract uncertain return
-  EXPECT_THAT(apply(" if(true) [[if (false) return;]] "), StartsWith("fail"));
+  EXPECT_THAT(apply(" if(true) [[if (false) return;]] "),
+  StartsWith("unavailable"));
+  EXPECT_THAT(
+  apply("#define RETURN_IF_ERROR(x) if (x) return\nRETU^RN_IF_ERROR(4);"),
+  StartsWith("unavailable"));
 
   FileName = "a.c";
   EXPECT_THAT(apply(" for([[int i = 0;]];);"), HasSubstr("unavailable"));



___
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] 16622d5 - [clang-tidy] Recognize single character needles for absl::StrContains.

2020-12-08 Thread Chris Kennelly via llvm-branch-commits

Author: Chris Kennelly
Date: 2020-12-08T10:01:30-05:00
New Revision: 16622d535c021b566c1304b6388a6399e606

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

LOG: [clang-tidy] Recognize single character needles for absl::StrContains.

Commit fbdff6f3ae0b in the Abseil tree adds an overload for
absl::StrContains to accept a single character needle for optimized
lookups.

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
index cd890e4837e0..977c1919cee3 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
@@ -31,6 +31,8 @@ using ::clang::transformer::makeRule;
 using ::clang::transformer::node;
 using ::clang::transformer::RewriteRule;
 
+AST_MATCHER(Type, isCharType) { return Node.isCharType(); }
+
 static const char DefaultStringLikeClasses[] = "::std::basic_string;"
"::std::basic_string_view;"
"::absl::string_view";
@@ -58,13 +60,15 @@ MakeRule(const LangOptions &LangOpts,
   hasUnqualifiedDesugaredType(recordType(hasDeclaration(StringLikeClass)));
   auto CharStarType =
   hasUnqualifiedDesugaredType(pointerType(pointee(isAnyCharacter(;
+  auto CharType = hasUnqualifiedDesugaredType(isCharType());
   auto StringNpos = declRefExpr(
   to(varDecl(hasName("npos"), hasDeclContext(StringLikeClass;
   auto StringFind = cxxMemberCallExpr(
   callee(cxxMethodDecl(
   hasName("find"),
-  hasParameter(0, parmVarDecl(anyOf(hasType(StringType),
-hasType(CharStarType)),
+  hasParameter(
+  0, parmVarDecl(anyOf(hasType(StringType), hasType(CharStarType),
+   hasType(CharType)),
   on(hasType(StringType)), hasArgument(0, 
expr().bind("parameter_to_find")),
   anyOf(hasArgument(1, integerLiteral(equals(0))),
 hasArgument(1, cxxDefaultArgExpr())),

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
index 9d4b03aa22f2..81a3fc4d3b97 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
@@ -226,17 +226,21 @@ void string_literal_and_char_ptr_tests() {
   // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(asv, cc);{{$}}
 }
 
-// Confirms that it does *not* match when the parameter to find() is a char,
-// because absl::StrContains is not implemented for char.
-void no_char_param_tests() {
+void char_param_tests() {
   std::string ss;
   ss.find('c') == std::string::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(ss, 'c');{{$}}
 
   std::string_view ssv;
   ssv.find('c') == std::string_view::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(ssv, 'c');{{$}}
 
   absl::string_view asv;
   asv.find('c') == absl::string_view::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(asv, 'c');{{$}}
 }
 
 #define FOO(a, b, c, d) ((a).find(b) == std::string::npos ? (c) : (d))



___
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] acd4950 - [FPEnv] Correct constrained metadata in fp16-ops-strict.c

2020-12-08 Thread Kevin P. Neal via llvm-branch-commits

Author: Kevin P. Neal
Date: 2020-12-08T10:18:32-05:00
New Revision: acd4950d4f1e4ef5375a8a894a5b359caf7e844b

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

LOG: [FPEnv] Correct constrained metadata in fp16-ops-strict.c

This test shows we're in some cases not getting strictfp information from
the AST. Correct that.

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/fp16-ops-strictfp.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 4210e810acb7..973cefd831e6 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2550,6 +2550,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const 
UnaryOperator *E, LValue LV,
   } else if (type->isRealFloatingType()) {
 // Add the inc/dec to the real part.
 llvm::Value *amt;
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 
 if (type->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) {
   // Another special case: half FP increment should be done via float
@@ -3001,6 +3002,7 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue(
   else
 OpInfo.LHS = EmitLoadOfLValue(LHSLV, E->getExprLoc());
 
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, OpInfo.FPFeatures);
   SourceLocation Loc = E->getExprLoc();
   OpInfo.LHS =
   EmitScalarConversion(OpInfo.LHS, LHSTy, E->getComputationLHSType(), Loc);

diff  --git a/clang/test/CodeGen/fp16-ops-strictfp.c 
b/clang/test/CodeGen/fp16-ops-strictfp.c
index fd50d56a852c..d81febad0c36 100644
--- a/clang/test/CodeGen/fp16-ops-strictfp.c
+++ b/clang/test/CodeGen/fp16-ops-strictfp.c
@@ -11,7 +11,6 @@
 //
 // Test that the constrained intrinsics are picking up the exception
 // metadata from the AST instead of the global default from the command line.
-// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
 
 #pragma float_control(except, on)
 
@@ -62,31 +61,31 @@ void foo(void) {
   // NOTNATIVE: store {{.*}} half {{.*}}, half*
   h1 = +h1;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float 
%{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float 
%{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: store {{.*}} half {{.*}}, half*
   h1++;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float 
%{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float 
%{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: store {{.*}} half {{.*}}, half*
   ++h1;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xHBC00, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, meta

[llvm-branch-commits] [llvm] 03e675f - [ARM] Turn pred_cast(xor(x, -1)) into xor(pred_cast(x), -1)

2020-12-08 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-08T15:22:46Z
New Revision: 03e675fd128bed754454fc176357ad0ec6660c47

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

LOG: [ARM] Turn pred_cast(xor(x, -1)) into xor(pred_cast(x), -1)

This folds a not (an xor -1) though a predicate_cast, so that it can be
turned into a VPNOT and potentially be folded away as an else predicate
inside a VPT block.

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

Added: 


Modified: 
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index bc9222151899..1c6acbcf1a88 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -13848,6 +13848,16 @@ PerformPREDICATE_CASTCombine(SDNode *N, 
TargetLowering::DAGCombinerInfo &DCI) {
 return DCI.DAG.getNode(ARMISD::PREDICATE_CAST, dl, VT, Op->getOperand(0));
   }
 
+  // Turn pred_cast(xor x, -1) into xor(pred_cast x, -1), in order to produce
+  // more VPNOT which might get folded as else predicates.
+  if (Op.getValueType() == MVT::i32 && isBitwiseNot(Op)) {
+SDValue X =
+DCI.DAG.getNode(ARMISD::PREDICATE_CAST, dl, VT, Op->getOperand(0));
+SDValue C = DCI.DAG.getNode(ARMISD::PREDICATE_CAST, dl, VT,
+DCI.DAG.getConstant(65535, dl, MVT::i32));
+return DCI.DAG.getNode(ISD::XOR, dl, VT, X, C);
+  }
+
   // Only the bottom 16 bits of the source register are used.
   if (Op.getValueType() == MVT::i32) {
 APInt DemandedMask = APInt::getLowBitsSet(32, 16);

diff  --git a/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll 
b/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
index 17f57743c301..2d5b6ba0cafa 100644
--- a/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
+++ b/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
@@ -52,14 +52,11 @@ define arm_aapcs_vfpcc void @const(<8 x i16> %acc0, <8 x 
i16> %acc1, i32* nocapt
 ; CHECK-NEXT:.save {r4, r6, r7, lr}
 ; CHECK-NEXT:push {r4, r6, r7, lr}
 ; CHECK-NEXT:vmsr p0, r1
-; CHECK-NEXT:mvns r1, r1
-; CHECK-NEXT:vpstt
+; CHECK-NEXT:vpsttee
 ; CHECK-NEXT:vaddvt.s16 r12, q1
 ; CHECK-NEXT:vaddvt.s16 r2, q0
-; CHECK-NEXT:vmsr p0, r1
-; CHECK-NEXT:vpstt
-; CHECK-NEXT:vaddvt.s16 r4, q1
-; CHECK-NEXT:vaddvt.s16 r6, q0
+; CHECK-NEXT:vaddve.s16 r4, q1
+; CHECK-NEXT:vaddve.s16 r6, q0
 ; CHECK-NEXT:stm.w r0, {r2, r6, r12}
 ; CHECK-NEXT:str r4, [r0, #12]
 ; CHECK-NEXT:pop {r4, r6, r7, pc}
@@ -88,9 +85,9 @@ entry:
 define arm_aapcs_vfpcc <4 x i32> @xorvpnot_i32(<4 x i32> %acc0, i16 signext 
%p0) {
 ; CHECK-LABEL: xorvpnot_i32:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:mvns r0, r0
-; CHECK-NEXT:vmov.i32 q1, #0x0
 ; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vmov.i32 q1, #0x0
+; CHECK-NEXT:vpnot
 ; CHECK-NEXT:vpsel q0, q0, q1
 ; CHECK-NEXT:bx lr
 entry:
@@ -104,9 +101,9 @@ entry:
 define arm_aapcs_vfpcc <8 x i16> @xorvpnot_i16(<8 x i16> %acc0, i16 signext 
%p0) {
 ; CHECK-LABEL: xorvpnot_i16:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:mvns r0, r0
-; CHECK-NEXT:vmov.i32 q1, #0x0
 ; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vmov.i32 q1, #0x0
+; CHECK-NEXT:vpnot
 ; CHECK-NEXT:vpsel q0, q0, q1
 ; CHECK-NEXT:bx lr
 entry:
@@ -120,9 +117,9 @@ entry:
 define arm_aapcs_vfpcc <16 x i8> @xorvpnot_i8(<16 x i8> %acc0, i16 signext 
%p0) {
 ; CHECK-LABEL: xorvpnot_i8:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:mvns r0, r0
-; CHECK-NEXT:vmov.i32 q1, #0x0
 ; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vmov.i32 q1, #0x0
+; CHECK-NEXT:vpnot
 ; CHECK-NEXT:vpsel q0, q0, q1
 ; CHECK-NEXT:bx lr
 entry:
@@ -133,6 +130,21 @@ entry:
   ret <16 x i8> %l6
 }
 
+define arm_aapcs_vfpcc <16 x i8> @xorvpnot_i8_2(<16 x i8> %acc0, i32 %p0) {
+; CHECK-LABEL: xorvpnot_i8_2:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vmov.i32 q1, #0x0
+; CHECK-NEXT:vpnot
+; CHECK-NEXT:vpsel q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %l3 = xor i32 %p0, 65535
+  %l5 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %l3)
+  %l6 = select <16 x i1> %l5, <16 x i8> %acc0, <16 x i8> zeroinitializer
+  ret <16 x i8> %l6
+}
+
 
 
 declare i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1>)



___
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] 8d2c095 - [clang-tidy] Omit std::make_unique/make_shared for default initialization.

2020-12-08 Thread Chris Kennelly via llvm-branch-commits

Author: Chris Kennelly
Date: 2020-12-08T10:34:17-05:00
New Revision: 8d2c095e5a6bd34f8bb5cffd5c57c8deea5b8647

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

LOG: [clang-tidy] Omit std::make_unique/make_shared for default initialization.

This extends the check for default initialization in arrays added in
547f89d6070 to include scalar types and exclude them from the suggested fix for
make_unique/make_shared.

Rewriting std::unique_ptr(new int) as std::make_unique() (or for
other, similar trivial T) switches from default initialization to value
initialization, a performance regression for trivial T.  For these use cases,
std::make_unique_for_overwrite is more suitable alternative.

Reviewed By: hokein

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique-default-init.cpp

Modified: 
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
clang-tools-extra/docs/clang-tidy/checks/modernize-make-shared.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-make-unique.rst
clang-tools-extra/test/clang-tidy/checkers/modernize-make-shared.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index c00067fa8257..a7aaca1de5bd 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -6,6 +6,7 @@
 //
 
//===--===//
 
+#include "../utils/TypeTraits.h"
 #include "MakeSharedCheck.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Lexer.h"
@@ -49,13 +50,17 @@ MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, 
ClangTidyContext *Context,
   Options.get("MakeSmartPtrFunctionHeader", "")),
   MakeSmartPtrFunctionName(
   Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)),
-  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
+  IgnoreDefaultInitialization(
+  Options.get("IgnoreDefaultInitialization", true)) {}
 
 void MakeSmartPtrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "IncludeStyle", Inserter.getStyle());
   Options.store(Opts, "MakeSmartPtrFunctionHeader", 
MakeSmartPtrFunctionHeader);
   Options.store(Opts, "MakeSmartPtrFunction", MakeSmartPtrFunctionName);
   Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+  Options.store(Opts, "IgnoreDefaultInitialization",
+IgnoreDefaultInitialization);
 }
 
 bool MakeSmartPtrCheck::isLanguageVersionSupported(
@@ -120,14 +125,18 @@ void MakeSmartPtrCheck::check(const 
MatchFinder::MatchResult &Result) {
   if (New->getType()->getPointeeType()->getContainedAutoType())
 return;
 
-  // Be conservative for cases where we construct an array without any
-  // initialization.
+  // Be conservative for cases where we construct and default initialize.
+  //
   // For example,
+  //P.reset(new int)// check fix: P = std::make_unique()
   //P.reset(new int[5]) // check fix: P = std::make_unique(5)
   //
-  // The fix of the check has side effect, it introduces default initialization
+  // The fix of the check has side effect, it introduces value initialization
   // which maybe unexpected and cause performance regression.
-  if (New->isArray() && !New->hasInitializer())
+  bool Initializes = New->hasInitializer() ||
+ !utils::type_traits::isTriviallyDefaultConstructible(
+ New->getAllocatedType(), *Result.Context);
+  if (!Initializes && IgnoreDefaultInitialization)
 return;
   if (Construct)
 checkConstruct(SM, Result.Context, Construct, Type, New);

diff  --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
index 7a1bba624c53..ca12d7734162 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -50,6 +50,7 @@ class MakeSmartPtrCheck : public ClangTidyCheck {
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
   const bool IgnoreMacros;
+  const bool IgnoreDefaultInitialization;
 
   void checkConstruct(SourceManager &SM, ASTContext *Ctx,
   const CXXConstructExpr *Construct, const QualType *Type,

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/modernize-make-shared.rst 
b/clang-

[llvm-branch-commits] [llvm] bbc5c4b - [X86] Regenerate clzero.ll tests

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

Author: Simon Pilgrim
Date: 2020-12-08T15:36:47Z
New Revision: bbc5c4bf40907275a1bca62711198afc51eebd1d

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

LOG: [X86] Regenerate clzero.ll tests

Replace X32 check prefixes with X86 - X32 is generally used for gnux triple 
tests

Added: 


Modified: 
llvm/test/CodeGen/X86/clzero.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/clzero.ll b/llvm/test/CodeGen/X86/clzero.ll
index a185cb7d05bd..a0a97ae348d2 100644
--- a/llvm/test/CodeGen/X86/clzero.ll
+++ b/llvm/test/CodeGen/X86/clzero.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s -mtriple=x86_64-linux -mattr=+clzero | FileCheck %s 
--check-prefix=X64
-; RUN: llc < %s -mtriple=i386-pc-linux -mattr=+clzero | FileCheck %s 
--check-prefix=X32
+; RUN: llc < %s -mtriple=i386-pc-linux -mattr=+clzero | FileCheck %s 
--check-prefix=X86
 
 define void @foo(i8* %p) #0 {
 ; X64-LABEL: foo:
@@ -9,11 +9,11 @@ define void @foo(i8* %p) #0 {
 ; X64-NEXT:clzero
 ; X64-NEXT:retq
 ;
-; X32-LABEL: foo:
-; X32:   # %bb.0: # %entry
-; X32-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-NEXT:clzero
-; X32-NEXT:retl
+; X86-LABEL: foo:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:clzero
+; X86-NEXT:retl
 entry:
   tail call void @llvm.x86.clzero(i8* %p) #1
   ret void



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


[llvm-branch-commits] [llvm] dcff846 - [X86] Regenerate sttni.ll tests

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

Author: Simon Pilgrim
Date: 2020-12-08T15:36:47Z
New Revision: dcff846f4dcac0aa605af0fb1a6290a9d79fb56e

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

LOG: [X86] Regenerate sttni.ll tests

Replace X32 check prefixes with X86 - X32 is generally used for gnux triple 
tests

Added: 


Modified: 
llvm/test/CodeGen/X86/sttni.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/sttni.ll b/llvm/test/CodeGen/X86/sttni.ll
index 021fb2ce15a9..53ba7d61fbd5 100644
--- a/llvm/test/CodeGen/X86/sttni.ll
+++ b/llvm/test/CodeGen/X86/sttni.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse4.2 | FileCheck %s 
--check-prefix=X32
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse4.2 | FileCheck %s 
--check-prefix=X86
 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s 
--check-prefix=X64
 
 declare i32 @llvm.x86.sse42.pcmpestric128(<16 x i8> %lhs, i32, <16 x i8>, i32, 
i8)
@@ -10,13 +10,13 @@ declare i32 @llvm.x86.sse42.pcmpistri128(<16 x i8> %lhs, 
<16 x i8>, i8)
 declare <16 x i8> @llvm.x86.sse42.pcmpistrm128(<16 x i8> %lhs, <16 x i8>, i8)
 
 define i1 @pcmpestri_reg_eq_i8(<16 x i8> %lhs, i32 %lhs_len, <16 x i8> %rhs, 
i32 %rhs_len) nounwind {
-; X32-LABEL: pcmpestri_reg_eq_i8:
-; X32:   # %bb.0: # %entry
-; X32-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-NEXT:movl {{[0-9]+}}(%esp), %edx
-; X32-NEXT:pcmpestri $24, %xmm1, %xmm0
-; X32-NEXT:setae %al
-; X32-NEXT:retl
+; X86-LABEL: pcmpestri_reg_eq_i8:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT:pcmpestri $24, %xmm1, %xmm0
+; X86-NEXT:setae %al
+; X86-NEXT:retl
 ;
 ; X64-LABEL: pcmpestri_reg_eq_i8:
 ; X64:   # %bb.0: # %entry
@@ -32,13 +32,13 @@ entry:
 }
 
 define i32 @pcmpestri_reg_idx_i8(<16 x i8> %lhs, i32 %lhs_len, <16 x i8> %rhs, 
i32 %rhs_len) nounwind {
-; X32-LABEL: pcmpestri_reg_idx_i8:
-; X32:   # %bb.0: # %entry
-; X32-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-NEXT:movl {{[0-9]+}}(%esp), %edx
-; X32-NEXT:pcmpestri $24, %xmm1, %xmm0
-; X32-NEXT:movl %ecx, %eax
-; X32-NEXT:retl
+; X86-LABEL: pcmpestri_reg_idx_i8:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT:pcmpestri $24, %xmm1, %xmm0
+; X86-NEXT:movl %ecx, %eax
+; X86-NEXT:retl
 ;
 ; X64-LABEL: pcmpestri_reg_idx_i8:
 ; X64:   # %bb.0: # %entry
@@ -53,31 +53,31 @@ entry:
 }
 
 define i32 @pcmpestri_reg_
diff _i8(<16 x i8> %lhs, i32 %lhs_len, <16 x i8> %rhs, i32 %rhs_len) nounwind {
-; X32-LABEL: pcmpestri_reg_
diff _i8:
-; X32:   # %bb.0: # %entry
-; X32-NEXT:pushl %ebp
-; X32-NEXT:movl %esp, %ebp
-; X32-NEXT:andl $-16, %esp
-; X32-NEXT:subl $48, %esp
-; X32-NEXT:movl 8(%ebp), %eax
-; X32-NEXT:movl 12(%ebp), %edx
-; X32-NEXT:pcmpestri $24, %xmm1, %xmm0
-; X32-NEXT:cmpl $16, %ecx
-; X32-NEXT:jne .LBB2_2
-; X32-NEXT:  # %bb.1:
-; X32-NEXT:xorl %eax, %eax
-; X32-NEXT:jmp .LBB2_3
-; X32-NEXT:  .LBB2_2: # %compare
-; X32-NEXT:movdqa %xmm0, (%esp)
-; X32-NEXT:andl $15, %ecx
-; X32-NEXT:movb (%esp,%ecx), %al
-; X32-NEXT:movdqa %xmm1, {{[0-9]+}}(%esp)
-; X32-NEXT:subb 16(%esp,%ecx), %al
-; X32-NEXT:  .LBB2_3: # %exit
-; X32-NEXT:movzbl %al, %eax
-; X32-NEXT:movl %ebp, %esp
-; X32-NEXT:popl %ebp
-; X32-NEXT:retl
+; X86-LABEL: pcmpestri_reg_
diff _i8:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:pushl %ebp
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:andl $-16, %esp
+; X86-NEXT:subl $48, %esp
+; X86-NEXT:movl 8(%ebp), %eax
+; X86-NEXT:movl 12(%ebp), %edx
+; X86-NEXT:pcmpestri $24, %xmm1, %xmm0
+; X86-NEXT:cmpl $16, %ecx
+; X86-NEXT:jne .LBB2_2
+; X86-NEXT:  # %bb.1:
+; X86-NEXT:xorl %eax, %eax
+; X86-NEXT:jmp .LBB2_3
+; X86-NEXT:  .LBB2_2: # %compare
+; X86-NEXT:movdqa %xmm0, (%esp)
+; X86-NEXT:andl $15, %ecx
+; X86-NEXT:movb (%esp,%ecx), %al
+; X86-NEXT:movdqa %xmm1, {{[0-9]+}}(%esp)
+; X86-NEXT:subb 16(%esp,%ecx), %al
+; X86-NEXT:  .LBB2_3: # %exit
+; X86-NEXT:movzbl %al, %eax
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:retl
 ;
 ; X64-LABEL: pcmpestri_reg_
diff _i8:
 ; X64:   # %bb.0: # %entry
@@ -117,18 +117,18 @@ exit:
 }
 
 define i1 @pcmpestri_mem_eq_i8(i8* %lhs_ptr, i32 %lhs_len, i8* %rhs_ptr, i32 
%rhs_len) nounwind {
-; X32-LABEL: pcmpestri_mem_eq_i8:
-; X32:   # %bb.0: # %entry
-; X32-NEXT:pushl %esi
-; X32-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-NEXT:movl {{[0-9]+}}(%esp), %edx
-; X32-NEXT:movl {{[0-9]+}}(

[llvm-branch-commits] [llvm] 3204282 - [X86] Regenerate addcarry2.ll tests

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

Author: Simon Pilgrim
Date: 2020-12-08T15:36:48Z
New Revision: 3204282a988eb6b8a78ac983c47681726b31d360

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

LOG: [X86] Regenerate addcarry2.ll tests

Replace X32 check prefixes with X86 - X32 is generally used for gnux triple 
tests

Added: 


Modified: 
llvm/test/CodeGen/X86/addcarry2.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/addcarry2.ll 
b/llvm/test/CodeGen/X86/addcarry2.ll
index 2fef838e57cf..a4069741e208 100644
--- a/llvm/test/CodeGen/X86/addcarry2.ll
+++ b/llvm/test/CodeGen/X86/addcarry2.ll
@@ -1,22 +1,22 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=i686-unknown-unknown --show-mc-encoding | FileCheck 
%s --check-prefix=X32
+; RUN: llc < %s -mtriple=i686-unknown-unknown --show-mc-encoding | FileCheck 
%s --check-prefix=X86
 ; RUN: llc < %s -mtriple=x86_64-unknown   --show-mc-encoding | FileCheck 
%s --check-prefix=X64
 
 define void @adc_load_store_64_15(i64* inreg %x, i64* inreg %x2, i64 inreg %y) 
nounwind {
-; X32-LABEL: adc_load_store_64_15:
-; X32:   # %bb.0:
-; X32-NEXT:pushl %esi # encoding: [0x56]
-; X32-NEXT:movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x08]
-; X32-NEXT:addl $1, %ecx # encoding: [0x83,0xc1,0x01]
-; X32-NEXT:adcl $0, %esi # encoding: [0x83,0xd6,0x00]
-; X32-NEXT:adcl $15, (%eax) # encoding: [0x83,0x10,0x0f]
-; X32-NEXT:adcl $0, 4(%eax) # encoding: [0x83,0x50,0x04,0x00]
-; X32-NEXT:setb %al # encoding: [0x0f,0x92,0xc0]
-; X32-NEXT:movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]
-; X32-NEXT:movl %eax, (%edx) # encoding: [0x89,0x02]
-; X32-NEXT:movl $0, 4(%edx) # encoding: 
[0xc7,0x42,0x04,0x00,0x00,0x00,0x00]
-; X32-NEXT:popl %esi # encoding: [0x5e]
-; X32-NEXT:retl # encoding: [0xc3]
+; X86-LABEL: adc_load_store_64_15:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %esi # encoding: [0x56]
+; X86-NEXT:movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x08]
+; X86-NEXT:addl $1, %ecx # encoding: [0x83,0xc1,0x01]
+; X86-NEXT:adcl $0, %esi # encoding: [0x83,0xd6,0x00]
+; X86-NEXT:adcl $15, (%eax) # encoding: [0x83,0x10,0x0f]
+; X86-NEXT:adcl $0, 4(%eax) # encoding: [0x83,0x50,0x04,0x00]
+; X86-NEXT:setb %al # encoding: [0x0f,0x92,0xc0]
+; X86-NEXT:movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]
+; X86-NEXT:movl %eax, (%edx) # encoding: [0x89,0x02]
+; X86-NEXT:movl $0, 4(%edx) # encoding: 
[0xc7,0x42,0x04,0x00,0x00,0x00,0x00]
+; X86-NEXT:popl %esi # encoding: [0x5e]
+; X86-NEXT:retl # encoding: [0xc3]
 ;
 ; X64-LABEL: adc_load_store_64_15:
 ; X64:   # %bb.0:
@@ -42,21 +42,21 @@ define void @adc_load_store_64_15(i64* inreg %x, i64* inreg 
%x2, i64 inreg %y) n
 }
 
 define void @adc_load_store_64_0x1000F(i64* inreg %x, i64* inreg %x2, i64 
inreg %y) nounwind {
-; X32-LABEL: adc_load_store_64_0x1000F:
-; X32:   # %bb.0:
-; X32-NEXT:pushl %esi # encoding: [0x56]
-; X32-NEXT:movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x08]
-; X32-NEXT:addl $1, %ecx # encoding: [0x83,0xc1,0x01]
-; X32-NEXT:adcl $0, %esi # encoding: [0x83,0xd6,0x00]
-; X32-NEXT:adcl $65551, (%eax) # encoding: [0x81,0x10,0x0f,0x00,0x01,0x00]
-; X32-NEXT:# imm = 0x1000F
-; X32-NEXT:adcl $0, 4(%eax) # encoding: [0x83,0x50,0x04,0x00]
-; X32-NEXT:setb %al # encoding: [0x0f,0x92,0xc0]
-; X32-NEXT:movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]
-; X32-NEXT:movl %eax, (%edx) # encoding: [0x89,0x02]
-; X32-NEXT:movl $0, 4(%edx) # encoding: 
[0xc7,0x42,0x04,0x00,0x00,0x00,0x00]
-; X32-NEXT:popl %esi # encoding: [0x5e]
-; X32-NEXT:retl # encoding: [0xc3]
+; X86-LABEL: adc_load_store_64_0x1000F:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %esi # encoding: [0x56]
+; X86-NEXT:movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x08]
+; X86-NEXT:addl $1, %ecx # encoding: [0x83,0xc1,0x01]
+; X86-NEXT:adcl $0, %esi # encoding: [0x83,0xd6,0x00]
+; X86-NEXT:adcl $65551, (%eax) # encoding: [0x81,0x10,0x0f,0x00,0x01,0x00]
+; X86-NEXT:# imm = 0x1000F
+; X86-NEXT:adcl $0, 4(%eax) # encoding: [0x83,0x50,0x04,0x00]
+; X86-NEXT:setb %al # encoding: [0x0f,0x92,0xc0]
+; X86-NEXT:movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]
+; X86-NEXT:movl %eax, (%edx) # encoding: [0x89,0x02]
+; X86-NEXT:movl $0, 4(%edx) # encoding: 
[0xc7,0x42,0x04,0x00,0x00,0x00,0x00]
+; X86-NEXT:popl %esi # encoding: [0x5e]
+; X86-NEXT:retl # encoding: [0xc3]
 ;
 ; X64-LABEL: adc_load_store_64_0x1000F:
 ; X64:   # %bb.0:
@@ -83,20 +83,20 @@ define void @adc_load_store_64_0x1000F(i64* inreg %x, i64* 
inreg %x2, i64 inreg
 }
 
 define void @adc_load_store_64_0x11000F(i64* inreg %x, i64* inreg %x2,

[llvm-branch-commits] [llvm] 0785f12 - [X86] Regenerate bmi-intrinsics-fast-isel.ll tests

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

Author: Simon Pilgrim
Date: 2020-12-08T15:36:48Z
New Revision: 0785f12e6ebb7cdffe7191b5fe9a430a2979217e

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

LOG: [X86] Regenerate bmi-intrinsics-fast-isel.ll tests

Replace X32 check prefixes with X86 - X32 is generally used for gnux triple 
tests

Added: 


Modified: 
llvm/test/CodeGen/X86/bmi-intrinsics-fast-isel.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/bmi-intrinsics-fast-isel.ll 
b/llvm/test/CodeGen/X86/bmi-intrinsics-fast-isel.ll
index c6950da4064d..3db5fdaf825a 100644
--- a/llvm/test/CodeGen/X86/bmi-intrinsics-fast-isel.ll
+++ b/llvm/test/CodeGen/X86/bmi-intrinsics-fast-isel.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -fast-isel-sink-local-values < %s -fast-isel 
-mtriple=i686-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefix=X32
+; RUN: llc -fast-isel-sink-local-values < %s -fast-isel 
-mtriple=i686-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefix=X86
 ; RUN: llc -fast-isel-sink-local-values < %s -fast-isel 
-mtriple=x86_64-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefix=X64
 
 ; NOTE: This should use IR equivalent to what is generated by 
clang/test/CodeGen/bmi-builtins.c
@@ -9,10 +9,10 @@
 ;
 
 define i16 @test__tzcnt_u16(i16 %a0) {
-; X32-LABEL: test__tzcnt_u16:
-; X32:   # %bb.0:
-; X32-NEXT:tzcntw {{[0-9]+}}(%esp), %ax
-; X32-NEXT:retl
+; X86-LABEL: test__tzcnt_u16:
+; X86:   # %bb.0:
+; X86-NEXT:tzcntw {{[0-9]+}}(%esp), %ax
+; X86-NEXT:retl
 ;
 ; X64-LABEL: test__tzcnt_u16:
 ; X64:   # %bb.0:
@@ -25,12 +25,12 @@ define i16 @test__tzcnt_u16(i16 %a0) {
 }
 
 define i32 @test__andn_u32(i32 %a0, i32 %a1) {
-; X32-LABEL: test__andn_u32:
-; X32:   # %bb.0:
-; X32-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-NEXT:xorl $-1, %eax
-; X32-NEXT:andl {{[0-9]+}}(%esp), %eax
-; X32-NEXT:retl
+; X86-LABEL: test__andn_u32:
+; X86:   # %bb.0:
+; X86-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:xorl $-1, %eax
+; X86-NEXT:andl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:retl
 ;
 ; X64-LABEL: test__andn_u32:
 ; X64:   # %bb.0:
@@ -44,11 +44,11 @@ define i32 @test__andn_u32(i32 %a0, i32 %a1) {
 }
 
 define i32 @test__bextr_u32(i32 %a0, i32 %a1) {
-; X32-LABEL: test__bextr_u32:
-; X32:   # %bb.0:
-; X32-NEXT:movl {{[0-9]+}}(%esp), %eax
-; X32-NEXT:bextrl %eax, {{[0-9]+}}(%esp), %eax
-; X32-NEXT:retl
+; X86-LABEL: test__bextr_u32:
+; X86:   # %bb.0:
+; X86-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:bextrl %eax, {{[0-9]+}}(%esp), %eax
+; X86-NEXT:retl
 ;
 ; X64-LABEL: test__bextr_u32:
 ; X64:   # %bb.0:
@@ -59,13 +59,13 @@ define i32 @test__bextr_u32(i32 %a0, i32 %a1) {
 }
 
 define i32 @test__blsi_u32(i32 %a0) {
-; X32-LABEL: test__blsi_u32:
-; X32:   # %bb.0:
-; X32-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-NEXT:xorl %eax, %eax
-; X32-NEXT:subl %ecx, %eax
-; X32-NEXT:andl %ecx, %eax
-; X32-NEXT:retl
+; X86-LABEL: test__blsi_u32:
+; X86:   # %bb.0:
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:xorl %eax, %eax
+; X86-NEXT:subl %ecx, %eax
+; X86-NEXT:andl %ecx, %eax
+; X86-NEXT:retl
 ;
 ; X64-LABEL: test__blsi_u32:
 ; X64:   # %bb.0:
@@ -79,12 +79,12 @@ define i32 @test__blsi_u32(i32 %a0) {
 }
 
 define i32 @test__blsmsk_u32(i32 %a0) {
-; X32-LABEL: test__blsmsk_u32:
-; X32:   # %bb.0:
-; X32-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-NEXT:leal -1(%ecx), %eax
-; X32-NEXT:xorl %ecx, %eax
-; X32-NEXT:retl
+; X86-LABEL: test__blsmsk_u32:
+; X86:   # %bb.0:
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:leal -1(%ecx), %eax
+; X86-NEXT:xorl %ecx, %eax
+; X86-NEXT:retl
 ;
 ; X64-LABEL: test__blsmsk_u32:
 ; X64:   # %bb.0:
@@ -98,12 +98,12 @@ define i32 @test__blsmsk_u32(i32 %a0) {
 }
 
 define i32 @test__blsr_u32(i32 %a0) {
-; X32-LABEL: test__blsr_u32:
-; X32:   # %bb.0:
-; X32-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-NEXT:leal -1(%ecx), %eax
-; X32-NEXT:andl %ecx, %eax
-; X32-NEXT:retl
+; X86-LABEL: test__blsr_u32:
+; X86:   # %bb.0:
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:leal -1(%ecx), %eax
+; X86-NEXT:andl %ecx, %eax
+; X86-NEXT:retl
 ;
 ; X64-LABEL: test__blsr_u32:
 ; X64:   # %bb.0:
@@ -117,10 +117,10 @@ define i32 @test__blsr_u32(i32 %a0) {
 }
 
 define i32 @test__tzcnt_u32(i32 %a0) {
-; X32-LABEL: test__tzcnt_u32:
-; X32:   # %bb.0:
-; X32-NEXT:tzcntl {{[0-9]+}}(%esp), %eax
-; X32-NEXT:retl
+; X86-LABEL: test__tzcnt_u32:
+; X86:   # %bb.0:
+; X86-NEXT:tzcntl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:retl
 ;
 ; X64-LABEL: test__tzcnt_u32:
 ; X64:   # %bb.0:
@@ -136,10 +1

[llvm-branch-commits] [llvm] e18f8d6 - [X86] Regenerate store-narrow.ll tests

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

Author: Simon Pilgrim
Date: 2020-12-08T15:36:49Z
New Revision: e18f8d63bd7f8cb0baa12f142a2542aeb40847d6

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

LOG: [X86] Regenerate store-narrow.ll tests

Replace X32 check prefixes with X86 - X32 is generally used for gnux triple 
tests

Added: 


Modified: 
llvm/test/CodeGen/X86/store-narrow.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/store-narrow.ll 
b/llvm/test/CodeGen/X86/store-narrow.ll
index f71f2eefa0fb..122e384ee3c8 100644
--- a/llvm/test/CodeGen/X86/store-narrow.ll
+++ b/llvm/test/CodeGen/X86/store-narrow.ll
@@ -1,22 +1,24 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; rdar://7860110
 ; RUN: llc -mtriple=x86_64-apple-darwin10.2 < %s | FileCheck %s 
-check-prefix=X64
-; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=1 < %s | 
FileCheck %s -check-prefix=X32 -check-prefix=X32-BWON
-; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=0 < %s | 
FileCheck %s -check-prefix=X32 -check-prefix=X32-BWOFF
+; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=1 < %s | 
FileCheck %s -check-prefixes=X86,X86-BWON
+; RUN: llc -mtriple=i686-apple-darwin10.2 -fixup-byte-word-insts=0 < %s | 
FileCheck %s -check-prefixes=X86,X86-BWOFF
+
 target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 
+; rdar://7860110
+
 define void @test1(i32* nocapture %a0, i8 zeroext %a1) nounwind ssp {
 ; X64-LABEL: test1:
 ; X64:   ## %bb.0: ## %entry
 ; X64-NEXT:movb %sil, (%rdi)
 ; X64-NEXT:retq
 ;
-; X32-LABEL: test1:
-; X32:   ## %bb.0: ## %entry
-; X32-NEXT:movb {{[0-9]+}}(%esp), %al
-; X32-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-NEXT:movb %al, (%ecx)
-; X32-NEXT:retl
+; X86-LABEL: test1:
+; X86:   ## %bb.0: ## %entry
+; X86-NEXT:movb {{[0-9]+}}(%esp), %al
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:movb %al, (%ecx)
+; X86-NEXT:retl
 entry:
   %A = load i32, i32* %a0, align 4
   %B = and i32 %A, -256 ; 0xFF00
@@ -32,12 +34,12 @@ define void @test2(i32* nocapture %a0, i8 zeroext %a1) 
nounwind ssp {
 ; X64-NEXT:movb %sil, 1(%rdi)
 ; X64-NEXT:retq
 ;
-; X32-LABEL: test2:
-; X32:   ## %bb.0: ## %entry
-; X32-NEXT:movb {{[0-9]+}}(%esp), %al
-; X32-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-NEXT:movb %al, 1(%ecx)
-; X32-NEXT:retl
+; X86-LABEL: test2:
+; X86:   ## %bb.0: ## %entry
+; X86-NEXT:movb {{[0-9]+}}(%esp), %al
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:movb %al, 1(%ecx)
+; X86-NEXT:retl
 entry:
   %A = load i32, i32* %a0, align 4
   %B = and i32 %A, -65281; 0x00FF
@@ -54,19 +56,19 @@ define void @test3(i32* nocapture %a0, i16 zeroext %a1) 
nounwind ssp {
 ; X64-NEXT:movw %si, (%rdi)
 ; X64-NEXT:retq
 ;
-; X32-BWON-LABEL: test3:
-; X32-BWON:   ## %bb.0: ## %entry
-; X32-BWON-NEXT:movzwl {{[0-9]+}}(%esp), %eax
-; X32-BWON-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-BWON-NEXT:movw %ax, (%ecx)
-; X32-BWON-NEXT:retl
+; X86-BWON-LABEL: test3:
+; X86-BWON:   ## %bb.0: ## %entry
+; X86-BWON-NEXT:movzwl {{[0-9]+}}(%esp), %eax
+; X86-BWON-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-BWON-NEXT:movw %ax, (%ecx)
+; X86-BWON-NEXT:retl
 ;
-; X32-BWOFF-LABEL: test3:
-; X32-BWOFF:   ## %bb.0: ## %entry
-; X32-BWOFF-NEXT:movw {{[0-9]+}}(%esp), %ax
-; X32-BWOFF-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-BWOFF-NEXT:movw %ax, (%ecx)
-; X32-BWOFF-NEXT:retl
+; X86-BWOFF-LABEL: test3:
+; X86-BWOFF:   ## %bb.0: ## %entry
+; X86-BWOFF-NEXT:movw {{[0-9]+}}(%esp), %ax
+; X86-BWOFF-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-BWOFF-NEXT:movw %ax, (%ecx)
+; X86-BWOFF-NEXT:retl
 entry:
   %A = load i32, i32* %a0, align 4
   %B = and i32 %A, -65536; 0x
@@ -82,19 +84,19 @@ define void @test4(i32* nocapture %a0, i16 zeroext %a1) 
nounwind ssp {
 ; X64-NEXT:movw %si, 2(%rdi)
 ; X64-NEXT:retq
 ;
-; X32-BWON-LABEL: test4:
-; X32-BWON:   ## %bb.0: ## %entry
-; X32-BWON-NEXT:movzwl {{[0-9]+}}(%esp), %eax
-; X32-BWON-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-BWON-NEXT:movw %ax, 2(%ecx)
-; X32-BWON-NEXT:retl
+; X86-BWON-LABEL: test4:
+; X86-BWON:   ## %bb.0: ## %entry
+; X86-BWON-NEXT:movzwl {{[0-9]+}}(%esp), %eax
+; X86-BWON-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-BWON-NEXT:movw %ax, 2(%ecx)
+; X86-BWON-NEXT:retl
 ;
-; X32-BWOFF-LABEL: test4:
-; X32-BWOFF:   ## %bb.0: ## %entry
-; X32-BWOFF-NEXT:movw {{[0-9]+}}(%esp), %ax
-; X32-BWOFF-NEXT:movl {{[0-9]+}}(%esp), %ecx
-; X32-BWOFF-NEXT:movw %ax, 2(%ecx)
-; X32-BWOFF-NEXT:retl
+;

[llvm-branch-commits] [llvm] 2812c15 - [PowerPC] Fix missing nop after call to weak callee.

2020-12-08 Thread Stefan Pintilie via llvm-branch-commits

Author: Stefan Pintilie
Date: 2020-12-08T09:38:44-06:00
New Revision: 2812c1515627904e31605bbd4f25a887a1f8eb12

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

LOG: [PowerPC] Fix missing nop after call to weak callee.

Weak functions can be replaced by other functions at link time. Previously it
was assumed that no matter what the weak callee function was replaced with it
would still share the same TOC as the caller. This is no longer true as a weak
callee with a TOC setup can be replaced by another function that was compiled
with PC Relative and does not have a TOC at all.

This patch makes sure that all calls to functions defined as weak from a caller
that has a valid TOC have a nop after the call to allow a place for the linker
to restore the TOC.

Reviewed By: NeHuang

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/ppc64-blnop.ll
llvm/test/CodeGen/PowerPC/ppc64-calls.ll
llvm/test/CodeGen/PowerPC/ppc64-sibcall.ll
llvm/test/CodeGen/PowerPC/pr41088.ll
llvm/test/CodeGen/PowerPC/preemption.ll
llvm/test/CodeGen/PowerPC/xray-tail-call-hidden.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 90968a3ef8a7..b52054936af0 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -4799,6 +4799,13 @@ static bool callsShareTOCBase(const Function *Caller, 
SDValue Callee,
   if (STICallee->isUsingPCRelativeCalls())
 return false;
 
+  // If the GV is not a strong definition then we need to assume it can be
+  // replaced by another function at link time. The function that replaces
+  // it may not share the same TOC as the caller since the callee may be
+  // replaced by a PC Relative version of the same function.
+  if (!GV->isStrongDefinitionForLinker())
+return false;
+
   // The medium and large code models are expected to provide a sufficiently
   // large TOC to provide all data addressing needs of a module with a
   // single TOC.
@@ -4806,12 +4813,6 @@ static bool callsShareTOCBase(const Function *Caller, 
SDValue Callee,
   CodeModel::Large == TM.getCodeModel())
 return true;
 
-  // Otherwise we need to ensure callee and caller are in the same section,
-  // since the linker may allocate multiple TOCs, and we don't know which
-  // sections will belong to the same TOC base.
-  if (!GV->isStrongDefinitionForLinker())
-return false;
-
   // Any explicitly-specified sections and section prefixes must also match.
   // Also, if we're using -ffunction-sections, then each function is always in
   // a 
diff erent section (the same is true for COMDAT functions).

diff  --git a/llvm/test/CodeGen/PowerPC/ppc64-blnop.ll 
b/llvm/test/CodeGen/PowerPC/ppc64-blnop.ll
index 6c3b55d59879..da08390e0748 100644
--- a/llvm/test/CodeGen/PowerPC/ppc64-blnop.ll
+++ b/llvm/test/CodeGen/PowerPC/ppc64-blnop.ll
@@ -76,7 +76,7 @@ define void @wo_hcaller(%class.T* %this, i8* %c) {
 
 ; CHECK-LABEL: wo_hcaller:
 ; CHECK: bl wo_hcallee
-; CHECK-NOT: nop
+; CHECK-NEXT: nop
 
 ; SCM-LABEL: wo_hcaller:
 ; SCM:   bl wo_hcallee
@@ -90,7 +90,7 @@ define void @wo_pcaller(%class.T* %this, i8* %c) {
 
 ; CHECK-LABEL: wo_pcaller:
 ; CHECK: bl wo_pcallee
-; CHECK-NOT: nop
+; CHECK-NEXT: nop
 
 ; SCM-LABEL:   wo_pcaller:
 ; SCM: bl wo_pcallee
@@ -114,7 +114,7 @@ define void @w_pcaller(i8* %ptr) {
 
 ; CHECK-LABEL: w_pcaller:
 ; CHECK: bl w_pcallee
-; CHECK-NOT: nop
+; CHECK-NEXT: nop
 
 ; SCM-LABEL: w_pcaller:
 ; SCM:   bl w_pcallee
@@ -128,7 +128,7 @@ define void @w_hcaller(i8* %ptr) {
 
 ; CHECK-LABEL: w_hcaller:
 ; CHECK: bl w_hcallee
-; CHECK-NOT: nop
+; CHECK-NEXT: nop
 
 ; SCM-LABEL: w_hcaller:
 ; SCM:   bl w_hcallee

diff  --git a/llvm/test/CodeGen/PowerPC/ppc64-calls.ll 
b/llvm/test/CodeGen/PowerPC/ppc64-calls.ll
index 245056f7add9..87a746093c45 100644
--- a/llvm/test/CodeGen/PowerPC/ppc64-calls.ll
+++ b/llvm/test/CodeGen/PowerPC/ppc64-calls.ll
@@ -23,18 +23,14 @@ define void @test_direct() nounwind readnone {
   ret void
 }
 
-; Calls to weak function requires a TOC restore 'nop' with the small codemodel
+; Calls to weak function requires a TOC restore 'nop' with all code models
 ; because the definition that gets choosen at link time may come from a
-; 
diff erent section even though we have seen a weak definition in the same
-; section at compile time.
-; With large and medium codemodels no TOC restore is needed, since we know
-; whichever definition is choosen it resides within the same DSO boundaries and
-; therefore shares the same TOC.
+; 
diff erent compilation unit that was compiled with PC Relative and has no TOC.

[llvm-branch-commits] [mlir] 02c9050 - [mlir] Tighten access of RewritePattern methods.

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

Author: Christian Sigg
Date: 2020-12-08T16:44:51+01:00
New Revision: 02c9050155dff70497b3423ae95ed7d2ab7675a8

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

LOG: [mlir] Tighten access of RewritePattern methods.

In RewritePattern, only expose `matchAndRewrite` as a public function. `match` 
can be protected (but needs to be protected because we want to call it from an 
override of `matchAndRewrite`). `rewrite` can be private.

For classes deriving from RewritePattern, all 3 functions can be private.

Side note: I didn't understand the need for the `using 
RewritePattern::matchAndRewrite` in derived classes, and started poking around. 
They are gone now, and I think the result is (only very slightly) cleaner.

Reviewed By: ftynse

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

Added: 


Modified: 
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/include/mlir/IR/PatternMatch.h
mlir/include/mlir/Transforms/DialectConversion.h

Removed: 




diff  --git 
a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h 
b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index bf41f29749de..5b605c165be6 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -571,11 +571,9 @@ class ConvertOpToLLVMPattern : public ConvertToLLVMPattern 
{
  &typeConverter.getContext(), typeConverter,
  benefit) {}
 
-  /// Wrappers around the RewritePattern methods that pass the derived op type.
-  void rewrite(Operation *op, ArrayRef operands,
-   ConversionPatternRewriter &rewriter) const final {
-rewrite(cast(op), operands, rewriter);
-  }
+private:
+  /// Wrappers around the ConversionPattern methods that pass the derived op
+  /// type.
   LogicalResult match(Operation *op) const final {
 return match(cast(op));
   }
@@ -584,6 +582,10 @@ class ConvertOpToLLVMPattern : public ConvertToLLVMPattern 
{
   ConversionPatternRewriter &rewriter) const final {
 return matchAndRewrite(cast(op), operands, rewriter);
   }
+  void rewrite(Operation *op, ArrayRef operands,
+   ConversionPatternRewriter &rewriter) const final {
+rewrite(cast(op), operands, rewriter);
+  }
 
   /// Rewrite and Match methods that operate on the SourceOp type. These must 
be
   /// overridden by the derived pattern class.
@@ -603,10 +605,6 @@ class ConvertOpToLLVMPattern : public ConvertToLLVMPattern 
{
 }
 return failure();
   }
-
-private:
-  using ConvertToLLVMPattern::match;
-  using ConvertToLLVMPattern::matchAndRewrite;
 };
 
 namespace LLVM {
@@ -636,6 +634,7 @@ class OneToOneConvertToLLVMPattern : public 
ConvertOpToLLVMPattern {
   using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
   using Super = OneToOneConvertToLLVMPattern;
 
+private:
   /// Converts the type of the result to an LLVM type, pass operands as is,
   /// preserve attributes.
   LogicalResult
@@ -655,6 +654,7 @@ class VectorConvertToLLVMPattern : public 
ConvertOpToLLVMPattern {
   using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
   using Super = VectorConvertToLLVMPattern;
 
+private:
   LogicalResult
   matchAndRewrite(SourceOp op, ArrayRef operands,
   ConversionPatternRewriter &rewriter) const override {

diff  --git a/mlir/include/mlir/IR/PatternMatch.h 
b/mlir/include/mlir/IR/PatternMatch.h
index 0bbb2216ee7b..1739cfa4a80c 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -156,17 +156,6 @@ class RewritePattern : public Pattern {
 public:
   virtual ~RewritePattern() {}
 
-  /// Rewrite the IR rooted at the specified operation with the result of
-  /// this pattern, generating any new operations with the specified
-  /// builder.  If an unexpected error is encountered (an internal
-  /// compiler error), it is emitted through the normal MLIR diagnostic
-  /// hooks and the IR is left in a valid state.
-  virtual void rewrite(Operation *op, PatternRewriter &rewriter) const;
-
-  /// Attempt to match against code rooted at the specified operation,
-  /// which is the same operation code as getRootKind().
-  virtual LogicalResult match(Operation *op) const;
-
   /// Attempt to match against code rooted at the specified operation,
   /// which is the same operation code as getRootKind(). If successful, this
   /// function will automatically perform the rewrite.
@@ -183,6 +172,18 @@ class RewritePattern : public Pattern {
   /// Inherit the base constructors from `Pattern`.
   using Pattern::Pattern;
 
+  /// Attempt to match against code rooted at the specified operation,
+  /// which is the same operat

[llvm-branch-commits] [llvm] 77b5097 - [ICP] Don't promote when target not defined in module

2020-12-08 Thread Teresa Johnson via llvm-branch-commits

Author: Teresa Johnson
Date: 2020-12-08T07:45:36-08:00
New Revision: 77b509710ce7e6aec9ab460bc22a34f44fa94ab3

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

LOG: [ICP] Don't promote when target not defined in module

This guards against cases where the symbol was dead code eliminated in
the binary by ThinLTO, and we have a sample profile collected for one
binary but used to optimize another.

Most of the benefit from ICP comes from inlining the target, which we
can't do with only a declaration anyway. If this is in the pre-ThinLTO
link step (e.g. for instrumentation based PGO), we will attempt the
promotion again in the ThinLTO backend after importing anyway, and we
don't need the early promotion to facilitate that.

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

Added: 


Modified: 
llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
llvm/test/LTO/Resolution/X86/load-sample-prof-icp.ll
llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll
llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
llvm/test/Transforms/PGOProfile/indirect_call_promotion_musttail.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp 
b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index bcd4e2e8e33c..5b9557a9b328 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -263,8 +263,15 @@ ICallPromotionFunc::getPromotionCandidatesForCallSite(
   break;
 }
 
+// Don't promote if the symbol is not defined in the module. This avoids
+// creating a reference to a symbol that doesn't exist in the module
+// This can happen when we compile with a sample profile collected from
+// one binary but used for another, which may have profiled targets that
+// aren't used in the new binary. We might have a declaration initially in
+// the case where the symbol is globally dead in the binary and removed by
+// ThinLTO.
 Function *TargetFunction = Symtab->getFunction(Target);
-if (TargetFunction == nullptr) {
+if (TargetFunction == nullptr || TargetFunction->isDeclaration()) {
   LLVM_DEBUG(dbgs() << " Not promote: Cannot find the target\n");
   ORE.emit([&]() {
 return OptimizationRemarkMissed(DEBUG_TYPE, "UnableToFindTarget", &CB)

diff  --git a/llvm/test/LTO/Resolution/X86/load-sample-prof-icp.ll 
b/llvm/test/LTO/Resolution/X86/load-sample-prof-icp.ll
index 8ebb0a134ffd..d4af2c4cc447 100644
--- a/llvm/test/LTO/Resolution/X86/load-sample-prof-icp.ll
+++ b/llvm/test/LTO/Resolution/X86/load-sample-prof-icp.ll
@@ -3,11 +3,11 @@
 ;
 ; RUN: opt -module-summary < %s -o %t.bc
 ; RUN: llvm-lto2 run -o %t.out %t.bc -save-temps \
-; RUN:   -r %t.bc,test,px -r %t.bc,bar,x \
+; RUN:   -r %t.bc,test,px -r %t.bc,bar,px -r %t.bc,externfunc,x \
 ; RUN:   -lto-sample-profile-file=%S/Inputs/load-sample-prof-icp.prof
 ; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s
 ; RUN: llvm-lto2 run -o %t.out %t.bc -save-temps \
-; RUN:   -r %t.bc,test,px -r %t.bc,bar,x -use-new-pm \
+; RUN:   -r %t.bc,test,px -r %t.bc,bar,px -r %t.bc,externfunc,x -use-new-pm \
 ; RUN:   -lto-sample-profile-file=%S/Inputs/load-sample-prof-icp.prof
 ; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s
 
@@ -26,9 +26,14 @@ define void @test(void ()*) #0 !dbg !7 {
   ret void
 }
 
-declare void @bar() local_unnamed_addr
+declare void @externfunc()
 
-attributes #0 = {"use-sample-profile"}
+define void @bar() #0 {
+  call void @externfunc()
+  ret void
+}
+
+attributes #0 = {"use-sample-profile" noinline}
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!3, !4, !5}

diff  --git a/llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll 
b/llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll
index c2101a98d0d1..a4f10c64170c 100644
--- a/llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll
+++ b/llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll
@@ -10,7 +10,9 @@ target triple = "x86_64-unknown-linux-gnu"
 
 declare noalias i8* @_Znwm(i64)
 declare void @_ZN1DC2Ev(%struct.D*);
-declare %struct.Derived* @_ZN1D4funcEv(%struct.D*);
+define %struct.Derived* @_ZN1D4funcEv(%struct.D*) {
+  ret %struct.Derived* null
+}
 
 define %struct.Base* @bar() {
 entry:

diff  --git a/llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll 
b/llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
index d0f27ac73e78..c36b2e90ec7a 100644
--- a/llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
+++ b/llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
@@ -10,7 +10,9 @@ target triple = "x86_64-unknown-linux-gnu"
 @_ZTIi = external constant i8*
 declare i8* @_Znw

[llvm-branch-commits] [flang] 1dd24e6 - [flang][openacc] Add clause validity tests for the update directive

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

Author: Valentin Clement
Date: 2020-12-08T10:47:06-05:00
New Revision: 1dd24e6ab7a70242edfa4139441bfe7753892b4e

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

LOG: [flang][openacc] Add clause validity tests for the update directive

Add couple of clause validity tests for the update directive and check for
the restriction where at least self, host or device clause must appear on the 
directive.

Reviewed By: sameeranjoshi

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

Added: 


Modified: 
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
flang/lib/Lower/OpenACC.cpp
flang/lib/Parser/openacc-parsers.cpp
flang/lib/Semantics/check-acc-structure.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 61c5bddc0afb..c86c2ec6e66b 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -85,6 +85,7 @@ class ParseTreeDumper {
   NODE_ENUM(parser::AccReductionOperator, Operator)
   NODE(parser, AccSizeExpr)
   NODE(parser, AccSizeExprList)
+  NODE(parser, AccSelfClause)
   NODE(parser, AccStandaloneDirective)
   NODE(parser, AccTileExpr)
   NODE(parser, AccTileExprList)

diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index 2dcb92b4a725..c990ddd5c915 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3873,6 +3873,12 @@ struct AccSizeExprList {
   WRAPPER_CLASS_BOILERPLATE(AccSizeExprList, std::list);
 };
 
+struct AccSelfClause {
+  UNION_CLASS_BOILERPLATE(AccSelfClause);
+  std::variant, AccObjectList> u;
+  CharBlock source;
+};
+
 struct AccGangArgument {
   TUPLE_CLASS_BOILERPLATE(AccGangArgument);
   std::tuple, std::optional> t;

diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index f9a60ca77174..6f45bb623d7d 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -335,13 +335,18 @@ genACCParallelOp(Fortran::lower::AbstractConverter 
&converter,
   firOpBuilder.getI1Type(), cond);
 } else if (const auto *selfClause =
std::get_if(&clause.u)) {
-  if (selfClause->v) {
-Value cond = fir::getBase(converter.genExprValue(
-*Fortran::semantics::GetExpr(*(selfClause->v;
-selfCond = firOpBuilder.createConvert(currentLocation,
-  firOpBuilder.getI1Type(), cond);
-  } else {
-addSelfAttr = true;
+  const Fortran::parser::AccSelfClause &accSelfClause = selfClause->v;
+  if (const auto *optCondition =
+  std::get_if>(
+  &accSelfClause.u)) {
+if (*optCondition) {
+  Value cond = fir::getBase(converter.genExprValue(
+  *Fortran::semantics::GetExpr(*optCondition)));
+  selfCond = firOpBuilder.createConvert(currentLocation,
+firOpBuilder.getI1Type(), 
cond);
+} else {
+  addSelfAttr = true;
+}
   }
 } else if (const auto *copyClause =
std::get_if(&clause.u)) {

diff  --git a/flang/lib/Parser/openacc-parsers.cpp 
b/flang/lib/Parser/openacc-parsers.cpp
index 510b80277138..bba886f2fbfd 100644
--- a/flang/lib/Parser/openacc-parsers.cpp
+++ b/flang/lib/Parser/openacc-parsers.cpp
@@ -98,13 +98,8 @@ TYPE_PARSER("AUTO" >> 
construct(construct()) ||
parenthesized(construct(
Parser{} / ":",
Parser{} ||
-// SELF clause is either a simple optional condition for compute construct
-// or a synonym of the HOST clause for the update directive 2.14.4 holding
-// an object list.
-"SELF" >> construct(construct(
-  maybe(parenthesized(scalarLogicalExpr ||
-construct(
-construct(parenthesized(Parser{}))) ||
+"SELF" >> construct(
+  construct(Parser{})) ||
 "SEQ" >> construct(construct()) ||
 "TILE" >> construct(construct(
   parenthesized(Parser{}))) ||
@@ -176,6 +171,12 @@ TYPE_PARSER(construct(
 parenthesized(first("NONE" >> pure(AccDefaultClause::Arg::None),
 "PRESENT" >> pure(AccDefaultClause::Arg::Present)
 
+// SELF clause is either a simple optional condition for compute construct
+// or a synonym of the HOST clause for the update directive 2.14.4 holding
+// an object list.
+TYPE_PARSER(construct(parenthesized(Parser{})) ||
+construct(maybe(parenthesized(scalarLogicalE

[llvm-branch-commits] [clang] d14c631 - [analyzer][StdLibraryFunctionsChecker] Make close and mmap to accept -1 as fd

2020-12-08 Thread Gabor Marton via llvm-branch-commits

Author: Gabor Marton
Date: 2020-12-08T16:58:30+01:00
New Revision: d14c63167315edfc4a4ad91fac9c866c6e0cb67f

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

LOG: [analyzer][StdLibraryFunctionsChecker] Make close and mmap to accept -1 as 
fd

close:
It is quite often that users chose to call close even if the fd is
negative. Theoretically, it would be nicer to close only valid fds, but
in practice the implementations of close just returns with EBADF in case
of a non-valid fd param. So, we can eliminate many false positives if we
let close to take -1 as an fd. Other negative values are very unlikely,
because open and other fd factories return with -1 in case of failure.

mmap:
In the case of MAP_ANONYMOUS flag (which is supported e.g. in Linux) the
mapping is not backed by any file; its contents are initialized to zero.
The fd argument is ignored; however, some implementations require fd to
be -1 if MAP_ANONYMOUS (or MAP_ANON) is specified, and portable
applications should ensure this.
Consequently, we must allow -1 as the 4th arg.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 8a34950ce7341..de825b2fee11f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1672,7 +1672,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 addToFunctionSummaryMap("close", Signature(ArgTypes{IntTy}, 
RetType{IntTy}),
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(
-0, WithinRange, Range(0, IntMax;
+0, WithinRange, Range(-1, IntMax;
 
 // long fpathconf(int fildes, int name);
 addToFunctionSummaryMap("fpathconf",
@@ -1734,7 +1734,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, 
SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, IntMax;
+ArgumentCondition(4, WithinRange, Range(-1, IntMax;
 
 Optional Off64_tTy = lookupTy("off64_t");
 // void *mmap64(void *addr, size_t length, int prot, int flags, int fd,
@@ -1746,7 +1746,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Summary(NoEvalCall)
 .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, 
SizeMax)))
 .ArgConstraint(
-ArgumentCondition(4, WithinRange, Range(0, IntMax;
+ArgumentCondition(4, WithinRange, Range(-1, IntMax;
 
 // int pipe(int fildes[2]);
 addToFunctionSummaryMap(



___
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] febe750 - [analyzer][StdLibraryFunctionsChecker] Add more return value contraints

2020-12-08 Thread Gabor Marton via llvm-branch-commits

Author: Gabor Marton
Date: 2020-12-08T17:04:29+01:00
New Revision: febe75032f6f8322cce1dcbba11a44559aaa14e3

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

LOG: [analyzer][StdLibraryFunctionsChecker] Add more return value contraints

This time, we add contraints to functions that either return with [0, -1] or
with a file descriptor.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index de825b2fee11..f0710a658148 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1322,21 +1322,31 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 .ArgConstraint(ArgumentCondition(
 0, WithinRange, Range(0, LongMax;
 
+const auto ReturnsZeroOrMinusOne =
+ConstraintSet{ReturnValueCondition(WithinRange, Range(-1, 0))};
+const auto ReturnsFileDescriptor =
+ConstraintSet{ReturnValueCondition(WithinRange, Range(-1, IntMax))};
+
 // int access(const char *pathname, int amode);
 addToFunctionSummaryMap(
 "access", Signature(ArgTypes{ConstCharPtrTy, IntTy}, RetType{IntTy}),
-Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
+Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
+.ArgConstraint(NotNull(ArgNo(0;
 
 // int faccessat(int dirfd, const char *pathname, int mode, int flags);
 addToFunctionSummaryMap(
 "faccessat",
 Signature(ArgTypes{IntTy, ConstCharPtrTy, IntTy, IntTy},
   RetType{IntTy}),
-Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(1;
+Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
+.ArgConstraint(NotNull(ArgNo(1;
 
 // int dup(int fildes);
 addToFunctionSummaryMap("dup", Signature(ArgTypes{IntTy}, RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsFileDescriptor)
 .ArgConstraint(ArgumentCondition(
 0, WithinRange, Range(0, IntMax;
 
@@ -1344,6 +1354,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 addToFunctionSummaryMap(
 "dup2", Signature(ArgTypes{IntTy, IntTy}, RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsFileDescriptor)
 .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))
 .ArgConstraint(
 ArgumentCondition(1, WithinRange, Range(0, IntMax;
@@ -1352,6 +1363,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 addToFunctionSummaryMap("fdatasync",
 Signature(ArgTypes{IntTy}, RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(ArgumentCondition(
 0, WithinRange, Range(0, IntMax;
 
@@ -1367,6 +1379,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 // int fsync(int fildes);
 addToFunctionSummaryMap("fsync", Signature(ArgTypes{IntTy}, 
RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(ArgumentCondition(
 0, WithinRange, Range(0, IntMax;
 
@@ -1376,13 +1389,16 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 addToFunctionSummaryMap(
 "truncate",
 Signature(ArgTypes{ConstCharPtrTy, Off_tTy}, RetType{IntTy}),
-Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
+Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
+.ArgConstraint(NotNull(ArgNo(0;
 
 // int symlink(const char *oldpath, const char *newpath);
 addToFunctionSummaryMap(
 "symlink",
 Signature(ArgTypes{ConstCharPtrTy, ConstCharPtrTy}, RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(NotNull(ArgNo(0)))
 .ArgConstraint(NotNull(ArgNo(1;
 
@@ -1392,6 +1408,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 Signature(ArgTypes{ConstCharPtrTy, IntTy, ConstCharPtrTy},
   RetType{IntTy}),
 Summary(NoEvalCall)
+.Case(ReturnsZeroOrMinusOne)
 .ArgConstraint(NotNul

[llvm-branch-commits] [mlir] 5844bc5 - [mlir][Shape] Canonicalize assume_all with one input and tensor_cast of constant_shape

2020-12-08 Thread Benjamin Kramer via llvm-branch-commits

Author: Benjamin Kramer
Date: 2020-12-08T17:07:24+01:00
New Revision: 5844bc540cafb4330e7625b83371f1dab90528c3

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

LOG: [mlir][Shape] Canonicalize assume_all with one input and tensor_cast of 
constant_shape

This allows simplifying some more complicated shape expressions

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
mlir/test/Dialect/Shape/canonicalize.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td 
b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index 52768e49001d..552de7e78f91 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -105,6 +105,7 @@ def Shape_ConstShapeOp : Shape_Op<"const_shape", 
[ConstantLike, NoSideEffect]> {
   let printer = [{ return ::print(p, *this); }];
   let parser = [{ return ::parse$cppClass(parser, result); }];
   let hasFolder = 1;
+  let hasCanonicalizer = 1;
 }
 
 def Shape_ConstSizeOp : Shape_Op<"const_size", [
@@ -630,6 +631,7 @@ def Shape_AssumingAllOp : Shape_Op<"assuming_all", 
[Commutative, NoSideEffect]>
   let assemblyFormat = "$inputs attr-dict";
 
   let hasFolder = 1;
+  let hasCanonicalizer = 1;
 
   let verifier = [{ return ::verify(*this); }];
 }

diff  --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp 
b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index fe57f7d7a52e..acb35b916f7e 100644
--- a/mlir/lib/Dialect/Shape/IR/Shape.cpp
+++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp
@@ -271,6 +271,12 @@ void AssumingOp::inlineRegionIntoParent(AssumingOp &op,
 
//===--===//
 // AssumingAllOp
 
//===--===//
+
+void AssumingAllOp::getCanonicalizationPatterns(
+OwningRewritePatternList &patterns, MLIRContext *context) {
+  patterns.insert(context);
+}
+
 OpFoldResult AssumingAllOp::fold(ArrayRef operands) {
   // Iterate in reverse to first handle all constant operands. They are
   // guaranteed to be the tail of the inputs because this is commutative.
@@ -394,6 +400,11 @@ static ParseResult parseConstShapeOp(OpAsmParser &parser,
 
 OpFoldResult ConstShapeOp::fold(ArrayRef) { return shapeAttr(); }
 
+void ConstShapeOp::getCanonicalizationPatterns(
+OwningRewritePatternList &patterns, MLIRContext *context) {
+  patterns.insert(context);
+}
+
 
//===--===//
 // CstrBroadcastableOp
 
//===--===//

diff  --git a/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td 
b/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
index c57ad8c8d17c..43c670a8582e 100644
--- a/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
+++ b/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
@@ -1,4 +1,5 @@
 include "mlir/Dialect/Shape/IR/ShapeOps.td"
+include "mlir/Dialect/StandardOps/IR/Ops.td"
 
 def AllInputShapesEq : Constraint>;
 
+def HasSingleElement : Constraint>;
+
 // Canonicalization patterns.
 
+def AssumingAllOneOp : Pat<(Shape_AssumingAllOp $args),
+   (replaceWithValue $args),
+   [(HasSingleElement $args)]>;
+
 def CstrBroadcastableEqOps : Pat<(Shape_CstrBroadcastableOp:$op $x, $x),
   (Shape_ConstWitnessOp ConstBoolAttrTrue)>;
 
@@ -23,3 +32,5 @@ def SizeToIndexToSizeCanonicalization : Pat<
   (Shape_IndexToSizeOp (Shape_SizeToIndexOp $arg)),
   (replaceWithValue $arg)>;
 
+def TensorCastConstShape : Pat <
+  (TensorCastOp (Shape_ConstShapeOp:$c $ty)), (replaceWithValue $c)>;

diff  --git a/mlir/test/Dialect/Shape/canonicalize.mlir 
b/mlir/test/Dialect/Shape/canonicalize.mlir
index 56a6ef74f54e..9cb01da75901 100644
--- a/mlir/test/Dialect/Shape/canonicalize.mlir
+++ b/mlir/test/Dialect/Shape/canonicalize.mlir
@@ -427,20 +427,23 @@ func @f() {
 
 // -
 
-// assuming_all should not be removed if not all witnesses are statically 
passing.
+// assuming_all should not be removed if more than one witness is not
+// statically passing
 //
 // Additionally check that the attribute is moved to the end as this op is
 // commutative.
 // CHECK-LABEL: func @f
 func @f() {
-  // CHECK-NEXT: %[[UNKNOWN:.*]] = "test.source"
-  // CHECK-NEXT: shape.assuming_all %[[UNKNOWN]]
+  // CHECK-NEXT: %[[UNKNOWN1:.*]] = "test.source"
+  // CHECK-NEXT: %[[UNKNOWN2:.*]] = "test.source"
+  // CHECK-NEXT: shape.assuming_all %[[UNKNOWN1]], %[[UNKNOWN2]]
   // CHECK-NEXT: consume.witness
   // CHECK-NEXT: return
   %0 = shape.const_witness true
   %1 = "test.sourc

[llvm-branch-commits] [libcxx] 8726f94 - [libc++] Add a CI job to backdeploy to macOS 10.14

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

Author: Louis Dionne
Date: 2020-12-08T11:07:56-05:00
New Revision: 8726f94cc74ff1e91a24cb7259e209995283ae0f

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

LOG: [libc++] Add a CI job to backdeploy to macOS 10.14

It adds coverage for back-deploying to a system that contains the
filesystem library, which 10.9 (currently our only back-deployment
target in the CI) does not have.

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

Added: 


Modified: 
libcxx/utils/ci/buildkite-pipeline.yml

Removed: 




diff  --git a/libcxx/utils/ci/buildkite-pipeline.yml 
b/libcxx/utils/ci/buildkite-pipeline.yml
index 888463720f56..10ac44d56647 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -275,3 +275,14 @@ steps:
   automatic:
 - exit_status: -1  # Agent was lost
   limit: 2
+
+  - label: "Apple back-deployment macosx10.14"
+command: "libcxx/utils/ci/run-buildbot 
x86_64-apple-system-backdeployment-10.14"
+artifact_paths:
+  - "**/test-results.xml"
+agents:
+  queue: "libcxx-macos-builders"
+retry:
+  automatic:
+- exit_status: -1  # Agent was lost
+  limit: 2



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


[llvm-branch-commits] [mlir] b4750f5 - Add sqrt lowering from standard to NVVM

2020-12-08 Thread Frederik Gossen via llvm-branch-commits

Author: Frederik Gossen
Date: 2020-12-08T17:08:27+01:00
New Revision: b4750f58d89f2fbc74489b5e56d30daadec47198

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

LOG: Add sqrt lowering from standard to NVVM

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

Added: 


Modified: 
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp 
b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index 4b7bb6e193a4..467c622f8bde 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -138,7 +138,7 @@ struct LowerGpuOpsToNVVMOpsPass
 target.addIllegalDialect();
 target.addIllegalOp();
+LLVM::Log2Op, LLVM::SinOp, LLVM::SqrtOp>();
 target.addIllegalOp();
 target.addLegalDialect();
 // TODO: Remove once we support replacing non-root ops.
@@ -187,6 +187,8 @@ void mlir::populateGpuToNVVMConversionPatterns(
  "__nv_rsqrt");
   patterns.insert>(converter, "__nv_sinf",
"__nv_sin");
+  patterns.insert>(converter, "__nv_sqrtf",
+"__nv_sqrt");
   patterns.insert>(converter, "__nv_tanhf",
 "__nv_tanh");
 }

diff  --git a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir 
b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
index 347cc48daa20..1c0257de0d55 100644
--- a/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
+++ b/mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
@@ -315,6 +315,26 @@ gpu.module @test_module {
 
 // -
 
+gpu.module @test_module {
+  // CHECK: llvm.func @__nv_sqrtf(!llvm.float) -> !llvm.float
+  // CHECK: llvm.func @__nv_sqrt(!llvm.double) -> !llvm.double
+  // CHECK-LABEL: func @gpu_sqrt
+  func @gpu_sqrt(%arg_f16 : f16, %arg_f32 : f32, %arg_f64 : f64)
+  -> (f16, f32, f64) {
+%result16 = std.sqrt %arg_f16 : f16
+// CHECK: llvm.fpext %{{.*}} : !llvm.half to !llvm.float
+// CHECK-NEXT: llvm.call @__nv_sqrtf(%{{.*}}) : (!llvm.float) -> 
!llvm.float
+// CHECK-NEXT: llvm.fptrunc %{{.*}} : !llvm.float to !llvm.half
+%result32 = std.sqrt %arg_f32 : f32
+// CHECK: llvm.call @__nv_sqrtf(%{{.*}}) : (!llvm.float) -> !llvm.float
+%result64 = std.sqrt %arg_f64 : f64
+// CHECK: llvm.call @__nv_sqrt(%{{.*}}) : (!llvm.double) -> !llvm.double
+std.return %result16, %result32, %result64 : f16, f32, f64
+  }
+}
+
+// -
+
 // Test that we handled properly operation with SymbolTable other than module 
op
 gpu.module @test_module {
   "test.symbol_scope"() ({



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


[llvm-branch-commits] [libcxx] c0428b3 - [libc++] ADL-proof . `__convert_to_integral` is not a customization point.

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

Author: Arthur O'Dwyer
Date: 2020-12-08T11:19:16-05:00
New Revision: c0428b3c0c1f3b78d39ceaf909908800fb7aabe3

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

LOG: [libc++] ADL-proof . `__convert_to_integral` is not a 
customization point.

The interesting change here is that we no longer consider 
`__convert_to_integral`
an ADL customization point for the user's types. I think the new behavior
is defensible. The old behavior had come from D7449, where Marshall explicitly
said "people can't define their own [`__convert_to_integral` overloads]."

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

Added: 

libcxx/test/std/iterators/iterator.primitives/iterator.operations/robust_against_adl.pass.cpp

Modified: 
libcxx/include/algorithm
libcxx/include/iterator

Removed: 




diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 3bb6c7829bcf..7944f9b6e1aa 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -895,7 +895,7 @@ inline _LIBCPP_INLINE_VISIBILITY 
_LIBCPP_CONSTEXPR_AFTER_CXX17
 _InputIterator
 for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
 {
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
 while (__n > 0)
 {
@@ -1614,7 +1614,7 @@ search_n(_ForwardIterator __first, _ForwardIterator 
__last,
  _Size __count, const _Tp& __value_, _BinaryPredicate __pred)
 {
 return _VSTD::__search_n::type>
-   (__first, __last, __convert_to_integral(__count), __value_, __pred,
+   (__first, __last, _VSTD::__convert_to_integral(__count), __value_, 
__pred,
typename iterator_traits<_ForwardIterator>::iterator_category());
 }
 
@@ -1625,7 +1625,7 @@ _ForwardIterator
 search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, 
const _Tp& __value_)
 {
 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
-return _VSTD::search_n(__first, __last, __convert_to_integral(__count),
+return _VSTD::search_n(__first, __last, 
_VSTD::__convert_to_integral(__count),
__value_, __equal_to<__v, _Tp>());
 }
 
@@ -1827,7 +1827,7 @@ typename enable_if
 >::type
 copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
 {
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
 if (__n > 0)
 {
@@ -1852,7 +1852,7 @@ typename enable_if
 >::type
 copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
 {
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
 return _VSTD::copy(__first, __first + __n, __result);
 }
@@ -2057,7 +2057,7 @@ inline _LIBCPP_INLINE_VISIBILITY 
_LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
 {
-   return _VSTD::__fill_n(__first, __convert_to_integral(__n), __value_);
+   return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), 
__value_);
 }
 
 // fill
@@ -2105,7 +2105,7 @@ inline _LIBCPP_INLINE_VISIBILITY 
_LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
 {
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
 for (; __n > 0; ++__first, (void) --__n)
 *__first = __gen();

diff  --git a/libcxx/include/iterator b/libcxx/include/iterator
index 90b5f41132d9..3e1fb610821a 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -663,9 +663,9 @@ void advance(_InputIter& __i, _Distance __orig_n)
 {
 _LIBCPP_ASSERT(__orig_n >= 0 || 
__is_cpp17_bidirectional_iterator<_InputIter>::value,
"Attempt to advance(it, n) with negative n on a 
non-bidirectional iterator");
-typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
 _IntegralSize __n = __orig_n;
-__advance(__i, __n, typename 
iterator_traits<_InputIter>::iterator_category());
+_VSTD::__advance(__i, __n, typename 
iterator_traits<_InputIter>::iterator_category());
 }
 
 template 
@@ -692,7 +692,7 @@ inline _LIBCPP_INLINE_VISIBILITY 
_LIBCPP_CONSTEXPR_AFTER_CXX14
 typename iterator_traits<_InputIter>::
diff erence_type
 distance(_InputIter __first, _InputIter __last)
 {
-return __distance(__first, __last, typename 
iterato

[llvm-branch-commits] [mlir] 111ae22 - [mlir] Use rewriting infrastructure in AsyncToLLVM

2020-12-08 Thread Tres Popp via llvm-branch-commits

Author: Tres Popp
Date: 2020-12-08T17:30:01+01:00
New Revision: 111ae220a3bff944e10a0760ce344630f4efc40d

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

LOG: [mlir] Use rewriting infrastructure in AsyncToLLVM

This is needed so a listener hears all changes during the dialect
conversion to allow correct rollbacks upon failure.

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

Added: 


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

Removed: 




diff  --git a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp 
b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
index c36cde1054ed..361bfa2b6fad 100644
--- a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
+++ b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
@@ -386,8 +386,10 @@ static CoroMachinery setupCoroMachinery(FuncOp func) {
   suspendBlock};
 }
 
-// Adds a suspension point before the `op`, and moves `op` and all operations
-// after it into the resume block. Returns a pointer to the resume block.
+// Add a LLVM coroutine suspension point to the end of suspended block, to
+// resume execution in resume block. The caller is responsible for creating the
+// two suspended/resume blocks with the desired ops contained in each block.
+// This function merely provides the required control flow logic.
 //
 // `coroState` must be a value returned from the call to @llvm.coro.save(...)
 // intrinsic (saved coroutine state).
@@ -399,6 +401,8 @@ static CoroMachinery setupCoroMachinery(FuncOp func) {
 // "op"(...)
 //   ^cleanup: ...
 //   ^suspend: ...
+//   ^resume:
+// "op"(...)
 //
 // After:
 //
@@ -411,20 +415,17 @@ static CoroMachinery setupCoroMachinery(FuncOp func) {
 //   ^cleanup: ...
 //   ^suspend: ...
 //
-static Block *addSuspensionPoint(CoroMachinery coro, Value coroState,
- Operation *op) {
+static void addSuspensionPoint(CoroMachinery coro, Value coroState,
+   Operation *op, Block *suspended, Block *resume,
+   OpBuilder &builder) {
+  Location loc = op->getLoc();
   MLIRContext *ctx = op->getContext();
   auto i1 = LLVM::LLVMType::getInt1Ty(ctx);
   auto i8 = LLVM::LLVMType::getInt8Ty(ctx);
 
-  Location loc = op->getLoc();
-  Block *splitBlock = op->getBlock();
-
-  // Split the block before `op`, newly added block is the resume block.
-  Block *resume = splitBlock->splitBlock(op);
-
   // Add a coroutine suspension in place of original `op` in the split block.
-  OpBuilder builder = OpBuilder::atBlockEnd(splitBlock);
+  OpBuilder::InsertionGuard guard(builder);
+  builder.setInsertionPointToEnd(suspended);
 
   auto constFalse =
   builder.create(loc, i1, builder.getBoolAttr(false));
@@ -445,7 +446,7 @@ static Block *addSuspensionPoint(CoroMachinery coro, Value 
coroState,
   Block *resumeOrCleanup = builder.createBlock(resume);
 
   // Suspend the coroutine ...?
-  builder.setInsertionPointToEnd(splitBlock);
+  builder.setInsertionPointToEnd(suspended);
   auto isNegOne = builder.create(
   loc, LLVM::ICmpPredicate::eq, coroSuspend.getResult(0), constNegOne);
   builder.create(loc, isNegOne, /*trueDest=*/coro.suspend,
@@ -457,12 +458,12 @@ static Block *addSuspensionPoint(CoroMachinery coro, 
Value coroState,
   loc, LLVM::ICmpPredicate::eq, coroSuspend.getResult(0), constZero);
   builder.create(loc, isZero, /*trueDest=*/resume,
  /*falseDest=*/coro.cleanup);
-
-  return resume;
 }
 
 // Outline the body region attached to the `async.execute` op into a standalone
 // function.
+//
+// Note that this is not reversible transformation.
 static std::pair
 outlineExecuteOp(SymbolTable &symbolTable, ExecuteOp execute) {
   ModuleOp module = execute.getParentOfType();
@@ -518,8 +519,11 @@ outlineExecuteOp(SymbolTable &symbolTable, ExecuteOp 
execute) {
   builder.create(loc, TypeRange(), kExecute, executeArgs);
 
   // Split the entry block before the terminator.
-  Block *resume = addSuspensionPoint(coro, coroSave.getResult(0),
- entryBlock->getTerminator());
+  auto *terminatorOp = entryBlock->getTerminator();
+  Block *suspended = terminatorOp->getBlock();
+  Block *resume = suspended->splitBlock(terminatorOp);
+  addSuspensionPoint(coro, coroSave.getResult(0), terminatorOp, suspended,
+ resume, builder);
 
   // Await on all dependencies before starting to execute the body region.
   builder.setInsertionPointToStart(resume);
@@ -740,7 +744,7 @@ class AwaitOpLoweringBase : public ConversionPattern {
 if (isInCoroutine) {
   const CoroMachinery &coro = outlined->getSecond();
 
-  OpBuilder builder(op);
+  OpBuilder builder(op, rewriter.getListener());
   MLIRContext *ctx = op->get

[llvm-branch-commits] [clang] 25f5df7 - SemaType.cpp - use castAs<> instead of getAs<> for dereferenced pointers

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

Author: Simon Pilgrim
Date: 2020-12-08T16:37:20Z
New Revision: 25f5df7e0bc950ad244e8da000ce4248bd41c140

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

LOG: SemaType.cpp - use castAs<> instead of getAs<> for dereferenced pointers

Fix static analyzer warnings - castAs<> will assert the type is correct, but 
getAs<> just returns null, which would just result in a dereferenced null 
pointer.

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index df46aa3bfc1f..fbdbfbc9f8ec 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7967,7 +7967,7 @@ static void HandleOpenCLAccessAttr(QualType &CurType, 
const ParsedAttr &Attr,
diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
   } else if (CurType->isPipeType()) {
 if (Attr.getSemanticSpelling() == OpenCLAccessAttr::Keyword_write_only) {
-  QualType ElemType = CurType->getAs()->getElementType();
+  QualType ElemType = CurType->castAs()->getElementType();
   CurType = S.Context.getWritePipeType(ElemType);
 }
   }
@@ -9021,7 +9021,7 @@ QualType Sema::BuildUnaryTransformType(QualType BaseType,
   return QualType();
 }
 
-EnumDecl *ED = BaseType->getAs()->getDecl();
+EnumDecl *ED = BaseType->castAs()->getDecl();
 assert(ED && "EnumType has no EnumDecl");
 
 DiagnoseUseOfDecl(ED, Loc);



___
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] 2a98409 - [mlir] Revert "Tighten access of RewritePattern methods."

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

Author: Christian Sigg
Date: 2020-12-08T17:40:44+01:00
New Revision: 2a9840900ccc0add8fc6aed0533ceec198b3514d

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

LOG: [mlir] Revert "Tighten access of RewritePattern methods."

This reverts commit 02c9050155dff70497b3423ae95ed7d2ab7675a8.
Painted myself into a corner with -Wvirtual_overload, private access, and final.

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

Added: 


Modified: 
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/include/mlir/IR/PatternMatch.h
mlir/include/mlir/Transforms/DialectConversion.h

Removed: 




diff  --git 
a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h 
b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index 5b605c165be6..bf41f29749de 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -571,9 +571,11 @@ class ConvertOpToLLVMPattern : public ConvertToLLVMPattern 
{
  &typeConverter.getContext(), typeConverter,
  benefit) {}
 
-private:
-  /// Wrappers around the ConversionPattern methods that pass the derived op
-  /// type.
+  /// Wrappers around the RewritePattern methods that pass the derived op type.
+  void rewrite(Operation *op, ArrayRef operands,
+   ConversionPatternRewriter &rewriter) const final {
+rewrite(cast(op), operands, rewriter);
+  }
   LogicalResult match(Operation *op) const final {
 return match(cast(op));
   }
@@ -582,10 +584,6 @@ class ConvertOpToLLVMPattern : public ConvertToLLVMPattern 
{
   ConversionPatternRewriter &rewriter) const final {
 return matchAndRewrite(cast(op), operands, rewriter);
   }
-  void rewrite(Operation *op, ArrayRef operands,
-   ConversionPatternRewriter &rewriter) const final {
-rewrite(cast(op), operands, rewriter);
-  }
 
   /// Rewrite and Match methods that operate on the SourceOp type. These must 
be
   /// overridden by the derived pattern class.
@@ -605,6 +603,10 @@ class ConvertOpToLLVMPattern : public ConvertToLLVMPattern 
{
 }
 return failure();
   }
+
+private:
+  using ConvertToLLVMPattern::match;
+  using ConvertToLLVMPattern::matchAndRewrite;
 };
 
 namespace LLVM {
@@ -634,7 +636,6 @@ class OneToOneConvertToLLVMPattern : public 
ConvertOpToLLVMPattern {
   using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
   using Super = OneToOneConvertToLLVMPattern;
 
-private:
   /// Converts the type of the result to an LLVM type, pass operands as is,
   /// preserve attributes.
   LogicalResult
@@ -654,7 +655,6 @@ class VectorConvertToLLVMPattern : public 
ConvertOpToLLVMPattern {
   using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
   using Super = VectorConvertToLLVMPattern;
 
-private:
   LogicalResult
   matchAndRewrite(SourceOp op, ArrayRef operands,
   ConversionPatternRewriter &rewriter) const override {

diff  --git a/mlir/include/mlir/IR/PatternMatch.h 
b/mlir/include/mlir/IR/PatternMatch.h
index 1739cfa4a80c..d97b328cdc01 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -156,6 +156,17 @@ class RewritePattern : public Pattern {
 public:
   virtual ~RewritePattern() {}
 
+  /// Rewrite the IR rooted at the specified operation with the result of
+  /// this pattern, generating any new operations with the specified
+  /// builder.  If an unexpected error is encountered (an internal
+  /// compiler error), it is emitted through the normal MLIR diagnostic
+  /// hooks and the IR is left in a valid state.
+  virtual void rewrite(Operation *op, PatternRewriter &rewriter) const;
+
+  /// Attempt to match against code rooted at the specified operation,
+  /// which is the same operation code as getRootKind().
+  virtual LogicalResult match(Operation *op) const;
+
   /// Attempt to match against code rooted at the specified operation,
   /// which is the same operation code as getRootKind(). If successful, this
   /// function will automatically perform the rewrite.
@@ -172,18 +183,6 @@ class RewritePattern : public Pattern {
   /// Inherit the base constructors from `Pattern`.
   using Pattern::Pattern;
 
-  /// Attempt to match against code rooted at the specified operation,
-  /// which is the same operation code as getRootKind().
-  virtual LogicalResult match(Operation *op) const;
-
-private:
-  /// Rewrite the IR rooted at the specified operation with the result of
-  /// this pattern, generating any new operations with the specified
-  /// builder.  If an unexpected error is encountered (an internal
-  /// compiler error), it is emitted through the normal MLIR diagnost

[llvm-branch-commits] [llvm] 9935b0f - [gn build] (manually) port db61b1844e11f

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

Author: Nico Weber
Date: 2020-12-08T11:45:43-05:00
New Revision: 9935b0fc9023c071c07523350b4f343d22e478f6

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

LOG: [gn build] (manually) port db61b1844e11f

Added: 


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

Removed: 




diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn 
b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
index 0292479ecd66..e7b532f57dab 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
@@ -197,6 +197,7 @@ static_library("builtins") {
 sources += [
   "comparetf2.c",
   "extenddftf2.c",
+  "extendhftf2.c",
   "extendsftf2.c",
   "fixtfdi.c",
   "fixtfsi.c",
@@ -212,6 +213,7 @@ static_library("builtins") {
   "floatuntitf.c",
   "multc3.c",
   "trunctfdf2.c",
+  "trunctfhf2.c",
   "trunctfsf2.c",
 ]
   }



___
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] 31e60b9 - [coroutine] should disable inline before calling coro split

2020-12-08 Thread Xun Li via llvm-branch-commits

Author: Xun Li
Date: 2020-12-08T08:53:08-08:00
New Revision: 31e60b9133596c185e6daac7f1761dc17e464826

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

LOG: [coroutine] should disable inline before calling coro split

This is a rework of D85812, which didn't land.
When callee coroutine function is inlined into caller coroutine function before 
coro-split pass, llvm will emits "coroutine should have exactly one defining 
@llvm.coro.begin". It seems that coro-early pass can not handle this quiet well.
So we believe that unsplited coroutine function should not be inlined.
This patch fix such issue by not inlining function if it has attribute 
"coroutine.presplit" (it means the function has not been splited) to fix this 
issue
test plan: check-llvm, check-clang

In D85812, there was suggestions on moving the macros to Attributes.td to avoid 
circular header dependency issue.
I believe it's not worth doing just to be able to use one constant string in 
one place.
Today, there are already 3 possible attribute values for "coroutine.presplit": 
https://github.com/llvm/llvm-project/blob/c6543cc6b8f107b58e7205d8fc64865a508bacba/llvm/lib/Transforms/Coroutines/CoroInternal.h#L40-L42
If we move them into Attributes.td, we would be adding 3 new attributes to 
EnumAttr, just to support this, which I think is an overkill.

Instead, I think the best way to do this is to add an API in Function class 
that checks whether this function is a coroutine, by checking the attribute by 
name directly.

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

Added: 
llvm/test/Transforms/Coroutines/Inputs/sample.text.prof
llvm/test/Transforms/Coroutines/coro-inline.ll

Modified: 
llvm/include/llvm/IR/Function.h
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/Transforms/IPO/AlwaysInliner.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index cf61db1d33479..019e3a98a1af5 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -268,6 +268,12 @@ class Function : public GlobalObject, public 
ilist_node {
 getContext(), AttributeList::FunctionIndex, Kind));
   }
 
+  /// A function will have the "coroutine.presplit" attribute if it's
+  /// a coroutine and has not gone through full CoroSplit pass.
+  bool isPresplitCoroutine() const {
+return hasFnAttribute("coroutine.presplit");
+  }
+
   enum ProfileCountType { PCT_Invalid, PCT_Real, PCT_Synthetic };
 
   /// Class to represent profile counts.

diff  --git a/llvm/lib/Analysis/InlineCost.cpp 
b/llvm/lib/Analysis/InlineCost.cpp
index 077b05edcd136..5ee12818e44cc 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2332,6 +2332,13 @@ Optional 
llvm::getAttributeBasedInliningDecision(
   if (!Callee)
 return InlineResult::failure("indirect call");
 
+  // When callee coroutine function is inlined into caller coroutine function
+  // before coro-split pass,
+  // coro-early pass can not handle this quiet well.
+  // So we won't inline the coroutine function if it have not been unsplited
+  if (Callee->isPresplitCoroutine())
+return InlineResult::failure("unsplited coroutine call");
+
   // Never inline calls with byval arguments that does not have the alloca
   // address space. Since byval arguments can be replaced with a copy to an
   // alloca, the inlined code would need to be adjusted to handle that the

diff  --git a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp 
b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
index cf810dbc39523..532599b42e0dc 100644
--- a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
+++ b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
@@ -46,7 +46,14 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
   SmallSetVector Calls;
   bool Changed = false;
   SmallVector InlinedFunctions;
-  for (Function &F : M)
+  for (Function &F : M) {
+// When callee coroutine function is inlined into caller coroutine function
+// before coro-split pass,
+// coro-early pass can not handle this quiet well.
+// So we won't inline the coroutine function if it have not been unsplited
+if (F.isPresplitCoroutine())
+  continue;
+
 if (!F.isDeclaration() && F.hasFnAttribute(Attribute::AlwaysInline) &&
 isInlineViable(F).isSuccess()) {
   Calls.clear();
@@ -90,6 +97,7 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
   // invalidation issues while deleting functions.
   InlinedFunctions.push_back(&F);
 }
+  }
 
   // Remove any live functions.
   erase_if(InlinedFunctions, [&](Function *F) {
@@ -182,6 +190,13 @@ InlineCost AlwaysInlinerLegacyPass::getInlineCost(CallBase 
&CB) {
   if (!Callee)
 return InlineCost::getNever("indirect call");
 
+  // When callee coroutine function

[llvm-branch-commits] [libcxx] 877170f - [libc++] [LWG3221] Add tests for wrapping operator+(year_month, months).

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

Author: Marek Kurdej
Date: 2020-12-08T18:08:04+01:00
New Revision: 877170f3eb2a7f288eca1e226e5a07d607f96474

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

LOG: [libc++] [LWG3221] Add tests for wrapping operator+(year_month, months).

The behaviour didn't change since commit 
5b08c1742a536f54bd5e270b00ff851cbc7314ef (Recommit  changes with a 
couple xtra tests marked to fail on apple's clang.)

* http://wg21.link/lwg3221

Reviewed By: ldionne, #libc

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

Added: 


Modified: 
libcxx/docs/Cxx2aStatusIssuesStatus.csv

libcxx/test/std/utilities/time/time.cal/time.cal.ym/time.cal.ym.nonmembers/plus.pass.cpp

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusIssuesStatus.csv 
b/libcxx/docs/Cxx2aStatusIssuesStatus.csv
index 3f371812eda7..aa5d93a55f6b 100644
--- a/libcxx/docs/Cxx2aStatusIssuesStatus.csv
+++ b/libcxx/docs/Cxx2aStatusIssuesStatus.csv
@@ -168,7 +168,7 @@
 "`3230 `__","Format specifier ``%y/%Y``\  is 
missing locale alternative versions","Belfast","",""
 "`3232 `__","Inconsistency in ``zoned_time``\  
deduction guides","Belfast","",""
 "`3222 `__","P0574R1 introduced preconditions on 
non-existent parameters","Belfast","",""
-"`3221 `__","Result of ``year_month``\  arithmetic 
with ``months``\  is ambiguous","Belfast","",""
+"`3221 `__","Result of ``year_month``\  arithmetic 
with ``months``\  is ambiguous","Belfast","|Complete|","8.0"
 "`3235 `__","``parse``\  manipulator without 
abbreviation is not callable","Belfast","",""
 "`3246 `__","What are the constraints on the 
template parameter of ``basic_format_arg``\ ?","Belfast","",""
 "`3253 `__","``basic_syncbuf::basic_syncbuf()``\  
should not be explicit","Belfast","",""

diff  --git 
a/libcxx/test/std/utilities/time/time.cal/time.cal.ym/time.cal.ym.nonmembers/plus.pass.cpp
 
b/libcxx/test/std/utilities/time/time.cal/time.cal.ym/time.cal.ym.nonmembers/plus.pass.cpp
index afd18cb0a3c6..315d74b75bbc 100644
--- 
a/libcxx/test/std/utilities/time/time.cal/time.cal.ym/time.cal.ym.nonmembers/plus.pass.cpp
+++ 
b/libcxx/test/std/utilities/time/time.cal/time.cal.ym/time.cal.ym.nonmembers/plus.pass.cpp
@@ -17,91 +17,91 @@
 // Returns: ym + dy.
 //
 // constexpr year_month operator+(const year_month& ym, const months& dm) 
noexcept;
-// Returns: A year_month value z such that z - ym == dm.
+// Returns: A year_month value z such that z.ok() && z - ym == dm is true.
 // Complexity: O(1) with respect to the value of dm.
 //
 // constexpr year_month operator+(const months& dm, const year_month& ym) 
noexcept;
 // Returns: ym + dm.
 
-
-
 #include 
 #include 
 #include 
 
 #include "test_macros.h"
 
-constexpr bool testConstexprYears(std::chrono::year_month ym)
-{
-std::chrono::years offset{23};
-if (static_cast((ym ).year()) !=  1) return false;
-if (static_cast((ym + offset).year()) != 24) return false;
-if (static_cast((offset + ym).year()) != 24) return false;
-return true;
+using year = std::chrono::year;
+using years = std::chrono::years;
+using month = std::chrono::month;
+using months = std::chrono::months;
+using year_month = std::chrono::year_month;
+
+// year_month + years
+constexpr bool test_ym_plus_y() {
+  ASSERT_NOEXCEPT(std::declval() + std::declval());
+  ASSERT_NOEXCEPT(std::declval() + std::declval());
+
+  ASSERT_SAME_TYPE(
+  year_month, decltype(std::declval() + 
std::declval()));
+  ASSERT_SAME_TYPE(
+  year_month, decltype(std::declval() + 
std::declval()));
+
+  year_month ym{year{1234}, std::chrono::January};
+  for (int i = 0; i <= 10; ++i) {
+year_month ym1 = ym + years{i};
+year_month ym2 = years{i} + ym;
+assert(static_cast(ym1.year()) == i + 1234);
+assert(static_cast(ym2.year()) == i + 1234);
+assert(ym1.month() == std::chrono::January);
+assert(ym2.month() == std::chrono::January);
+assert(ym1 == ym2);
+  }
+
+  return true;
 }
 
-
-constexpr bool testConstexprMonths(std::chrono::year_month ym)
-{
-std::chrono::months offset{6};
-if (static_cast((ym ).month()) !=  1) return false;
-if (static_cast((ym + offset).month()) !=  7) return false;
-if (static_cast((offset + ym).month()) !=  7) return false;
-return true;
+// year_month + months
+constexpr bool test_ym_plus_m() {
+  ASSERT_NOEXCEPT(std::declval() + std::declval());
+  ASSERT_NOEXCEPT(std::declval() + std::declval());
+
+  ASSERT_SAME_TYPE(year_month, decltype(std::declval() +
+std::declval()));
+  ASSERT_SAME_TYPE(year_month, decltype(std::dec

[llvm-branch-commits] [clang-tools-extra] 4a0528e - [clangd][NFC] Small tweak to combined provider

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

Author: Nathan James
Date: 2020-12-08T17:12:56Z
New Revision: 4a0528e4a0e3e4504db8650bf2bf7d6977ffa018

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

LOG: [clangd][NFC] Small tweak to combined provider

This should address the FIXME about clang3.9 dervied to base unique_ptr 
constructor not working.

Reviewed By: sammccall

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigProvider.cpp 
b/clang-tools-extra/clangd/ConfigProvider.cpp
index 0933e7e2c283..05b2ba50566d 100644
--- a/clang-tools-extra/clangd/ConfigProvider.cpp
+++ b/clang-tools-extra/clangd/ConfigProvider.cpp
@@ -144,7 +144,7 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef 
RelPath,
 
 std::unique_ptr
 Provider::combine(std::vector Providers) {
-  struct CombinedProvider : Provider {
+  class CombinedProvider : public Provider {
 std::vector Providers;
 
 std::vector
@@ -156,14 +156,13 @@ Provider::combine(std::vector 
Providers) {
   }
   return Result;
 }
+
+  public:
+CombinedProvider(std::vector Providers)
+: Providers(std::move(Providers)) {}
   };
-  auto Result = std::make_unique();
-  Result->Providers = std::move(Providers);
-  // FIXME: This is a workaround for a bug in older versions of clang (< 3.9)
-  //   The constructor that is supposed to allow for Derived to Base
-  //   conversion does not work. Remove this if we drop support for such
-  //   configurations.
-  return std::unique_ptr(Result.release());
+
+  return std::make_unique(std::move(Providers));
 }
 
 Config Provider::getConfig(const Params &P, DiagnosticCallback DC) const {



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


[llvm-branch-commits] [llvm] b15491e - [AArch64][GlobalISel] Select G_SADDO and G_SSUBO

2020-12-08 Thread Jessica Paquette via llvm-branch-commits

Author: Jessica Paquette
Date: 2020-12-08T09:18:28-08:00
New Revision: b15491eb333809e907e51d1b05da2a6a6344a427

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

LOG: [AArch64][GlobalISel] Select G_SADDO and G_SSUBO

We didn't have selector support for these.

Selection code is similar to `getAArch64XALUOOp` in AArch64ISelLowering. Similar
to that code, this returns the AArch64CC and the instruction produced. In SDAG,
this is used to optimize select + overflow and condition branch + overflow
pairs. (See `AArch64TargetLowering::LowerBR_CC` and
`AArch64TargetLowering::LowerSelect`)

(G_USUBO should be easy to add here, but it isn't legalized right now.)

This also factors out the existing G_UADDO selection code, and removes an
unnecessary check for s32/s64. AFAIK, we shouldn't ever get anything other than
s32/s64. It makes more sense for this to be handled by the type assertion in
`emitAddSub`.

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

Added: 
llvm/lib/Target/AArch64/GISel/select-saddo.mir
llvm/lib/Target/AArch64/GISel/select-ssubo.mir

Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 8d75acd9f183..f23743b43db8 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -258,6 +258,14 @@ class AArch64InstructionSelector : public 
InstructionSelector {
   MachineInstr *emitCSetForFCmp(Register Dst, CmpInst::Predicate Pred,
 MachineIRBuilder &MIRBuilder) const;
 
+  /// Emit the overflow op for \p Opcode.
+  ///
+  /// \p Opcode is expected to be an overflow op's opcode, e.g. G_UADDO,
+  /// G_USUBO, etc.
+  std::pair
+  emitOverflowOp(unsigned Opcode, Register Dst, MachineOperand &LHS,
+ MachineOperand &RHS, MachineIRBuilder &MIRBuilder) const;
+
   /// Emit a TB(N)Z instruction which tests \p Bit in \p TestReg.
   /// \p IsNegative is true if the test should be "not zero".
   /// This will also optimize the test bit instruction when possible.
@@ -2672,35 +2680,23 @@ bool AArch64InstructionSelector::select(MachineInstr 
&I) {
 I.eraseFromParent();
 return true;
   }
-  case TargetOpcode::G_UADDO: {
-// TODO: Support other types.
-unsigned OpSize = Ty.getSizeInBits();
-if (OpSize != 32 && OpSize != 64) {
-  LLVM_DEBUG(
-  dbgs()
-  << "G_UADDO currently only supported for 32 and 64 b types.\n");
-  return false;
-}
-
-// TODO: Support vectors.
-if (Ty.isVector()) {
-  LLVM_DEBUG(dbgs() << "G_UADDO currently only supported for scalars.\n");
-  return false;
-}
-
-// Add and set the set condition flag.
+  case TargetOpcode::G_SADDO:
+  case TargetOpcode::G_UADDO:
+  case TargetOpcode::G_SSUBO: {
+// Emit the operation and get the correct condition code.
 MachineIRBuilder MIRBuilder(I);
-emitADDS(I.getOperand(0).getReg(), I.getOperand(2), I.getOperand(3),
- MIRBuilder);
+auto OpAndCC = emitOverflowOp(Opcode, I.getOperand(0).getReg(),
+  I.getOperand(2), I.getOperand(3), 
MIRBuilder);
 
 // Now, put the overflow result in the register given by the first operand
-// to the G_UADDO. CSINC increments the result when the predicate is false,
-// so to get the increment when it's true, we need to use the inverse. In
-// this case, we want to increment when carry is set.
+// to the overflow op. CSINC increments the result when the predicate is
+// false, so to get the increment when it's true, we need to use the
+// inverse. In this case, we want to increment when carry is set.
+Register ZReg = AArch64::WZR;
 auto CsetMI = MIRBuilder
   .buildInstr(AArch64::CSINCWr, {I.getOperand(1).getReg()},
-  {Register(AArch64::WZR), 
Register(AArch64::WZR)})
-  .addImm(getInvertedCondCode(AArch64CC::HS));
+  {ZReg, ZReg})
+  .addImm(getInvertedCondCode(OpAndCC.second));
 constrainSelectedInstRegOperands(*CsetMI, TII, TRI, RBI);
 I.eraseFromParent();
 return true;
@@ -4287,6 +4283,23 @@ AArch64InstructionSelector::emitCSetForICMP(Register 
DefReg, unsigned Pred,
   return &*I;
 }
 
+std::pair
+AArch64InstructionSelector::emitOverflowOp(unsigned Opcode, Register Dst,
+   MachineOperand &LHS,
+   MachineOperand &RHS,
+   MachineIRBuilder &MIRBuilder) const 
{
+  s

[llvm-branch-commits] [llvm] 09f2f96 - [ScalarizeMaskedMemIntrinsic] Move from CodeGen into Transforms

2020-12-08 Thread Anna Thomas via llvm-branch-commits

Author: Anna Thomas
Date: 2020-12-08T12:25:58-05:00
New Revision: 09f2f9605fbaff2b72c586d76256c9e6e312a0f3

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

LOG: [ScalarizeMaskedMemIntrinsic] Move from CodeGen into Transforms

ScalarizeMaskedMemIntrinsic is currently a codeGen level pass. The pass
is actually operating on IR level and does not use any code gen specific
passes.  It is useful to move it into transforms directory so that it
can be more widely used as a mid-level transform as well (apart from
usage in codegen pipeline).
In particular, we have a usecase downstream where we would like to use
this pass in our mid-level pipeline which operates on IR level.

The next change will be to add support for new PM.

Reviewers: craig.topper, apilipenko, skatkov
Reviewed-By: skatkov
Differential Revision: https://reviews.llvm.org/D92407

Added: 
llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp

Modified: 
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/Transforms/Scalar/CMakeLists.txt
llvm/lib/Transforms/Scalar/Scalar.cpp

Removed: 
llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp



diff  --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt
index e7ac998f3efa..7dc854cbbf20 100644
--- a/llvm/lib/CodeGen/CMakeLists.txt
+++ b/llvm/lib/CodeGen/CMakeLists.txt
@@ -148,7 +148,6 @@ add_llvm_component_library(LLVMCodeGen
   ResetMachineFunctionPass.cpp
   SafeStack.cpp
   SafeStackLayout.cpp
-  ScalarizeMaskedMemIntrin.cpp
   ScheduleDAG.cpp
   ScheduleDAGInstrs.cpp
   ScheduleDAGPrinter.cpp

diff  --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index 5000373ef54a..92a2b73f52e3 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -98,7 +98,6 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
   initializeRegisterCoalescerPass(Registry);
   initializeRenameIndependentSubregsPass(Registry);
   initializeSafeStackLegacyPassPass(Registry);
-  initializeScalarizeMaskedMemIntrinPass(Registry);
   initializeShrinkWrapPass(Registry);
   initializeSjLjEHPreparePass(Registry);
   initializeSlotIndexesPass(Registry);

diff  --git a/llvm/lib/Transforms/Scalar/CMakeLists.txt 
b/llvm/lib/Transforms/Scalar/CMakeLists.txt
index 2b41ed6d9190..0205e0d9a6ae 100644
--- a/llvm/lib/Transforms/Scalar/CMakeLists.txt
+++ b/llvm/lib/Transforms/Scalar/CMakeLists.txt
@@ -66,6 +66,7 @@ add_llvm_component_library(LLVMScalarOpts
   SROA.cpp
   Scalar.cpp
   Scalarizer.cpp
+  ScalarizeMaskedMemIntrin.cpp
   SeparateConstOffsetFromGEP.cpp
   SimpleLoopUnswitch.cpp
   SimplifyCFGPass.cpp

diff  --git a/llvm/lib/Transforms/Scalar/Scalar.cpp 
b/llvm/lib/Transforms/Scalar/Scalar.cpp
index 3282d8a4afc1..32dcbc562c4d 100644
--- a/llvm/lib/Transforms/Scalar/Scalar.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalar.cpp
@@ -95,6 +95,7 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
   initializeRedundantDbgInstEliminationPass(Registry);
   initializeRegToMemLegacyPass(Registry);
   initializeRewriteStatepointsForGCLegacyPassPass(Registry);
+  initializeScalarizeMaskedMemIntrinPass(Registry);
   initializeSCCPLegacyPassPass(Registry);
   initializeSROALegacyPassPass(Registry);
   initializeCFGSimplifyPassPass(Registry);

diff  --git a/llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp 
b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
similarity index 100%
rename from llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
rename to llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp



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


[llvm-branch-commits] [clang] 27ea7d0 - Fix inconsistent availability attribute message string literal check.

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

Author: Nigel Perks
Date: 2020-12-08T12:33:59-05:00
New Revision: 27ea7d0a6e0dc51e0214707bcc265fa6f9dc9bc6

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

LOG: Fix inconsistent availability attribute message string literal check.

Function Parser::ParseAvailabilityAttribute checks that the message string of
an availability attribute is not a wide string literal. Test case
clang/test/Parser/attr-availability.c specifies that a string literal is
expected.

The code checked that the first token in a string concatenation is a string
literal, and then that the concatenated string consists of 1-byte characters.
On a target where wide character is 1 byte, a string concatenation "a" L"b"
passes both those checks, but L"b" alone is rejected. More generally, "a" u8"b"
passes the checks, but u8"b" alone is rejected.

So check isAscii() instead of character size.

Added: 


Modified: 
clang/lib/Parse/ParseDecl.cpp
clang/test/Parser/attr-availability.c

Removed: 




diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 7ebf06a04fa7..780d48958cb9 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1119,7 +1119,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo 
&Availability,
   // Also reject wide string literals.
   if (StringLiteral *MessageStringLiteral =
   cast_or_null(MessageExpr.get())) {
-if (MessageStringLiteral->getCharByteWidth() != 1) {
+if (!MessageStringLiteral->isAscii()) {
   Diag(MessageStringLiteral->getSourceRange().getBegin(),
diag::err_expected_string_literal)
 << /*Source='availability attribute'*/ 2;

diff  --git a/clang/test/Parser/attr-availability.c 
b/clang/test/Parser/attr-availability.c
index d812296d9354..d3b640a2feea 100644
--- a/clang/test/Parser/attr-availability.c
+++ b/clang/test/Parser/attr-availability.c
@@ -22,6 +22,14 @@ void f7() 
__attribute__((availability(macosx,message=L"wide"))); // expected-err
 
 void f8() __attribute__((availability(macosx,message="a" L"b"))); // 
expected-error {{expected string literal for optional message in 'availability' 
attribute}}
 
+void f9() __attribute__((availability(macosx,message=u8"b"))); // 
expected-error {{expected string literal for optional message in 'availability' 
attribute}}
+
+void f10() __attribute__((availability(macosx,message="a" u8"b"))); // 
expected-error {{expected string literal for optional message in 'availability' 
attribute}}
+
+void f11() __attribute__((availability(macosx,message=u"b"))); // 
expected-error {{expected string literal for optional message in 'availability' 
attribute}}
+
+void f12() __attribute__((availability(macosx,message="a" u"b"))); // 
expected-error {{expected string literal for optional message in 'availability' 
attribute}}
+
 // rdar://10095131
 enum E{
 gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), 
// expected-error {{expected string literal for optional message in 
'availability' attribute}}



___
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] 4c70b6e - [LV] Make optimal-epilog-vectorization-profitability.ll more robust

2020-12-08 Thread Bardia Mahjour via llvm-branch-commits

Author: Bardia Mahjour
Date: 2020-12-08T12:35:08-05:00
New Revision: 4c70b6ee45e89268598d1bd0811778244f136025

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

LOG: [LV] Make optimal-epilog-vectorization-profitability.ll more robust

Add a CHECK to properly limit the scope of CHECK-NOTs

Added: 


Modified: 

llvm/test/Transforms/LoopVectorize/PowerPC/optimal-epilog-vectorization-profitability.ll

Removed: 




diff  --git 
a/llvm/test/Transforms/LoopVectorize/PowerPC/optimal-epilog-vectorization-profitability.ll
 
b/llvm/test/Transforms/LoopVectorize/PowerPC/optimal-epilog-vectorization-profitability.ll
index 7cb5f34fa57c..88cfa5bd40c5 100644
--- 
a/llvm/test/Transforms/LoopVectorize/PowerPC/optimal-epilog-vectorization-profitability.ll
+++ 
b/llvm/test/Transforms/LoopVectorize/PowerPC/optimal-epilog-vectorization-profitability.ll
@@ -16,6 +16,7 @@ target triple = "powerpc64le-unknown-linux-gnu"
 ; CHECK-NOT: vec.epilog.ph
 ; CHECK-NOT: vec.epilog.vector.body
 ; CHECK-NOT: vec.epilog.middle.block
+; CHECK: ret void
 
 define dso_local void @f1(float* noalias %aa, float* noalias %bb, float* 
noalias %cc, i32 signext %N) #0 {
 entry:
@@ -53,6 +54,7 @@ for.end:  ; preds = 
%for.end.loopexit, %
 ; CHECK-NOT: vec.epilog.ph
 ; CHECK-NOT: vec.epilog.vector.body
 ; CHECK-NOT: vec.epilog.middle.block
+; CHECK: ret void
 
 define dso_local void @f2(float* noalias %aa, float* noalias %bb, float* 
noalias %cc, i32 signext %N) #1 {
 entry:
@@ -90,6 +92,7 @@ for.end:  ; preds = 
%for.end.loopexit, %
 ; CHECK-MIN-D-NOT: vec.epilog.ph
 ; CHECK-MIN-D-NOT: vec.epilog.vector.body
 ; CHECK-MIN-D-NOT: vec.epilog.middle.block
+; CHECK-MIN-D: ret void
 
 ; Specify a smaller minimum VF (via `-epilogue-vectorization-minimum-VF=4`) and
 ; make sure the epilogue gets vectorized in that case.
@@ -99,6 +102,7 @@ for.end:  ; preds = 
%for.end.loopexit, %
 ; CHECK-MIN-4: vec.epilog.ph
 ; CHECK-MIN-4: vec.epilog.vector.body
 ; CHECK-MIN-4: vec.epilog.middle.block
+; CHECK-MIN-4: ret void
 
 define dso_local void @f3(float* noalias %aa, float* noalias %bb, float* 
noalias %cc, i32 signext %N) {
 entry:



___
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] 8e6fc1f - [AArch64][SVE] Add lowering for llvm.maxnum|minnum for scalable type.

2020-12-08 Thread Huihui Zhang via llvm-branch-commits

Author: Huihui Zhang
Date: 2020-12-08T09:35:53-08:00
New Revision: 8e6fc1f97eb9a63780158470596ddbec3d0ecd59

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

LOG: [AArch64][SVE] Add lowering for llvm.maxnum|minnum for scalable type.

LLVM intrinsic llvm.maxnum|minnum is overloaded intrinsic, can be used on any
floating-point or vector of floating-point type.
This patch extends current infrastructure to support scalable vector type.

This patch also fix a warning message of incorrect use of 
EVT::getVectorNumElements()
for scalable type, when DAGCombiner trying to split scalable vector.

Reviewed By: sdesmalen

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sve-fp.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 6d5a54198c0b..8f0c9542b3e7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -19552,8 +19552,8 @@ static SDValue getSubVectorSrc(SDValue V, SDValue 
Index, EVT SubVT) {
   auto *IndexC = dyn_cast(Index);
   if (IndexC && V.getOpcode() == ISD::CONCAT_VECTORS &&
   V.getOperand(0).getValueType() == SubVT &&
-  (IndexC->getZExtValue() % SubVT.getVectorNumElements()) == 0) {
-uint64_t SubIdx = IndexC->getZExtValue() / SubVT.getVectorNumElements();
+  (IndexC->getZExtValue() % SubVT.getVectorMinNumElements()) == 0) {
+uint64_t SubIdx = IndexC->getZExtValue() / SubVT.getVectorMinNumElements();
 return V.getOperand(SubIdx);
   }
   return SDValue();

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 700c281cdaa9..20f5ded99350 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1130,6 +1130,8 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine &TM,
   setOperationAction(ISD::FADD, VT, Custom);
   setOperationAction(ISD::FDIV, VT, Custom);
   setOperationAction(ISD::FMA, VT, Custom);
+  setOperationAction(ISD::FMAXNUM, VT, Custom);
+  setOperationAction(ISD::FMINNUM, VT, Custom);
   setOperationAction(ISD::FMUL, VT, Custom);
   setOperationAction(ISD::FNEG, VT, Custom);
   setOperationAction(ISD::FSUB, VT, Custom);

diff  --git a/llvm/test/CodeGen/AArch64/sve-fp.ll 
b/llvm/test/CodeGen/AArch64/sve-fp.ll
index a54412cee9bf..2c1f8df086b6 100644
--- a/llvm/test/CodeGen/AArch64/sve-fp.ll
+++ b/llvm/test/CodeGen/AArch64/sve-fp.ll
@@ -592,6 +592,194 @@ define  @fabs_nxv2f64( %a) {
   ret  %res
 }
 
+; maxnum minnum
+
+define  @maxnum_nxv16f16( %a,  %b) {
+; CHECK-LABEL: maxnum_nxv16f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.h
+; CHECK-NEXT:fmaxnm z0.h, p0/m, z0.h, z2.h
+; CHECK-NEXT:fmaxnm z1.h, p0/m, z1.h, z3.h
+; CHECK-NEXT:ret
+  %res = call  @llvm.maxnum.nxv16f16( 
%a,  %b)
+  ret  %res
+}
+
+define  @maxnum_nxv8f16( %a,  %b) {
+; CHECK-LABEL: maxnum_nxv8f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.h
+; CHECK-NEXT:fmaxnm z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+  %res = call  @llvm.maxnum.nxv8f16( %a, 
 %b)
+  ret  %res
+}
+
+define  @maxnum_nxv4f16( %a,  %b) {
+; CHECK-LABEL: maxnum_nxv4f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s
+; CHECK-NEXT:fmaxnm z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+  %res = call  @llvm.maxnum.nxv4f16( %a, 
 %b)
+  ret  %res
+}
+
+define  @maxnum_nxv2f16( %a,  %b) {
+; CHECK-LABEL: maxnum_nxv2f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.d
+; CHECK-NEXT:fmaxnm z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+  %res = call  @llvm.maxnum.nxv2f16( %a, 
 %b)
+  ret  %res
+}
+
+define  @maxnum_nxv8f32( %a,  %b) {
+; CHECK-LABEL: maxnum_nxv8f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s
+; CHECK-NEXT:fmaxnm z0.s, p0/m, z0.s, z2.s
+; CHECK-NEXT:fmaxnm z1.s, p0/m, z1.s, z3.s
+; CHECK-NEXT:ret
+  %res = call  @llvm.maxnum.nxv8f32( 
%a,  %b)
+  ret  %res
+}
+
+define  @maxnum_nxv4f32( %a,  %b) {
+; CHECK-LABEL: maxnum_nxv4f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s
+; CHECK-NEXT:fmaxnm z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT:ret
+  %res = call  @llvm.maxnum.nxv4f32( 
%a,  %b)
+  ret  %res
+}
+
+define  @maxnum_nxv2f32( %a,  %b) {
+; CHECK-LABEL: maxnum_nxv2f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.d
+; CHECK-NEXT:fmaxnm z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT:ret
+  %res = call  @llvm.maxnum.nxv2f32( 
%a,  %b)
+  ret  %res
+}
+
+define  @maxnum_nxv4f64( %a,  %b) {
+; CHECK-LABEL: maxnum_nxv4f64:
+; CHECK: 

[llvm-branch-commits] [llvm] 2a06628 - [VectorCombine] add tests for load of insert/extract; NFC

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

Author: Sanjay Patel
Date: 2020-12-08T12:56:54-05:00
New Revision: 2a06628185b4598fa8a6a5b733028b4255818ce9

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

LOG: [VectorCombine] add tests for load of insert/extract; 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 4b2859238a69..66b9f89dd8dd 100644
--- a/llvm/test/Transforms/VectorCombine/X86/load.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/load.ll
@@ -496,3 +496,44 @@ define void @PR47558_multiple_use_load(<2 x float>* 
nocapture nonnull %resultptr
   store <2 x float> %result1, <2 x float>* %resultptr, align 8
   ret void
 }
+
+define <4 x float> @load_v2f32_extract_insert_v4f32(<2 x float>* align 16 
dereferenceable(16) %p) {
+; CHECK-LABEL: @load_v2f32_extract_insert_v4f32(
+; CHECK-NEXT:[[L:%.*]] = load <2 x float>, <2 x float>* [[P:%.*]], align 4
+; CHECK-NEXT:[[S:%.*]] = extractelement <2 x float> [[L]], i32 0
+; CHECK-NEXT:[[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0
+; CHECK-NEXT:ret <4 x float> [[R]]
+;
+  %l = load <2 x float>, <2 x float>* %p, align 4
+  %s = extractelement <2 x float> %l, i32 0
+  %r = insertelement <4 x float> undef, float %s, i32 0
+  ret <4 x float> %r
+}
+
+define <4 x float> @load_v8f32_extract_insert_v4f32(<8 x float>* align 16 
dereferenceable(16) %p) {
+; CHECK-LABEL: @load_v8f32_extract_insert_v4f32(
+; CHECK-NEXT:[[L:%.*]] = load <8 x float>, <8 x float>* [[P:%.*]], align 4
+; CHECK-NEXT:[[S:%.*]] = extractelement <8 x float> [[L]], i32 0
+; CHECK-NEXT:[[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0
+; CHECK-NEXT:ret <4 x float> [[R]]
+;
+  %l = load <8 x float>, <8 x float>* %p, align 4
+  %s = extractelement <8 x float> %l, i32 0
+  %r = insertelement <4 x float> undef, float %s, i32 0
+  ret <4 x float> %r
+}
+
+define <8 x i32> @load_v1i32_extract_insert_v8i32_extra_use(<1 x i32>* align 
16 dereferenceable(16) %p, <1 x i32>* %store_ptr) {
+; CHECK-LABEL: @load_v1i32_extract_insert_v8i32_extra_use(
+; CHECK-NEXT:[[L:%.*]] = load <1 x i32>, <1 x i32>* [[P:%.*]], align 4
+; CHECK-NEXT:store <1 x i32> [[L]], <1 x i32>* [[STORE_PTR:%.*]], align 4
+; CHECK-NEXT:[[S:%.*]] = extractelement <1 x i32> [[L]], i32 0
+; CHECK-NEXT:[[R:%.*]] = insertelement <8 x i32> undef, i32 [[S]], i32 0
+; CHECK-NEXT:ret <8 x i32> [[R]]
+;
+  %l = load <1 x i32>, <1 x i32>* %p, align 4
+  store <1 x i32> %l, <1 x i32>* %store_ptr
+  %s = extractelement <1 x i32> %l, i32 0
+  %r = insertelement <8 x i32> undef, i32 %s, i32 0
+  ret <8 x i32> %r
+}



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


[llvm-branch-commits] [llvm] 554e6db - [test] Rewrite phi-empty.ll into a unittest

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

Author: Arthur Eubanks
Date: 2020-12-08T09:59:31-08:00
New Revision: 554e6db18e0f264481bdab20dca9cc772d90270e

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

LOG: [test] Rewrite phi-empty.ll into a unittest

phi-empty.ll does not pass under the new PM because the NPM runs
-loop-simplify. Running -loop-simplify ends up not reproing
https://llvm.org/PR48296.

Verified that this test fails when 9eb2c011 is reverted.

Reviewed By: spatel

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

Added: 


Modified: 
llvm/unittests/IR/BasicBlockTest.cpp

Removed: 
llvm/test/Transforms/LoopRotate/phi-empty.ll



diff  --git a/llvm/test/Transforms/LoopRotate/phi-empty.ll 
b/llvm/test/Transforms/LoopRotate/phi-empty.ll
deleted file mode 100644
index 9337133f8903..
--- a/llvm/test/Transforms/LoopRotate/phi-empty.ll
+++ /dev/null
@@ -1,39 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -lcssa -loop-rotate < %s | FileCheck %s
-
-; After rotate, the phi has no operands because it has no predecessors.
-; We might want to delete that instruction instead, but we do not
-; fail/assert by assuming that the phi is invalid IR.
-
-define void @PR48296(i1 %cond) {
-; CHECK-LABEL: @PR48296(
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:br label [[LOOP:%.*]]
-; CHECK:   loop:
-; CHECK-NEXT:br i1 [[COND:%.*]], label [[INC:%.*]], label 
[[LOOP_BACKEDGE:%.*]]
-; CHECK:   loop.backedge:
-; CHECK-NEXT:br label [[LOOP]]
-; CHECK:   dead:
-; CHECK-NEXT:unreachable
-; CHECK:   inc:
-; CHECK-NEXT:br label [[LOOP_BACKEDGE]]
-; CHECK:   return:
-; CHECK-NEXT:[[R:%.*]] = phi i32
-; CHECK-NEXT:ret void
-;
-entry:
-  br label %loop
-
-loop:
-  br i1 %cond, label %inc, label %loop
-
-dead:; No predecessors!
-  br i1 %cond, label %inc, label %return
-
-inc:
-  br label %loop
-
-return:
-  %r = phi i32 [ undef, %dead ]
-  ret void
-}

diff  --git a/llvm/unittests/IR/BasicBlockTest.cpp 
b/llvm/unittests/IR/BasicBlockTest.cpp
index fcdc9c2c07fb..fa923c90c729 100644
--- a/llvm/unittests/IR/BasicBlockTest.cpp
+++ b/llvm/unittests/IR/BasicBlockTest.cpp
@@ -11,9 +11,11 @@
 #include "llvm/AsmParser/Parser.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Instructions.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/NoFolder.h"
+#include "llvm/IR/Verifier.h"
 #include "llvm/Support/SourceMgr.h"
 #include "gmock/gmock-matchers.h"
 #include "gtest/gtest.h"
@@ -165,6 +167,23 @@ TEST(BasicBlockTest, ComesBefore) {
   EXPECT_FALSE(Ret->comesBefore(Ret));
 }
 
+TEST(BasicBlockTest, EmptyPhi) {
+  LLVMContext Ctx;
+
+  Module *M = new Module("MyModule", Ctx);
+  FunctionType *FT = FunctionType::get(Type::getVoidTy(Ctx), {}, false);
+  Function *F = Function::Create(FT, Function::ExternalLinkage, "", M);
+
+  BasicBlock *BB1 = BasicBlock::Create(Ctx, "", F);
+  ReturnInst::Create(Ctx, BB1);
+
+  Type *Ty = Type::getInt32PtrTy(Ctx);
+  BasicBlock *BB2 = BasicBlock::Create(Ctx, "", F);
+  PHINode::Create(Ty, 0, "", BB2);
+  ReturnInst::Create(Ctx, BB2);
+  EXPECT_FALSE(verifyModule(*M, &errs()));
+}
+
 class InstrOrderInvalidationTest : public ::testing::Test {
 protected:
   void SetUp() 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] [llvm] 10987e3 - Remove unused include. NFC.

2020-12-08 Thread Benjamin Kramer via llvm-branch-commits

Author: Benjamin Kramer
Date: 2020-12-08T19:03:56+01:00
New Revision: 10987e30be7737855ac5bc4289b3abc052f7d403

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

LOG: Remove unused include. NFC.

This is also a layering violation.

Added: 


Modified: 
llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp 
b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
index 82c110a4b2ab..fb5ad3fb1c88 100644
--- a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
+++ b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
@@ -15,7 +15,6 @@
 
 #include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
-#include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
 #include "llvm/IR/Constants.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] [llvm] 5f18e2f - Move createScalarizeMaskedMemIntrinPass to Scalar.h

2020-12-08 Thread Benjamin Kramer via llvm-branch-commits

Author: Benjamin Kramer
Date: 2020-12-08T19:08:09+01:00
New Revision: 5f18e2f31ecbda5ace100cd2925ef7a0cafe3c3b

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

LOG: Move createScalarizeMaskedMemIntrinPass to Scalar.h

Added: 


Modified: 
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/Transforms/Scalar.h
llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/Passes.h 
b/llvm/include/llvm/CodeGen/Passes.h
index e3aa32bffb71..a74334e6200c 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -76,10 +76,6 @@ namespace llvm {
   /// matching during instruction selection.
   FunctionPass *createCodeGenPreparePass();
 
-  /// createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather
-  /// and scatter intrinsics with scalar code when target doesn't support them.
-  FunctionPass *createScalarizeMaskedMemIntrinPass();
-
   /// AtomicExpandID -- Lowers atomic operations in terms of either cmpxchg
   /// load-linked/store-conditional loops.
   extern char &AtomicExpandID;

diff  --git a/llvm/include/llvm/Transforms/Scalar.h 
b/llvm/include/llvm/Transforms/Scalar.h
index 68f678432471..2cebd89fdddb 100644
--- a/llvm/include/llvm/Transforms/Scalar.h
+++ b/llvm/include/llvm/Transforms/Scalar.h
@@ -545,6 +545,14 @@ Pass *createWarnMissedTransformationsPass();
 // instruction in a function.
 //
 FunctionPass *createInstSimplifyLegacyPass();
+
+
+//===--===//
+//
+// createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather
+// and scatter intrinsics with scalar code when target doesn't support them.
+//
+FunctionPass *createScalarizeMaskedMemIntrinPass();
 } // End llvm namespace
 
 #endif

diff  --git a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp 
b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
index fb5ad3fb1c88..98d85f4f5844 100644
--- a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
+++ b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
@@ -31,6 +31,7 @@
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Transforms/Scalar.h"
 #include 
 #include 
 



___
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] d7e71b5 - [compiler-rt santizer] Use clock_gettime instead of timespec_get

2020-12-08 Thread Teresa Johnson via llvm-branch-commits

Author: Jeroen Dobbelaere
Date: 2020-12-08T10:10:17-08:00
New Revision: d7e71b5db8427309ad12249633ea86cccdc5a701

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

LOG: [compiler-rt santizer] Use clock_gettime instead of timespec_get

On RH66, timespec_get is not available. Use clock_gettime instead.

This problem was introduced with D87120

Reviewed By: tejohnson

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

Added: 


Modified: 
compiler-rt/lib/memprof/memprof_allocator.cpp
compiler-rt/lib/memprof/memprof_rtl.cpp

Removed: 




diff  --git a/compiler-rt/lib/memprof/memprof_allocator.cpp 
b/compiler-rt/lib/memprof/memprof_allocator.cpp
index 0f9263e66fe0..259c7c144ab7 100644
--- a/compiler-rt/lib/memprof/memprof_allocator.cpp
+++ b/compiler-rt/lib/memprof/memprof_allocator.cpp
@@ -52,7 +52,7 @@ static int GetTimestamp(void) {
 return 0;
   }
   timespec ts;
-  timespec_get(&ts, TIME_UTC);
+  clock_gettime(CLOCK_REALTIME, &ts);
   return (ts.tv_sec - memprof_init_timestamp_s) * 1000 + ts.tv_nsec / 100;
 }
 

diff  --git a/compiler-rt/lib/memprof/memprof_rtl.cpp 
b/compiler-rt/lib/memprof/memprof_rtl.cpp
index 8e1335aea875..d6d606f666ee 100644
--- a/compiler-rt/lib/memprof/memprof_rtl.cpp
+++ b/compiler-rt/lib/memprof/memprof_rtl.cpp
@@ -234,7 +234,7 @@ void MemprofInitTime() {
   if (LIKELY(memprof_timestamp_inited))
 return;
   timespec ts;
-  timespec_get(&ts, TIME_UTC);
+  clock_gettime(CLOCK_REALTIME, &ts);
   memprof_init_timestamp_s = ts.tv_sec;
   memprof_timestamp_inited = 1;
 }



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


[llvm-branch-commits] [clang-tools-extra] c6348e8 - cppcoreguidelines Narrowing Conversions Check: detect narrowing conversions involving typedefs

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

Author: Eric Seidel
Date: 2020-12-08T13:10:41-05:00
New Revision: c6348e8c95ee1eaa9dd2322b278def7a4127ff26

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

LOG: cppcoreguidelines Narrowing Conversions Check: detect narrowing 
conversions involving typedefs

The check 'cppcoreguidelines-narrowing-conversions' does not detect conversions
involving typedef. This notably includes the standard fixed-width integer types
like int32_t, uint64_t, etc. Now look through the typedefs at the desugared 
type.

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
index 1837ccb6002f..3ab300dc499f 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -48,8 +48,10 @@ void NarrowingConversionsCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(
   traverse(
   ast_type_traits::TK_AsIs,
-  implicitCastExpr(hasImplicitDestinationType(builtinType()),
-   hasSourceExpression(hasType(builtinType())),
+  implicitCastExpr(hasImplicitDestinationType(
+   hasUnqualifiedDesugaredType(builtinType())),
+   hasSourceExpression(hasType(
+   hasUnqualifiedDesugaredType(builtinType(,
unless(hasSourceExpression(IsCeilFloorCallExpr)),
unless(hasParent(castExpr())),
unless(isInTemplateInstantiation()))
@@ -58,16 +60,18 @@ void 
NarrowingConversionsCheck::registerMatchers(MatchFinder *Finder) {
 
   // Binary operators:
   //   i += 0.5;
-  Finder->addMatcher(binaryOperator(isAssignmentOperator(),
-hasLHS(expr(hasType(builtinType(,
-hasRHS(expr(hasType(builtinType(,
-unless(hasRHS(IsCeilFloorCallExpr)),
-unless(isInTemplateInstantiation()),
-// The `=` case generates an implicit cast
-// which is covered by the previous 
matcher.
-unless(hasOperatorName("=")))
- .bind("binary_op"),
- this);
+  Finder->addMatcher(
+  binaryOperator(
+  isAssignmentOperator(),
+  hasLHS(expr(hasType(hasUnqualifiedDesugaredType(builtinType(),
+  hasRHS(expr(hasType(hasUnqualifiedDesugaredType(builtinType(),
+  unless(hasRHS(IsCeilFloorCallExpr)),
+  unless(isInTemplateInstantiation()),
+  // The `=` case generates an implicit cast
+  // which is covered by the previous matcher.
+  unless(hasOperatorName("=")))
+  .bind("binary_op"),
+  this);
 }
 
 static const BuiltinType *getBuiltinType(const Expr &E) {

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp
index cc817a021fde..493a447913bd 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp
@@ -343,4 +343,17 @@ void macro_context() {
   DERP(i, .5l);
 }
 
+// We understand typedefs.
+void typedef_context() {
+  typedef long long myint64_t;
+  int i;
+  myint64_t i64;
+
+  i64 = i64; // Okay, no conversion.
+  i64 = i;   // Okay, no narrowing.
+
+  i = i64;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 
'myint64_t' (aka 'long long') to signed type 'int' is implementation-defined 
[cppcoreguidelines-narrowing-conversions]
+}
+
 } // namespace floats



___
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] 1821265 - [Time-report] Add a flag -ftime-report={per-pass, per-pass-run} to control the pass timing aggregation

2020-12-08 Thread Yuanfang Chen via llvm-branch-commits

Author: Yuanfang Chen
Date: 2020-12-08T10:13:19-08:00
New Revision: 1821265db681cd2289fce9331e3aed26bdf814e3

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

LOG: [Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control 
the pass timing aggregation

Currently, -ftime-report + new pass manager emits one line of report for each
pass run. This potentially causes huge output text especially with regular LTO
or large single file (Obeserved in private tests and was reported in D51276).
The behaviour of -ftime-report + legacy pass manager is
emitting one line of report for each pass object which has relatively reasonable
text output size. This patch adds a flag `-ftime-report=` to control time report
aggregation for new pass manager.

The flag is for new pass manager only. Using it with legacy pass manager gives
an error. It is a driver and cc1 flag. `per-pass` is the new default so
`-ftime-report` is aliased to `-ftime-report=per-pass`. Before this patch,
functionality-wise `-ftime-report` is aliased to `-ftime-report=per-pass-run`.

* Adds an boolean variable TimePassesHandler::PerRun to control per-pass vs 
per-pass-run.
* Adds a new clang CodeGen flag CodeGenOptions::TimePassesPerRun to work with 
the existing CodeGenOptions::TimePasses.
* Remove FrontendOptions::ShowTimers, its uses are replaced by the existing 
CodeGenOptions::TimePasses.
* Remove FrontendTimesIsEnabled (It was introduced in D45619 which was largely 
reverted.)

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

Added: 
clang/test/Driver/time-report.c
clang/test/Misc/time-passes.c

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/FrontendOptions.h
clang/include/clang/Frontend/Utils.h
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CMakeLists.txt
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/IR/PassTimingInfo.h
llvm/include/llvm/Pass.h
llvm/lib/IR/PassTimingInfo.cpp
llvm/test/Other/time-passes.ll

Removed: 
clang/lib/Frontend/FrontendTiming.cpp



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index d4bbdbfa13b5..9c3b4f8289f9 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -252,7 +252,8 @@ CODEGENOPT(SpeculativeLoadHardening, 1, 0) ///< Enable 
speculative load hardenin
 CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Enable fine-grained 
bitfield accesses.
 CODEGENOPT(StrictEnums   , 1, 0) ///< Optimize based on strict enum 
definition.
 CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict 
vtable pointers
-CODEGENOPT(TimePasses, 1, 0) ///< Set when -ftime-report is enabled.
+CODEGENOPT(TimePasses, 1, 0) ///< Set when -ftime-report or 
-ftime-report= is enabled.
+CODEGENOPT(TimePassesPerRun  , 1, 0) ///< Set when -ftime-report=per-pass-run 
is enabled.
 CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is enabled.
 VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500) ///< Minimum time granularity 
(in microseconds),
///< traced by time profiler

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 794aa24f997d..8cabcd671161 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2005,7 +2005,12 @@ def Wframe_larger_than_EQ : Joined<["-"], 
"Wframe-larger-than=">, Group
 def : Flag<["-"], "fterminated-vtables">, Alias;
 def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">, Group;
 def ftime_report : Flag<["-"], "ftime-report">, Group, 
Flags<[CC1Option]>,
-  MarshallingInfoFlag<"FrontendOpts.ShowTimers">;
+  MarshallingInfoFlag<"CodeGenOpts.TimePasses">;
+def ftime_report_EQ: Joined<["-"], "ftime-report=">, Group,
+  Flags<[CC1Option]>, Values<"per-pass,per-pass-run">,
+  MarshallingInfoFlag<"CodeGenOpts.TimePassesPerRun">,
+  HelpText<"(For new pass manager) \"per-pass\": one report for each pass; "
+   "\"per-pass-run\": one report for each pass invocation">;
 def ftime_trace : Flag<["-"], "ftime-trace">, Group,
   HelpText<"Turn on time profiler. Generates JSON file based on output 
filename.">,
   DocBrief<[{

diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index b06ad5203e75..223c1e05d053 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -239,9 +239,6 @@ class FrontendOptions {

[llvm-branch-commits] [llvm] 3e86fbc - [RISCV] Replace custom isel code for RISCVISD::READ_CYCLE_WIDE with isel pattern

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

Author: Craig Topper
Date: 2020-12-08T10:23:37-08:00
New Revision: 3e86fbc97189366866aac4286fb9c412c1fb526c

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

LOG: [RISCV] Replace custom isel code for RISCVISD::READ_CYCLE_WIDE with isel 
pattern

This node returns 2 results and uses a chain. As long as we use a DAG as part 
of the pseudo instruction definition where we can use the "set" operator, it 
looks like tablegen can handle use a pattern for this without a problem. I 
believe the original implementation was copied from PowerPC.

This also fixes the pseudo instruction so that it is marked as having side 
effects to match the definition of CSRRS and the RV64 instruction. And we don't 
need to explicitly clear mayLoad/mayStore since those can be inferred now.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.td

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp 
b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index 65395706a40a..e4ffb42eca28 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -143,13 +143,6 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
 }
 break;
   }
-  case RISCVISD::READ_CYCLE_WIDE:
-assert(!Subtarget->is64Bit() && "READ_CYCLE_WIDE is only used on riscv32");
-
-ReplaceNode(Node, CurDAG->getMachineNode(RISCV::ReadCycleWide, DL, 
MVT::i32,
- MVT::i32, MVT::Other,
- Node->getOperand(0)));
-return;
   }
 
   // Select the default instruction.

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index f6eec9e0f870..768dd8a636fe 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -25,6 +25,8 @@ def SDT_RISCVCall : SDTypeProfile<0, -1, [SDTCisVT<0, 
XLenVT>]>;
 def SDT_RISCVSelectCC : SDTypeProfile<1, 5, [SDTCisSameAs<1, 2>,
  SDTCisSameAs<0, 4>,
  SDTCisSameAs<4, 5>]>;
+def SDT_RISCVReadCycleWide : SDTypeProfile<2, 0, [SDTCisVT<0, i32>,
+  SDTCisVT<1, i32>]>;
 
 // Target-independent nodes, but with target-specific formats.
 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_CallSeqStart,
@@ -52,6 +54,10 @@ def riscv_sllw  : SDNode<"RISCVISD::SLLW", 
SDTIntShiftOp>;
 def riscv_sraw  : SDNode<"RISCVISD::SRAW", SDTIntShiftOp>;
 def riscv_srlw  : SDNode<"RISCVISD::SRLW", SDTIntShiftOp>;
 
+def riscv_read_cycle_wide : SDNode<"RISCVISD::READ_CYCLE_WIDE",
+   SDT_RISCVReadCycleWide,
+   [SDNPHasChain, SDNPSideEffect]>;
+
 
//===--===//
 // Operand and SDNode transformation definitions.
 
//===--===//
@@ -1170,9 +1176,10 @@ let Predicates = [IsRV64] in
 def : Pat<(readcyclecounter), (CSRRS CYCLE.Encoding, X0)>;
 // On RV32, ReadCycleWide will be expanded to the suggested loop reading both
 // halves of the 64-bit "cycle" CSR.
-let Predicates = [IsRV32], usesCustomInserter = 1, hasSideEffects = 0,
-mayLoad = 0, mayStore = 0, hasNoSchedulingInfo = 1 in
-def ReadCycleWide : Pseudo<(outs GPR:$lo, GPR:$hi), (ins), [], "", "">;
+let Predicates = [IsRV32], usesCustomInserter = 1, hasNoSchedulingInfo = 1 in
+def ReadCycleWide : Pseudo<(outs GPR:$lo, GPR:$hi), (ins),
+   [(set GPR:$lo, GPR:$hi, (riscv_read_cycle_wide))],
+   "", "">;
 
 /// traps
 



___
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] 4fede8b - [flang] Implement derived type description table encoding

2020-12-08 Thread peter klausler via llvm-branch-commits

Author: peter klausler
Date: 2020-12-08T10:26:58-08:00
New Revision: 4fede8bc8a015477f2a8feeb30a1d2a2e155106d

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

LOG: [flang] Implement derived type description table encoding

Define Fortran derived types that describe the characteristics
of derived types, and instantiations of parameterized derived
types, that are of relevance to the runtime language support
library.  Define a suite of corresponding C++ structure types
for the runtime library to use to interpret instances of the
descriptions.

Create instances of these description types in Semantics as
static initializers for compiler-created objects in the scopes
that define or instantiate user derived types.

Delete obsolete code from earlier attempts to package runtime
type information.

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

Added: 
flang/include/flang/Semantics/runtime-type-info.h
flang/lib/Semantics/runtime-type-info.cpp
flang/module/__fortran_type_info.f90
flang/runtime/derived.cpp
flang/runtime/derived.h
flang/runtime/type-info.h
flang/test/Semantics/typeinfo01.f90

Modified: 
flang/docs/RuntimeTypeInfo.md
flang/include/flang/Semantics/scope.h
flang/lib/Semantics/CMakeLists.txt
flang/lib/Semantics/compute-offsets.cpp
flang/lib/Semantics/semantics.cpp
flang/lib/Semantics/tools.cpp
flang/module/__fortran_builtins.f90
flang/module/iso_c_binding.f90
flang/runtime/CMakeLists.txt
flang/runtime/allocatable.cpp
flang/runtime/allocatable.h
flang/runtime/descriptor.cpp
flang/runtime/descriptor.h
flang/runtime/transformational.cpp
flang/tools/f18/CMakeLists.txt
flang/tools/f18/f18.cpp

Removed: 
flang/runtime/derived-type.cpp
flang/runtime/derived-type.h



diff  --git a/flang/docs/RuntimeTypeInfo.md b/flang/docs/RuntimeTypeInfo.md
index 2a511b208d0e..391b6ea5f88b 100644
--- a/flang/docs/RuntimeTypeInfo.md
+++ b/flang/docs/RuntimeTypeInfo.md
@@ -216,7 +216,7 @@ So the derived type information for a defined assignment 
needs to
 comprise:
 * address(es) of the subroutine
 * whether the first, second, or both arguments are descriptors
-* whether the subroutine is elemental
+* whether the subroutine is elemental (necessarily also impure)
 
 ### User defined derived type I/O
 

diff  --git a/flang/include/flang/Semantics/runtime-type-info.h 
b/flang/include/flang/Semantics/runtime-type-info.h
new file mode 100644
index ..71b5cac58eb5
--- /dev/null
+++ b/flang/include/flang/Semantics/runtime-type-info.h
@@ -0,0 +1,38 @@
+//===-- include/flang/Semantics/runtime-type-info.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// BuildRuntimeDerivedTypeTables() translates the scopes of derived types
+// and parameterized derived type instantiations into the type descriptions
+// defined in module/__fortran_type_info.f90, packaging these descriptions
+// as static initializers for compiler-created objects.
+
+#ifndef FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
+#define FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
+
+#include 
+#include 
+
+namespace llvm {
+class raw_ostream;
+}
+
+namespace Fortran::semantics {
+class Scope;
+class SemanticsContext;
+class Symbol;
+
+struct RuntimeDerivedTypeTables {
+  Scope *schemata{nullptr};
+  std::set names;
+};
+
+RuntimeDerivedTypeTables BuildRuntimeDerivedTypeTables(SemanticsContext &);
+
+void Dump(llvm::raw_ostream &, const RuntimeDerivedTypeTables &);
+} // namespace Fortran::semantics
+#endif // FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_

diff  --git a/flang/include/flang/Semantics/scope.h 
b/flang/include/flang/Semantics/scope.h
index cae94dfac9e8..535e2bd50dce 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -197,8 +197,11 @@ class Scope {
 
   std::size_t size() const { return size_; }
   void set_size(std::size_t size) { size_ = size; }
-  std::size_t alignment() const { return alignment_; }
-  void set_alignment(std::size_t alignment) { alignment_ = alignment; }
+  std::optional alignment() const { return alignment_; }
+
+  void SetAlignment(std::size_t n) {
+alignment_ = std::max(alignment_.value_or(0), n);
+  }
 
   ImportKind GetImportKind() const;
   // Names appearing in IMPORT statements in this scope
@@ -242,11 +245,18 @@ class Scope {
 
   void InstantiateDerivedTypes(SemanticsContext &);
 
+  const Symbol *runtimeDerivedTypeDescription() const {
+return runtimeDerivedTypeDescription_;
+  }
+  void set_run

[llvm-branch-commits] [mlir] 94e645f - [mlir] Async: Add numWorkerThreads argument to createAsyncParallelForPass

2020-12-08 Thread Eugene Zhulenev via llvm-branch-commits

Author: Eugene Zhulenev
Date: 2020-12-08T10:30:14-08:00
New Revision: 94e645f9cce8fba26b4aec069103794f1779065f

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

LOG: [mlir] Async: Add numWorkerThreads argument to createAsyncParallelForPass

Add an option to pass the number of worker threads to select the number of 
async regions for parallel for transformation.
```
std::unique_ptr> createAsyncParallelForPass(int 
numWorkerThreads);
```

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Async/Passes.h
mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Async/Passes.h 
b/mlir/include/mlir/Dialect/Async/Passes.h
index 9716bde76593..ab5abdc28611 100644
--- a/mlir/include/mlir/Dialect/Async/Passes.h
+++ b/mlir/include/mlir/Dialect/Async/Passes.h
@@ -19,6 +19,9 @@ namespace mlir {
 
 std::unique_ptr> createAsyncParallelForPass();
 
+std::unique_ptr>
+createAsyncParallelForPass(int numWorkerThreads);
+
 std::unique_ptr> createAsyncRefCountingPass();
 
 std::unique_ptr> 
createAsyncRefCountingOptimizationPass();

diff  --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp 
b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
index c6508610c796..d6553974bc38 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
@@ -96,6 +96,10 @@ struct AsyncParallelForRewrite : public 
OpRewritePattern {
 struct AsyncParallelForPass
 : public AsyncParallelForBase {
   AsyncParallelForPass() = default;
+  AsyncParallelForPass(int numWorkerThreads) {
+assert(numWorkerThreads >= 1);
+numConcurrentAsyncExecute = numWorkerThreads;
+  }
   void runOnFunction() override;
 };
 
@@ -276,3 +280,8 @@ void AsyncParallelForPass::runOnFunction() {
 std::unique_ptr> mlir::createAsyncParallelForPass() {
   return std::make_unique();
 }
+
+std::unique_ptr>
+mlir::createAsyncParallelForPass(int numWorkerThreads) {
+  return std::make_unique(numWorkerThreads);
+}



___
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] 7b007ac - [lld-macho][nfc] Move some methods from InputFile to ObjFile

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

Author: Jez Ng
Date: 2020-12-08T10:34:32-08:00
New Revision: 7b007ac0800babe750c58b1aead15e1c3e7f3b0f

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

LOG: [lld-macho][nfc] Move some methods from InputFile to ObjFile

Additionally:
1. Move the helper functions in InputSection.h below the definition of
   `InputSection`, so the important stuff is on top
2. Remove unnecessary `explicit`

Reviewed By: #lld-macho, compnerd

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

Added: 


Modified: 
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/InputSection.cpp
lld/MachO/InputSection.h

Removed: 




diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 1339152901ce..24600090c491 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -155,7 +155,7 @@ const load_command *macho::findCommand(const mach_header_64 
*hdr,
   return nullptr;
 }
 
-void InputFile::parseSections(ArrayRef sections) {
+void ObjFile::parseSections(ArrayRef sections) {
   subsections.reserve(sections.size());
   auto *buf = reinterpret_cast(mb.getBufferStart());
 
@@ -192,8 +192,8 @@ static InputSection *findContainingSubsection(SubsectionMap 
&map,
   return it->second;
 }
 
-void InputFile::parseRelocations(const section_64 &sec,
- SubsectionMap &subsecMap) {
+void ObjFile::parseRelocations(const section_64 &sec,
+   SubsectionMap &subsecMap) {
   auto *buf = reinterpret_cast(mb.getBufferStart());
   ArrayRef anyRelInfos(
   reinterpret_cast(buf + sec.reloff),
@@ -266,8 +266,8 @@ static macho::Symbol *createAbsolute(const 
structs::nlist_64 &sym,
/*isExternal=*/false);
 }
 
-macho::Symbol *InputFile::parseNonSectionSymbol(const structs::nlist_64 &sym,
-StringRef name) {
+macho::Symbol *ObjFile::parseNonSectionSymbol(const structs::nlist_64 &sym,
+  StringRef name) {
   uint8_t type = sym.n_type & N_TYPE;
   switch (type) {
   case N_UNDF:
@@ -289,8 +289,8 @@ macho::Symbol *InputFile::parseNonSectionSymbol(const 
structs::nlist_64 &sym,
   }
 }
 
-void InputFile::parseSymbols(ArrayRef nList,
- const char *strtab, bool subsectionsViaSymbols) {
+void ObjFile::parseSymbols(ArrayRef nList,
+   const char *strtab, bool subsectionsViaSymbols) {
   // resize(), not reserve(), because we are going to create N_ALT_ENTRY 
symbols
   // out-of-sequence.
   symbols.resize(nList.size());

diff  --git a/lld/MachO/InputFiles.h b/lld/MachO/InputFiles.h
index 59638ac197cf..877ccaef2fef 100644
--- a/lld/MachO/InputFiles.h
+++ b/lld/MachO/InputFiles.h
@@ -64,7 +64,6 @@ class InputFile {
   MemoryBufferRef mb;
 
   std::vector symbols;
-  ArrayRef sectionHeaders;
   std::vector subsections;
   // Provides an easy way to sort InputFiles deterministically.
   const int id;
@@ -80,15 +79,6 @@ class InputFile {
   InputFile(Kind kind, const llvm::MachO::InterfaceFile &interface)
   : id(idCount++), fileKind(kind), name(saver.save(interface.getPath())) {}
 
-  void parseSections(ArrayRef);
-
-  void parseSymbols(ArrayRef nList, const char *strtab,
-bool subsectionsViaSymbols);
-
-  Symbol *parseNonSectionSymbol(const structs::nlist_64 &sym, StringRef name);
-
-  void parseRelocations(const llvm::MachO::section_64 &, SubsectionMap &);
-
 private:
   const Kind fileKind;
   const StringRef name;
@@ -99,21 +89,26 @@ class InputFile {
 // .o file
 class ObjFile : public InputFile {
 public:
-  explicit ObjFile(MemoryBufferRef mb, uint32_t modTime, StringRef 
archiveName);
+  ObjFile(MemoryBufferRef mb, uint32_t modTime, StringRef archiveName);
   static bool classof(const InputFile *f) { return f->kind() == ObjKind; }
 
   llvm::DWARFUnit *compileUnit = nullptr;
   const uint32_t modTime;
+  ArrayRef sectionHeaders;
 
 private:
+  void parseSections(ArrayRef);
+  void parseSymbols(ArrayRef nList, const char *strtab,
+bool subsectionsViaSymbols);
+  Symbol *parseNonSectionSymbol(const structs::nlist_64 &sym, StringRef name);
+  void parseRelocations(const llvm::MachO::section_64 &, SubsectionMap &);
   void parseDebugInfo();
 };
 
 // command-line -sectcreate file
 class OpaqueFile : public InputFile {
 public:
-  explicit OpaqueFile(MemoryBufferRef mb, StringRef segName,
-  StringRef sectName);
+  OpaqueFile(MemoryBufferRef mb, StringRef segName, StringRef sectName);
   static bool classof(const InputFile *f) { return f->kind() == OpaqueKind; }
 };
 

diff  --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp
index 80c263301f41..8477d78d2f3f 100644
--- a/lld/MachO/InputSection.c

[llvm-branch-commits] [lld] 78976bf - [lld-macho] Support parsing of bitcode within archives

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

Author: Jez Ng
Date: 2020-12-08T10:34:32-08:00
New Revision: 78976bf3dae2a4fac3b7fb2ab1a8d8e986ea36ff

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

LOG: [lld-macho] Support parsing of bitcode within archives

Also error out if we find anything other than an object or bitcode file
in the archive.

Note that we were previously inserting the symbols and sections of the
unpacked ObjFile into the containing ArchiveFile. This was actually
unnecessary -- we can just insert the ObjectFile (or BitcodeFile) into
the `inputFiles` vector. This is the approach taken by LLD-ELF.

Reviewed By: thakis

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

Added: 
lld/test/MachO/bitcode-nodatalayout.ll
lld/test/MachO/invalid/bad-archive-member.s
lld/test/MachO/lto-archive.ll

Modified: 
lld/MachO/InputFiles.cpp

Removed: 




diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 24600090c491..c452648a1b11 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -631,15 +631,26 @@ void ArchiveFile::fetch(const object::Archive::Symbol 
&sym) {
   // to it later.
   const object::Archive::Symbol sym_copy = sym;
 
-  auto file = make(mb, modTime, getName());
+  InputFile *file;
+  switch (identify_magic(mb.getBuffer())) {
+  case file_magic::macho_object:
+file = make(mb, modTime, getName());
+break;
+  case file_magic::bitcode:
+file = make(mb);
+break;
+  default:
+StringRef bufname =
+CHECK(c.getName(), toString(this) + ": could not get buffer name");
+error(toString(this) + ": archive member " + bufname +
+  " has unhandled file type");
+return;
+  }
+  inputFiles.push_back(file);
 
   // ld64 doesn't demangle sym here even with -demangle. Match that, so
   // intentionally no call to toMachOString() here.
   printArchiveMemberLoad(sym_copy.getName(), file);
-
-  symbols.insert(symbols.end(), file->symbols.begin(), file->symbols.end());
-  subsections.insert(subsections.end(), file->subsections.begin(),
- file->subsections.end());
 }
 
 BitcodeFile::BitcodeFile(MemoryBufferRef mbref)

diff  --git a/lld/test/MachO/bitcode-nodatalayout.ll 
b/lld/test/MachO/bitcode-nodatalayout.ll
new file mode 100644
index ..5e1c43c928d9
--- /dev/null
+++ b/lld/test/MachO/bitcode-nodatalayout.ll
@@ -0,0 +1,13 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+; RUN: not %lld %t.o -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: error: input module has no datalayout
+
+; This bitcode file has no datalayout.
+; Check that we error out producing a reasonable diagnostic.
+target triple = "x86_64-apple-macosx10.15.0"
+
+define void @_start() {
+  ret void
+}

diff  --git a/lld/test/MachO/invalid/bad-archive-member.s 
b/lld/test/MachO/invalid/bad-archive-member.s
new file mode 100644
index ..15ab524476d3
--- /dev/null
+++ b/lld/test/MachO/invalid/bad-archive-member.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
+# RUN: %lld -dylib -lSystem %t/foo.o -o %t/foo.dylib
+# RUN: rm -f %t/foo.a
+# RUN: llvm-ar rcs %t/foo.a %t/foo.dylib
+# RUN: not %lld %t/test.o %t/foo.a -o /dev/null 2>&1 | FileCheck %s 
-DFILE=%t/foo.a
+# CHECK: error: [[FILE]]: archive member foo.dylib has unhandled file type
+
+#--- foo.s
+.globl _foo
+_foo:
+  ret
+
+#--- test.s
+.globl _main
+_main:
+  callq _foo
+  ret

diff  --git a/lld/test/MachO/lto-archive.ll b/lld/test/MachO/lto-archive.ll
new file mode 100644
index ..42b2c0fb5759
--- /dev/null
+++ b/lld/test/MachO/lto-archive.ll
@@ -0,0 +1,28 @@
+; REQUIRES: x86
+; RUN: split-file %s %t
+; RUN: llvm-as %t/foo.ll -o %t/foo.o
+; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
+; RUN: rm -f %t/foo.a
+; RUN: llvm-ar rcs %t/foo.a %t/foo.o
+; RUN: %lld -save-temps -lSystem %t/test.o %t/foo.a -o %t/test
+; RUN: llvm-objdump -d --macho --no-show-raw-insn %t/test | FileCheck %s
+
+; CHECK:  _main:
+; CHECK-NEXT: callq _foo
+; CHECK-NEXT: retq
+
+;--- foo.ll
+
+target triple = "x86_64-apple-macosx10.15.0"
+target datalayout = 
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @foo() {
+  ret void
+}
+
+;--- test.s
+
+.globl _main
+_main:
+  callq _foo
+  ret



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


[llvm-branch-commits] [llvm] 3c01af9 - DenseMap: fix build with clang in C++20 mode

2020-12-08 Thread Nuno Lopes via llvm-branch-commits

Author: Nuno Lopes
Date: 2020-12-08T18:39:31Z
New Revision: 3c01af9aeebe01030e6138cece02675d2f148bb3

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

LOG: DenseMap: fix build with clang in C++20 mode
clang was complaing about this code:
llvm/include/llvm/IR/PassManager.h:715:17: error: ISO C++20 considers use of 
overloaded operator '!=' to be ambiguous despite there being a unique best 
viable function with non-reversed arguments 
[-Werror,-Wambiguous-reversed-operator]
  if (IMapI != IsResultInvalidated.end())
  ~ ^  ~
llvm/include/llvm/ADT/DenseMap.h:1253:8: note: candidate function with 
non-reversed arguments
  bool operator!=(const ConstIterator &RHS) const {
   ^
llvm/include/llvm/ADT/DenseMap.h:1246:8: note: ambiguous candidate function 
with reversed arguments
  bool operator==(const ConstIterator &RHS) const {
   ^

The warning is triggered when the DenseMapIterator (lhs) is not const and so
the == operator is applied to different types on lhs/rhs.
Using a template allows the function to be available for both const/non-const
iterator types and gets rid of the warning

Added: 


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

Removed: 




diff  --git a/llvm/include/llvm/ADT/DenseMap.h 
b/llvm/include/llvm/ADT/DenseMap.h
index f591ee07ac00..7da347125c34 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -1189,8 +1189,6 @@ class DenseMapIterator : DebugEpochBase::HandleBase {
   friend class DenseMapIterator;
   friend class DenseMapIterator;
 
-  using ConstIterator = DenseMapIterator;
-
 public:
   using 
diff erence_type = ptr
diff _t;
   using value_type =
@@ -1243,14 +1241,17 @@ class DenseMapIterator : DebugEpochBase::HandleBase {
 return Ptr;
   }
 
-  bool operator==(const ConstIterator &RHS) const {
+  template 
+  bool operator==(const T &RHS) const {
 assert((!Ptr || isHandleInSync()) && "handle not in sync!");
 assert((!RHS.Ptr || RHS.isHandleInSync()) && "handle not in sync!");
 assert(getEpochAddress() == RHS.getEpochAddress() &&
"comparing incomparable iterators!");
 return Ptr == RHS.Ptr;
   }
-  bool operator!=(const ConstIterator &RHS) const {
+
+  template 
+  bool operator!=(const T &RHS) const {
 assert((!Ptr || isHandleInSync()) && "handle not in sync!");
 assert((!RHS.Ptr || RHS.isHandleInSync()) && "handle not in sync!");
 assert(getEpochAddress() == RHS.getEpochAddress() &&



___
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] ce19966 - [AArch64][GlobalISel] Don't explicitly write to the zero register in emitCMN

2020-12-08 Thread Jessica Paquette via llvm-branch-commits

Author: Jessica Paquette
Date: 2020-12-08T10:42:05-08:00
New Revision: ce199667f65bcddc31c8c4be2b723f9132815fe6

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

LOG: [AArch64][GlobalISel] Don't explicitly write to the zero register in 
emitCMN

This case was missed in 78ccb0359d8da3269636d85933dd8afe50a2211f.

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

Added: 


Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-compare.mir

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index f23743b43db8..493167e284cf 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -4067,7 +4067,8 @@ AArch64InstructionSelector::emitCMN(MachineOperand &LHS, 
MachineOperand &RHS,
 MachineIRBuilder &MIRBuilder) const {
   MachineRegisterInfo &MRI = MIRBuilder.getMF().getRegInfo();
   bool Is32Bit = (MRI.getType(LHS.getReg()).getSizeInBits() == 32);
-  return emitADDS(Is32Bit ? AArch64::WZR : AArch64::XZR, LHS, RHS, MIRBuilder);
+  auto RC = Is32Bit ? &AArch64::GPR32RegClass : &AArch64::GPR64RegClass;
+  return emitADDS(MRI.createVirtualRegister(RC), LHS, RHS, MIRBuilder);
 }
 
 MachineInstr *

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-compare.mir 
b/llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-compare.mir
index 81cebc507b3d..f6e40381fc25 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-compare.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/opt-fold-compare.mir
@@ -45,7 +45,7 @@ body: |
 ; CHECK: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
 ; CHECK: [[COPY2:%[0-9]+]]:gpr32 = COPY $wzr
-; CHECK: $wzr = ADDSWrr [[COPY]], [[COPY1]], implicit-def $nzcv
+; CHECK: [[ADDSWrr:%[0-9]+]]:gpr32 = ADDSWrr [[COPY]], [[COPY1]], 
implicit-def $nzcv
 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr [[COPY2]], $wzr, 0, implicit 
$nzcv
 ; CHECK: $w0 = COPY [[CSINCWr]]
 ; CHECK: RET_ReallyLR implicit $w0
@@ -76,7 +76,7 @@ body: |
 ; CHECK: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
 ; CHECK: [[COPY2:%[0-9]+]]:gpr32 = COPY $wzr
-; CHECK: $wzr = ADDSWrr [[COPY]], [[COPY1]], implicit-def $nzcv
+; CHECK: [[ADDSWrr:%[0-9]+]]:gpr32 = ADDSWrr [[COPY]], [[COPY1]], 
implicit-def $nzcv
 ; CHECK: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr [[COPY2]], $wzr, 0, implicit 
$nzcv
 ; CHECK: $w0 = COPY [[CSINCWr]]
 ; CHECK: RET_ReallyLR implicit $w0
@@ -171,7 +171,7 @@ body: |
 ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
 ; CHECK: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1
 ; CHECK: [[COPY2:%[0-9]+]]:gpr64 = COPY $xzr
-; CHECK: $xzr = ADDSXrr [[COPY]], [[COPY1]], implicit-def $nzcv
+; CHECK: [[ADDSXrr:%[0-9]+]]:gpr64 = ADDSXrr [[COPY]], [[COPY1]], 
implicit-def $nzcv
 ; CHECK: [[CSINCXr:%[0-9]+]]:gpr64 = CSINCXr [[COPY2]], $xzr, 0, implicit 
$nzcv
 ; CHECK: $x0 = COPY [[CSINCXr]]
 ; CHECK: RET_ReallyLR implicit $x0
@@ -202,7 +202,7 @@ body: |
 ; CHECK: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
 ; CHECK: [[COPY1:%[0-9]+]]:gpr64 = COPY $x1
 ; CHECK: [[COPY2:%[0-9]+]]:gpr64 = COPY $xzr
-; CHECK: $xzr = ADDSXrr [[COPY]], [[COPY1]], implicit-def $nzcv
+; CHECK: [[ADDSXrr:%[0-9]+]]:gpr64 = ADDSXrr [[COPY]], [[COPY1]], 
implicit-def $nzcv
 ; CHECK: [[CSINCXr:%[0-9]+]]:gpr64 = CSINCXr [[COPY2]], $xzr, 0, implicit 
$nzcv
 ; CHECK: $x0 = COPY [[CSINCXr]]
 ; CHECK: RET_ReallyLR implicit $x0
@@ -572,7 +572,7 @@ body: |
 ; CHECK-LABEL: name: cmn_s32_neg_imm
 ; CHECK: liveins: $w0, $w1
 ; CHECK: %reg0:gpr32sp = COPY $w0
-; CHECK: $wzr = SUBSWri %reg0, 1, 0, implicit-def $nzcv
+; CHECK: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri %reg0, 1, 0, implicit-def 
$nzcv
 ; CHECK: %cmp:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
 ; CHECK: $w0 = COPY %cmp
 ; CHECK: RET_ReallyLR implicit $w0
@@ -600,7 +600,7 @@ body: |
 ; CHECK: liveins: $w0, $x0, $x1
 ; CHECK: %reg0:gpr64sp = COPY $x0
 ; CHECK: %reg1:gpr32 = COPY $w0
-; CHECK: $xzr = ADDSXrx %reg0, %reg1, 50, implicit-def $nzcv
+; CHECK: [[ADDSXrx:%[0-9]+]]:gpr64 = ADDSXrx %reg0, %reg1, 50, 
implicit-def $nzcv
 ; CHECK: %cmp:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
 ; CHECK: $w0 = COPY %cmp
 ; CHECK: RET_ReallyLR implicit $w0



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bi

[llvm-branch-commits] [llvm] cd9a52b - [AArch64][GlobalISel] Fold binops on the true side of G_SELECT

2020-12-08 Thread Jessica Paquette via llvm-branch-commits

Author: Jessica Paquette
Date: 2020-12-08T10:42:59-08:00
New Revision: cd9a52b99e685e8a77dd85d25c7d1ec8b86b9f55

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

LOG: [AArch64][GlobalISel] Fold binops on the true side of G_SELECT

This implements the following folds:

```
G_SELECT cc, (G_SUB 0, %x), %false -> CSNEG %x, %false, inv_cc
G_SELECT cc, (G_XOR x, -1), %false -> CSINV %x, %false, inv_cc
```

This is similar to the folds introduced in
5bc0bd05e6a8d788e08cdf3d154f3a33202aee53.

In 5bc0bd05e6a8d788e08cdf3d154f3a33202aee53 I mentioned that we may prefer to do
this in AArch64PostLegalizerLowering.

I think that it's probably better to do this in the selector. The way we select
G_SELECT depends on what register banks end up being assigned to it. If we did
this in AArch64PostLegalizerLowering, then we'd end up checking *every* G_SELECT
to see if it's worth swapping operands. Doing it in the selector allows us to
restrict the optimization to only relevant G_SELECTs.

Also fix up some comments in `TryFoldBinOpIntoSelect` which are kind of
confusing IMO.

Example IR: https://godbolt.org/z/3qPGca

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

Added: 


Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 493167e284cf..c447f75681e7 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -1033,31 +1033,36 @@ AArch64InstructionSelector::emitSelect(Register Dst, 
Register True,
   // By default, we'll try and emit a CSEL.
   unsigned Opc = Is32Bit ? AArch64::CSELWr : AArch64::CSELXr;
   bool Optimized = false;
-  auto TryFoldBinOpIntoSelect = [&Opc, &False, Is32Bit, &MRI]() {
+  auto TryFoldBinOpIntoSelect = [&Opc, Is32Bit, &CC, &MRI](Register &Reg,
+   bool Invert) {
 // Attempt to fold:
 //
-// sub = G_SUB 0, x
-// select = G_SELECT cc, true, sub
+// %sub = G_SUB 0, %x
+// %select = G_SELECT cc, %reg, %sub
 //
 // Into:
-// select = CSNEG true, x, cc
+// %select = CSNEG %reg, %x, cc
 Register MatchReg;
-if (mi_match(False, MRI, m_Neg(m_Reg(MatchReg {
+if (mi_match(Reg, MRI, m_Neg(m_Reg(MatchReg {
   Opc = Is32Bit ? AArch64::CSNEGWr : AArch64::CSNEGXr;
-  False = MatchReg;
+  Reg = MatchReg;
+  if (Invert)
+CC = AArch64CC::getInvertedCondCode(CC);
   return true;
 }
 
 // Attempt to fold:
 //
-// xor = G_XOR x, -1
-// select = G_SELECT cc, true, xor
+// %xor = G_XOR %x, -1
+// %select = G_SELECT cc, %reg, %xor
 //
 // Into:
-// select = CSINV true, x, cc
-if (mi_match(False, MRI, m_Not(m_Reg(MatchReg {
+// %select = CSINV %reg, %x, cc
+if (mi_match(Reg, MRI, m_Not(m_Reg(MatchReg {
   Opc = Is32Bit ? AArch64::CSINVWr : AArch64::CSINVXr;
-  False = MatchReg;
+  Reg = MatchReg;
+  if (Invert)
+CC = AArch64CC::getInvertedCondCode(CC);
   return true;
 }
 
@@ -1139,7 +1144,8 @@ AArch64InstructionSelector::emitSelect(Register Dst, 
Register True,
 return false;
   };
 
-  Optimized |= TryFoldBinOpIntoSelect();
+  Optimized |= TryFoldBinOpIntoSelect(False, /*Invert = */ false);
+  Optimized |= TryFoldBinOpIntoSelect(True, /*Invert = */ true);
   Optimized |= TryOptSelectCst();
   auto SelectInst = MIB.buildInstr(Opc, {Dst}, {True, False}).addImm(CC);
   constrainSelectedInstRegOperands(*SelectInst, TII, TRI, RBI);

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir 
b/llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir
index 2d7928f906ed..d2eee15c5cb6 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir
@@ -376,6 +376,36 @@ body: |
 $w0 = COPY %select(s32)
 RET_ReallyLR implicit $w0
 
+...
+---
+name:csneg_inverted_cc
+legalized:   true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+liveins: $w0, $w1, $w2
+; G_SELECT cc, (G_SUB 0, %x), %false -> CSNEG %x, %false, inv_cc
+
+; CHECK-LABEL: name: csneg_inverted_cc
+; CHECK: liveins: $w0, $w1, $w2
+; CHECK: %reg0:gpr32 = COPY $w0
+; CHECK: %reg1:gpr32 = COPY $w1
+; CHECK: %f:gpr32 = COPY $w2
+; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
+; CHECK: %select:gpr32 = CSNEGWr %reg1, %f, 0, implicit $nzcv
+; CHECK: $w0 = COPY %select
+; CHECK: RET_Real

[llvm-branch-commits] [libcxx] b526d87 - [libc++] Add std::hash specialization if char8_t is enabled

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

Author: Yuriy Chernyshov
Date: 2020-12-08T13:46:18-05:00
New Revision: b526d8761895643cb42e62997240344420d65e0f

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

LOG: [libc++] Add std::hash specialization if char8_t is enabled

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

Added: 


Modified: 
libcxx/include/functional
libcxx/include/utility

Removed: 




diff  --git a/libcxx/include/functional b/libcxx/include/functional
index 22c73c5790bd..ffcff35f6e4d 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -470,6 +470,7 @@ template <> struct hash;
 template <> struct hash;
 template <> struct hash;
 template <> struct hash;
+template <> struct hash; // since C++20
 template <> struct hash;
 template <> struct hash;
 template <> struct hash;

diff  --git a/libcxx/include/utility b/libcxx/include/utility
index 2af552b4b347..6f27af70646b 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -1364,6 +1364,16 @@ struct _LIBCPP_TEMPLATE_VIS hash
 size_t operator()(unsigned char __v) const _NOEXCEPT {return 
static_cast(__v);}
 };
 
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash
+: public unary_function
+{
+_LIBCPP_INLINE_VISIBILITY
+size_t operator()(char8_t __v) const _NOEXCEPT {return 
static_cast(__v);}
+};
+#endif // !_LIBCPP_NO_HAS_CHAR8_T
+
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
 
 template <>



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


[llvm-branch-commits] [compiler-rt] 3bd2ad5 - [DFSan] Add several math functions to ABI list.

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

Author: Matt Morehouse
Date: 2020-12-08T10:51:05-08:00
New Revision: 3bd2ad5a0828e956400393e3ea153c417f256aab

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

LOG: [DFSan] Add several math functions to ABI list.

These are all straightforward functional entries.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/done_abilist.txt

Removed: 




diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index 21464819e0fe..40dd0f54929b 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -48,20 +48,49 @@ fun:tolower=functional
 fun:toupper=functional
 
 # Functions that return a value that is data-dependent on the input.
+fun:__isinf=functional
+fun:__isinff=functional
+fun:__signbit=functional
+fun:__signbitf=functional
+fun:__signbitl=functional
 fun:btowc=functional
 fun:exp=functional
 fun:exp2=functional
+fun:expf=functional
+fun:expl=functional
 fun:fabs=functional
 fun:finite=functional
+fun:finitef=functional
+fun:finitel=functional
 fun:floor=functional
 fun:fmod=functional
 fun:isinf=functional
+fun:isinff=functional
+fun:isinfl=functional
 fun:isnan=functional
+fun:isnanf=functional
+fun:isnanl=functional
 fun:log=functional
+fun:log1p=functional
+fun:log1pf=functional
+fun:log1pl=functional
+fun:log2=functional
+fun:log2f=functional
+fun:log2l=functional
 fun:modf=functional
+fun:nextafter=functional
+fun:nextafterf=functional
+fun:nextafterl=functional
+fun:nexttoward=functional
+fun:nexttowardf=functional
+fun:nexttowardl=functional
 fun:pow=functional
+fun:powf=functional
+fun:powl=functional
 fun:round=functional
 fun:sqrt=functional
+fun:sqrtf=functional
+fun:sqrtl=functional
 fun:wctob=functional
 
 # Functions that produce an output that does not depend on the input (shadow is



___
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] 5b5d3fa - [AArch64][GlobalISel] Fold G_SELECT cc, %t, (G_ADD %x, 1) -> CSINC %t, %x, cc

2020-12-08 Thread Jessica Paquette via llvm-branch-commits

Author: Jessica Paquette
Date: 2020-12-08T10:53:37-08:00
New Revision: 5b5d3fa9d9cf9e0b8904de0dc9ea5248f6a37ed1

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

LOG: [AArch64][GlobalISel] Fold G_SELECT cc, %t, (G_ADD %x, 1) -> CSINC %t, %x, 
cc

This implements

```
G_SELECT cc, %true, (G_ADD %x, 1) -> CSINC %true, %x, cc
G_SELECT cc, (G_ADD %x, 1), %false -> CSINC %x, %false, inv_cc
```

Godbolt example: https://godbolt.org/z/eoPqKq

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

Added: 


Modified: 
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir

Removed: 




diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index c447f75681e7..0c1e23820c90 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -1066,6 +1066,21 @@ AArch64InstructionSelector::emitSelect(Register Dst, 
Register True,
   return true;
 }
 
+// Attempt to fold:
+//
+// %add = G_ADD %x, 1
+// %select = G_SELECT cc, %reg, %add
+//
+// Into:
+// %select = CSINC %reg, %x, cc
+if (mi_match(Reg, MRI, m_GAdd(m_Reg(MatchReg), m_SpecificICst(1 {
+  Opc = Is32Bit ? AArch64::CSINCWr : AArch64::CSINCXr;
+  Reg = MatchReg;
+  if (Invert)
+CC = AArch64CC::getInvertedCondCode(CC);
+  return true;
+}
+
 return false;
   };
 

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir 
b/llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir
index d2eee15c5cb6..336e59b03a0f 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/select-select.mir
@@ -592,3 +592,61 @@ body: |
 %select:gpr(s64) = G_SELECT %cond(s1), %t, %xor
 $x0 = COPY %select(s64)
 RET_ReallyLR implicit $x0
+
+...
+---
+name:csinc_s32
+legalized:   true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+liveins: $w0, $w1, $w2
+; G_SELECT cc, %true, (G_ADD %x, 1) -> CSINC %true, %x, cc
+; CHECK-LABEL: name: csinc_s32
+; CHECK: liveins: $w0, $w1, $w2
+; CHECK: %reg0:gpr32 = COPY $w0
+; CHECK: %reg1:gpr32 = COPY $w1
+; CHECK: %t:gpr32 = COPY $w2
+; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
+; CHECK: %select:gpr32 = CSINCWr %t, %reg1, 1, implicit $nzcv
+; CHECK: $w0 = COPY %select
+; CHECK: RET_ReallyLR implicit $w0
+%reg0:gpr(s32) = COPY $w0
+%reg1:gpr(s32) = COPY $w1
+%cond:gpr(s1) = G_TRUNC %reg0(s32)
+%t:gpr(s32) = COPY $w2
+%one:gpr(s32) = G_CONSTANT i32 1
+%add:gpr(s32) = G_ADD %reg1(s32), %one
+%select:gpr(s32) = G_SELECT %cond(s1), %t, %add
+$w0 = COPY %select(s32)
+RET_ReallyLR implicit $w0
+
+...
+---
+name:csinc_s32_inverted_cc
+legalized:   true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+liveins: $w0, $w1, $w2
+; G_SELECT cc, (G_ADD %x, 1), %false -> CSINC %x, %false, inv_cc
+; CHECK-LABEL: name: csinc_s32_inverted_cc
+; CHECK: liveins: $w0, $w1, $w2
+; CHECK: %reg0:gpr32 = COPY $w0
+; CHECK: %reg1:gpr32 = COPY $w1
+; CHECK: %f:gpr32 = COPY $w2
+; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
+; CHECK: %select:gpr32 = CSINCWr %reg1, %f, 0, implicit $nzcv
+; CHECK: $w0 = COPY %select
+; CHECK: RET_ReallyLR implicit $w0
+%reg0:gpr(s32) = COPY $w0
+%reg1:gpr(s32) = COPY $w1
+%cond:gpr(s1) = G_TRUNC %reg0(s32)
+%f:gpr(s32) = COPY $w2
+%one:gpr(s32) = G_CONSTANT i32 1
+%add:gpr(s32) = G_ADD %reg1(s32), %one
+%select:gpr(s32) = G_SELECT %cond(s1), %add, %f
+$w0 = COPY %select(s32)
+RET_ReallyLR implicit $w0



___
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] 3c5bed7 - [clangd] ExpandAutoType: Do not offer code action on lambdas.

2020-12-08 Thread Adam Czachorowski via llvm-branch-commits

Author: Adam Czachorowski
Date: 2020-12-08T20:03:16+01:00
New Revision: 3c5bed734f9e02bd3bc4fbd1e0acc53506823ebf

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

LOG: [clangd] ExpandAutoType: Do not offer code action on lambdas.

We can't expand lambda types anyway. Now we simply not offer the code
action instead of showing it and then returning an error in apply().

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
clang-tools-extra/clangd/test/check-fail.test
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
index 61f68a688252..6d38eb1de82a 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -63,6 +63,25 @@ bool isStructuredBindingType(const SelectionTree::Node *N) {
   return N && N->ASTNode.get();
 }
 
+// Returns true iff Node is a lambda, and thus should not be expanded. Loc is
+// the location of the auto type.
+bool isDeducedAsLambda(const SelectionTree::Node *Node, SourceLocation Loc) {
+  // getDeducedType() does a traversal, which we want to avoid in prepare().
+  // But at least check this isn't auto x = []{...};, which can't ever be
+  // expanded.
+  // (It would be nice if we had an efficient getDeducedType(), instead).
+  for (const auto *It = Node; It; It = It->Parent) {
+if (const auto *DD = It->ASTNode.get()) {
+  if (DD->getTypeSourceInfo() &&
+  DD->getTypeSourceInfo()->getTypeLoc().getBeginLoc() == Loc) {
+if (auto *RD = DD->getType()->getAsRecordDecl())
+  return RD->isLambda();
+  }
+}
+  }
+  return false;
+}
+
 bool ExpandAutoType::prepare(const Selection& Inputs) {
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
@@ -70,11 +89,13 @@ bool ExpandAutoType::prepare(const Selection& Inputs) {
   if (const AutoTypeLoc Result = TypeNode->getAs()) {
 // Code in apply() does handle 'decltype(auto)' yet.
 if (!Result.getTypePtr()->isDecltypeAuto() &&
-!isStructuredBindingType(Node))
+!isStructuredBindingType(Node) &&
+!isDeducedAsLambda(Node, Result.getBeginLoc()))
   CachedLocation = Result;
   }
 }
   }
+
   return (bool) CachedLocation;
 }
 

diff  --git a/clang-tools-extra/clangd/test/check-fail.test 
b/clang-tools-extra/clangd/test/check-fail.test
index 0ee777f02cc5..dd50b59b2c79 100644
--- a/clang-tools-extra/clangd/test/check-fail.test
+++ b/clang-tools-extra/clangd/test/check-fail.test
@@ -11,4 +11,5 @@
 // CHECK: All checks completed, 2 errors
 
 #include "missing.h"
-auto x = []{};
+void fun();
+auto x = fun;

diff  --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp 
b/clang-tools-extra/clangd/unittests/TweakTests.cpp
index 85edd92d27da..0dcf8feb786f 100644
--- a/clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -559,8 +559,7 @@ TEST_F(ExpandAutoTypeTest, Test) {
   EXPECT_THAT(apply("au^to x = &ns::Func;"),
   StartsWith("fail: Could not expand type of function pointer"));
   // lambda types are not replaced
-  EXPECT_THAT(apply("au^to x = []{};"),
-  StartsWith("fail: Could not expand type of lambda expression"));
+  EXPECT_UNAVAILABLE("au^to x = []{};");
   // inline namespaces
   EXPECT_EQ(apply("au^to x = inl_ns::Visible();"),
 "Visible x = inl_ns::Visible();");



___
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] c823d74 - [flang][openacc] Add missing loop construct restriction and validity tests

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

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

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

LOG: [flang][openacc] Add missing loop construct restriction and validity tests

Add restriction on loop construct associated with DO CONCURRENT. Add couple of 
tests to ensure
clause validity checks.

Reviewed By: sameeranjoshi

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

Added: 


Modified: 
flang/lib/Semantics/canonicalize-acc.cpp
flang/test/Semantics/acc-canonicalization-validity.f90
flang/test/Semantics/acc-clause-validity.f90

Removed: 




diff  --git a/flang/lib/Semantics/canonicalize-acc.cpp 
b/flang/lib/Semantics/canonicalize-acc.cpp
index 4916f2269ceb..0241508543ba 100644
--- a/flang/lib/Semantics/canonicalize-acc.cpp
+++ b/flang/lib/Semantics/canonicalize-acc.cpp
@@ -64,6 +64,8 @@ class CanonicalizationOfAcc {
 std::size_t tileArgNb = listTileExpr.size();
 
 const auto &outer{std::get>(x.t)};
+if (outer->IsDoConcurrent())
+  return; // Tile is not allowed on DO CONURRENT
 for (const parser::DoConstruct *loop{&*outer}; loop && tileArgNb > 0;
  --tileArgNb) {
   const auto &block{std::get(loop->t)};
@@ -82,6 +84,27 @@ class CanonicalizationOfAcc {
 }
   }
 
+  // Check constraint on line 1835 in Section 2.9
+  // A tile and collapse clause may not appear on loop that is associated with
+  // do concurrent.
+  template 
+  void CheckDoConcurrentClauseRestriction(const C &x) {
+const auto &doCons{std::get>(x.t)};
+if (!doCons->IsDoConcurrent())
+  return;
+const auto &beginLoopDirective = std::get(x.t);
+const auto &accClauseList =
+std::get(beginLoopDirective.t);
+for (const auto &clause : accClauseList.v) {
+  if (std::holds_alternative(clause.u) ||
+  std::holds_alternative(clause.u)) {
+messages_.Say(beginLoopDirective.source,
+"TILE and COLLAPSE clause may not appear on loop construct "
+"associated with DO CONCURRENT"_err_en_US);
+  }
+}
+  }
+
   void RewriteOpenACCLoopConstruct(parser::OpenACCLoopConstruct &x,
   parser::Block &block, parser::Block::iterator it) {
 // Check the sequence of DoConstruct in the same iteration
@@ -112,8 +135,12 @@ class CanonicalizationOfAcc {
   "DO loop after the %s directive must have loop 
control"_err_en_US,
   parser::ToUpperCaseLetters(dir.source.ToString()));
 }
+
+CheckDoConcurrentClauseRestriction(x);
 CheckTileClauseRestriction(x);
+
 return; // found do-loop
   }
 }
@@ -163,8 +190,12 @@ class CanonicalizationOfAcc {
   "DO loop after the %s directive must have loop 
control"_err_en_US,
   parser::ToUpperCaseLetters(dir.source.ToString()));
 }
+
+CheckDoConcurrentClauseRestriction(x);
 CheckTileClauseRestriction(x);
+
 return; // found do-loop
   }
 }

diff  --git a/flang/test/Semantics/acc-canonicalization-validity.f90 
b/flang/test/Semantics/acc-canonicalization-validity.f90
index 350f6315867c..bb7afaf463f1 100644
--- a/flang/test/Semantics/acc-canonicalization-validity.f90
+++ b/flang/test/Semantics/acc-canonicalization-validity.f90
@@ -13,6 +13,7 @@ program openacc_clause_validity
   integer :: i, j
   integer :: N = 256
   real(8) :: a(256)
+  real(8) :: aa(256, 256)
 
   !ERROR: A DO loop must follow the LOOP directive
   !$acc loop
@@ -106,4 +107,20 @@ program openacc_clause_validity
 a(i) = 3.14
   end do
 
+  !$acc parallel
+  !ERROR: TILE and COLLAPSE clause may not appear on loop construct associated 
with DO CONCURRENT
+  !$acc loop collapse(2)
+  do concurrent (i = 1:N, j = 1:N)
+aa(i, j) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !ERROR: TILE and COLLAPSE clause may not appear on loop construct associated 
with DO CONCURRENT
+  !$acc loop tile(2, 2)
+  do concurrent (i = 1:N, j = 1:N)
+aa(i, j) = 3.14
+  end do
+  !$acc end parallel
+
 end program openacc_clause_validity

diff  --git a/flang/test/Semantics/acc-clause-validity.f90 
b/flang/test/Semantics/acc-clause-validity.f90
index 22b332841df4..993119871add 100644
--- a/flang/test/Semantics/acc-clause-validity.f90
+++ b/flang/test/Semantics/acc-clause-validity.f90
@@ -219,6 +219,14 @@ program openacc_clause_validity
   end do
   !$acc end parallel
 
+  !$acc parallel
+  !ERROR: SEQ and AUTO clauses are mutually exclusive and may not appear on 
the same LOOP directive
+  !$acc loop auto seq
+  do i = 1, N
+a(i) = 3.14
+  end do
+  !$acc end parallel
+
   !$acc parallel
   !$acc loop tile(2)
   do i = 1, N
@@ -287,6 +295,14 @@ program openacc_clause_validity
   end d

[llvm-branch-commits] [clang] fc750f6 - [PPC] Fixing a typo in altivec.h. Commenting out an unnecessary macro

2020-12-08 Thread Masoud Ataei via llvm-branch-commits

Author: Masoud Ataei
Date: 2020-12-08T19:21:02Z
New Revision: fc750f609dfb2fd51b6810cc55058568dfe4b3a9

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

LOG: [PPC] Fixing a typo in altivec.h. Commenting out an unnecessary macro

Added: 


Modified: 
clang/lib/Headers/altivec.h

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 24d600e95201..2b82113de311 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -3502,7 +3502,7 @@ static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_div(vector signed __int128 __a, vector signed __int128 __b) {
   return __a / __b;
 }
-#endif __POWER10_VECTOR__
+#endif /* __POWER10_VECTOR__ */
 
 /* vec_xvtdiv */
 



___
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] 88e5893 - [RISCV] When parsing vsetvli in the assembler, use StringRef::getAsInteger instead of APInt's string constructor

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

Author: Craig Topper
Date: 2020-12-08T11:25:39-08:00
New Revision: 88e58939dcea54d59a77277d420a014dc90b06e7

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

LOG: [RISCV] When parsing vsetvli in the assembler, use StringRef::getAsInteger 
instead of APInt's string constructor

APInt's string constructor asserts on error. Since this is the parser and we 
don't yet know if the string is a valid integer we shouldn't use that.

Instead use StringRef::getAsInteger which returns a bool to indicate success or 
failure.

Since we no longer need APInt, use 'unsigned' instead.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/MC/RISCV/rvv/invalid.s

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index d5692af9e681..9245e09a6163 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -867,12 +867,11 @@ struct RISCVOperand : public MCParsedAsmOperand {
   }
 
   static std::unique_ptr
-  createVType(APInt Sew, APInt Lmul, bool Fractional, bool TailAgnostic,
+  createVType(unsigned Sew, unsigned Lmul, bool Fractional, bool TailAgnostic,
   bool MaskedoffAgnostic, SMLoc S, bool IsRV64) {
 auto Op = std::make_unique(KindTy::VType);
-Sew.ashrInPlace(3);
-unsigned SewLog2 = Sew.logBase2();
-unsigned LmulLog2 = Lmul.logBase2();
+unsigned SewLog2 = Log2_32(Sew / 8);
+unsigned LmulLog2 = Log2_32(Lmul);
 Op->VType.Sew = static_cast(SewLog2);
 if (Fractional) {
   unsigned Flmul = 8 - LmulLog2;
@@ -1598,7 +1597,9 @@ OperandMatchResultTy 
RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
   StringRef Name = getLexer().getTok().getIdentifier();
   if (!Name.consume_front("e"))
 return MatchOperand_NoMatch;
-  APInt Sew(16, Name, 10);
+  unsigned Sew;
+  if (Name.getAsInteger(10, Sew))
+return MatchOperand_NoMatch;
   if (Sew != 8 && Sew != 16 && Sew != 32 && Sew != 64 && Sew != 128 &&
   Sew != 256 && Sew != 512 && Sew != 1024)
 return MatchOperand_NoMatch;
@@ -1616,7 +1617,9 @@ OperandMatchResultTy 
RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
   if (Name.consume_front("f")) {
 Fractional = true;
   }
-  APInt Lmul(16, Name, 10);
+  unsigned Lmul;
+  if (Name.getAsInteger(10, Lmul))
+return MatchOperand_NoMatch;
   if (Lmul != 1 && Lmul != 2 && Lmul != 4 && Lmul != 8)
 return MatchOperand_NoMatch;
   getLexer().Lex();

diff  --git a/llvm/test/MC/RISCV/rvv/invalid.s 
b/llvm/test/MC/RISCV/rvv/invalid.s
index 040d7455dfb4..cadafcb35468 100644
--- a/llvm/test/MC/RISCV/rvv/invalid.s
+++ b/llvm/test/MC/RISCV/rvv/invalid.s
@@ -31,6 +31,12 @@ vsetvli a2, a0, e8,m1,ma
 vsetvli a2, a0, e8,m1,mu
 # CHECK-ERROR: operand must be 
e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
 
+vsetvli a2, a0, e8x,m1,tu,mu
+# CHECK-ERROR: operand must be 
e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
+vsetvli a2, a0, e8,m1z,tu,mu
+# CHECK-ERROR: operand must be 
e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
 vadd.vv v1, v3, v2, v4.t
 # CHECK-ERROR: operand must be v0.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] fb5b611 - [RISCV] Detect more errors when parsing vsetvli in the assembler

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

Author: Craig Topper
Date: 2020-12-08T11:25:39-08:00
New Revision: fb5b611af917f02337b69727fb8082e1ea3b22d5

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

LOG: [RISCV] Detect more errors when parsing vsetvli in the assembler

-Reject an "mf1" lmul
-Make sure tail agnostic is exactly "tu" or "ta" not just that it starts with 
"tu" or "ta"
-Make sure mask agnostic is exactly "mu" or "ma" not just that it starts with 
"mu" or "ma"

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

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/MC/RISCV/rvv/invalid.s

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 9245e09a6163..03c62487e2ee 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1622,6 +1622,8 @@ OperandMatchResultTy 
RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
 return MatchOperand_NoMatch;
   if (Lmul != 1 && Lmul != 2 && Lmul != 4 && Lmul != 8)
 return MatchOperand_NoMatch;
+  if (Fractional && Lmul == 1)
+return MatchOperand_NoMatch;
   getLexer().Lex();
 
   if (!getLexer().is(AsmToken::Comma))
@@ -1631,9 +1633,9 @@ OperandMatchResultTy 
RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
   Name = getLexer().getTok().getIdentifier();
   // ta or tu
   bool TailAgnostic;
-  if (Name.consume_front("ta"))
+  if (Name == "ta")
 TailAgnostic = true;
-  else if (Name.consume_front("tu"))
+  else if (Name == "tu")
 TailAgnostic = false;
   else
 return MatchOperand_NoMatch;
@@ -1646,9 +1648,9 @@ OperandMatchResultTy 
RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
   Name = getLexer().getTok().getIdentifier();
   // ma or mu
   bool MaskedoffAgnostic;
-  if (Name.consume_front("ma"))
+  if (Name == "ma")
 MaskedoffAgnostic = true;
-  else if (Name.consume_front("mu"))
+  else if (Name == "mu")
 MaskedoffAgnostic = false;
   else
 return MatchOperand_NoMatch;

diff  --git a/llvm/test/MC/RISCV/rvv/invalid.s 
b/llvm/test/MC/RISCV/rvv/invalid.s
index cadafcb35468..671373050441 100644
--- a/llvm/test/MC/RISCV/rvv/invalid.s
+++ b/llvm/test/MC/RISCV/rvv/invalid.s
@@ -37,6 +37,15 @@ vsetvli a2, a0, e8x,m1,tu,mu
 vsetvli a2, a0, e8,m1z,tu,mu
 # CHECK-ERROR: operand must be 
e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
 
+vsetvli a2, a0, e8,mf1,tu,mu
+# CHECK-ERROR: operand must be 
e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
+vsetvli a2, a0, e8,m1,tu,mut
+# CHECK-ERROR: operand must be 
e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
+vsetvli a2, a0, e8,m1,tut,mu
+# CHECK-ERROR: operand must be 
e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
 vadd.vv v1, v3, v2, v4.t
 # CHECK-ERROR: operand must be v0.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] bf30d7d - [gn build] Move ScalarizeMaskedMemIntrin.cpp

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

Author: Arthur Eubanks
Date: 2020-12-08T11:33:45-08:00
New Revision: bf30d7de7632a9b71761e6e2186aee7353a2960e

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

LOG: [gn build] Move ScalarizeMaskedMemIntrin.cpp

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
index 1ae43869fbe5..a1e117bb716e 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
@@ -169,7 +169,6 @@ static_library("CodeGen") {
 "ResetMachineFunctionPass.cpp",
 "SafeStack.cpp",
 "SafeStackLayout.cpp",
-"ScalarizeMaskedMemIntrin.cpp",
 "ScheduleDAG.cpp",
 "ScheduleDAGInstrs.cpp",
 "ScheduleDAGPrinter.cpp",

diff  --git a/llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn
index 278406ba37b4..3842ab2fa8f3 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn
@@ -77,6 +77,7 @@ static_library("Scalar") {
 "SROA.cpp",
 "Scalar.cpp",
 "Scalarizer.cpp",
+"ScalarizeMaskedMemIntrin.cpp",
 "SeparateConstOffsetFromGEP.cpp",
 "SimpleLoopUnswitch.cpp",
 "SimplifyCFGPass.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] [flang] d553243 - [flang][openacc] Update reference to OpenACC 3.1 specification

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

Author: Valentin Clement
Date: 2020-12-08T14:36:38-05:00
New Revision: d553243fe4b5e1992c07aff7b54b16160a4d5e97

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

LOG: [flang][openacc] Update reference to OpenACC 3.1 specification

Update all reference from the specification to the new OpenACC 3.1
document.

Reviewed By: SouraVX

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

Added: 


Modified: 
flang/include/flang/Parser/parse-tree.h
flang/lib/Parser/openacc-parsers.cpp
flang/lib/Semantics/check-acc-structure.cpp
flang/lib/Semantics/check-acc-structure.h
flang/tools/f18/f18.cpp
llvm/include/llvm/Frontend/OpenACC/ACC.td
mlir/include/mlir/Dialect/OpenACC/OpenACC.h
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td

Removed: 




diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index c990ddd5c915..6bed37c2b871 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3781,7 +3781,7 @@ struct OpenMPConstruct {
   u;
 };
 
-// Parse tree nodes for OpenACC 3.0 directives and clauses
+// Parse tree nodes for OpenACC 3.1 directives and clauses
 
 struct AccObject {
   UNION_CLASS_BOILERPLATE(AccObject);

diff  --git a/flang/lib/Parser/openacc-parsers.cpp 
b/flang/lib/Parser/openacc-parsers.cpp
index bba886f2fbfd..b4d2b285cd6c 100644
--- a/flang/lib/Parser/openacc-parsers.cpp
+++ b/flang/lib/Parser/openacc-parsers.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-// Top-level grammar specification for OpenACC 3.0.
+// Top-level grammar specification for OpenACC 3.1.
 
 #include "basic-parsers.h"
 #include "expr-parsers.h"

diff  --git a/flang/lib/Semantics/check-acc-structure.cpp 
b/flang/lib/Semantics/check-acc-structure.cpp
index d6be718aa2c1..c88e7f8eaaa3 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -23,14 +23,11 @@
 namespace Fortran::semantics {
 
 static constexpr inline AccClauseSet
-parallelAndKernelsOnlyAllowedAfterDeviceTypeClauses{
+computeConstructOnlyAllowedAfterDeviceTypeClauses{
 llvm::acc::Clause::ACCC_async, llvm::acc::Clause::ACCC_wait,
 llvm::acc::Clause::ACCC_num_gangs, llvm::acc::Clause::ACCC_num_workers,
 llvm::acc::Clause::ACCC_vector_length};
 
-static constexpr inline AccClauseSet serialOnlyAllowedAfterDeviceTypeClauses{
-llvm::acc::Clause::ACCC_async, llvm::acc::Clause::ACCC_wait};
-
 static constexpr inline AccClauseSet loopOnlyAllowedAfterDeviceTypeClauses{
 llvm::acc::Clause::ACCC_auto, llvm::acc::Clause::ACCC_collapse,
 llvm::acc::Clause::ACCC_independent, llvm::acc::Clause::ACCC_gang,
@@ -80,27 +77,19 @@ void AccStructureChecker::Leave(const 
parser::OpenACCBlockConstruct &x) {
   switch (blockDir.v) {
   case llvm::acc::Directive::ACCD_kernels:
   case llvm::acc::Directive::ACCD_parallel:
-// Restriction - 880-881 (KERNELS)
-// Restriction - 843-844 (PARALLEL)
-CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type,
-parallelAndKernelsOnlyAllowedAfterDeviceTypeClauses);
-// Restriction - 877 (KERNELS)
-// Restriction - 840 (PARALLEL)
-CheckNoBranching(block, GetContext().directive, blockDir.source);
-break;
   case llvm::acc::Directive::ACCD_serial:
-// Restriction - 919
+// Restriction - line 1004-1005
 CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type,
-serialOnlyAllowedAfterDeviceTypeClauses);
-// Restriction - 916
-CheckNoBranching(block, llvm::acc::Directive::ACCD_serial, 
blockDir.source);
+computeConstructOnlyAllowedAfterDeviceTypeClauses);
+// Restriction - line 1001
+CheckNoBranching(block, GetContext().directive, blockDir.source);
 break;
   case llvm::acc::Directive::ACCD_data:
-// Restriction - 1117-1118
+// Restriction - line 1249-1250
 CheckRequireAtLeastOneOf();
 break;
   case llvm::acc::Directive::ACCD_host_data:
-// Restriction - 1578
+// Restriction - line 1746
 CheckRequireAtLeastOneOf();
 break;
   default:
@@ -117,7 +106,7 @@ void AccStructureChecker::Enter(
 
 void AccStructureChecker::Leave(
 const parser::OpenACCStandaloneDeclarativeConstruct &) {
-  // Restriction - 2075
+  // Restriction - line 2409
   CheckAtLeastOneClause();
   dirContext_.pop_back();
 }
@@ -144,18 +133,10 @@ void AccStructureChecker::Leave(const 
parser::OpenACCCombinedConstruct &x) {
   switch (combinedDir.v) {
   case llvm::acc::Directive::ACCD_kernels_loop:
   case llvm::acc::Directive::ACCD_parallel_loop:
-// Restriction - 1962 -> (880-881) (KERNELS LOOP)
-// Restriction - 1962 -> (843-844) (PARALLEL LOOP)
-CheckOnlyAll

[llvm-branch-commits] [llvm] a2c157e - [cmake] Make ExecutionEngine/Orc/Shared depend on intrinsics_gen to fix modules build

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

Author: Raphael Isemann
Date: 2020-12-08T20:41:35+01:00
New Revision: a2c157eb3ebc5ed7e8037f7942991bd344a882cc

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

LOG: [cmake] Make ExecutionEngine/Orc/Shared depend on intrinsics_gen to fix 
modules build

The LLVM_ENABLE_MODULES builds currently randomly fail due depending on the
headers generated by the intrinsics_gen target, but the current dependency only 
model
the non-modules dependencies:

```
While building module 'LLVM_ExecutionEngine' imported from 
llvm-project/llvm/lib/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.cpp:13:
While building module 'LLVM_intrinsic_gen' imported from 
llvm-project/llvm/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h:17:
In file included from :1:
In file included from llvm-project/llvm/include/llvm/IR/Argument.h:18:
llvm/include/llvm/IR/Attributes.h:75:14: fatal error: 'llvm/IR/Attributes.inc' 
file not found
#include "llvm/IR/Attributes.inc"
 ^~~~
```

Depending on whether intrinsics_gen runs before compiling Orc/Shared files we 
either fail or include an outdated Attributes.inc
in module builds. The Clang modules require these additional dependencies as 
including/importing one module requires all
includes headers by that module to be parsable.

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

Added: 


Modified: 
llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt

Removed: 




diff  --git a/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt 
b/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt
index 808408c0e5df..62da0c71fb3f 100644
--- a/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/Orc/Shared/CMakeLists.txt
@@ -5,6 +5,9 @@ add_llvm_component_library(LLVMOrcShared
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/ExecutionEngine/Orc
 
+  DEPENDS
+  intrinsics_gen
+
   LINK_COMPONENTS
   Support
   )



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


[llvm-branch-commits] [llvm] dee1e6a - [llvm-lto2] Use NPM with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER

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

Author: Arthur Eubanks
Date: 2020-12-08T11:43:19-08:00
New Revision: dee1e6ac42e6e25e639fb053831f0723b90c18bd

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

LOG: [llvm-lto2] Use NPM with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER

Reviewed By: tejohnson

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

Added: 


Modified: 
llvm/tools/llvm-lto2/llvm-lto2.cpp

Removed: 




diff  --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp 
b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 4d7d7d8efe7d..b84bfff81582 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -17,6 +17,7 @@
 
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
 #include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
@@ -144,7 +145,7 @@ static cl::opt
 static cl::opt
 UseNewPM("use-new-pm",
  cl::desc("Run LTO passes using the new pass manager"),
- cl::init(false), cl::Hidden);
+ cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden);
 
 static cl::opt
 DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden,



___
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] 1f67247 - [DebugInfo] Add handling of stringLengthExp operand of DIStringType.

2020-12-08 Thread Chih-Ping Chen via llvm-branch-commits

Author: Chih-Ping Chen
Date: 2020-12-08T14:49:59-05:00
New Revision: 1f67247eea13f62f26de3b0eca3755ed8b3a2b8e

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

LOG: [DebugInfo] Add handling of stringLengthExp operand of DIStringType.

This patch makes DWARF writer emit DW_AT_string_length using
the stringLengthExp operand of DIStringType.

This is part of the effort to add debug info support for
Fortran deferred length strings.

Also updated the tests to exercise the change.

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

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/test/DebugInfo/X86/distringtype.ll
llvm/test/DebugInfo/fortran-string-type.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index a74ee0f736a4..b552a07c99c0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -696,6 +696,15 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const 
DIStringType *STy) {
   if (DIVariable *Var = STy->getStringLength()) {
 if (auto *VarDIE = getDIE(Var))
   addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE);
+  } else if (DIExpression *Expr = STy->getStringLengthExp()) {
+DIELoc *Loc = new (DIEValueAllocator) DIELoc;
+DIEDwarfExpression DwarfExpr(*Asm, getCU(), *Loc);
+// This is to describe the memory location of the
+// length of a Fortran deferred length string, so
+// lock it down as such.
+DwarfExpr.setMemoryLocationKind();
+DwarfExpr.addExpression(Expr);
+addBlock(Buffer, dwarf::DW_AT_string_length, DwarfExpr.finalize());
   } else {
 uint64_t Size = STy->getSizeInBits() >> 3;
 addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);

diff  --git a/llvm/test/DebugInfo/X86/distringtype.ll 
b/llvm/test/DebugInfo/X86/distringtype.ll
index 65fac64ae3b1..5d53de29f82d 100644
--- a/llvm/test/DebugInfo/X86/distringtype.ll
+++ b/llvm/test/DebugInfo/X86/distringtype.ll
@@ -1,17 +1,23 @@
 ;; Test for !DIStringType.!DIStringType is used to construct a Fortran
 ;; CHARACTER intrinsic type, with a LEN type parameter where LEN is a
 ;; dynamic parameter as in a deferred-length CHARACTER. LLVM after
-;; processing this !DIStringType metadata, generates DW_AT_string_length 
attribute.
-;; !DIStringType(name: "character(*)", stringLength: !{{[0-9]+}},
-;; stringLengthExpression: !DIExpression(), size: 32)
+;; processing !DIStringType metadata in either of the following forms,
+;; generates DW_AT_string_length attribute
+;; !DIStringType(name: "character(*)", stringLength: !{{[0-9]+}})
+;; !DIStringType(name: "character(*)", stringLengthExpr: !DIExpression(...))
 
 ; RUN: llc -filetype=obj  %s -o - | llvm-dwarfdump - | FileCheck %s
 ; CHECK:   DW_TAG_string_type
+; CHECK:  DW_AT_name  (".str.DEFERRED")
+; CHECK-NEXT: DW_AT_string_length 
(DW_OP_push_object_address, DW_OP_plus_uconst 0x8)
+; CHECK:   DW_TAG_string_type
 ; CHECK:  DW_AT_name  ("character(*)!2")
 ; CHECK-NEXT: DW_AT_string_length
 
-;; sample fortran testcase involving assumed length string type.
+;; sample fortran testcase involving deferred and assumed length string types.
 ;; program assumedLength
+;;   character(len=:), allocatable :: deferred
+;;   allocate(character(10)::deferred)
 ;;   call sub('Hello')
 ;;   call sub('Goodbye')
 ;;   contains
@@ -22,111 +28,144 @@
 ;;   end subroutine sub
 ;; end program assumedLength
 
+; ModuleID = 'distring.f90'
+source_filename = "distring.f90"
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-%struct.struct_ul_MAIN__324 = type <{ i8* }>
-
-@.C327_MAIN_ = internal constant [7 x i8] c"Goodbye"
-@.C326_MAIN_ = internal constant [5 x i8] c"Hello"
-@.C306_MAIN_ = internal constant i32 0
-@.C336_assumedlength_sub = internal constant i32 14
-@.C306_assumedlength_sub = internal constant i32 0
-@.C307_assumedlength_sub = internal constant i64 0
-@.C331_assumedlength_sub = internal constant i32 6
-@.C329_assumedlength_sub = internal constant [8 x i8] c"test.f90"
-@.C328_assumedlength_sub = internal constant i32 8
-
-define void @MAIN_() !dbg !5 {
-L.entry:
-  %.S_331 = alloca %struct.struct_ul_MAIN__324, align 8
-  %0 = bitcast i32* @.C306_MAIN_ to i8*, !dbg !8
-  %1 = bitcast void (...)* @fort_init to void (i8*, ...)*, !dbg !8
-  call void (i8*, ...) %1(i8* %0), !dbg !8
-  br label %L.LB1_335
-
-L.LB1_335:; preds = %L.entry
-  %2 = bitcast [5 x i8]* @.C326_MAIN_ to i64*, !dbg !9
-  %3 = bitcast %struct.struct_ul_MAIN__324* %.S_331 to i64*, !dbg !9

[llvm-branch-commits] [clang-tools-extra] 39431e4 - [clang-tidy] Introduce misc No Integer To Pointer Cast check

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

Author: Roman Lebedev
Date: 2020-12-08T22:55:13+03:00
New Revision: 39431e479ffddc81120911f031921b2d637e967f

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

LOG: [clang-tidy] Introduce misc No Integer To Pointer Cast check

While casting an (integral) pointer to an integer is obvious - you just get
the integral value of the pointer, casting an integer to an (integral) pointer
is deceivingly different. While you will get a pointer with that integral value,
if you got that integral value via a pointer-to-integer cast originally,
the new pointer will lack the provenance information from the original pointer.

So while (integral) pointer to integer casts are effectively no-ops,
and are transparent to the optimizer, integer to (integral) pointer casts
are *NOT* transparent, and may conceal information from optimizer.

While that may be the intention, it is not always so. For example,
let's take a look at a routine to align the pointer up to the multiple of 16:
The obvious, naive implementation for that is:

```
  char* src(char* maybe_underbiased_ptr) {
uintptr_t maybe_underbiased_intptr = (uintptr_t)maybe_underbiased_ptr;
uintptr_t aligned_biased_intptr = maybe_underbiased_intptr + 15;
uintptr_t aligned_intptr = aligned_biased_intptr & (~15);
return (char*)aligned_intptr; // warning: avoid integer to pointer casts 
[misc-no-inttoptr]
  }
```

The check will rightfully diagnose that cast.

But when provenance concealment is not the goal of the code, but an accident,
this example can be rewritten as follows, without using integer to pointer cast:

```
  char*
  tgt(char* maybe_underbiased_ptr) {
  uintptr_t maybe_underbiased_intptr = (uintptr_t)maybe_underbiased_ptr;
  uintptr_t aligned_biased_intptr = maybe_underbiased_intptr + 15;
  uintptr_t aligned_intptr = aligned_biased_intptr & (~15);
  uintptr_t bias = aligned_intptr - maybe_underbiased_intptr;
  return maybe_underbiased_ptr + bias;
  }
```

See also:
* D71499
* [[ https://www.cs.utah.edu/~regehr/oopsla18.pdf | Juneyoung Lee, Chung-Kil 
Hur, Ralf Jung, Zhengyang Liu, John Regehr, and Nuno P. Lopes. 2018. 
Reconciling High-Level Optimizations and Low-Level Code in LLVM. Proc. ACM 
Program. Lang. 2, OOPSLA, Article 125 (November 2018), 28 pages. ]]

Reviewed By: aaron.ballman

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

Added: 
clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.cpp
clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.h
clang-tools-extra/docs/clang-tidy/checks/performance-no-int-to-ptr.rst
clang-tools-extra/test/clang-tidy/checkers/performance-no-int-to-ptr.c
clang-tools-extra/test/clang-tidy/checkers/performance-no-int-to-ptr.cpp

Modified: 
clang-tools-extra/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
index 0e38e9fc5c0c..315364641692 100644
--- a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
@@ -13,6 +13,7 @@ add_clang_library(clangTidyPerformanceModule
   MoveConstArgCheck.cpp
   MoveConstructorInitCheck.cpp
   NoAutomaticMoveCheck.cpp
+  NoIntToPtrCheck.cpp
   NoexceptMoveConstructorCheck.cpp
   PerformanceTidyModule.cpp
   TriviallyDestructibleCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.cpp
new file mode 100644
index ..bc82a21bbf5a
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/performance/NoIntToPtrCheck.cpp
@@ -0,0 +1,34 @@
+//===--- NoIntToPtrCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NoIntToPtrCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+void NoIntToPtrCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(castExpr(hasCastKind(CK_IntegralToPointer),
+  unless(hasSourceExpression(integerLiteral(
+ .bind("x"),
+ this);
+}
+
+void NoIntToPtrCheck::check(const MatchFinder::MatchResult &R

[llvm-branch-commits] [flang] b53115b - [flang][openacc] Avoid use of init, shutdown and set in compute construct

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

Author: Valentin Clement
Date: 2020-12-08T15:14:44-05:00
New Revision: b53115b6c8aa9a107bb80e704b077b253037514f

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

LOG: [flang][openacc] Avoid use of init, shutdown and set in compute construct

init, shutdown and set directive are not allowed in compute construct.

Reviewed By: SouraVX

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

Added: 


Modified: 
flang/lib/Semantics/check-acc-structure.cpp
flang/lib/Semantics/check-acc-structure.h
flang/test/Semantics/acc-clause-validity.f90

Removed: 




diff  --git a/flang/lib/Semantics/check-acc-structure.cpp 
b/flang/lib/Semantics/check-acc-structure.cpp
index c88e7f8eaaa31..c120f9a591e6c 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -54,6 +54,35 @@ bool 
AccStructureChecker::CheckAllowedModifier(llvm::acc::Clause clause) {
   return false;
 }
 
+bool AccStructureChecker::IsComputeConstruct(
+llvm::acc::Directive directive) const {
+  return directive == llvm::acc::ACCD_parallel ||
+  directive == llvm::acc::ACCD_parallel_loop ||
+  directive == llvm::acc::ACCD_serial ||
+  directive == llvm::acc::ACCD_serial_loop ||
+  directive == llvm::acc::ACCD_kernels ||
+  directive == llvm::acc::ACCD_kernels_loop;
+}
+
+bool AccStructureChecker::IsInsideComputeConstruct() const {
+  if (dirContext_.size() <= 1)
+return false;
+
+  // Check all nested context skipping the first one.
+  for (std::size_t i = dirContext_.size() - 1; i > 0; --i) {
+if (IsComputeConstruct(dirContext_[i - 1].directive))
+  return true;
+  }
+  return false;
+}
+
+void AccStructureChecker::CheckNotInComputeConstruct() {
+  if (IsInsideComputeConstruct())
+context_.Say(GetContext().directiveSource,
+"Directive %s may not be called within a compute region"_err_en_US,
+ContextDirectiveAsFortran());
+}
+
 void AccStructureChecker::Enter(const parser::AccClause &x) {
   SetContextClause(x);
 }
@@ -175,12 +204,16 @@ void AccStructureChecker::Leave(const 
parser::OpenACCStandaloneConstruct &x) {
   switch (standaloneDir.v) {
   case llvm::acc::Directive::ACCD_enter_data:
   case llvm::acc::Directive::ACCD_exit_data:
-  case llvm::acc::Directive::ACCD_set:
 // Restriction - line 1310-1311 (ENTER DATA)
 // Restriction - line 1312-1313 (EXIT DATA)
-// Restriction - line 2610 (SET)
 CheckRequireAtLeastOneOf();
 break;
+  case llvm::acc::Directive::ACCD_set:
+// Restriction - line 2610
+CheckRequireAtLeastOneOf();
+// Restriction - line 2602
+CheckNotInComputeConstruct();
+break;
   case llvm::acc::Directive::ACCD_update:
 // Restriction - line 2636
 CheckRequireAtLeastOneOf();
@@ -188,6 +221,12 @@ void AccStructureChecker::Leave(const 
parser::OpenACCStandaloneConstruct &x) {
 CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type,
 updateOnlyAllowedAfterDeviceTypeClauses);
 break;
+  case llvm::acc::Directive::ACCD_init:
+  case llvm::acc::Directive::ACCD_shutdown:
+// Restriction - line 2525 (INIT)
+// Restriction - line 2561 (SHUTDOWN)
+CheckNotInComputeConstruct();
+break;
   default:
 break;
   }

diff  --git a/flang/lib/Semantics/check-acc-structure.h 
b/flang/lib/Semantics/check-acc-structure.h
index 85f01ba8271d9..29d40b9cbe67f 100644
--- a/flang/lib/Semantics/check-acc-structure.h
+++ b/flang/lib/Semantics/check-acc-structure.h
@@ -114,6 +114,9 @@ class AccStructureChecker
 private:
 
   bool CheckAllowedModifier(llvm::acc::Clause clause);
+  bool IsComputeConstruct(llvm::acc::Directive directive) const;
+  bool IsInsideComputeConstruct() const;
+  void CheckNotInComputeConstruct();
   llvm::StringRef getClauseName(llvm::acc::Clause clause) override;
   llvm::StringRef getDirectiveName(llvm::acc::Directive directive) override;
 };

diff  --git a/flang/test/Semantics/acc-clause-validity.f90 
b/flang/test/Semantics/acc-clause-validity.f90
index 993119871adda..1f98d0f2559ff 100644
--- a/flang/test/Semantics/acc-clause-validity.f90
+++ b/flang/test/Semantics/acc-clause-validity.f90
@@ -53,6 +53,195 @@ program openacc_clause_validity
   !$acc init device_type(2, i, j)
   !$acc init device_num(i) device_type(i, j) if(ifCondition)
 
+  !$acc parallel
+  !ERROR: Directive INIT may not be called within a compute region
+  !$acc init
+  !$acc end parallel
+
+  !$acc serial
+  !ERROR: Directive INIT may not be called within a compute region
+  !$acc init
+  !$acc end serial
+
+  !$acc kernels
+  !ERROR: Directive INIT may not be called within a compute region
+  !$acc init
+  !$acc end kernels
+
+  !$acc parallel
+  !$acc loop
+  do i = 1, N
+!ERROR: Directive INIT may not be called within a compute region
+ 

[llvm-branch-commits] [llvm] bf14979 - [gn build] Port 1821265db68

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

Author: LLVM GN Syncbot
Date: 2020-12-08T20:15:44Z
New Revision: bf14979e34bf8e855eb2cae19a971a4e77bf30b7

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

LOG: [gn build] Port 1821265db68

Added: 


Modified: 
llvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn
index 1713e5ac0c3a6..1e4d3679cd537 100644
--- a/llvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/Frontend/BUILD.gn
@@ -32,7 +32,6 @@ static_library("Frontend") {
 "FrontendAction.cpp",
 "FrontendActions.cpp",
 "FrontendOptions.cpp",
-"FrontendTiming.cpp",
 "HeaderIncludeGen.cpp",
 "InitHeaderSearch.cpp",
 "InitPreprocessor.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] abd80ac - [gn build] Port 39431e479ff

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

Author: LLVM GN Syncbot
Date: 2020-12-08T20:15:45Z
New Revision: abd80ac9b83c09b98b6b0bb3f2d4630d37e070ef

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

LOG: [gn build] Port 39431e479ff

Added: 


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

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
index 18539d78800a..148d65e50763 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
@@ -21,6 +21,7 @@ static_library("performance") {
 "MoveConstArgCheck.cpp",
 "MoveConstructorInitCheck.cpp",
 "NoAutomaticMoveCheck.cpp",
+"NoIntToPtrCheck.cpp",
 "NoexceptMoveConstructorCheck.cpp",
 "PerformanceTidyModule.cpp",
 "TriviallyDestructibleCheck.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] 98bca0a - [RISCV] Add isel patterns for SBCLRI/SBSETI/SBINVI(W) instruction

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

Author: Craig Topper
Date: 2020-12-08T12:22:40-08:00
New Revision: 98bca0a60574c4276cfc85833fe29d8f4beff7f6

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

LOG: [RISCV] Add isel patterns for SBCLRI/SBSETI/SBINVI(W) instruction

We can use these instructions for single bit immediates that are too large for 
ANDI/ORI/CLRI.

The _10 test cases are to make sure that we still use ANDI/ORI/CLRI for small 
immediates.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
llvm/test/CodeGen/RISCV/rv32Zbs.ll
llvm/test/CodeGen/RISCV/rv32Zbt.ll
llvm/test/CodeGen/RISCV/rv64Zbb.ll
llvm/test/CodeGen/RISCV/rv64Zbs.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
index 2f663cad82b8..a4c390091125 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -59,6 +59,44 @@ def ImmROTL2RW : SDNodeXFormgetValueType(0));
 }]>;
 
+// Checks if this mask has a single 0 bit and cannot be used with ANDI.
+def SBCLRMask : ImmLeafis64Bit())
+return !isInt<12>(Imm) && isPowerOf2_64(~Imm);
+  return !isInt<12>(Imm) && isPowerOf2_32(~Imm);
+}]>;
+
+// Checks if this mask has a single 1 bit and cannot be used with ORI/XORI.
+def SBSETINVMask : ImmLeafis64Bit())
+return !isInt<12>(Imm) && isPowerOf2_64(Imm);
+  return !isInt<12>(Imm) && isPowerOf2_32(Imm);
+}]>;
+
+def SBCLRXForm : SDNodeXFormgetTargetConstant(N->getAPIntValue().countTrailingOnes(),
+   SDLoc(N), N->getValueType(0));
+}]>;
+
+def SBSETINVXForm : SDNodeXFormgetTargetConstant(N->getAPIntValue().countTrailingZeros(),
+   SDLoc(N), N->getValueType(0));
+}]>;
+
+// Similar to above, but makes sure the immediate has 33 sign bits. When used
+// with an AND/OR/XOR where the other operand has at least 33 sign bits, the
+// result will have 33 sign bits. This can match SBCLRIW/SBSETIW/SBINVIW.
+def SBCLRWMask : ImmLeaf(Imm) && !isInt<12>(Imm) && isPowerOf2_32(~Imm);
+}]>;
+
+def SBSETINVWMask : ImmLeaf(Imm) && !isInt<12>(Imm) && isPowerOf2_32(Imm);
+}]>;
+
 
//===--===//
 // Instruction class templates
 
//===--===//
@@ -692,6 +730,13 @@ def : Pat<(and (shiftop GPR:$rs1, GPR:$rs2), 1),
 
 def : Pat<(shiftop 1, GPR:$rs2),
   (SBSET X0, GPR:$rs2)>;
+
+def : Pat<(and GPR:$rs1, SBCLRMask:$mask),
+  (SBCLRI GPR:$rs1, (SBCLRXForm imm:$mask))>;
+def : Pat<(or GPR:$rs1, SBSETINVMask:$mask),
+  (SBSETI GPR:$rs1, (SBSETINVXForm imm:$mask))>;
+def : Pat<(xor GPR:$rs1, SBSETINVMask:$mask),
+  (SBINVI GPR:$rs1, (SBSETINVXForm imm:$mask))>;
 }
 
 let Predicates = [HasStdExtZbb] in {
@@ -902,6 +947,14 @@ def : Pat<(and (riscv_srlw GPR:$rs1, GPR:$rs2), 1),
 
 def : Pat<(riscv_sllw 1, GPR:$rs2),
   (SBSETW X0, GPR:$rs2)>;
+
+def : Pat<(and (assertsexti32 GPR:$rs1), SBCLRWMask:$mask),
+  (SBCLRIW GPR:$rs1, (SBCLRXForm imm:$mask))>;
+def : Pat<(or (assertsexti32 GPR:$rs1), SBSETINVWMask:$mask),
+  (SBSETIW GPR:$rs1, (SBSETINVXForm imm:$mask))>;
+def : Pat<(xor (assertsexti32 GPR:$rs1), SBSETINVWMask:$mask),
+  (SBINVIW GPR:$rs1, (SBSETINVXForm imm:$mask))>;
+
 } // Predicates = [HasStdExtZbs, IsRV64]
 
 let Predicates = [HasStdExtZbb, IsRV64] in {

diff  --git a/llvm/test/CodeGen/RISCV/rv32Zbs.ll 
b/llvm/test/CodeGen/RISCV/rv32Zbs.ll
index 355389340da5..ebe33744725a 100644
--- a/llvm/test/CodeGen/RISCV/rv32Zbs.ll
+++ b/llvm/test/CodeGen/RISCV/rv32Zbs.ll
@@ -485,3 +485,245 @@ define i64 @sbexti_i64(i64 %a) nounwind {
   %and = and i64 %shr, 1
   ret i64 %and
 }
+
+define i32 @sbclri_i32_10(i32 %a) nounwind {
+; RV32I-LABEL: sbclri_i32_10:
+; RV32I:   # %bb.0:
+; RV32I-NEXT:andi a0, a0, -1025
+; RV32I-NEXT:ret
+;
+; RV32IB-LABEL: sbclri_i32_10:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:andi a0, a0, -1025
+; RV32IB-NEXT:ret
+;
+; RV32IBS-LABEL: sbclri_i32_10:
+; RV32IBS:   # %bb.0:
+; RV32IBS-NEXT:andi a0, a0, -1025
+; RV32IBS-NEXT:ret
+  %and = and i32 %a, -1025
+  ret i32 %and
+}
+
+define i32 @sbclri_i32_11(i32 %a) nounwind {
+; RV32I-LABEL: sbclri_i32_11:
+; RV32I:   # %bb.0:
+; RV32I-NEXT:lui a1, 1048575
+; RV32I-NEXT:addi a1, a1, 2047
+; RV32I-NEXT:and a0, a0, a1
+; RV32I-NEXT:ret
+;
+; RV32IB-LABEL: sbclri_i32_11:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:sbclri a0, a0, 11
+; RV32IB-NEXT:ret
+;
+; RV32IBS-LABEL: sbclri_i32_11:
+; RV32IBS:   # %bb.0:
+; RV32IBS-NEXT:sbclri a0, a0, 11
+; RV32IBS-NEXT:ret
+  %and = and i32 %a, -2049
+  ret i32 %

[llvm-branch-commits] [llvm] 4aa842a - [AMDGPU] Add new pseudos for indirect addressing with VGPR Indexing

2020-12-08 Thread Austin Kerbow via llvm-branch-commits

Author: Austin Kerbow
Date: 2020-12-08T12:24:12-08:00
New Revision: 4aa842a800b53806a9e25f03b4e21f6879801a38

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

LOG: [AMDGPU] Add new pseudos for indirect addressing with VGPR Indexing

It is possible for copies or spills to be inserted in the middle of indirect
addressing sequences which use VGPR indexing. Spills to accvgprs could be
effected by the indexing mode.

Add new pseudo instructions that are expanded after register allocation to avoid
the problematic spill or copy placement.

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

Added: 
llvm/test/CodeGen/AMDGPU/expand-si-indirect.mir

Modified: 
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.h
llvm/lib/Target/AMDGPU/SIInstructions.td
llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.i128.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-extract-vector-elt.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-insert-vector-elt.mir
llvm/test/CodeGen/AMDGPU/indirect-addressing-si-gfx9.ll
llvm/test/CodeGen/AMDGPU/indirect-addressing-si.ll
llvm/test/CodeGen/AMDGPU/indirect-addressing-term.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index 20b7c7849397..b157c03672d1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -2656,14 +2656,12 @@ bool 
AMDGPUInstructionSelector::selectG_EXTRACT_VECTOR_ELT(
 return true;
   }
 
-  BuildMI(*BB, MI, DL, TII.get(AMDGPU::S_SET_GPR_IDX_ON))
-.addReg(IdxReg)
-.addImm(AMDGPU::VGPRIndexMode::SRC0_ENABLE);
-  BuildMI(*BB, MI, DL, TII.get(AMDGPU::V_MOV_B32_e32), DstReg)
-.addReg(SrcReg, 0, SubReg)
-.addReg(SrcReg, RegState::Implicit)
-.addReg(AMDGPU::M0, RegState::Implicit);
-  BuildMI(*BB, MI, DL, TII.get(AMDGPU::S_SET_GPR_IDX_OFF));
+  const MCInstrDesc &GPRIDXDesc =
+  TII.getIndirectGPRIDXPseudo(TRI.getRegSizeInBits(*SrcRC), true);
+  BuildMI(*BB, MI, DL, GPRIDXDesc, DstReg)
+  .addReg(SrcReg)
+  .addReg(IdxReg)
+  .addImm(SubReg);
 
   MI.eraseFromParent();
   return true;
@@ -2717,25 +2715,27 @@ bool 
AMDGPUInstructionSelector::selectG_INSERT_VECTOR_ELT(
   MachineBasicBlock *BB = MI.getParent();
   const DebugLoc &DL = MI.getDebugLoc();
 
-  if (IndexMode) {
-BuildMI(*BB, MI, DL, TII.get(AMDGPU::S_SET_GPR_IDX_ON))
-  .addReg(IdxReg)
-  .addImm(AMDGPU::VGPRIndexMode::DST_ENABLE);
-  } else {
+  if (!IndexMode) {
 BuildMI(*BB, &MI, DL, TII.get(AMDGPU::COPY), AMDGPU::M0)
   .addReg(IdxReg);
-  }
 
-  const MCInstrDesc &RegWriteOp
-= TII.getIndirectRegWritePseudo(VecSize, ValSize,
-VecRB->getID() == AMDGPU::SGPRRegBankID);
-  BuildMI(*BB, MI, DL, RegWriteOp, DstReg)
-.addReg(VecReg)
-.addReg(ValReg)
-.addImm(SubReg);
+const MCInstrDesc &RegWriteOp = TII.getIndirectRegWriteMovRelPseudo(
+VecSize, ValSize, VecRB->getID() == AMDGPU::SGPRRegBankID);
+BuildMI(*BB, MI, DL, RegWriteOp, DstReg)
+.addReg(VecReg)
+.addReg(ValReg)
+.addImm(SubReg);
+MI.eraseFromParent();
+return true;
+  }
 
-  if (IndexMode)
-BuildMI(*BB, MI, DL, TII.get(AMDGPU::S_SET_GPR_IDX_OFF));
+  const MCInstrDesc &GPRIDXDesc =
+  TII.getIndirectGPRIDXPseudo(TRI.getRegSizeInBits(*VecRC), false);
+  BuildMI(*BB, MI, DL, GPRIDXDesc, DstReg)
+  .addReg(VecReg)
+  .addReg(ValReg)
+  .addReg(IdxReg)
+  .addImm(SubReg);
 
   MI.eraseFromParent();
   return true;

diff  --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 57caa002b194..1accee5ccd2a 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -3461,20 +3461,14 @@ SITargetLowering::emitGWSMemViolTestLoop(MachineInstr 
&MI,
 // will only do one iteration. In the worst case, this will loop 64 times.
 //
 // TODO: Just use v_readlane_b32 if we know the VGPR has a uniform value.
-static MachineBasicBlock::iterator emitLoadM0FromVGPRLoop(
-  const SIInstrInfo *TII,
-  MachineRegisterInfo &MRI,
-  MachineBasicBlock &OrigBB,
-  MachineBasicBlock &LoopBB,
-  const DebugLoc &DL,
-  const MachineOperand &IdxReg,
-  unsigned InitReg,
-  unsigned ResultReg,
-  unsigned PhiReg,
-  unsigned InitSaveExecReg,
-  int Offset,
-  bool UseGPRIdxMode,
-  bool IsIndirectSrc) {
+static MachineBasicBlock::iterator
+emitLoadM0FromVGPRLoop(const SIInstrInfo *TII, MachineRegisterInfo &MRI,
+ 

[llvm-branch-commits] [clang-tools-extra] 2755393 - [clang-tidy] Add support for diagnostics with no location

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

Author: Nathan James
Date: 2020-12-08T20:29:31Z
New Revision: 27553933a8693d508eb7f7c24a14f66b3d006d2c

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

LOG: [clang-tidy] Add support for diagnostics with no location

Add methods for emitting diagnostics with no location as well as a special 
diagnostic for configuration errors.
These show up in the errors as [clang-tidy-config].
The reason to use a custom name rather than the check name is to distinguish 
the error isn't the same category as the check that reported it.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.h
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index be68dfbedb29..af19da2419ab 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -42,7 +42,7 @@ std::string UnparseableIntegerOptionError::message() const {
 
 ClangTidyCheck::ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context)
 : CheckName(CheckName), Context(Context),
-  Options(CheckName, Context->getOptions().CheckOptions) {
+  Options(CheckName, Context->getOptions().CheckOptions, Context) {
   assert(Context != nullptr);
   assert(!CheckName.empty());
 }
@@ -52,6 +52,17 @@ DiagnosticBuilder ClangTidyCheck::diag(SourceLocation Loc, 
StringRef Message,
   return Context->diag(CheckName, Loc, Message, Level);
 }
 
+DiagnosticBuilder ClangTidyCheck::diag(StringRef Message,
+   DiagnosticIDs::Level Level) {
+  return Context->diag(CheckName, Message, Level);
+}
+
+DiagnosticBuilder
+ClangTidyCheck::configurationDiag(StringRef Description,
+  DiagnosticIDs::Level Level) {
+  return Context->configurationDiag(Description, Level);
+}
+
 void ClangTidyCheck::run(const ast_matchers::MatchFinder::MatchResult &Result) 
{
   // For historical reasons, checks don't implement the MatchFinder run()
   // callback directly. We keep the run()/check() distinction to avoid 
interface
@@ -59,9 +70,11 @@ void ClangTidyCheck::run(const 
ast_matchers::MatchFinder::MatchResult &Result) {
   check(Result);
 }
 
-ClangTidyCheck::OptionsView::OptionsView(StringRef CheckName,
- const ClangTidyOptions::OptionMap &CheckOptions)
-: NamePrefix(CheckName.str() + "."), CheckOptions(CheckOptions) {}
+ClangTidyCheck::OptionsView::OptionsView(
+StringRef CheckName, const ClangTidyOptions::OptionMap &CheckOptions,
+ClangTidyContext *Context)
+: NamePrefix(CheckName.str() + "."), CheckOptions(CheckOptions),
+  Context(Context) {}
 
 llvm::Expected
 ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
@@ -121,7 +134,7 @@ bool ClangTidyCheck::OptionsView::get(StringRef 
LocalName,
   llvm::Expected ValueOr = get(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logIfOptionParsingError(ValueOr.takeError());
+  reportOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -140,7 +153,7 @@ bool 
ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName,
   llvm::Expected ValueOr = getLocalOrGlobal(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logIfOptionParsingError(ValueOr.takeError());
+  reportOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -199,11 +212,11 @@ llvm::Expected 
ClangTidyCheck::OptionsView::getEnumInt(
   Iter->getValue().Value);
 }
 
-void ClangTidyCheck::OptionsView::logIfOptionParsingError(llvm::Error &&Err) {
+void ClangTidyCheck::OptionsView::reportOptionParsingError(
+llvm::Error &&Err) const {
   if (auto Re

[llvm-branch-commits] [libcxx] 3e46b3a - [libc++] NFC: Indent feature-test macro script consistently

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

Author: Louis Dionne
Date: 2020-12-08T15:42:57-05:00
New Revision: 3e46b3a1880ce919dfafa012984fd3b44e978a2e

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

LOG: [libc++] NFC: Indent feature-test macro script consistently

Added: 


Modified: 
libcxx/utils/generate_feature_test_macro_components.py

Removed: 




diff  --git a/libcxx/utils/generate_feature_test_macro_components.py 
b/libcxx/utils/generate_feature_test_macro_components.py
index 79a9929ebb7c..c3b28c555811 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -143,192 +143,192 @@ def add_version_header(tc):
 "name": "__cpp_lib_byte",
 "values": { "c++17": int(201603) },
 "headers": ["cstddef"],
-   }, {
+  }, {
 "name": "__cpp_lib_hardware_interference_size",
 "values": { "c++17": int(201703) },
 "headers": ["new"],
 "unimplemented": True,
-   }, {
+  }, {
 "name": "__cpp_lib_launder",
 "values": { "c++17": int(201606) },
 "headers": ["new"],
-   }, {
+  }, {
 "name": "__cpp_lib_uncaught_exceptions",
 "values": { "c++17": int(201411) },
 "headers": ["exception"],
-   }, {
+  }, {
 "name": "__cpp_lib_as_const",
 "values": { "c++17": int(201510) },
 "headers": ["utility"],
-   }, {
+  }, {
 "name": "__cpp_lib_make_from_tuple",
 "values": { "c++17": int(201606) },
 "headers": ["tuple"],
-   }, {
+  }, {
 "name": "__cpp_lib_apply",
 "values": { "c++17": int(201603) },
 "headers": ["tuple"],
-   }, {
+  }, {
 "name": "__cpp_lib_optional",
 "values": { "c++17": int(201606) },
 "headers": ["optional"],
-   }, {
+  }, {
 "name": "__cpp_lib_variant",
 "values": { "c++17": int(201606) },
 "headers": ["variant"],
-   }, {
+  }, {
 "name": "__cpp_lib_any",
 "values": { "c++17": int(201606) },
 "headers": ["any"],
-   }, {
+  }, {
 "name": "__cpp_lib_addressof_constexpr",
 "values": { "c++17": int(201603) },
 "headers": ["memory"],
 "depends": "TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700",
 "internal_depends": "!defined(_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF)",
-   }, {
+  }, {
 "name": "__cpp_lib_raw_memory_algorithms",
 "values": { "c++17": int(201606) },
 "headers": ["memory"],
-   }, {
+  }, {
 "name": "__cpp_lib_enable_shared_from_this",
 "values": { "c++17": int(201603) },
 "headers": ["memory"],
-   }, {
+  }, {
 "name": "__cpp_lib_shared_ptr_weak_type",
 "values": { "c++17": int(201606) },
 "headers": ["memory"],
-   }, {
+  }, {
 "name": "__cpp_lib_shared_ptr_arrays",
 "values": { "c++17": int(201611) },
 "headers": ["memory"],
 "unimplemented": True,
-   }, {
+  }, {
 "name": "__cpp_lib_memory_resource",
 "values": { "c++17": int(201603) },
 "headers": ["memory_resource"],
 "unimplemented": True,
-   }, {
+  }, {
 "name": "__cpp_lib_boyer_moore_searcher",
 "values": { "c++17": int(201603) },
 "headers": ["functional"],
 "unimplemented": True,
-   }, {
+  }, {
 "name": "__cpp_lib_not_fn",
 "values": { "c++17": int(201603) },
 "headers": ["functional"],
-   }, {
+  }, {
 "name": "__cpp_lib_bool_constant",
 "values": { "c++17": int(201505) },
 "headers": ["type_traits"],
-   }, {
+  }, {
 "name": "__cpp_lib_type_trait_variable_templates",
 "values": { "c++17": int(201510) },
 "headers": ["type_traits"],
-   }, {
+  }, {
 "name": "__cpp_lib_logical_traits",
 "values": { "c++17": int(201510) },
 "headers": ["type_traits"],
-   }, {
+  }, {
 "name": "__cpp_lib_is_swappable",
 "values": { "c++17": int(201603) },
 "headers": ["type_traits"],
-   }, {
+  }, {
 "name": "__cpp_lib_is_invocable",
 "values": { "c++17": int(201703) },
 "headers": ["type_traits"],
-   }, {
+  }, {
 "name": "__cpp_lib_has_unique_object_representations",
 "values": { "c++17": int(201606) },
 "headers": ["type_traits"],
 "depends": 
"TEST_HAS_BUILTIN_IDENTIFIER(__has_unique_object_representations) || 
TEST_GCC_VER >= 700",
 "internal_depends": "defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS)",
-   }, {
+  }, {
 "name": "__cpp_lib_is_aggregate",
 "values": { "c++17": int(201703) },
 "headers": ["type_traits"],
 "depends": "TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || 
TEST_GCC_VER_NEW >= 7001",
 "internal_depends": "!defined(_LIBCPP_HAS_NO_IS_AGGREGATE)",
-   }, {
+  }, {
 "name": "__cpp_lib_chrono",
 "values": { "c++17": int(201611) },
 "headers": ["chrono"],
-   }, {
+  }, {
 "name": "__cpp_lib_execution",
 "values": { "c++17": int(201603) },
 "headers": ["execution"],
 "unimplemented": True
-   }

  1   2   >