[llvm-branch-commits] [llvm] 4ffcd4f - Revert "[LV] Vectorize (some) early and multiple exit loops"

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

Author: Arthur Eubanks
Date: 2020-12-28T10:05:41-08:00
New Revision: 4ffcd4fe9ac2ee948948f732baa16663eb63f1c7

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

LOG: Revert "[LV] Vectorize (some) early and multiple exit loops"

This reverts commit e4df6a40dad66e989a4333c11d39cf3ed9635135.

Breaks Windows bots, e.g. http://45.33.8.238/win/30472/step_4.txt
and http://lab.llvm.org:8011/#/builders/83/builds/2078/steps/5/logs/stdio

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/control-flow.ll
llvm/test/Transforms/LoopVectorize/loop-form.ll
llvm/test/Transforms/LoopVectorize/loop-legality-checks.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 911309c9421c..60e1cc9a4a59 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -1095,15 +1095,9 @@ bool LoopVectorizationLegality::canVectorizeLoopCFG(Loop 
*Lp,
   return false;
   }
 
-  // We currently must have a single "exit block" after the loop. Note that
-  // multiple "exiting blocks" inside the loop are allowed, provided they all
-  // reach the single exit block.
-  // TODO: This restriction can be relaxed in the near future, it's here solely
-  // to allow separation of changes for review. We need to generalize the phi
-  // update logic in a number of places.
-  BasicBlock *ExitBB = Lp->getUniqueExitBlock();
-  if (!ExitBB) {
-reportVectorizationFailure("The loop must have a unique exit block",
+  // We must have a single exiting block.
+  if (!Lp->getExitingBlock()) {
+reportVectorizationFailure("The loop must have an exiting block",
 "loop control flow is not understood by vectorizer",
 "CFGNotUnderstood", ORE, TheLoop);
 if (DoExtraAnalysis)
@@ -1112,14 +1106,11 @@ bool 
LoopVectorizationLegality::canVectorizeLoopCFG(Loop *Lp,
   return false;
   }
 
-  // The existing code assumes that LCSSA implies that phis are single entry
-  // (which was true when we had at most a single exiting edge from the latch).
-  // In general, there's nothing which prevents an LCSSA phi in exit block from
-  // having two or more values if there are multiple exiting edges leading to
-  // the exit block.  (TODO: implement general case)
-  if (!empty(ExitBB->phis()) && !ExitBB->getSinglePredecessor()) {
-reportVectorizationFailure("The loop must have no live-out values if "
-   "it has more than one exiting block",
+  // We only handle bottom-tested loops, i.e. loop in which the condition is
+  // checked at the end of each iteration. With that we can assume that all
+  // instructions in the loop are executed the same number of times.
+  if (Lp->getExitingBlock() != Lp->getLoopLatch()) {
+reportVectorizationFailure("The exiting block is not the loop latch",
 "loop control flow is not understood by vectorizer",
 "CFGNotUnderstood", ORE, TheLoop);
 if (DoExtraAnalysis)

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c48b650c3c3e..5889d5e55339 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -837,8 +837,7 @@ class InnerLoopVectorizer {
   /// Middle Block between the vector and the scalar.
   BasicBlock *LoopMiddleBlock;
 
-  /// The (unique) ExitBlock of the scalar loop.  Note that
-  /// there can be multiple exiting edges reaching this block.
+  /// The ExitBlock of the scalar loop.
   BasicBlock *LoopExitBlock;
 
   /// The vector loop body.
@@ -1549,16 +1548,11 @@ class LoopVectorizationCostModel {
 return InterleaveInfo.getInterleaveGroup(Instr);
   }
 
-  /// Returns true if we're required to use a scalar epilogue for at least
-  /// the final iteration of the original loop.
+  /// Returns true if an interleaved group requires a scalar iteration
+  /// to handle accesses with gaps, and there is nothing preventing us from
+  /// creating a scalar epilogue.
   bool requiresScalarEpilogue() const {
-if (!isScalarEpilogueAllowed())
-  return false;
-// If we might exit from anywhere but the latch, must run the exiting
-// iteration in scalar form.
-if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch())
-  return true;
-return InterleaveInfo.requiresScalarEpilogue();
+return isScalarEpilogueAllowed() && 
InterleaveInfo.requiresScalarEpilogue();
   }
 
   /// Returns true if a scalar epilogue is not allowed due to optsize or a
@@ -2918,7 +2912,7 @@ PHIN

[llvm-branch-commits] [llvm] 4b33b23 - Reapply "[LV] Vectorize (some) early and multiple exit loops"" w/fix for builder

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

Author: Philip Reames
Date: 2020-12-28T10:13:28-08:00
New Revision: 4b33b2387787aef5020450cdcc8dde231eb0a5fc

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

LOG: Reapply "[LV] Vectorize (some) early and multiple exit loops"" w/fix for 
builder

This reverts commit 4ffcd4fe9ac2ee948948f732baa16663eb63f1c7 thus restoring 
e4df6a40dad.

The only change from the original patch is to add "llvm::" before the call to 
empty(iterator_range).  This is a speculative fix for the ambiguity reported on 
some builders.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/control-flow.ll
llvm/test/Transforms/LoopVectorize/loop-form.ll
llvm/test/Transforms/LoopVectorize/loop-legality-checks.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 60e1cc9a4a59..65b3132dc3f1 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -1095,9 +1095,15 @@ bool LoopVectorizationLegality::canVectorizeLoopCFG(Loop 
*Lp,
   return false;
   }
 
-  // We must have a single exiting block.
-  if (!Lp->getExitingBlock()) {
-reportVectorizationFailure("The loop must have an exiting block",
+  // We currently must have a single "exit block" after the loop. Note that
+  // multiple "exiting blocks" inside the loop are allowed, provided they all
+  // reach the single exit block.
+  // TODO: This restriction can be relaxed in the near future, it's here solely
+  // to allow separation of changes for review. We need to generalize the phi
+  // update logic in a number of places.
+  BasicBlock *ExitBB = Lp->getUniqueExitBlock();
+  if (!ExitBB) {
+reportVectorizationFailure("The loop must have a unique exit block",
 "loop control flow is not understood by vectorizer",
 "CFGNotUnderstood", ORE, TheLoop);
 if (DoExtraAnalysis)
@@ -1106,11 +1112,14 @@ bool 
LoopVectorizationLegality::canVectorizeLoopCFG(Loop *Lp,
   return false;
   }
 
-  // We only handle bottom-tested loops, i.e. loop in which the condition is
-  // checked at the end of each iteration. With that we can assume that all
-  // instructions in the loop are executed the same number of times.
-  if (Lp->getExitingBlock() != Lp->getLoopLatch()) {
-reportVectorizationFailure("The exiting block is not the loop latch",
+  // The existing code assumes that LCSSA implies that phis are single entry
+  // (which was true when we had at most a single exiting edge from the latch).
+  // In general, there's nothing which prevents an LCSSA phi in exit block from
+  // having two or more values if there are multiple exiting edges leading to
+  // the exit block.  (TODO: implement general case)
+  if (!llvm::empty(ExitBB->phis()) && !ExitBB->getSinglePredecessor()) {
+reportVectorizationFailure("The loop must have no live-out values if "
+   "it has more than one exiting block",
 "loop control flow is not understood by vectorizer",
 "CFGNotUnderstood", ORE, TheLoop);
 if (DoExtraAnalysis)

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5889d5e55339..c48b650c3c3e 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -837,7 +837,8 @@ class InnerLoopVectorizer {
   /// Middle Block between the vector and the scalar.
   BasicBlock *LoopMiddleBlock;
 
-  /// The ExitBlock of the scalar loop.
+  /// The (unique) ExitBlock of the scalar loop.  Note that
+  /// there can be multiple exiting edges reaching this block.
   BasicBlock *LoopExitBlock;
 
   /// The vector loop body.
@@ -1548,11 +1549,16 @@ class LoopVectorizationCostModel {
 return InterleaveInfo.getInterleaveGroup(Instr);
   }
 
-  /// Returns true if an interleaved group requires a scalar iteration
-  /// to handle accesses with gaps, and there is nothing preventing us from
-  /// creating a scalar epilogue.
+  /// Returns true if we're required to use a scalar epilogue for at least
+  /// the final iteration of the original loop.
   bool requiresScalarEpilogue() const {
-return isScalarEpilogueAllowed() && 
InterleaveInfo.requiresScalarEpilogue();
+if (!isScalarEpilogueAllowed())
+  return false;
+// If we might exit from anywhere but the latch, must run the exiting
+// iteration in scalar form.
+if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch())
+  return true;
+return InterleaveInfo.requiresScalarEpilogue();
   }
 
   /// Return

[llvm-branch-commits] [libcxx] 30f589c - [libc++] Constexpr-proof some machinery in not_fn.pass.cpp. NFCI.

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

Author: Arthur O'Dwyer
Date: 2020-12-28T13:24:07-05:00
New Revision: 30f589c912115b4653f596eb3fd5bf62412f8aa7

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

LOG: [libc++] Constexpr-proof some machinery in not_fn.pass.cpp. NFCI.

We don't need to use global variables here; we can store the "State"
of this machinery on the stack, so that it's constexpr-friendly.

Added: 


Modified: 
libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp 
b/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
index 56ed61500d3c..75f7f9fd4f02 100644
--- a/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
@@ -135,59 +135,60 @@ inline constexpr CallType operator|(CallType LHS, 
CallType RHS) {
 }
 
 struct ForwardingCallObject {
+  struct State {
+CallType  last_call_type = CT_None;
+TypeID const& (*last_call_args)() = nullptr;
+
+template 
+constexpr void set_call(CallType type) {
+  assert(last_call_type == CT_None);
+  assert(last_call_args == nullptr);
+  last_call_type = type;
+  last_call_args = &makeArgumentID;
+}
+
+template 
+constexpr bool check_call(CallType type) {
+  bool result =
+   last_call_type == type
+&& last_call_args
+&& *last_call_args == &makeArgumentID;
+  last_call_type = CT_None;
+  last_call_args = nullptr;
+  return result;
+}
+  };
+
+  State *st_;
+
+  explicit constexpr ForwardingCallObject(State& st) : st_(&st) {}
 
   template 
-  bool operator()(Args&&...) & {
-  set_call(CT_NonConst | CT_LValue);
+  constexpr bool operator()(Args&&...) & {
+  st_->set_call(CT_NonConst | CT_LValue);
   return true;
   }
 
   template 
-  bool operator()(Args&&...) const & {
-  set_call(CT_Const | CT_LValue);
+  constexpr bool operator()(Args&&...) const & {
+  st_->set_call(CT_Const | CT_LValue);
   return true;
   }
 
   // Don't allow the call operator to be invoked as an rvalue.
   template 
-  bool operator()(Args&&...) && {
-  set_call(CT_NonConst | CT_RValue);
+  constexpr bool operator()(Args&&...) && {
+  st_->set_call(CT_NonConst | CT_RValue);
   return true;
   }
 
   template 
-  bool operator()(Args&&...) const && {
-  set_call(CT_Const | CT_RValue);
+  constexpr bool operator()(Args&&...) const && {
+  st_->set_call(CT_Const | CT_RValue);
   return true;
   }
-
-  template 
-  static void set_call(CallType type) {
-  assert(last_call_type == CT_None);
-  assert(last_call_args == nullptr);
-  last_call_type = type;
-  last_call_args = &makeArgumentID();
-  }
-
-  template 
-  static bool check_call(CallType type) {
-  bool result =
-   last_call_type == type
-&& last_call_args
-&& *last_call_args == makeArgumentID();
-  last_call_type = CT_None;
-  last_call_args = nullptr;
-  return result;
-  }
-
-  static CallType  last_call_type;
-  static TypeID const* last_call_args;
 };
 
-CallType ForwardingCallObject::last_call_type = CT_None;
-TypeID const* ForwardingCallObject::last_call_args = nullptr;
-
-
 
 ///
 //BOOL TEST TYPES
@@ -467,85 +468,86 @@ void call_operator_sfinae_test() {
 void call_operator_forwarding_test()
 {
 using Fn = ForwardingCallObject;
-auto obj = std::not_fn(Fn{});
+Fn::State st;
+auto obj = std::not_fn(Fn{st});
 const auto& c_obj = obj;
 { // test zero args
 obj();
-assert(Fn::check_call<>(CT_NonConst | CT_LValue));
+assert(st.check_call<>(CT_NonConst | CT_LValue));
 std::move(obj)();
-assert(Fn::check_call<>(CT_NonConst | CT_RValue));
+assert(st.check_call<>(CT_NonConst | CT_RValue));
 c_obj();
-assert(Fn::check_call<>(CT_Const | CT_LValue));
+assert(st.check_call<>(CT_Const | CT_LValue));
 std::move(c_obj)();
-assert(Fn::check_call<>(CT_Const | CT_RValue));
+assert(st.check_call<>(CT_Const | CT_RValue));
 }
 { // test value categories
 int x = 42;
 const int cx = 42;
 obj(x);
-assert(Fn::check_call(CT_NonConst | CT_LValue));
+assert(st.check_call(CT_NonConst | CT_LValue));
 obj(cx);
-assert(Fn::check_call(CT_NonConst | CT_LValue));
+assert(st.check_call(CT_NonConst | CT_LValue));
 obj(std::move(x));
-assert(Fn::check_call(CT_NonConst | CT_LValue));
+assert(st.check_call(CT_NonConst | CT_LValue));
 ob

[llvm-branch-commits] [libcxx] 7b00e9f - [libc++] [P1065] Constexpr invoke, reference_wrapper, mem_fn, not_fn, default_searcher.

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

Author: Arthur O'Dwyer
Date: 2020-12-28T13:24:07-05:00
New Revision: 7b00e9fae3853d4693e608cc52f6d6da5059f5ff

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

LOG: [libc++] [P1065] Constexpr invoke, reference_wrapper, mem_fn, not_fn, 
default_searcher.

This completes the implementation of P1065 "constexpr INVOKE":
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1065r2.html

This doesn't yet complete the implementation of P1032 "Misc constexpr bits,"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1032r1.html
but it does complete all of the  bits, which means
that we can now set `__cpp_lib_constexpr_functional` for C++20.

This could use more constexpr tests for `std::reference_wrapper`,
but the existing tests are extremely non-constexpr-friendly and
so I don't want to get into that rabbit-hole today.

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

Added: 

libcxx/test/std/utilities/function.objects/func.invoke/invoke_constexpr.pass.cpp

Modified: 
libcxx/docs/Cxx2aStatusPaperStatus.csv
libcxx/docs/FeatureTestMacroTable.rst
libcxx/include/__functional_base
libcxx/include/functional
libcxx/include/type_traits
libcxx/include/version

libcxx/test/std/language.support/support.limits/support.limits.general/array.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/string_view.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp

libcxx/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp

libcxx/test/std/utilities/function.objects/func.memfn/member_function_const.pass.cpp
libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp

libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pass.cpp

libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py

Removed: 




diff  --git a/libcxx/docs/Cxx2aStatusPaperStatus.csv 
b/libcxx/docs/Cxx2aStatusPaperStatus.csv
index c495e0210cf7..fe5b2f5d4771 100644
--- a/libcxx/docs/Cxx2aStatusPaperStatus.csv
+++ b/libcxx/docs/Cxx2aStatusPaperStatus.csv
@@ -109,7 +109,7 @@
 "`P0980 `__","LWG","Making std::string 
constexpr","Cologne","",""
 "`P1004 `__","LWG","Making std::vector 
constexpr","Cologne","",""
 "`P1035 `__","LWG","Input Range 
Adaptors","Cologne","",""
-"`P1065 `__","LWG","Constexpr INVOKE","Cologne","",""
+"`P1065 `__","LWG","Constexpr 
INVOKE","Cologne","|Complete|","12.0"
 "`P1135 `__","LWG","The C++20 Synchronization 
Library","Cologne","|Complete|","11.0"
 "`P1207 `__","LWG","Movability of Single-pass 
Iterators","Cologne","",""
 "`P1208 `__","LWG","Adopt source_location for 
C++20","Cologne","",""

diff  --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 091d4b795233..5930cdaffaec 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -194,7 +194,7 @@ Status
 - -
 ``__cpp_lib_constexpr_dynamic_alloc`` ``201907L``
 - -
-``__cpp_lib_constexpr_misc``  *unimplemented*
+``__cpp_lib_constexpr_functional````201907L``
 - -
 ``__cpp_lib_constexpr_numeric``   ``201911L``
 - -

diff  --git a/libcxx/include/__functional_base 
b/libcxx/include/__functional_base
index c84e7eb11567..708c1a23e84b 100644
--- a/libcxx/include/__functional_base
+++ b/libcxx/include/__functional_base
@@ -382,20 +382,23 @@ private:
 
 public:
 // construct/copy/destroy
-_LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+reference_wrapper(type& __f) _NOEX

[llvm-branch-commits] [llvm] 9abc457 - [NewPM][AMDGPU] Port amdgpu-simplifylib/amdgpu-usenative

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

Author: Arthur Eubanks
Date: 2020-12-28T10:38:51-08:00
New Revision: 9abc457724bd54014328a6f0b7ed230bacd9f610

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

LOG: [NewPM][AMDGPU] Port amdgpu-simplifylib/amdgpu-usenative

And add them to the pipeline via
AMDGPUTargetMachine::registerPassBuilderCallbacks(), which mirrors
AMDGPUTargetMachine::adjustPassManager().

These passes can't be unconditionally added to PassRegistry.def since
they are only present when the AMDGPU backend is enabled. And there are
no target-specific headers in llvm/include, so parsing these pass names
must occur somewhere in the AMDGPU directory. I decided the best place
was inside the TargetMachine, since the PassBuilder invokes
TargetMachine::registerPassBuilderCallbacks() anyway. If we come up with
a cleaner solution for target-specific passes in the future that's fine,
but there aren't too many target-specific IR passes living in
target-specific directories so it shouldn't be too bad to change in the
future.

Reviewed By: ychen, arsenm

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPU.h
llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
llvm/lib/Target/AMDGPU/CMakeLists.txt
llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
llvm/utils/gn/secondary/llvm/lib/Target/AMDGPU/BUILD.gn

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 132036fbcfd0..22d264e2880b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -10,8 +10,9 @@
 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPU_H
 #define LLVM_LIB_TARGET_AMDGPU_AMDGPU_H
 
-#include "llvm/IR/IntrinsicsR600.h" // TODO: Sink this.
 #include "llvm/IR/IntrinsicsAMDGPU.h" // TODO: Sink this.
+#include "llvm/IR/IntrinsicsR600.h"   // TODO: Sink this.
+#include "llvm/IR/PassManager.h"
 #include "llvm/Support/CodeGen.h"
 
 namespace llvm {
@@ -75,6 +76,14 @@ ModulePass *createAMDGPUPropagateAttributesLatePass(const 
TargetMachine *);
 FunctionPass *createAMDGPURewriteOutArgumentsPass();
 FunctionPass *createSIModeRegisterPass();
 
+struct AMDGPUSimplifyLibCallsPass : PassInfoMixin {
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+struct AMDGPUUseNativeCallsPass : PassInfoMixin {
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
 void initializeAMDGPUDAGToDAGISelPass(PassRegistry&);
 
 void initializeAMDGPUMachineCFGStructurizerPass(PassRegistry&);

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
index a72f16956e72..eedcb2e1a793 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
@@ -26,6 +26,7 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/ValueSymbolTable.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/Debug.h"
@@ -1750,6 +1751,40 @@ bool AMDGPUSimplifyLibCalls::runOnFunction(Function &F) {
   return Changed;
 }
 
+PreservedAnalyses AMDGPUSimplifyLibCallsPass::run(Function &F,
+  FunctionAnalysisManager &AM) 
{
+  AMDGPULibCalls Simplifier;
+  Simplifier.initNativeFuncs();
+
+  bool Changed = false;
+  auto AA = &AM.getResult(F);
+
+  LLVM_DEBUG(dbgs() << "AMDIC: process function ";
+ F.printAsOperand(dbgs(), false, F.getParent()); dbgs() << '\n';);
+
+  for (auto &BB : F) {
+for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E;) {
+  // Ignore non-calls.
+  CallInst *CI = dyn_cast(I);
+  ++I;
+  // Ignore intrinsics that do not become real instructions.
+  if (!CI || isa(CI) || CI->isLifetimeStartOrEnd())
+continue;
+
+  // Ignore indirect calls.
+  Function *Callee = CI->getCalledFunction();
+  if (Callee == 0)
+continue;
+
+  LLVM_DEBUG(dbgs() << "AMDIC: try folding " << *CI << "\n";
+ dbgs().flush());
+  if (Simplifier.fold(CI, AA))
+Changed = true;
+}
+  }
+  return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
+}
+
 bool AMDGPUUseNativeCalls::runOnFunction(Function &F) {
   if (skipFunction(F) || UseNative.empty())
 return false;
@@ -1772,3 +1807,32 @@ bool AMDGPUUseNativeCalls::runOnFunction(Function &F) {
   }
   return Changed;
 }
+
+PreservedAnalyses AMDGPUUseNativeCallsPass::run(Function &F,
+FunctionAnalysisManager &AM) {
+  if (UseNative.empty())
+return PreservedAnalyses::all();

[llvm-branch-commits] [libcxx] dd756e3 - [libc++] Fix a test failure in 7b00e9fae3 (D93815).

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

Author: Arthur O'Dwyer
Date: 2020-12-28T13:55:40-05:00
New Revision: dd756e3e84812bd962a5b5eaf4f10e9c9338c232

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

LOG: [libc++] Fix a test failure in 7b00e9fae3 (D93815).

"LLVM Buildbot on libcxx-libcxxabi-x86_64-linux-debian" is not happy
with default-initializing the `double` member of `A` in a constexpr
function. At least I'm pretty sure that's what it's complaining about.

Added: 


Modified: 
libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp 
b/libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
index 5cb4d2d28ab5..d6cd06cd8cd0 100644
--- a/libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.memfn/member_data.pass.cpp
@@ -25,7 +25,7 @@ TEST_CONSTEXPR_CXX20 bool
 test(F f)
 {
 {
-A a;
+A a = {0.0};
 f(a) = 5;
 assert(a.data_ == 5);
 A* ap = &a;



___
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] 76a718e - [lldb] Deduplicate some lldb-server tests

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

Author: Pavel Labath
Date: 2020-12-28T20:16:08+01:00
New Revision: 76a718ee939ed84d95b005f36cfbd103a702522f

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

LOG: [lldb] Deduplicate some lldb-server tests

Merge llgs and debugserver flavours

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
lldb/test/API/tools/lldb-server/TestGdbRemoteHostInfo.py
lldb/test/API/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py

lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
index 9ffa7e26fab7..dd427b66ca89 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
@@ -1,17 +1,17 @@
-
-
 import gdbremote_testcase
 import lldbgdbserverutils
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-
 class TestGdbRemoteAttach(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-def attach_with_vAttach(self):
+def test_attach_with_vAttach(self):
+self.build()
+self.set_inferior_startup_attach_manually()
+
 # Start the inferior, start the debug monitor, nothing is attached yet.
 procs = self.prep_debug_monitor_and_inferior(
 inferior_args=["sleep:60"])
@@ -49,15 +49,3 @@ def attach_with_vAttach(self):
 self.assertIsNotNone(pid_text)
 reported_pid = int(pid_text, base=16)
 self.assertEqual(reported_pid, inferior.pid)
-
-@debugserver_test
-def test_attach_with_vAttach_debugserver(self):
-self.build()
-self.set_inferior_startup_attach_manually()
-self.attach_with_vAttach()
-
-@llgs_test
-def test_attach_with_vAttach_llgs(self):
-self.build()
-self.set_inferior_startup_attach_manually()
-self.attach_with_vAttach()

diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
index e9eaab322821..22af21d132da 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
@@ -34,7 +34,7 @@ def init_lldb_server(self):
 def generate_hex_path(self, target):
 return str(os.path.join(self.getBuildDir(), target)).encode().hex()
 
-@llgs_test
+@add_test_categories(["llgs"])
 def test_autocomplete_path(self):
 self.build()
 self.init_lldb_server()

diff  --git 
a/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
index 103ecfd292cd..fcf115647801 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
@@ -57,45 +57,21 @@ def stop_notification_contains_generic_register(
 self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
 self.trace("{} reg_info:{}".format(generic_register_name, reg_info))
 
-def stop_notification_contains_aarch64_vg_register(self):
-# Generate a stop reply, parse out expedited registers from stop
-# notification.
-expedited_registers = self.gather_expedited_registers()
-self.assertIsNotNone(expedited_registers)
-self.assertTrue(len(expedited_registers) > 0)
-
-# Gather target register infos.
-reg_infos = self.gather_register_infos()
-
-# Find the vg register.
-reg_info = self.find_register_with_name_and_dwarf_regnum(
-reg_infos, 'vg', '46')
-self.assertIsNotNone(reg_info)
-
-# Ensure the expedited registers contained it.
-self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
-self.trace("{} reg_info:{}".format('vg', reg_info))
+def test_stop_notification_contains_any_registers(self):
+self.build()
+self.set_inferior_startup_launch()
 
-def stop_notification_contains_any_registers(self):
 # Generate a stop reply, parse out expedited registers from stop
 # notification.
 expedited_registers = self.gather_expedited_registers()
 # Verify we have at least one expedited register.
 self.assertTrue(len(expedited_registers) > 0)
 
-@debugserver_test
-def test_stop_notification_con

[llvm-branch-commits] [llvm] cf8f682 - [RISCV] Adjust tested vor ops for more stable tests. NFC.

2020-12-28 Thread Fraser Cormack via llvm-branch-commits

Author: Fraser Cormack
Date: 2020-12-28T19:33:25Z
New Revision: cf8f682c2dd478d76e729f5d998e56b9acef8aa4

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

LOG: [RISCV] Adjust tested vor ops for more stable tests. NFC.

Added: 


Modified: 
llvm/test/CodeGen/RISCV/rvv/vor-sdnode-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vor-sdnode-rv64.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/rvv/vor-sdnode-rv32.ll 
b/llvm/test/CodeGen/RISCV/rvv/vor-sdnode-rv32.ll
index f07f7fdea176..410da16bc3ab 100644
--- a/llvm/test/CodeGen/RISCV/rvv/vor-sdnode-rv32.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/vor-sdnode-rv32.ll
@@ -17,9 +17,9 @@ define  @vor_vx_nxv1i8_0( 
%va) {
 ; CHECK-LABEL: vor_vx_nxv1i8_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e8,mf8,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i8 -1, i32 0
+  %head = insertelement  undef, i8 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -66,9 +66,9 @@ define  @vor_vx_nxv2i8_0( 
%va) {
 ; CHECK-LABEL: vor_vx_nxv2i8_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e8,mf4,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i8 -1, i32 0
+  %head = insertelement  undef, i8 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -115,9 +115,9 @@ define  @vor_vx_nxv4i8_0( 
%va) {
 ; CHECK-LABEL: vor_vx_nxv4i8_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e8,mf2,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i8 -1, i32 0
+  %head = insertelement  undef, i8 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -164,9 +164,9 @@ define  @vor_vx_nxv8i8_0( 
%va) {
 ; CHECK-LABEL: vor_vx_nxv8i8_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e8,m1,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i8 -1, i32 0
+  %head = insertelement  undef, i8 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -213,9 +213,9 @@ define  @vor_vx_nxv16i8_0( %va) {
 ; CHECK-LABEL: vor_vx_nxv16i8_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e8,m2,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i8 -1, i32 0
+  %head = insertelement  undef, i8 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -262,9 +262,9 @@ define  @vor_vx_nxv32i8_0( %va) {
 ; CHECK-LABEL: vor_vx_nxv32i8_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e8,m4,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i8 -1, i32 0
+  %head = insertelement  undef, i8 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -311,9 +311,9 @@ define  @vor_vx_nxv64i8_0( %va) {
 ; CHECK-LABEL: vor_vx_nxv64i8_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e8,m8,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i8 -1, i32 0
+  %head = insertelement  undef, i8 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -360,9 +360,9 @@ define  @vor_vx_nxv1i16_0( %va) {
 ; CHECK-LABEL: vor_vx_nxv1i16_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e16,mf4,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i16 -1, i32 0
+  %head = insertelement  undef, i16 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -409,9 +409,9 @@ define  @vor_vx_nxv2i16_0( %va) {
 ; CHECK-LABEL: vor_vx_nxv2i16_0:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:vsetvli a0, zero, e16,mf2,ta,mu
-; CHECK-NEXT:vor.vi v16, v16, -1
+; CHECK-NEXT:vor.vi v16, v16, -12
 ; CHECK-NEXT:ret
-  %head = insertelement  undef, i16 -1, i32 0
+  %head = insertelement  undef, i16 -12, i32 0
   %splat = shufflevector  %head,  undef, 
 zeroinitializer
   %vc = or  %va, %splat
   ret  %vc
@@ -458,9 +458,9 @@ define  @vor_vx_nxv4i16_0( %va) {
 ; CHECK-LABEL: vor_vx_nxv4i16_0:
 ; CHECK:  

[llvm-branch-commits] [clang] 34405b4 - [CodeGen][ObjC] Destroy callee-destroyed arguments in the caller

2020-12-28 Thread Akira Hatanaka via llvm-branch-commits

Author: Akira Hatanaka
Date: 2020-12-28T11:52:27-08:00
New Revision: 34405b41d61580ff893057784b1b19f81f66bad3

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

LOG: [CodeGen][ObjC] Destroy callee-destroyed arguments in the caller
function when the receiver is nil

Callee-destroyed arguments to a method have to be destroyed in the
caller function when the receiver is nil as the method doesn't get
executed. This fixes PR48207.

rdar://71808391

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

Added: 
clang/test/CodeGenObjC/objc-dispatch-null-check.m

Modified: 
clang/include/clang/AST/Decl.h
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/test/CodeGenObjC/strong-in-c-struct.m
clang/test/CodeGenObjC/weak-in-c-struct.m
clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index ab24c8779df2..47c282f0a63d 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1664,6 +1664,9 @@ class ParmVarDecl : public VarDecl {
 return ParmVarDeclBits.IsObjCMethodParam;
   }
 
+  /// Determines whether this parameter is destroyed in the callee function.
+  bool isDestroyedInCallee() const;
+
   unsigned getFunctionScopeDepth() const {
 if (ParmVarDeclBits.IsObjCMethodParam) return 0;
 return ParmVarDeclBits.ScopeDepthOrObjCQuals;

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index f0c925f9cdf9..3cea3c23b527 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2738,6 +2738,17 @@ SourceRange ParmVarDecl::getSourceRange() const {
   return DeclaratorDecl::getSourceRange();
 }
 
+bool ParmVarDecl::isDestroyedInCallee() const {
+  if (hasAttr())
+return true;
+
+  auto *RT = getType()->getAs();
+  if (RT && RT->getDecl()->isParamDestroyedInCallee())
+return true;
+
+  return false;
+}
+
 Expr *ParmVarDecl::getDefaultArg() {
   assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!");
   assert(!hasUninstantiatedDefaultArg() &&

diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index dff86744698d..465d2c5449d5 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -1765,6 +1765,24 @@ struct NullReturnState {
   assert(RV.isScalar() &&
  "NullReturnState::complete - arg not on object");
   CGF.EmitARCRelease(RV.getScalarVal(), ARCImpreciseLifetime);
+} else {
+  QualType QT = ParamDecl->getType();
+  auto *RT = QT->getAs();
+  if (RT && RT->getDecl()->isParamDestroyedInCallee()) {
+RValue RV = I->getRValue(CGF);
+QualType::DestructionKind DtorKind = QT.isDestructedType();
+switch (DtorKind) {
+case QualType::DK_cxx_destructor:
+  CGF.destroyCXXObject(CGF, RV.getAggregateAddress(), QT);
+  break;
+case QualType::DK_nontrivial_c_struct:
+  CGF.destroyNonTrivialCStruct(CGF, RV.getAggregateAddress(), QT);
+  break;
+default:
+  llvm_unreachable("unexpected dtor kind");
+  break;
+}
+  }
 }
   }
 }
@@ -2241,7 +2259,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction 
&CGF,
   // Emit a null-check if there's a consumed argument other than the receiver.
   if (!RequiresNullCheck && CGM.getLangOpts().ObjCAutoRefCount && Method) {
 for (const auto *ParamDecl : Method->parameters()) {
-  if (ParamDecl->hasAttr()) {
+  if (ParamDecl->isDestroyedInCallee()) {
 RequiresNullCheck = true;
 break;
   }
@@ -7350,7 +7368,7 @@ 
CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF,
   bool requiresnullCheck = false;
   if (CGM.getLangOpts().ObjCAutoRefCount && method)
 for (const auto *ParamDecl : method->parameters()) {
-  if (ParamDecl->hasAttr()) {
+  if (ParamDecl->isDestroyedInCallee()) {
 if (!nullReturn.NullBB)
   nullReturn.init(CGF, arg0);
 requiresnullCheck = true;

diff  --git a/clang/test/CodeGenObjC/objc-dispatch-null-check.m 
b/clang/test/CodeGenObjC/objc-dispatch-null-check.m
new file mode 100644
index ..0c43955db2fa
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-dispatch-null-check.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 
-fobjc-dispatch-method=non-legacy -fobjc-arc -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: %[[STRUCT_STRONG:.*]] = type { i8* }
+
+typedef struct {
+  id x;
+} Strong;
+
+Strong getStrong(void);
+
+@interface I0
+- (void)passStrong:(Strong)a;
+@end
+
+// CHECK-LABEL: define void @test0(
+// CHECK: %[[AGG_TMP:.*]] = alloca %[[STRUCT_STRO

[llvm-branch-commits] [llvm] 6d02d12 - [AMDGPU][MC][NFC] Added more tests for flat_global

2020-12-28 Thread Dmitry Preobrazhensky via llvm-branch-commits

Author: Dmitry Preobrazhensky
Date: 2020-12-28T23:00:56+03:00
New Revision: 6d02d12e172ac85d750e1abe48a0c24559c63158

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

LOG: [AMDGPU][MC][NFC] Added more tests for flat_global

Restored tests from 7898803c638497ad32e2d4a189d5597d4eb4506e

Added: 


Modified: 
llvm/test/MC/AMDGPU/flat-global.s

Removed: 




diff  --git a/llvm/test/MC/AMDGPU/flat-global.s 
b/llvm/test/MC/AMDGPU/flat-global.s
index 77092e0b3493..10f152cc2f85 100644
--- a/llvm/test/MC/AMDGPU/flat-global.s
+++ b/llvm/test/MC/AMDGPU/flat-global.s
@@ -241,6 +241,26 @@ global_atomic_cmpswap v1, v3, v[5:6], s[2:3] glc
 // GFX9: global_atomic_cmpswap v1, v3, v[5:6], s[2:3] glc ; encoding: 
[0x00,0x80,0x05,0xdd,0x03,0x05,0x02,0x01]
 // VI-ERR: error: instruction not supported on this GPU
 
+global_atomic_cmpswap v1, v[2:3], v[4:5], off offset:-1 glc
+// GCN: global_atomic_cmpswap v1, v[2:3], v[4:5], off offset:-1 glc ; 
encoding: [0xff,0x9f,0x05,0xdd,0x02,0x04,0x7f,0x01]
+// GFX10: global_atomic_cmpswap v1, v[2:3], v[4:5], off offset:-1 glc ; 
encoding: [0xff,0x8f,0xc5,0xdc,0x02,0x04,0x7d,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap v1, v[2:3], v[254:255], off offset:-1 glc
+// GCN: global_atomic_cmpswap v1, v[2:3], v[254:255], off offset:-1 glc ; 
encoding: [0xff,0x9f,0x05,0xdd,0x02,0xfe,0x7f,0x01]
+// GFX10: global_atomic_cmpswap v1, v[2:3], v[254:255], off offset:-1 glc ; 
encoding: [0xff,0x8f,0xc5,0xdc,0x02,0xfe,0x7d,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap v1, v2, v[4:5], s[2:3] offset:-1 glc
+// GCN: global_atomic_cmpswap v1, v2, v[4:5], s[2:3] offset:-1 glc ; encoding: 
[0xff,0x9f,0x05,0xdd,0x02,0x04,0x02,0x01]
+// GFX10: global_atomic_cmpswap v1, v2, v[4:5], s[2:3] offset:-1 glc ; 
encoding: [0xff,0x8f,0xc5,0xdc,0x02,0x04,0x02,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap v1, v[2:3], v[4:5], off glc
+// GCN: global_atomic_cmpswap v1, v[2:3], v[4:5], off glc ; encoding: 
[0x00,0x80,0x05,0xdd,0x02,0x04,0x7f,0x01]
+// GFX10: global_atomic_cmpswap v1, v[2:3], v[4:5], off glc ; encoding: 
[0x00,0x80,0xc5,0xdc,0x02,0x04,0x7d,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
 global_atomic_cmpswap_x2 v[5:6], v[7:10], off
 // GFX10: encoding: [0x00,0x80,0x44,0xdd,0x05,0x07,0x7d,0x00]
 // GFX9: global_atomic_cmpswap_x2 v[5:6], v[7:10], off ; encoding: 
[0x00,0x80,0x84,0xdd,0x05,0x07,0x7f,0x00]
@@ -256,6 +276,26 @@ global_atomic_cmpswap_x2 v[1:2], v5, v[7:10], s[2:3] glc
 // GFX9: global_atomic_cmpswap_x2 v[1:2], v5, v[7:10], s[2:3] glc ; encoding: 
[0x00,0x80,0x85,0xdd,0x05,0x07,0x02,0x01]
 // VI-ERR: error: instruction not supported on this GPU
 
+global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off offset:-1 glc
+// GCN: global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off offset:-1 glc ; 
encoding: [0xff,0x9f,0x85,0xdd,0x05,0x07,0x7f,0x01]
+// GFX10: global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off offset:-1 glc 
; encoding: [0xff,0x8f,0x45,0xdd,0x05,0x07,0x7d,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[1:2], v[5:6], v[252:255], off offset:-1 glc
+// GCN: global_atomic_cmpswap_x2 v[1:2], v[5:6], v[252:255], off offset:-1 glc 
; encoding: [0xff,0x9f,0x85,0xdd,0x05,0xfc,0x7f,0x01]
+// GFX10: global_atomic_cmpswap_x2 v[1:2], v[5:6], v[252:255], off offset:-1 
glc ; encoding: [0xff,0x8f,0x45,0xdd,0x05,0xfc,0x7d,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[1:2], v5, v[252:255], s[2:3] offset:-1 glc
+// GCN: global_atomic_cmpswap_x2 v[1:2], v5, v[252:255], s[2:3] offset:-1 glc 
; encoding: [0xff,0x9f,0x85,0xdd,0x05,0xfc,0x02,0x01]
+// GFX10: global_atomic_cmpswap_x2 v[1:2], v5, v[252:255], s[2:3] offset:-1 
glc ; encoding: [0xff,0x8f,0x45,0xdd,0x05,0xfc,0x02,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
+global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off glc
+// GCN: global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off glc ; encoding: 
[0x00,0x80,0x85,0xdd,0x05,0x07,0x7f,0x01]
+// GFX10: global_atomic_cmpswap_x2 v[1:2], v[5:6], v[7:10], off glc ; 
encoding: [0x00,0x80,0x45,0xdd,0x05,0x07,0x7d,0x01]
+// VI-ERR: error: instruction not supported on this GPU
+
 global_atomic_swap v[3:4], v5, off
 // GFX10: encoding: [0x00,0x80,0xc0,0xdc,0x03,0x05,0x7d,0x00]
 // GFX9: global_atomic_swap v[3:4], v5, off   ; encoding: 
[0x00,0x80,0x00,0xdd,0x03,0x05,0x7f,0x00]



___
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] f931290 - [PowerPC] Parse and ignore .machine

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

Author: Fangrui Song
Date: 2020-12-28T12:20:40-08:00
New Revision: f931290308abd0eebecae385cd32ca3a25ddd9be

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

LOG: [PowerPC] Parse and ignore .machine

glibc/sysdeps/powerpc/powerpc64 has .machine
{altivec,power4,power5,power6,power7,power8} (.machine power9 is planned in
sysdeps/powerpc/powerpc64/power9/strcmp.S).
The diagnostic is not useful anyway so just delete it.

Added: 


Modified: 
llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
llvm/test/MC/PowerPC/ppc-machine.s

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp 
b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index 2ff87c20ab25..085acffdb5f0 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -1656,11 +1656,7 @@ bool PPCAsmParser::ParseDirectiveMachine(SMLoc L) {
 
   // FIXME: Right now, the parser always allows any available
   // instruction, so the .machine directive is not useful.
-  // Implement ".machine any" (by doing nothing) for the benefit
-  // of existing assembler code.  Likewise, we can then implement
-  // ".machine push" and ".machine pop" as no-op.
-  if (CPU != "any" && CPU != "push" && CPU != "pop" && CPU != "ppc64")
-return TokError("unrecognized machine type");
+  // In the wild, any/push/pop/ppc64/altivec/power[4-9] are seen.
 
   Parser.Lex();
 

diff  --git a/llvm/test/MC/PowerPC/ppc-machine.s 
b/llvm/test/MC/PowerPC/ppc-machine.s
index 22a6cd7ef73a..f7b71f868799 100644
--- a/llvm/test/MC/PowerPC/ppc-machine.s
+++ b/llvm/test/MC/PowerPC/ppc-machine.s
@@ -15,3 +15,8 @@
.machine "pop"
 
.machine ppc64
+
+# Used in glibc.
+   .machine altivec
+   .machine power4
+   .machine power8



___
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] ef93f7a - [SimplifyCFG] FoldBranchToCommonDest: gracefully handle unreachable code ()

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

Author: Roman Lebedev
Date: 2020-12-28T23:31:19+03:00
New Revision: ef93f7a11c347534ac768ec8bbbed64cd20c41d2

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

LOG: [SimplifyCFG] FoldBranchToCommonDest: gracefully handle unreachable code ()

We might be dealing with an unreachable code,
so the bonus instruction we clone might be self-referencing.

There is a sanity check that all uses of bonus instructions
that are not in the original block with said bonus instructions
are PHI nodes, and that is obviously not the case
for self-referencing instructions..

So if we find such an use, just rewrite it.

Thanks to Mikael Holmén for the reproducer!

Fixes https://bugs.llvm.org/show_bug.cgi?id=48450#c8

Added: 


Modified: 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 67e0d2ac9cd7..7d5f6daba7b2 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2986,6 +2986,13 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, 
DomTreeUpdater *DTU,
  "Non-external users are never PHI instructions.");
   return false;
 }
+if (User->getParent() == PredBlock) {
+  // The "exteral" use is in the block into which we just cloned 
the
+  // bonus instruction. This means two things: 1. we are in an
+  // unreachable block 2. the instruction is self-referencing.
+  // So let's just rewrite it...
+  return true;
+}
 (void)BI;
 assert(isa(User) && "All external users must be PHI's.");
 auto *PN = cast(User);

diff  --git a/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll 
b/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
index 3a70241fed16..7455cc691cf9 100644
--- a/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
+++ b/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
@@ -836,3 +836,57 @@ for.bodythread-pre-split.loopback:
 if.end.loopexit:
   ret void
 }
+
+@f.b = external global i16, align 1
+define void @pr48450_3() {
+; CHECK-LABEL: @pr48450_3(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[FOR_COND1:%.*]]
+; CHECK:   for.cond1:
+; CHECK-NEXT:[[V:%.*]] = load i16, i16* @f.b, align 1
+; CHECK-NEXT:[[CMP:%.*]] = icmp slt i16 [[V]], 1
+; CHECK-NEXT:call void @llvm.assume(i1 [[CMP]])
+; CHECK-NEXT:br label [[FOR_COND1]]
+;
+entry:
+  br label %for.cond1
+
+for.cond1:
+  %v = load i16, i16* @f.b, align 1
+  %cmp = icmp slt i16 %v, 1
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body:
+  br label %for.cond1
+
+for.end:
+  %tobool = icmp ne i16 %v, 0
+  br i1 %tobool, label %if.then, label %if.end
+
+if.then:
+  unreachable
+
+if.end:
+  br label %for.cond2
+
+for.cond2:
+  %c.0 = phi i16 [ undef, %if.end ], [ %inc, %if.end7 ]
+  %cmp3 = icmp slt i16 %c.0, 1
+  br i1 %cmp3, label %for.body4, label %for.cond.cleanup
+
+for.cond.cleanup:
+  br label %cleanup
+
+for.body4:
+  br i1 undef, label %if.then6, label %if.end7
+
+if.then6:
+  br label %cleanup
+
+if.end7:
+  %inc = add nsw i16 %c.0, 1
+  br label %for.cond2
+
+cleanup:
+  unreachable
+}



___
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] 87c032f - [IR] Make Value::getType() work better with invalid IR.

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

Author: Chris Lattner
Date: 2020-12-28T12:37:01-08:00
New Revision: 87c032f7b449cee97751d86739e249738029bf63

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

LOG: [IR] Make Value::getType() work better with invalid IR.

The asmprinter would crash when dumping IR objects that had their
operands dropped.  With this change, we now get this output, which
makes op->dump() style debugging more useful.

%5 = "firrtl.eq"(<>, <>) : (<>, <>) -> 
!firrtl.uint<1>

Previously the asmprinter would crash getting the types of the null operands.

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

Added: 


Modified: 
mlir/lib/IR/Value.cpp

Removed: 




diff  --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp
index fd7e5b5d64e5..b29641a084a0 100644
--- a/mlir/lib/IR/Value.cpp
+++ b/mlir/lib/IR/Value.cpp
@@ -32,6 +32,11 @@ Value::Value(Operation *op, unsigned resultNo) {
 
 /// Return the type of this value.
 Type Value::getType() const {
+  // Support a null Value so the asmprinter doesn't crash on invalid IR (e.g.
+  // operations that have dropAllReferences() called on them).
+  if (!*this)
+return Type();
+
   if (BlockArgument arg = dyn_cast())
 return arg.getType();
 



___
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] 1351f71 - [InstSimplify] add tests for ctpop; NFC (PR48608)

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

Author: Sanjay Patel
Date: 2020-12-28T16:06:19-05:00
New Revision: 1351f719d49642f7f1254d13e90d8d3a2824dcde

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

LOG: [InstSimplify] add tests for ctpop; NFC (PR48608)

Added: 


Modified: 
llvm/test/Transforms/InstSimplify/call.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstSimplify/call.ll 
b/llvm/test/Transforms/InstSimplify/call.ll
index bfbd101b046c..fa73e07b4c45 100644
--- a/llvm/test/Transforms/InstSimplify/call.ll
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -1287,6 +1287,8 @@ define i32 @call_undef_musttail() {
 
 ; This is not the builtin fmax, so we don't know anything about its behavior.
 
+declare float @fmaxf(float, float)
+
 define float @nobuiltin_fmax() {
 ; CHECK-LABEL: @nobuiltin_fmax(
 ; CHECK-NEXT:[[M:%.*]] = call float @fmaxf(float 0.00e+00, float 
1.00e+00) [[ATTR3:#.*]]
@@ -1298,6 +1300,62 @@ define float @nobuiltin_fmax() {
   ret float %r
 }
 
-declare float @fmaxf(float, float)
+
+declare i32 @llvm.ctpop.i32(i32)
+declare <3 x i33> @llvm.ctpop.v3i33(<3 x i33>)
+declare i1 @llvm.ctpop.i1(i1)
+
+define i32 @ctpop_lowbit(i32 %x) {
+; CHECK-LABEL: @ctpop_lowbit(
+; CHECK-NEXT:[[B:%.*]] = and i32 [[X:%.*]], 1
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.ctpop.i32(i32 [[B]])
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %b = and i32 %x, 1
+  %r = call i32 @llvm.ctpop.i32(i32 %b)
+  ret i32 %r
+}
+
+define i32 @ctpop_pow2(i32 %x) {
+; CHECK-LABEL: @ctpop_pow2(
+; CHECK-NEXT:[[B:%.*]] = and i32 [[X:%.*]], 4
+; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.ctpop.i32(i32 [[B]])
+; CHECK-NEXT:ret i32 [[R]]
+;
+  %b = and i32 %x, 4
+  %r = call i32 @llvm.ctpop.i32(i32 %b)
+  ret i32 %r
+}
+
+define <3 x i33> @ctpop_signbit(<3 x i33> %x) {
+; CHECK-LABEL: @ctpop_signbit(
+; CHECK-NEXT:[[B:%.*]] = lshr <3 x i33> [[X:%.*]], 
+; CHECK-NEXT:[[R:%.*]] = tail call <3 x i33> @llvm.ctpop.v3i33(<3 x i33> 
[[B]])
+; CHECK-NEXT:ret <3 x i33> [[R]]
+;
+  %b = lshr <3 x i33> %x, 
+  %r = tail call <3 x i33> @llvm.ctpop.v3i33(<3 x i33> %b)
+  ret <3 x i33> %r
+}
+
+define <3 x i33> @ctpop_notsignbit(<3 x i33> %x) {
+; CHECK-LABEL: @ctpop_notsignbit(
+; CHECK-NEXT:[[B:%.*]] = lshr <3 x i33> [[X:%.*]], 
+; CHECK-NEXT:[[R:%.*]] = tail call <3 x i33> @llvm.ctpop.v3i33(<3 x i33> 
[[B]])
+; CHECK-NEXT:ret <3 x i33> [[R]]
+;
+  %b = lshr <3 x i33> %x, 
+  %r = tail call <3 x i33> @llvm.ctpop.v3i33(<3 x i33> %b)
+  ret <3 x i33> %r
+}
+
+define i1 @ctpop_bool(i1 %x) {
+; CHECK-LABEL: @ctpop_bool(
+; CHECK-NEXT:[[R:%.*]] = tail call i1 @llvm.ctpop.i1(i1 [[X:%.*]])
+; CHECK-NEXT:ret i1 [[R]]
+;
+  %r = tail call i1 @llvm.ctpop.i1(i1 %x)
+  ret i1 %r
+}
 
 attributes #0 = { nobuiltin readnone }



___
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] 236c452 - [InstSimplify] remove ctpop of 1 (low) bit

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

Author: Sanjay Patel
Date: 2020-12-28T16:06:20-05:00
New Revision: 236c4524a7cd3051a150690b4f4f55f496e7e248

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

LOG: [InstSimplify] remove ctpop of 1 (low) bit

https://llvm.org/PR48608

As noted in the test comment, we could handle a more general
case in instcombine and remove this, but I don't have evidence
that we need to do that.

https://alive2.llvm.org/ce/z/MRW9gD

Added: 


Modified: 
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/ctpop.ll
llvm/test/Transforms/InstSimplify/call.ll

Removed: 




diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp 
b/llvm/lib/Analysis/InstructionSimplify.cpp
index 27b73a5a8236..30c7ecff7940 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5246,6 +5246,15 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value 
*Op0,
 // bitreverse(bitreverse(x)) -> x
 if (match(Op0, m_BitReverse(m_Value(X return X;
 break;
+  case Intrinsic::ctpop: {
+// If everything but the lowest bit is zero, that bit is the pop-count. Ex:
+// ctpop(and X, 1) --> and X, 1
+unsigned BitWidth = Op0->getType()->getScalarSizeInBits();
+if (MaskedValueIsZero(Op0, APInt::getHighBitsSet(BitWidth, BitWidth - 1),
+  Q.DL, 0, Q.AC, Q.CxtI, Q.DT))
+  return Op0;
+break;
+  }
   case Intrinsic::exp:
 // exp(log(x)) -> x
 if (Q.CxtI->hasAllowReassoc() &&

diff  --git a/llvm/test/Transforms/InstCombine/ctpop.ll 
b/llvm/test/Transforms/InstCombine/ctpop.ll
index 33b95b02dd2e..237fb0458225 100644
--- a/llvm/test/Transforms/InstCombine/ctpop.ll
+++ b/llvm/test/Transforms/InstCombine/ctpop.ll
@@ -84,11 +84,11 @@ define <2 x i1> @test5vec(<2 x i32> %arg) {
   ret <2 x i1> %res
 }
 
-; Make sure we don't add range metadata to i1 ctpop.
+; No intrinsic or range needed - ctpop of bool bit is the bit itself.
+
 define i1 @test6(i1 %arg) {
 ; CHECK-LABEL: @test6(
-; CHECK-NEXT:[[CNT:%.*]] = call i1 @llvm.ctpop.i1(i1 [[ARG:%.*]])
-; CHECK-NEXT:ret i1 [[CNT]]
+; CHECK-NEXT:ret i1 [[ARG:%.*]]
 ;
   %cnt = call i1 @llvm.ctpop.i1(i1 %arg)
   ret i1 %cnt

diff  --git a/llvm/test/Transforms/InstSimplify/call.ll 
b/llvm/test/Transforms/InstSimplify/call.ll
index fa73e07b4c45..841582ab8974 100644
--- a/llvm/test/Transforms/InstSimplify/call.ll
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -1308,14 +1308,16 @@ declare i1 @llvm.ctpop.i1(i1)
 define i32 @ctpop_lowbit(i32 %x) {
 ; CHECK-LABEL: @ctpop_lowbit(
 ; CHECK-NEXT:[[B:%.*]] = and i32 [[X:%.*]], 1
-; CHECK-NEXT:[[R:%.*]] = call i32 @llvm.ctpop.i32(i32 [[B]])
-; CHECK-NEXT:ret i32 [[R]]
+; CHECK-NEXT:ret i32 [[B]]
 ;
   %b = and i32 %x, 1
   %r = call i32 @llvm.ctpop.i32(i32 %b)
   ret i32 %r
 }
 
+; Negative test - only low bit allowed
+; This could be reduced by instcombine to and+shift.
+
 define i32 @ctpop_pow2(i32 %x) {
 ; CHECK-LABEL: @ctpop_pow2(
 ; CHECK-NEXT:[[B:%.*]] = and i32 [[X:%.*]], 4
@@ -1330,14 +1332,15 @@ define i32 @ctpop_pow2(i32 %x) {
 define <3 x i33> @ctpop_signbit(<3 x i33> %x) {
 ; CHECK-LABEL: @ctpop_signbit(
 ; CHECK-NEXT:[[B:%.*]] = lshr <3 x i33> [[X:%.*]], 
-; CHECK-NEXT:[[R:%.*]] = tail call <3 x i33> @llvm.ctpop.v3i33(<3 x i33> 
[[B]])
-; CHECK-NEXT:ret <3 x i33> [[R]]
+; CHECK-NEXT:ret <3 x i33> [[B]]
 ;
   %b = lshr <3 x i33> %x, 
   %r = tail call <3 x i33> @llvm.ctpop.v3i33(<3 x i33> %b)
   ret <3 x i33> %r
 }
 
+; Negative test - only 1 bit allowed
+
 define <3 x i33> @ctpop_notsignbit(<3 x i33> %x) {
 ; CHECK-LABEL: @ctpop_notsignbit(
 ; CHECK-NEXT:[[B:%.*]] = lshr <3 x i33> [[X:%.*]], 
@@ -1351,8 +1354,7 @@ define <3 x i33> @ctpop_notsignbit(<3 x i33> %x) {
 
 define i1 @ctpop_bool(i1 %x) {
 ; CHECK-LABEL: @ctpop_bool(
-; CHECK-NEXT:[[R:%.*]] = tail call i1 @llvm.ctpop.i1(i1 [[X:%.*]])
-; CHECK-NEXT:ret i1 [[R]]
+; CHECK-NEXT:ret i1 [[X:%.*]]
 ;
   %r = tail call i1 @llvm.ctpop.i1(i1 %x)
   ret i1 %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] 4a16c50 - [InstCombine] Disable unsafe select transform behind a flag

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

Author: Nikita Popov
Date: 2020-12-28T22:43:52+01:00
New Revision: 4a16c507cb68e425226e81598d91963aacdd57ed

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

LOG: [InstCombine] Disable unsafe select transform behind a flag

This disables the poison-unsafe select -> and/or transform behind
a flag (we continue to perform the fold by default). This is intended
to simplify evaluation and testing while we teach various passes
to directly recognize the select pattern.

This only disables the main select -> and/or transform. A number of
related ones are instead changed to canonicalize to the a ? b : false
and a ? true : b forms which represent and/or respectively. This
requires a bit of care to avoid infinite loops, as we do not want
!a ? b : false to be converted into a ? false : b.

The basic idea here is the same as D93065, but keeps the change
behind a flag for now.

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

Added: 
llvm/test/Transforms/InstCombine/select-and-or.ll

Modified: 
llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h 
b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
index aee6e3734baa..a5aed720cda6 100644
--- a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
+++ b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
@@ -213,6 +213,17 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {

Pred,
Constant 
*C);
 
+  static bool shouldAvoidAbsorbingNotIntoSelect(const SelectInst &SI) {
+// a ? b : false and a ? true : b are the canonical form of logical and/or.
+// This includes !a ? b : false and !a ? true : b. Absorbing the not into
+// the select by swapping operands would break recognition of this pattern
+// in other analyses, so don't do that.
+return match(&SI, PatternMatch::m_LogicalAnd(PatternMatch::m_Value(),
+ PatternMatch::m_Value())) ||
+   match(&SI, PatternMatch::m_LogicalOr(PatternMatch::m_Value(),
+PatternMatch::m_Value()));
+  }
+
   /// Return true if the specified value is free to invert (apply ~ to).
   /// This happens in cases where the ~ can be eliminated.  If 
WillInvertAllUses
   /// is true, work under the assumption that the caller intends to remove all
@@ -267,6 +278,8 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
   case Instruction::Select:
 if (U.getOperandNo() != 0) // Only if the value is used as select cond.
   return false;
+if (shouldAvoidAbsorbingNotIntoSelect(*cast(I)))
+  return false;
 break;
   case Instruction::Br:
 assert(U.getOperandNo() == 0 && "Must be branching on that value.");

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 075667629c5f..5dcea0f5cdf1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -47,6 +47,11 @@ using namespace PatternMatch;
 
 #define DEBUG_TYPE "instcombine"
 
+/// FIXME: Enabled by default until the pattern is supported well.
+static cl::opt EnableUnsafeSelectTransform(
+"instcombine-unsafe-select-transform", cl::init(true),
+cl::desc("Enable poison-unsafe select to and/or transform"));
+
 static Value *createMinMax(InstCombiner::BuilderTy &Builder,
SelectPatternFlavor SPF, Value *A, Value *B) {
   CmpInst::Predicate Pred = getMinMaxPred(SPF);
@@ -2567,38 +2572,43 @@ Instruction 
*InstCombinerImpl::visitSelectInst(SelectInst &SI) {
 
   if (SelType->isIntOrIntVectorTy(1) &&
   TrueVal->getType() == CondVal->getType()) {
-if (match(TrueVal, m_One())) {
+if (EnableUnsafeSelectTransform && match(TrueVal, m_One())) {
   // Change: A = select B, true, C --> A = or B, C
   return BinaryOperator::CreateOr(CondVal, FalseVal);
 }
-if (match(TrueVal, m_Zero())) {
-  // Change: A = select B, false, C --> A = and !B, C
-  Value *NotCond = Builder.CreateNot(CondVal, "not." + CondVal->getName());
-  return BinaryOperator::CreateAnd(NotCond, FalseVal);
-}
-if (match(FalseVal, m_Zero())) {
+if (EnableUnsafeSelectTransform && match(FalseVal, m_Zero())) {
   // Change: A = select B, C, false --> A = and B, C
   return BinaryOperator::CreateAnd(CondVal, TrueVal);
 }
+
+// select a, false, b -> select !a, b, false
+if (match(TrueVal, m_Zero())) {
+  Value *Not

[llvm-branch-commits] [llvm] 0f2c180 - [ValueTracking] Implement impliesPoison

2020-12-28 Thread Juneyoung Lee via llvm-branch-commits

Author: Juneyoung Lee
Date: 2020-12-29T06:50:38+09:00
New Revision: 0f2c180163a2cc3d6239a32d379ec3d773e56a2f

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

LOG: [ValueTracking] Implement impliesPoison

This PR adds impliesPoison(ValAssumedPoison, V) that returns true if V is
poison under the assumption that ValAssumedPoison is poison.

For example, impliesPoison('icmp X, 10', 'icmp X, Y') return true because
'icmp X, Y' is poison if 'icmp X, 10' is poison.

impliesPoison can be used for sound optimization of select, as discussed in
D77868.

Reviewed By: nikic

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

Added: 


Modified: 
llvm/include/llvm/Analysis/ValueTracking.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/unittests/Analysis/ValueTrackingTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/ValueTracking.h 
b/llvm/include/llvm/Analysis/ValueTracking.h
index f8ca8b8015bf..86c0991451c5 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -620,6 +620,11 @@ constexpr unsigned MaxAnalysisRecursionDepth = 6;
   bool canCreateUndefOrPoison(const Operator *Op);
   bool canCreatePoison(const Operator *Op);
 
+  /// Return true if V is poison given that ValAssumedPoison is already poison.
+  /// For example, if ValAssumedPoison is `icmp X, 10` and V is `icmp X, 5`,
+  /// impliesPoison returns true.
+  bool impliesPoison(const Value *ValAssumedPoison, const Value *V);
+
   /// Return true if this function can prove that V does not have undef bits
   /// and is never poison. If V is an aggregate value or vector, check whether
   /// all elements (except padding) are not undef or poison.

diff  --git a/llvm/lib/Analysis/ValueTracking.cpp 
b/llvm/lib/Analysis/ValueTracking.cpp
index 0e32e7f4b102..303240d03c72 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4809,6 +4809,64 @@ bool llvm::canCreatePoison(const Operator *Op) {
   return ::canCreateUndefOrPoison(Op, /*PoisonOnly=*/true);
 }
 
+bool llvm::impliesPoison(const Value *ValAssumedPoison, const Value *V) {
+  // Construct a set of values which are known to be poison from the knowledge
+  // that ValAssumedPoison is poison.
+  SmallPtrSet PoisonValues;
+  PoisonValues.insert(ValAssumedPoison);
+  const Instruction *PoisonI = dyn_cast(ValAssumedPoison);
+  unsigned Depth = 0;
+  const unsigned MaxDepth = 2;
+
+  while (PoisonI && Depth < MaxDepth) {
+// We'd like to know whether an operand of PoisonI is also poison.
+if (canCreatePoison(cast(PoisonI)))
+  // PoisonI can be a poison-generating instruction, so don't look further
+  break;
+
+const Value *NextVal = nullptr;
+bool MoreThanOneCandidate = false;
+// See which operand can be poison
+for (const auto &Op : PoisonI->operands()) {
+  if (!isGuaranteedNotToBeUndefOrPoison(Op.get())) {
+// Op can be poison.
+if (NextVal) {
+  // There is more than one operand that can make PoisonI poison.
+  MoreThanOneCandidate = true;
+  break;
+}
+NextVal = Op.get();
+  }
+}
+
+if (NextVal == nullptr) {
+  // All operands are non-poison, so PoisonI cannot be poison.
+  // Since assumption is false, return true
+  return true;
+} else if (MoreThanOneCandidate)
+  break;
+
+Depth++;
+PoisonValues.insert(NextVal);
+PoisonI = dyn_cast(NextVal);
+  }
+
+  if (PoisonValues.contains(V))
+return true;
+
+  // Let's look one level further, by seeing its arguments if I was an
+  // instruction.
+  // This happens when I is e.g. 'icmp X, const' where X is in PoisonValues.
+  const auto *I = dyn_cast(V);
+  if (I && propagatesPoison(cast(I))) {
+for (const auto &Op : I->operands())
+  if (PoisonValues.count(Op.get()))
+return true;
+  }
+
+  return false;
+}
+
 static bool programUndefinedIfUndefOrPoison(const Value *V,
 bool PoisonOnly);
 

diff  --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp 
b/llvm/unittests/Analysis/ValueTrackingTest.cpp
index 8d24f524b59d..009166a24a1f 100644
--- a/llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -695,6 +695,59 @@ TEST_F(ValueTrackingTest, ComputeNumSignBits_Shuffle2) {
   EXPECT_EQ(ComputeNumSignBits(A, M->getDataLayout()), 1u);
 }
 
+TEST_F(ValueTrackingTest, impliesPoisonTest_Identity) {
+  parseAssembly("define void @test(i32 %x, i32 %y) {\n"
+"  %A = add i32 %x, %y\n"
+"  ret void\n"
+"}");
+  EXPECT_TRUE(impliesPoison(A, A));
+}
+
+TEST_F(ValueTrackingTest, impliesPoisonTest_ICmp) {
+  parseAssembly("define void @test(i32 %x) {\n"

[llvm-branch-commits] [llvm] 44ee14f - [WebAssembly][NFC] Finish cleaning up SIMD tablegen

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

Author: Thomas Lively
Date: 2020-12-28T13:59:23-08:00
New Revision: 44ee14f993ff093c3c3ef65ab5aa1fdd3f7a1dc6

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

LOG: [WebAssembly][NFC] Finish cleaning up SIMD tablegen

This commit is a follow-on to c2c2e9119e73, using the `Vec` records introduced
in that commit in the rest of the SIMD instruction definitions. Also removes
unnecessary types in output patterns.

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

Added: 


Modified: 
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp

Removed: 




diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td 
b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index df4de49ee4c8..707b7e3998d0 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -37,74 +37,98 @@ def ImmI#SIZE : ImmLeaf;
 
+// Create vector with identical lanes: splat
+def splat2 : PatFrag<(ops node:$x), (build_vector $x, $x)>;
+def splat4 : PatFrag<(ops node:$x), (build_vector $x, $x, $x, $x)>;
+def splat8 : PatFrag<(ops node:$x), (build_vector $x, $x, $x, $x,
+  $x, $x, $x, $x)>;
+def splat16 : PatFrag<(ops node:$x),
+  (build_vector $x, $x, $x, $x, $x, $x, $x, $x,
+$x, $x, $x, $x, $x, $x, $x, $x)>;
+
 class Vec {
   ValueType vt;
+  ValueType int_vt;
   ValueType lane_vt;
   WebAssemblyRegClass lane_rc;
   int lane_bits;
   ImmLeaf lane_idx;
+  PatFrag splat;
   string prefix;
   Vec split;
 }
 
 def I8x16 : Vec {
   let vt = v16i8;
+  let int_vt = vt;
   let lane_vt = i32;
   let lane_rc = I32;
   let lane_bits = 8;
   let lane_idx = LaneIdx16;
+  let splat = splat16;
   let prefix = "i8x16";
 }
 
 def I16x8 : Vec {
   let vt = v8i16;
+  let int_vt = vt;
   let lane_vt = i32;
   let lane_rc = I32;
   let lane_bits = 16;
   let lane_idx = LaneIdx8;
+  let splat = splat8;
   let prefix = "i16x8";
   let split = I8x16;
 }
 
 def I32x4 : Vec {
   let vt = v4i32;
+  let int_vt = vt;
   let lane_vt = i32;
   let lane_rc = I32;
   let lane_bits = 32;
   let lane_idx = LaneIdx4;
+  let splat = splat4;
   let prefix = "i32x4";
   let split = I16x8;
 }
 
 def I64x2 : Vec {
   let vt = v2i64;
+  let int_vt = vt;
   let lane_vt = i64;
   let lane_rc = I64;
   let lane_bits = 64;
   let lane_idx = LaneIdx2;
+  let splat = splat2;
   let prefix = "i64x2";
   let split = I32x4;
 }
 
 def F32x4 : Vec {
   let vt = v4f32;
+  let int_vt = v4i32;
   let lane_vt = f32;
   let lane_rc = F32;
   let lane_bits = 32;
   let lane_idx = LaneIdx4;
+  let splat = splat4;
   let prefix = "f32x4";
 }
 
 def F64x2 : Vec {
   let vt = v2f64;
+  let int_vt = v2i64;
   let lane_vt = f64;
   let lane_rc = F64;
   let lane_bits = 64;
   let lane_idx = LaneIdx2;
+  let splat = splat2;
   let prefix = "f64x2";
 }
 
 defvar AllVecs = [I8x16, I16x8, I32x4, I64x2, F32x4, F64x2];
+defvar IntVecs = [I8x16, I16x8, I32x4, I64x2];
 
 
//===--===//
 // Load and store
@@ -289,11 +313,11 @@ multiclass LoadLanePatNoOffset {
   defvar load_lane_a64 = !cast("LOAD_LANE_"#vec#"_A64");
   def : Pat<(vec.vt (kind (i32 I32:$addr),
   (vec.vt V128:$vec), (i32 vec.lane_idx:$idx))),
-(load_lane_a32 0, 0, imm:$idx, I32:$addr, V128:$vec)>,
+(load_lane_a32 0, 0, imm:$idx, $addr, $vec)>,
 Requires<[HasAddr32]>;
   def : Pat<(vec.vt (kind (i64 I64:$addr),
   (vec.vt V128:$vec), (i32 vec.lane_idx:$idx))),
-(load_lane_a64 0, 0, imm:$idx, I64:$addr, V128:$vec)>,
+(load_lane_a64 0, 0, imm:$idx, $addr, $vec)>,
 Requires<[HasAddr64]>;
 }
 
@@ -359,12 +383,10 @@ defm "" : SIMDStoreLane;
 // Select stores with no constant offset.
 multiclass StoreLanePatNoOffset {
   def : Pat<(kind (i32 I32:$addr), (vec.vt V128:$vec), (i32 
vec.lane_idx:$idx)),
-(!cast("STORE_LANE_"#vec#"_A32")
-  0, 0, imm:$idx, I32:$addr, vec.vt:$vec)>,
+(!cast("STORE_LANE_"#vec#"_A32") 0, 0, imm:$idx, $addr, $vec)>,
 Requires<[HasAddr32]>;
   def : Pat<(kind (i64 I64:$addr), (vec.vt V128:$vec), (i32 
vec.lane_idx:$idx)),
-(!cast("STORE_LANE_"#vec#"_A64")
-  0, 0, imm:$idx, I64:$addr, vec.vt:$vec)>,
+(!cast("STORE_LANE_"#vec#"_A64") 0, 0, imm:$idx, $addr, $vec)>,
 Requires<[HasAddr64]>;
 }
 
@@ -381,16 +403,16 @@ defm : StoreLanePatNoOffset;
 
//===--===//
 
 // Constant: v128.const
-multiclass ConstVec {
+multiclass ConstVec {
   let isMoveImm = 1, isReMaterializab

[llvm-branch-commits] [llvm] 6c36286 - [NewPM] Fix CGSCCOptimizerLateEPCallbacks place in pipeline

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

Author: Arthur Eubanks
Date: 2020-12-28T14:03:10-08:00
New Revision: 6c36286a2e180443005d31a9cec2ca182963bcad

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

LOG: [NewPM] Fix CGSCCOptimizerLateEPCallbacks place in pipeline

CGSCCOptimizerLateEPCallbacks are supposed to be run before the function
simplification pipeline, like in the legacy PM and as specified in the
comments for registerCGSCCOptimizerLateEPCallback().

Reviewed By: ychen

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

Added: 


Modified: 
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/new-pm-defaults.ll

Removed: 




diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 635e7bab1a7a..1f1004c2c414 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -986,14 +986,14 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel 
Level, ThinLTOPhase Phase,
   if (Level == OptimizationLevel::O2 || Level == OptimizationLevel::O3)
 MainCGPipeline.addPass(OpenMPOptPass());
 
+  for (auto &C : CGSCCOptimizerLateEPCallbacks)
+C(MainCGPipeline, Level);
+
   // Lastly, add the core function simplification pipeline nested inside the
   // CGSCC walk.
   MainCGPipeline.addPass(createCGSCCToFunctionPassAdaptor(
   buildFunctionSimplificationPipeline(Level, Phase)));
 
-  for (auto &C : CGSCCOptimizerLateEPCallbacks)
-C(MainCGPipeline, Level);
-
   return MIWP;
 }
 
@@ -1800,6 +1800,13 @@ ModulePassManager 
PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
 MPM.addPass(
 createModuleToFunctionPassAdaptor(LowerMatrixIntrinsicsPass(true)));
 
+  if (!CGSCCOptimizerLateEPCallbacks.empty()) {
+CGSCCPassManager CGPM(DebugLogging);
+for (auto &C : CGSCCOptimizerLateEPCallbacks)
+  C(CGPM, Level);
+if (!CGPM.isEmpty())
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+  }
   if (!LateLoopOptimizationsEPCallbacks.empty()) {
 LoopPassManager LPM(DebugLogging);
 for (auto &C : LateLoopOptimizationsEPCallbacks)
@@ -1825,13 +1832,6 @@ ModulePassManager 
PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
 if (!FPM.isEmpty())
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
-  if (!CGSCCOptimizerLateEPCallbacks.empty()) {
-CGSCCPassManager CGPM(DebugLogging);
-for (auto &C : CGSCCOptimizerLateEPCallbacks)
-  C(CGPM, Level);
-if (!CGPM.isEmpty())
-  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
-  }
   if (!VectorizerStartEPCallbacks.empty()) {
 FunctionPassManager FPM(DebugLogging);
 for (auto &C : VectorizerStartEPCallbacks)

diff  --git a/llvm/test/Other/new-pm-defaults.ll 
b/llvm/test/Other/new-pm-defaults.ll
index 6377aa0cd813..62f9d895fa72 100644
--- a/llvm/test/Other/new-pm-defaults.ll
+++ b/llvm/test/Other/new-pm-defaults.ll
@@ -128,6 +128,7 @@
 ; CHECK-O3-NEXT: Running pass: ArgumentPromotionPass
 ; CHECK-O2-NEXT: Running pass: OpenMPOptPass on (foo)
 ; CHECK-O3-NEXT: Running pass: OpenMPOptPass on (foo)
+; CHECK-EP-CGSCC-LATE-NEXT: Running pass: NoOpCGSCCPass
 ; CHECK-O-NEXT: Starting llvm::Function pass manager run.
 ; CHECK-O-NEXT: Running pass: SROA
 ; CHECK-O-NEXT: Running pass: EarlyCSEPass
@@ -206,7 +207,6 @@
 ; CHECK-O-NEXT: Running pass: InstCombinePass
 ; CHECK-EP-PEEPHOLE-NEXT: Running pass: NoOpFunctionPass
 ; CHECK-O-NEXT: Finished llvm::Function pass manager run.
-; CHECK-EP-CGSCC-LATE-NEXT: Running pass: NoOpCGSCCPass
 ; CHECK-O-NEXT: Finished CGSCC pass manager run.
 ; CHECK-O-NEXT: Finished llvm::Module pass manager run.
 ; CHECK-O-NEXT: Running pass: GlobalOptPass



___
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] 5e09e99 - [WebAssembly] Prototype extending pairwise add instructions

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

Author: Thomas Lively
Date: 2020-12-28T14:11:14-08:00
New Revision: 5e09e9979bc60f0fca0e80e7f72f1260bd1bbca5

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

LOG: [WebAssembly] Prototype extending pairwise add instructions

As proposed in https://github.com/WebAssembly/simd/pull/380. This commit makes
the new instructions available only via clang builtins and LLVM intrinsics to
make their use opt-in while they are still being evaluated for inclusion in the
SIMD proposal.

Depends on D93771.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 023365bec7f8..d6860e0b13be 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -133,6 +133,12 @@ TARGET_BUILTIN(__builtin_wasm_extmul_high_i32x4_s_i64x2, 
"V2LLiV4iV4i", "nc", "s
 TARGET_BUILTIN(__builtin_wasm_extmul_low_i32x4_u_i64x2, "V2ULLiV4UiV4Ui", 
"nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_extmul_high_i32x4_u_i64x2, "V2ULLiV4UiV4Ui", 
"nc", "simd128")
 
+TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i8x16_s_i16x8, "V8sV16Sc", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i8x16_u_i16x8, "V8UsV16Uc", 
"nc", "simd128")
+
+TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i16x8_s_i32x4, "V4iV8s", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i16x8_u_i32x4, "V4UiV8Us", "nc", 
"simd128")
+
 TARGET_BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_signselect_i8x16, "V16ScV16ScV16ScV16Sc", "nc", 
"simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 60bfa90e22fc..0c02dbfe8469 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16932,6 +16932,28 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_extadd_pairwise_i8x16_s_i16x8:
+  case WebAssembly::BI__builtin_wasm_extadd_pairwise_i8x16_u_i16x8:
+  case WebAssembly::BI__builtin_wasm_extadd_pairwise_i16x8_s_i32x4:
+  case WebAssembly::BI__builtin_wasm_extadd_pairwise_i16x8_u_i32x4: {
+Value *Vec = EmitScalarExpr(E->getArg(0));
+unsigned IntNo;
+switch (BuiltinID) {
+case WebAssembly::BI__builtin_wasm_extadd_pairwise_i8x16_s_i16x8:
+case WebAssembly::BI__builtin_wasm_extadd_pairwise_i16x8_s_i32x4:
+  IntNo = Intrinsic::wasm_extadd_pairwise_signed;
+  break;
+case WebAssembly::BI__builtin_wasm_extadd_pairwise_i8x16_u_i16x8:
+case WebAssembly::BI__builtin_wasm_extadd_pairwise_i16x8_u_i32x4:
+  IntNo = Intrinsic::wasm_extadd_pairwise_unsigned;
+  break;
+default:
+  llvm_unreachable("unexptected builtin ID");
+}
+
+Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
+return Builder.CreateCall(Callee, Vec);
+  }
   case WebAssembly::BI__builtin_wasm_bitselect: {
 Value *V1 = EmitScalarExpr(E->getArg(0));
 Value *V2 = EmitScalarExpr(E->getArg(1));

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index 76dd2622fe2f..a07c278c33af 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -603,6 +603,34 @@ u64x2 extmul_high_i32x4_u_i64x2(u32x4 x, u32x4 y) {
   // WEBASSEMBLY-NEXT: ret
 }
 
+i16x8 extadd_pairwise_i8x16_s_i16x8(i8x16 v) {
+  return __builtin_wasm_extadd_pairwise_i8x16_s_i16x8(v);
+  // WEBASSEMBLY: call <8 x i16> @llvm.wasm.extadd.pairwise.signed.v8i16(
+  // WEBASSEMBLY-SAME: <16 x i8> %v)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+u16x8 extadd_pairwise_i8x16_u_i16x8(u8x16 v) {
+  return __builtin_wasm_extadd_pairwise_i8x16_u_i16x8(v);
+  // WEBASSEMBLY: call <8 x i16> @llvm.wasm.extadd.pairwise.unsigned.v8i16(
+  // WEBASSEMBLY-SAME: <16 x i8> %v)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+i32x4 extadd_pairwise_i16x8_s_i32x4(i16x8 v) {
+  return __builtin_wasm_extadd_pairwise_i16x8_s_i32x4(v);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.extadd.pairwise.signed.v4i32(
+  // WEBASSEMBLY-SAME: <8 x i16> %v)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+u32x4 extadd_pairwise_i16x8_u_i32x4(u16x8 v) {
+  return __builtin_wasm_extadd_pairwise_i16x8_u_i32

[llvm-branch-commits] [mlir] 25007b4 - [MLIR][NFC] Change FunctionLike::setAllArgAttrs/setAllResultAttrs to do a one-shot attribute update.

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

Author: Rahul Joshi
Date: 2020-12-28T14:15:47-08:00
New Revision: 25007b4d7e094c569d512770bd2397d8667fd3db

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

LOG: [MLIR][NFC] Change FunctionLike::setAllArgAttrs/setAllResultAttrs to do a 
one-shot attribute update.

- Change FunctionLike::setAllArgAttrs() and setAllResultAttrs() to rebuild the 
new list of
  function attributes locally and call setAttr() just once instead of calling
  setArgAttr()/setResultAttrs() for each argument which incrementally build the
  attribute dictionary and can end up creating a lot of unused DictionaryAttr's 
(which are
  uniqued and nor garbage collected).

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

Added: 


Modified: 
mlir/include/mlir/IR/FunctionSupport.h

Removed: 




diff  --git a/mlir/include/mlir/IR/FunctionSupport.h 
b/mlir/include/mlir/IR/FunctionSupport.h
index fd50e0dbb512..481dc5a6986f 100644
--- a/mlir/include/mlir/IR/FunctionSupport.h
+++ b/mlir/include/mlir/IR/FunctionSupport.h
@@ -333,11 +333,7 @@ class FunctionLike : public 
OpTrait::TraitBase {
   /// Set the attributes held by the argument at 'index'. `attributes` may be
   /// null, in which case any existing argument attributes are removed.
   void setArgAttrs(unsigned index, DictionaryAttr attributes);
-  void setAllArgAttrs(ArrayRef attributes) {
-assert(attributes.size() == getNumArguments());
-for (unsigned i = 0, e = attributes.size(); i != e; ++i)
-  setArgAttrs(i, attributes[i]);
-  }
+  void setAllArgAttrs(ArrayRef attributes);
 
   /// If the an attribute exists with the specified name, change it to the new
   /// value. Otherwise, add a new attribute with the specified name/value.
@@ -400,11 +396,7 @@ class FunctionLike : public 
OpTrait::TraitBase {
   /// Set the attributes held by the result at 'index'. `attributes` may be
   /// null, in which case any existing argument attributes are removed.
   void setResultAttrs(unsigned index, DictionaryAttr attributes);
-  void setAllResultAttrs(ArrayRef attributes) {
-assert(attributes.size() == getNumResults());
-for (unsigned i = 0, e = attributes.size(); i != e; ++i)
-  setResultAttrs(i, attributes[i]);
-  }
+  void setAllResultAttrs(ArrayRef attributes);
 
   /// If the an attribute exists with the specified name, change it to the new
   /// value. Otherwise, add a new attribute with the specified name/value.
@@ -591,6 +583,26 @@ void FunctionLike::setArgAttrs(unsigned 
index,
  attributes);
 }
 
+template 
+void FunctionLike::setAllArgAttrs(
+ArrayRef attributes) {
+  assert(attributes.size() == getNumArguments());
+  NamedAttrList attrs = this->getOperation()->getAttrs();
+
+  // Instead of calling setArgAttrs() multiple times, which rebuild the
+  // attribute dictionary every time, build a new list of attributes for the
+  // operation so that we rebuild the attribute dictionary in one shot.
+  SmallString<8> argAttrName;
+  for (unsigned i = 0, e = attributes.size(); i != e; ++i) {
+StringRef attrName = getArgAttrName(i, argAttrName);
+if (!attributes[i] || attributes[i].empty())
+  attrs.erase(attrName);
+else
+  attrs.set(attrName, attributes[i]);
+  }
+  this->getOperation()->setAttrs(attrs);
+}
+
 /// If the an attribute exists with the specified name, change it to the new
 /// value. Otherwise, add a new attribute with the specified name/value.
 template 
@@ -648,6 +660,26 @@ void FunctionLike::setResultAttrs(unsigned 
index,
   attributes);
 }
 
+template 
+void FunctionLike::setAllResultAttrs(
+ArrayRef attributes) {
+  assert(attributes.size() == getNumResults());
+  NamedAttrList attrs = this->getOperation()->getAttrs();
+
+  // Instead of calling setResultAttrs() multiple times, which rebuild the
+  // attribute dictionary every time, build a new list of attributes for the
+  // operation so that we rebuild the attribute dictionary in one shot.
+  SmallString<8> resultAttrName;
+  for (unsigned i = 0, e = attributes.size(); i != e; ++i) {
+StringRef attrName = getResultAttrName(i, resultAttrName);
+if (!attributes[i] || attributes[i].empty())
+  attrs.erase(attrName);
+else
+  attrs.set(attrName, attributes[i]);
+  }
+  this->getOperation()->setAttrs(attrs);
+}
+
 /// If the an attribute exists with the specified name, change it to the new
 /// value. Otherwise, add a new attribute with the specified name/value.
 template 



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


[llvm-branch-commits] [llvm] e6ae623 - [IROutliner] Adding support for consolidating functions with different output arguments.

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

Author: Andrew Litteken
Date: 2020-12-28T16:17:07-06:00
New Revision: e6ae623314bab3ddd983ed941bf63a6d4c63a1f4

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

LOG: [IROutliner] Adding support for consolidating functions with different 
output arguments.

Certain regions can have values introduced inside the region that are
used outside of the region. These may not be the same for each similar
region, so we must create one over arching set of arguments for the
consolidated function.

We do this by iterating over the outputs for each extracted function,
and creating as many different arguments to encapsulate the different
outputs sets. For each output set, we create a different block with the
necessary stores from the value to the output register. There is then
one switch statement, controlled by an argument to the function, to
differentiate which block to use.

Changed Tests for consistency:
llvm/test/Transforms/IROutliner/extraction.ll
llvm/test/Transforms/IROutliner/illegal-assumes.ll
llvm/test/Transforms/IROutliner/illegal-memcpy.ll
llvm/test/Transforms/IROutliner/illegal-memmove.ll
llvm/test/Transforms/IROutliner/illegal-vaarg.ll

Tests to test new functionality:
llvm/test/Transforms/IROutliner/outlining-different-output-blocks.ll
llvm/test/Transforms/IROutliner/outlining-remapped-outputs.ll
llvm/test/Transforms/IROutliner/outlining-same-output-blocks.ll

Reviewers: jroelofs, paquette

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

Added: 
llvm/test/Transforms/IROutliner/outlining-different-output-blocks.ll
llvm/test/Transforms/IROutliner/outlining-remapped-outputs.ll
llvm/test/Transforms/IROutliner/outlining-same-output-blocks.ll

Modified: 
llvm/include/llvm/Transforms/IPO/IROutliner.h
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/test/Transforms/IROutliner/extraction.ll
llvm/test/Transforms/IROutliner/illegal-assumes.ll
llvm/test/Transforms/IROutliner/illegal-memcpy.ll
llvm/test/Transforms/IROutliner/illegal-memmove.ll
llvm/test/Transforms/IROutliner/illegal-vaarg.ll

Removed: 




diff  --git a/llvm/include/llvm/Transforms/IPO/IROutliner.h 
b/llvm/include/llvm/Transforms/IPO/IROutliner.h
index 87f276d82df7..2048d6d6d1a1 100644
--- a/llvm/include/llvm/Transforms/IPO/IROutliner.h
+++ b/llvm/include/llvm/Transforms/IPO/IROutliner.h
@@ -73,6 +73,10 @@ struct OutlinableRegion {
   /// The number of extracted inputs from the CodeExtractor.
   unsigned NumExtractedInputs;
 
+  /// The corresponding BasicBlock with the appropriate stores for this
+  /// OutlinableRegion in the overall function.
+  unsigned OutputBlockNum;
+
   /// Mapping the extracted argument number to the argument number in the
   /// overall function.  Since there will be inputs, such as elevated constants
   /// that are not the same in each region in a SimilarityGroup, or values that
@@ -87,6 +91,11 @@ struct OutlinableRegion {
   /// since the CodeExtractor does not recognize constants.
   DenseMap AggArgToConstant;
 
+  /// The global value numbers that are used as outputs for this section. Once
+  /// extracted, each output will be stored to an output register.  This
+  /// documents the global value numbers that are used in this pattern.
+  SmallVector GVNStores;
+
   /// Used to create an outlined function.
   CodeExtractor *CE = nullptr;
 
@@ -192,6 +201,15 @@ class IROutliner {
   void findAddInputsOutputs(Module &M, OutlinableRegion &Region,
 DenseSet &NotSame);
 
+  /// Update the output mapping based on the load instruction, and the outputs
+  /// of the extracted function.
+  ///
+  /// \param Region - The region extracted
+  /// \param Outputs - The outputs from the extracted function.
+  /// \param LI - The load instruction used to update the mapping.
+  void updateOutputMapping(OutlinableRegion &Region,
+   ArrayRef Outputs, LoadInst *LI);
+
   /// Extract \p Region into its own function.
   ///
   /// \param [in] Region - The region to be extracted into its own function.
@@ -218,6 +236,11 @@ class IROutliner {
   /// TargetTransformInfo lambda for target specific information.
   function_ref getTTI;
 
+  /// A mapping from newly created reloaded output values to the original 
value.
+  /// If an value is replace by an output from an outlined region, this maps
+  /// that Value, back to its original Value.
+  DenseMap OutputMappings;
+
   /// IRSimilarityIdentifier lambda to retrieve IRSimilarityIdentifier.
   function_ref getIRSI;
 

diff  --git a/llvm/lib/Transforms/IPO/IROutliner.cpp 
b/llvm/lib/Transforms/IPO/IROutliner.cpp
index 12a30744a652..ec6bfaef26ec 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -50,6 +50,9 @@ struct OutlinableGroup {
   

[llvm-branch-commits] [llvm] 85af1d6 - [test] Fix pr45360.ll under NPM

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

Author: Arthur Eubanks
Date: 2020-12-28T14:42:52-08:00
New Revision: 85af1d6257fac0741002f0144622f05c4ee1632c

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

LOG: [test] Fix pr45360.ll under NPM

The IR is the same under the NPM, but some basic block labels and value
names are different.

Added: 


Modified: 
llvm/test/Transforms/IndVarSimplify/X86/pr45360.ll

Removed: 




diff  --git a/llvm/test/Transforms/IndVarSimplify/X86/pr45360.ll 
b/llvm/test/Transforms/IndVarSimplify/X86/pr45360.ll
index e86277adf936..d0857fa707b1 100644
--- a/llvm/test/Transforms/IndVarSimplify/X86/pr45360.ll
+++ b/llvm/test/Transforms/IndVarSimplify/X86/pr45360.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -O2 -scev-cheap-expansion-budget=1024 %s | FileCheck %s
+; TODO: Run under new PM after switch. The IR is the same but basic block 
labels are 
diff erent.
+; RUN: opt -S -O2 -scev-cheap-expansion-budget=1024 %s -enable-new-pm=0 | 
FileCheck %s
 
 ; See https://bugs.llvm.org/show_bug.cgi?id=45360
 ; This is reduced from that (runnable) test.



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


[llvm-branch-commits] [clang] 4ddf140 - Fix PR35902: incorrect alignment used for ubsan check.

2020-12-28 Thread James Y Knight via llvm-branch-commits

Author: James Y Knight
Date: 2020-12-28T18:11:17-05:00
New Revision: 4ddf140c00408ecee9d20f4470e69e0f696d8f8a

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

LOG: Fix PR35902: incorrect alignment used for ubsan check.

UBSan was using the complete-object align rather than nv alignment
when checking the "this" pointer of a method.

Furthermore, CGF.CXXABIThisAlignment was also being set incorrectly,
due to an incorrectly negated test. The latter doesn't appear to have
had any impact, due to it not really being used anywhere.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCXXABI.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGenCXX/catch-undef-behavior.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 9d5ebdeff35b..9714730e3c4b 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -135,8 +135,8 @@ void CGCXXABI::buildThisParam(CodeGenFunction &CGF, 
FunctionArgList ¶ms) {
   // down to whether we know it's a complete object or not.
   auto &Layout = CGF.getContext().getASTRecordLayout(MD->getParent());
   if (MD->getParent()->getNumVBases() == 0 || // avoid vcall in common case
-  MD->getParent()->hasAttr() ||
-  !isThisCompleteObject(CGF.CurGD)) {
+  MD->getParent()->isEffectivelyFinal() ||
+  isThisCompleteObject(CGF.CurGD)) {
 CGF.CXXABIThisAlignment = Layout.getAlignment();
   } else {
 CGF.CXXABIThisAlignment = Layout.getNonVirtualAlignment();

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 005ee74c1876..a8a91c59ff2d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1137,11 +1137,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   MD->getParent()->getLambdaCaptureDefault() == LCD_None)
 SkippedChecks.set(SanitizerKind::Null, true);
 
-  EmitTypeCheck(isa(MD) ? TCK_ConstructorCall
-: TCK_MemberCall,
-Loc, CXXABIThisValue, ThisTy,
-getContext().getTypeAlignInChars(ThisTy->getPointeeType()),
-SkippedChecks);
+  EmitTypeCheck(
+  isa(MD) ? TCK_ConstructorCall : TCK_MemberCall,
+  Loc, CXXABIThisValue, ThisTy, CXXABIThisAlignment, SkippedChecks);
 }
   }
 

diff  --git a/clang/test/CodeGenCXX/catch-undef-behavior.cpp 
b/clang/test/CodeGenCXX/catch-undef-behavior.cpp
index 28c92ba8a1a9..a75b9d455d7c 100644
--- a/clang/test/CodeGenCXX/catch-undef-behavior.cpp
+++ b/clang/test/CodeGenCXX/catch-undef-behavior.cpp
@@ -430,8 +430,8 @@ namespace VBaseObjectSize {
   // Note: C is laid out such that offsetof(C, B) + sizeof(B) extends outside
   // the C object.
   struct alignas(16) A { void *a1, *a2; };
-  struct B : virtual A { void *b; };
-  struct C : virtual A, virtual B {};
+  struct B : virtual A { void *b; void* g(); };
+  struct C : virtual A, virtual B { };
   // CHECK-LABEL: define {{.*}} @_ZN15VBaseObjectSize1fERNS_1BE(
   B &f(B &b) {
 // Size check: check for nvsize(B) == 16 (do not require size(B) == 32)
@@ -443,6 +443,15 @@ namespace VBaseObjectSize {
 // CHECK: and i64 [[PTRTOINT]], 7,
 return b;
   }
+
+  // CHECK-LABEL: define {{.*}} @_ZN15VBaseObjectSize1B1gEv(
+  void *B::g() {
+// Ensure that the check on the "this" pointer also uses the proper
+// alignment. We should be using nvalign(B) == 8, not 16.
+// CHECK: [[PTRTOINT:%.+]] = ptrtoint {{.*}} to i64,
+// CHECK: and i64 [[PTRTOINT]], 7
+return nullptr;
+  }
 }
 
 namespace FunctionSanitizerVirtualCalls {



___
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] c0a2d3b - [libc++] Fix a test failure in 7b00e9fae3 (D93815).

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

Author: Arthur O'Dwyer
Date: 2020-12-28T18:46:07-05:00
New Revision: c0a2d3b90b3b024247cb38f73219ed595e974431

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

LOG: [libc++] Fix a test failure in 7b00e9fae3 (D93815).

"LLVM Buildbot on libcxx-libcxxabi-libunwind-armv7-linux" is not happy
with comparing `unsigned` and `int` [-Werror,-Wsign-compare].

Added: 


Modified: 

libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
 
b/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
index bc9ba2f860b4..59e5f7f52f01 100644
--- 
a/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
+++ 
b/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp
@@ -40,7 +40,7 @@
 
 struct count_equal
 {
-unsigned *count;
+int *count;
 
 template 
 TEST_CONSTEXPR_CXX14 bool operator()(const T& x, const T& y) const
@@ -50,11 +50,11 @@ struct count_equal
 template 
 TEST_CONSTEXPR_CXX20
 void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result) {
-unsigned count = 0;
+int count = 0;
 std::default_searcher s{b2, e2, count_equal{&count}};
 assert(result == std::search(b1, e1, s));
-auto d1 = std::distance(b1, e1);
-auto d2 = std::distance(b2, e2);
+int d1 = std::distance(b1, e1);
+int d2 = std::distance(b2, e2);
 assert((count >= 1) || (d2 == 0) || (d1 < d2));
 assert((d1 < d2) || count <= d1 * (d1 - d2 + 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] [flang] f782d5e - [flang] Detect call to abstract interface

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

Author: Tim Keith
Date: 2020-12-28T16:36:34-08:00
New Revision: f782d5ea86f6fc82b51a0de688bf292f39cc4814

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

LOG: [flang] Detect call to abstract interface

A subroutine call or function reference to an abstract interface is
not legal.

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

Added: 


Modified: 
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/resolve20.f90

Removed: 




diff  --git a/flang/lib/Semantics/resolve-names.cpp 
b/flang/lib/Semantics/resolve-names.cpp
index 73c624aefa22..2412758f340b 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -5879,7 +5879,10 @@ void ResolveNamesVisitor::HandleProcedureName(
   return; // reported error
 }
 CheckImplicitNoneExternal(name.source, *symbol);
-if (IsProcedure(*symbol) || symbol->has() ||
+if (symbol->has() &&
+symbol->attrs().test(Attr::ABSTRACT)) {
+  Say(name, "Abstract interface '%s' may not be called"_err_en_US);
+} else if (IsProcedure(*symbol) || symbol->has() ||
 symbol->has() ||
 symbol->has()) {
   // Symbols with DerivedTypeDetails, ObjectEntityDetails and

diff  --git a/flang/test/Semantics/resolve20.f90 
b/flang/test/Semantics/resolve20.f90
index f9cfc7cb1006..94bd4c18a6a0 100644
--- a/flang/test/Semantics/resolve20.f90
+++ b/flang/test/Semantics/resolve20.f90
@@ -61,7 +61,18 @@ subroutine forward
 procedure(proc), deferred :: p1
   end type t1
 
+  abstract interface
+function f()
+end function
+  end interface
+
 contains
   subroutine bar
   end subroutine
+  subroutine test
+!ERROR: Abstract interface 'foo' may not be called
+call foo()
+!ERROR: Abstract interface 'f' may not be called
+x = f()
+  end subroutine
 end module



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


[llvm-branch-commits] [llvm] 4646de5 - [NewPM][CodeGen] Introduce CodeGenPassBuilder to help build codegen pipeline

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

Author: Yuanfang Chen
Date: 2020-12-28T17:36:36-08:00
New Revision: 4646de5d75cfce3da4ddeffb6eb8e66e38238800

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

LOG: [NewPM][CodeGen] Introduce CodeGenPassBuilder to help build codegen 
pipeline

Following up on D67687.
Please refer to the RFC here 
http://lists.llvm.org/pipermail/llvm-dev/2020-July/143309.html

`CodeGenPassBuilder` is the NPM counterpart of `TargetPassConfig` with below 
differences.
- Debugging features (MIR print/verify, disable pass, start/stop-before/after, 
etc.) living in `TargetPassConfig` are moved to use PassInstrument as much as 
possible. (Implementation also lives in `TargetPassConfig.cpp`)
- `TargetPassConfig` is a polymorphic base (virtual inheritance) to build the 
target-dependent pipeline whereas `CodeGenPassBuilder` is the CRTP base/helper 
to implement the target-dependent pipeline. The motivation is flexibility for 
targets to customize the pipeline, inlining opportunity, and fits the overall 
NPM value semantics design.
- `TargetPassConfig` is a legacy immutable pass to declare hooks for targets to 
customize some target-independent codegen layer behavior. This is partially 
ported to TargetMachine::options. The rest, such as 
`createMachineScheduler/createPostMachineScheduler`, are left out for now. They 
should be implemented in LLVMTargetMachine in the future.

Reviewed By: arsenm, aeubanks

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

Added: 
llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
llvm/include/llvm/CodeGen/MachinePassRegistry.def
llvm/include/llvm/Target/CGPassBuilderOption.h
llvm/lib/CodeGen/CodeGenPassBuilder.cpp

Modified: 
llvm/include/llvm/CodeGen/TargetPassConfig.h
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/LLVMTargetMachine.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h 
b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
new file mode 100644
index ..12c93a0c4cf2
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
@@ -0,0 +1,1143 @@
+//===- Construction of codegen pass pipelines --*- 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
+//
+//===--===//
+/// \file
+///
+/// Interfaces for registering analysis passes, producing common pass manager
+/// configurations, and parsing of pass pipelines.
+///
+//===--===//
+
+#ifndef LLVM_CODEGEN_CODEGENPASSBUILDER_H
+#define LLVM_CODEGEN_CODEGENPASSBUILDER_H
+
+#include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/Analysis/BasicAliasAnalysis.h"
+#include "llvm/Analysis/CFLAndersAliasAnalysis.h"
+#include "llvm/Analysis/CFLSteensAliasAnalysis.h"
+#include "llvm/Analysis/ScopedNoAliasAA.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
+#include "llvm/CodeGen/ExpandReductions.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
+#include "llvm/CodeGen/MachinePassManager.h"
+#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
+#include "llvm/CodeGen/UnreachableBlockElim.h"
+#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/IR/Verifier.h"
+#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCTargetOptions.h"
+#include "llvm/Support/CodeGen.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Target/CGPassBuilderOption.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Transforms/Scalar.h"
+#include "llvm/Transforms/Scalar/ConstantHoisting.h"
+#include "llvm/Transforms/Scalar/LoopPassManager.h"
+#include "llvm/Transforms/Scalar/LoopStrengthReduce.h"
+#include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h"
+#include "llvm/Transforms/Scalar/MergeICmps.h"
+#include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
+#include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
+#include "llvm/Transforms/Utils/LowerInvoke.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace llvm {
+
+// FIXME: Dummy target independent passes definitions that have not yet been
+// ported to new pass manager. Once they do, remove these.
+#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR)  

[llvm-branch-commits] [llvm] 94427af - Revert "[NewPM][CodeGen] Introduce CodeGenPassBuilder to help build codegen pipeline"

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

Author: Yuanfang Chen
Date: 2020-12-28T17:44:22-08:00
New Revision: 94427af60c66ffea655a3084825c6c3a9deec1ad

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

LOG: Revert "[NewPM][CodeGen] Introduce CodeGenPassBuilder to help build 
codegen pipeline"

This reverts commit 4646de5d75cfce3da4ddeffb6eb8e66e38238800.

Some bots have build failure.

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetPassConfig.h
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/LLVMTargetMachine.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp

Removed: 
llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
llvm/include/llvm/CodeGen/MachinePassRegistry.def
llvm/include/llvm/Target/CGPassBuilderOption.h
llvm/lib/CodeGen/CodeGenPassBuilder.cpp



diff  --git a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h 
b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
deleted file mode 100644
index 12c93a0c4cf2..
--- a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
+++ /dev/null
@@ -1,1143 +0,0 @@
-//===- Construction of codegen pass pipelines --*- 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
-//
-//===--===//
-/// \file
-///
-/// Interfaces for registering analysis passes, producing common pass manager
-/// configurations, and parsing of pass pipelines.
-///
-//===--===//
-
-#ifndef LLVM_CODEGEN_CODEGENPASSBUILDER_H
-#define LLVM_CODEGEN_CODEGENPASSBUILDER_H
-
-#include "llvm/ADT/FunctionExtras.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/Analysis/BasicAliasAnalysis.h"
-#include "llvm/Analysis/CFLAndersAliasAnalysis.h"
-#include "llvm/Analysis/CFLSteensAliasAnalysis.h"
-#include "llvm/Analysis/ScopedNoAliasAA.h"
-#include "llvm/Analysis/TargetTransformInfo.h"
-#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
-#include "llvm/CodeGen/ExpandReductions.h"
-#include "llvm/CodeGen/MachineModuleInfo.h"
-#include "llvm/CodeGen/MachinePassManager.h"
-#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
-#include "llvm/CodeGen/UnreachableBlockElim.h"
-#include "llvm/IR/IRPrintingPasses.h"
-#include "llvm/IR/PassManager.h"
-#include "llvm/IR/Verifier.h"
-#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCStreamer.h"
-#include "llvm/MC/MCTargetOptions.h"
-#include "llvm/Support/CodeGen.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Target/CGPassBuilderOption.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/Scalar/ConstantHoisting.h"
-#include "llvm/Transforms/Scalar/LoopPassManager.h"
-#include "llvm/Transforms/Scalar/LoopStrengthReduce.h"
-#include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h"
-#include "llvm/Transforms/Scalar/MergeICmps.h"
-#include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
-#include "llvm/Transforms/Utils.h"
-#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
-#include "llvm/Transforms/Utils/LowerInvoke.h"
-#include 
-#include 
-#include 
-#include 
-#include 
-
-namespace llvm {
-
-// FIXME: Dummy target independent passes definitions that have not yet been
-// ported to new pass manager. Once they do, remove these.
-#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR)  
\
-  struct PASS_NAME : public PassInfoMixin { 
\
-template  PASS_NAME(Ts &&...) {}   
\
-PreservedAnalyses run(Function &, FunctionAnalysisManager &) { 
\
-  return PreservedAnalyses::all(); 
\
-}  
\
-  };
-#define DUMMY_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR)
\
-  struct PASS_NAME : public PassInfoMixin { 
\
-template  PASS_NAME(Ts &&...) {}   
\
-PreservedAnalyses run(Module &, ModuleAnalysisManager &) { 
\
-  return PreservedAnalyses::all(); 
\
-}  
\
-  };
-#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR)
\
-  struct PASS_NAME : public PassInfoMixin { 
\
-template  PASS_NAME(Ts &&...) {}   
\
-Err

[llvm-branch-commits] [llvm] 0e9abcf - [AMDGPU][NewPM] Port amdgpu-promote-alloca(-to-vector)

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

Author: Arthur Eubanks
Date: 2020-12-28T17:52:31-08:00
New Revision: 0e9abcfc1920f25a959eaa08116427b795e10dd8

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

LOG: [AMDGPU][NewPM] Port amdgpu-promote-alloca(-to-vector)

And add to AMDGPU opt pipeline.

Don't pin an opt run to the legacy PM when -enable-new-pm=1 if these
passes (or passes introduced in https://reviews.llvm.org/D93863) are in
the list of passes.

Reviewed By: arsenm

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPU.h
llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/test/CodeGen/AMDGPU/sroa-before-unroll.ll
llvm/test/CodeGen/AMDGPU/vector-alloca.ll
llvm/tools/opt/opt.cpp

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 22d264e2880b..6a0ba20e8026 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -208,6 +208,23 @@ FunctionPass *createAMDGPUPromoteAllocaToVector();
 void initializeAMDGPUPromoteAllocaToVectorPass(PassRegistry&);
 extern char &AMDGPUPromoteAllocaToVectorID;
 
+struct AMDGPUPromoteAllocaPass : PassInfoMixin {
+  AMDGPUPromoteAllocaPass(TargetMachine &TM) : TM(TM) {}
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+private:
+  TargetMachine &TM;
+};
+
+struct AMDGPUPromoteAllocaToVectorPass
+: PassInfoMixin {
+  AMDGPUPromoteAllocaToVectorPass(TargetMachine &TM) : TM(TM) {}
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+private:
+  TargetMachine &TM;
+};
+
 Pass *createAMDGPUStructurizeCFGPass();
 FunctionPass *createAMDGPUISelDag(
   TargetMachine *TM = nullptr,

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
index 4cfe0edfc533..3dc7b1643081 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -42,6 +42,7 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
@@ -83,8 +84,26 @@ static cl::opt PromoteAllocaToVectorLimit(
 
 // FIXME: This can create globals so should be a module pass.
 class AMDGPUPromoteAlloca : public FunctionPass {
+public:
+  static char ID;
+
+  AMDGPUPromoteAlloca() : FunctionPass(ID) {}
+
+  bool runOnFunction(Function &F) override;
+
+  StringRef getPassName() const override { return "AMDGPU Promote Alloca"; }
+
+  bool handleAlloca(AllocaInst &I, bool SufficientLDS);
+
+  void getAnalysisUsage(AnalysisUsage &AU) const override {
+AU.setPreservesCFG();
+FunctionPass::getAnalysisUsage(AU);
+  }
+};
+
+class AMDGPUPromoteAllocaImpl {
 private:
-  const TargetMachine *TM;
+  const TargetMachine &TM;
   Module *Mod = nullptr;
   const DataLayout *DL = nullptr;
 
@@ -116,28 +135,14 @@ class AMDGPUPromoteAlloca : public FunctionPass {
   /// Check whether we have enough local memory for promotion.
   bool hasSufficientLocalMem(const Function &F);
 
-public:
-  static char ID;
-
-  AMDGPUPromoteAlloca() : FunctionPass(ID) {}
-
-  bool doInitialization(Module &M) override;
-  bool runOnFunction(Function &F) override;
-
-  StringRef getPassName() const override { return "AMDGPU Promote Alloca"; }
-
   bool handleAlloca(AllocaInst &I, bool SufficientLDS);
 
-  void getAnalysisUsage(AnalysisUsage &AU) const override {
-AU.setPreservesCFG();
-FunctionPass::getAnalysisUsage(AU);
-  }
+public:
+  AMDGPUPromoteAllocaImpl(TargetMachine &TM) : TM(TM) {}
+  bool run(Function &F);
 };
 
 class AMDGPUPromoteAllocaToVector : public FunctionPass {
-private:
-  unsigned MaxVGPRs;
-
 public:
   static char ID;
 
@@ -149,8 +154,6 @@ class AMDGPUPromoteAllocaToVector : public FunctionPass {
 return "AMDGPU Promote Alloca to vector";
   }
 
-  bool handleAlloca(AllocaInst &I);
-
   void getAnalysisUsage(AnalysisUsage &AU) const override {
 AU.setPreservesCFG();
 FunctionPass::getAnalysisUsage(AU);
@@ -171,32 +174,41 @@ INITIALIZE_PASS(AMDGPUPromoteAllocaToVector, DEBUG_TYPE 
"-to-vector",
 char &llvm::AMDGPUPromoteAllocaID = AMDGPUPromoteAlloca::ID;
 char &llvm::AMDGPUPromoteAllocaToVectorID = AMDGPUPromoteAllocaToVector::ID;
 
-bool AMDGPUPromoteAlloca::doInitialization(Module &M) {
-  Mod = &M;
-  DL = &Mod->getDataLayout();
+bool AMDGPUPromoteAlloca::runOnFunction(Function &F) {
+  if (skipFunction(F))
+return false;
 
+  if (auto *TPC = getAnalysisIfAvailable()) {
+return AMDGPUPromoteAllocaImpl(TPC->getTM()).run(F);
+  }
   return false;
 }
 
-bool AMDGPUPromoteAlloca::runOnFunction(Function &F) {
-  if (skipFunction(F))
-  

[llvm-branch-commits] [llvm] 4f568fb - [PowerPC] Do not emit HW loop when TLS var accessed in PHI of loop exit

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

Author: Nemanja Ivanovic
Date: 2020-12-28T20:36:16-06:00
New Revision: 4f568fbd21636c7c8d071f1901084cc0ae87f3ee

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

LOG: [PowerPC] Do not emit HW loop when TLS var accessed in PHI of loop exit

If any PHI nodes in loop exit blocks have incoming values from the
loop that are accesses of TLS variables with local dynamic or general
dynamic TLS model, the address will be computed inside the loop. Since
this includes a call to __tls_get_addr, this will in turn cause the
CTR loops verifier to complain.
Disable CTR loops in such cases.

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

Added: 
llvm/test/CodeGen/PowerPC/pr48527.ll

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

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
index 011056c21b13..4de1f2aba416 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
@@ -335,6 +335,29 @@ PPCTTIImpl::getUserCost(const User *U, ArrayRef Operands,
   return BaseT::getUserCost(U, Operands, CostKind);
 }
 
+// Determining the address of a TLS variable results in a function call in
+// certain TLS models.
+static bool memAddrUsesCTR(const Value *MemAddr, const PPCTargetMachine &TM,
+   SmallPtrSetImpl &Visited) {
+  // No need to traverse again if we already checked this operand.
+  if (!Visited.insert(MemAddr).second)
+return false;
+  const auto *GV = dyn_cast(MemAddr);
+  if (!GV) {
+// Recurse to check for constants that refer to TLS global variables.
+if (const auto *CV = dyn_cast(MemAddr))
+  for (const auto &CO : CV->operands())
+if (memAddrUsesCTR(CO, TM, Visited))
+  return true;
+return false;
+  }
+
+  if (!GV->isThreadLocal())
+return false;
+  TLSModel::Model Model = TM.getTLSModel(GV);
+  return Model == TLSModel::GeneralDynamic || Model == TLSModel::LocalDynamic;
+}
+
 bool PPCTTIImpl::mightUseCTR(BasicBlock *BB, TargetLibraryInfo *LibInfo,
  SmallPtrSetImpl &Visited) {
   const PPCTargetMachine &TM = ST->getTargetMachine();
@@ -353,31 +376,6 @@ bool PPCTTIImpl::mightUseCTR(BasicBlock *BB, 
TargetLibraryInfo *LibInfo,
 return false;
   };
 
-  // Determining the address of a TLS variable results in a function call in
-  // certain TLS models.
-  std::function memAddrUsesCTR =
-  [&memAddrUsesCTR, &TM, &Visited](const Value *MemAddr) -> bool {
-// No need to traverse again if we already checked this operand.
-if (!Visited.insert(MemAddr).second)
-  return false;
-const auto *GV = dyn_cast(MemAddr);
-if (!GV) {
-  // Recurse to check for constants that refer to TLS global variables.
-  if (const auto *CV = dyn_cast(MemAddr))
-for (const auto &CO : CV->operands())
-  if (memAddrUsesCTR(CO))
-return true;
-
-  return false;
-}
-
-if (!GV->isThreadLocal())
-  return false;
-TLSModel::Model Model = TM.getTLSModel(GV);
-return Model == TLSModel::GeneralDynamic ||
-  Model == TLSModel::LocalDynamic;
-  };
-
   auto isLargeIntegerTy = [](bool Is32Bit, Type *Ty) {
 if (IntegerType *ITy = dyn_cast(Ty))
   return ITy->getBitWidth() > (Is32Bit ? 32U : 64U);
@@ -676,7 +674,7 @@ bool PPCTTIImpl::mightUseCTR(BasicBlock *BB, 
TargetLibraryInfo *LibInfo,
 }
 
 for (Value *Operand : J->operands())
-  if (memAddrUsesCTR(Operand))
+  if (memAddrUsesCTR(Operand, TM, Visited))
 return true;
   }
 
@@ -736,6 +734,24 @@ bool PPCTTIImpl::isHardwareLoopProfitable(Loop *L, 
ScalarEvolution &SE,
 }
   }
 
+  // If an exit block has a PHI that accesses a TLS variable as one of the
+  // incoming values from the loop, we cannot produce a CTR loop because the
+  // address for that value will be computed in the loop.
+  SmallVector ExitBlocks;
+  L->getExitBlocks(ExitBlocks);
+  for (auto &BB : ExitBlocks) {
+for (auto &PHI : BB->phis()) {
+  for (int Idx = 0, EndIdx = PHI.getNumIncomingValues(); Idx < EndIdx;
+   Idx++) {
+const BasicBlock *IncomingBB = PHI.getIncomingBlock(Idx);
+const Value *IncomingValue = PHI.getIncomingValue(Idx);
+if (L->contains(IncomingBB) &&
+memAddrUsesCTR(IncomingValue, TM, Visited))
+  return false;
+  }
+}
+  }
+
   LLVMContext &C = L->getHeader()->getContext();
   HWLoopInfo.CountType = TM.isPPC64() ?
 Type::getInt64Ty(C) : Type::getInt32Ty(C);

diff  --git a/llvm/test/CodeGen/PowerPC/pr48527.ll 
b/llvm/test/CodeGen/PowerPC/pr48527.ll
new file mode 100644
index ..eaff15ce071e
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/pr

[llvm-branch-commits] [llvm] 8b67c98 - [UpdateTestChecks] Fix update_analyze_test_checks.py failure

2020-12-28 Thread Juneyoung Lee via llvm-branch-commits

Author: Juneyoung Lee
Date: 2020-12-29T11:56:59+09:00
New Revision: 8b67c98c4774313ab0ce5db1a975d2e69850368a

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

LOG: [UpdateTestChecks] Fix update_analyze_test_checks.py failure

Added: 


Modified: 
llvm/utils/update_analyze_test_checks.py

Removed: 




diff  --git a/llvm/utils/update_analyze_test_checks.py 
b/llvm/utils/update_analyze_test_checks.py
index 38add9d4ab01..921a3bc08537 100755
--- a/llvm/utils/update_analyze_test_checks.py
+++ b/llvm/utils/update_analyze_test_checks.py
@@ -110,7 +110,10 @@ def main():
 
 builder = common.FunctionTestBuilder(
   run_list = prefix_list,
-  flags = args,
+  flags = type('', (object,), {
+'verbose': args.verbose,
+'function_signature': False,
+'check_attributes': False}),
   scrubber_args = [])
 
 for prefixes, opt_args in prefix_list:



___
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] f3f9ce3 - [RISCV] Define vmclr.m/vmset.m intrinsics.

2020-12-28 Thread Zakk Chen via llvm-branch-commits

Author: Zakk Chen
Date: 2020-12-28T18:57:17-08:00
New Revision: f3f9ce3b7948b250bc532818ed76a64cea8b6fbe

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

LOG: [RISCV] Define vmclr.m/vmset.m intrinsics.

Define vmclr.m/vmset.m intrinsics and lower to vmxor.mm/vmxnor.mm.

Ideally all rvv pseudo instructions could be implemented in C header,
but those two instructions don't take an input, codegen can not guarantee
that the source register becomes the same as the destination.

We expand pseduo-v-inst into corresponding v-inst in
RISCVExpandPseudoInsts pass.

Reviewed By: craig.topper, frasercrmck

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

Added: 
llvm/test/CodeGen/RISCV/rvv/vmclr-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vmclr-rv64.ll
llvm/test/CodeGen/RISCV/rvv/vmset-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vmset-rv64.ll

Modified: 
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td 
b/llvm/include/llvm/IR/IntrinsicsRISCV.td
index be11b518416c..d72dc5a4dd59 100644
--- a/llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -404,6 +404,12 @@ let TargetPrefix = "riscv" in {
 [LLVMMatchType<0>, LLVMMatchType<0>,
  LLVMMatchType<0>, llvm_anyint_ty],
 [IntrNoMem]>, RISCVVIntrinsic;
+  // Output: (vector)
+  // Input: (vl)
+  class RISCVNullaryIntrinsic
+: Intrinsic<[llvm_anyvector_ty],
+[llvm_anyint_ty],
+[IntrNoMem]>, RISCVVIntrinsic;
 
   multiclass RISCVUSLoad {
 def "int_riscv_" # NAME : RISCVUSLoad;
@@ -701,6 +707,8 @@ let TargetPrefix = "riscv" in {
   def int_riscv_vmnor: RISCVBinaryAAANoMask;
   def int_riscv_vmornot: RISCVBinaryAAANoMask;
   def int_riscv_vmxnor: RISCVBinaryAAANoMask;
+  def int_riscv_vmclr : RISCVNullaryIntrinsic;
+  def int_riscv_vmset : RISCVNullaryIntrinsic;
 
   defm vpopc : RISCVMaskUnarySOut;
   defm vfirst : RISCVMaskUnarySOut;
@@ -724,9 +732,8 @@ let TargetPrefix = "riscv" in {
[IntrNoMem]>, RISCVVIntrinsic;
   // Output: (vector)
   // Input: (vl)
-  def int_riscv_vid : Intrinsic<[llvm_anyvector_ty],
-[llvm_anyint_ty],
-[IntrNoMem]>, RISCVVIntrinsic;
+  def int_riscv_vid : RISCVNullaryIntrinsic;
+
   // Output: (vector)
   // Input: (maskedoff, mask, vl)
   def int_riscv_vid_mask : Intrinsic<[llvm_anyvector_ty],

diff  --git a/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp 
b/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp
index 660ae915f7b8..5f50892ca886 100644
--- a/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp
+++ b/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp
@@ -60,6 +60,8 @@ class RISCVExpandPseudo : public MachineFunctionPass {
   MachineBasicBlock::iterator MBBI,
   MachineBasicBlock::iterator &NextMBBI);
   bool expandVSetVL(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI);
+  bool expandVMSET_VMCLR(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator MBBI, unsigned Opcode);
 };
 
 char RISCVExpandPseudo::ID = 0;
@@ -102,6 +104,24 @@ bool RISCVExpandPseudo::expandMI(MachineBasicBlock &MBB,
 return expandLoadTLSGDAddress(MBB, MBBI, NextMBBI);
   case RISCV::PseudoVSETVLI:
 return expandVSetVL(MBB, MBBI);
+  case RISCV::PseudoVMCLR_M_B1:
+  case RISCV::PseudoVMCLR_M_B2:
+  case RISCV::PseudoVMCLR_M_B4:
+  case RISCV::PseudoVMCLR_M_B8:
+  case RISCV::PseudoVMCLR_M_B16:
+  case RISCV::PseudoVMCLR_M_B32:
+  case RISCV::PseudoVMCLR_M_B64:
+// vmclr.m vd => vmxor.mm vd, vd, vd
+return expandVMSET_VMCLR(MBB, MBBI, RISCV::VMXOR_MM);
+  case RISCV::PseudoVMSET_M_B1:
+  case RISCV::PseudoVMSET_M_B2:
+  case RISCV::PseudoVMSET_M_B4:
+  case RISCV::PseudoVMSET_M_B8:
+  case RISCV::PseudoVMSET_M_B16:
+  case RISCV::PseudoVMSET_M_B32:
+  case RISCV::PseudoVMSET_M_B64:
+// vmset.m vd => vmxnor.mm vd, vd, vd
+return expandVMSET_VMCLR(MBB, MBBI, RISCV::VMXNOR_MM);
   }
 
   return false;
@@ -213,6 +233,19 @@ bool RISCVExpandPseudo::expandVSetVL(MachineBasicBlock 
&MBB,
   return true;
 }
 
+bool RISCVExpandPseudo::expandVMSET_VMCLR(MachineBasicBlock &MBB,
+  MachineBasicBlock::iterator MBBI,
+  unsigned Opcode) {
+  DebugLoc DL = MBBI->getDebugLoc();
+  Register DstReg = MBBI->getOperand(0).getReg();
+  const MCInstrDesc &Desc = TII->get(Opcode);
+  BuildMI(MBB, MBBI, DL, Desc, DstReg)
+  .addReg(DstReg, RegState::Undef)
+  .addR

[llvm-branch-commits] [llvm] 1e23802 - [IROutliner] Merging identical output blocks for extracted functions.

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

Author: Andrew Litteken
Date: 2020-12-28T21:01:48-06:00
New Revision: 1e23802507d18ef8cb5a063325ff442ac7f527be

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

LOG: [IROutliner] Merging identical output blocks for extracted functions.

Many of the sets of output stores will be the same. When a block is
created, we check if there is an output block with the same set of store
instructions. If there is, we map the output block of the region back
to the block, so that the extra argument controlling the switch
statement can be set to the appropriate block value.

Tests:
- llvm/test/Transforms/IROutliner/outlining-same-output-blocks.ll

Reviewers: jroelofs, paquette

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

Added: 


Modified: 
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/test/Transforms/IROutliner/extraction.ll
llvm/test/Transforms/IROutliner/illegal-assumes.ll
llvm/test/Transforms/IROutliner/illegal-memcpy.ll
llvm/test/Transforms/IROutliner/illegal-memmove.ll
llvm/test/Transforms/IROutliner/illegal-vaarg.ll
llvm/test/Transforms/IROutliner/outlining-remapped-outputs.ll
llvm/test/Transforms/IROutliner/outlining-same-output-blocks.ll

Removed: 




diff  --git a/llvm/lib/Transforms/IPO/IROutliner.cpp 
b/llvm/lib/Transforms/IPO/IROutliner.cpp
index ec6bfaef26ec..4c0e09911ab9 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -53,6 +53,11 @@ struct OutlinableGroup {
   /// The return block for the overall function.
   BasicBlock *EndBB = nullptr;
 
+  /// A set containing the 
diff erent GVN store sets needed. Each array contains
+  /// a sorted list of the 
diff erent values that need to be stored into output
+  /// registers.
+  DenseSet> OutputGVNCombinations;
+
   /// Flag for whether the \ref ArgumentTypes have been defined after the
   /// extraction of the first region.
   bool InputTypesSet = false;
@@ -67,6 +72,13 @@ struct OutlinableGroup {
   /// \param [in,out] NotSame contains the global value numbers where the
   /// constant is not always the same, and must be passed in as an argument.
   void findSameConstants(DenseSet &NotSame);
+
+  /// For the regions, look at each set of GVN stores needed and account for
+  /// each combination.  Add an argument to the argument types if there is
+  /// more than one combination.
+  ///
+  /// \param [in] M - The module we are outlining from.
+  void collectGVNStoreSets(Module &M);
 };
 
 /// Move the contents of \p SourceBB to before the last instruction of \p
@@ -266,6 +278,17 @@ void OutlinableGroup::findSameConstants(DenseSet 
&NotSame) {
 collectRegionsConstants(*Region, GVNToConstant, NotSame);
 }
 
+void OutlinableGroup::collectGVNStoreSets(Module &M) {
+  for (OutlinableRegion *OS : Regions) 
+OutputGVNCombinations.insert(OS->GVNStores);
+
+  // We are adding an extracted argument to decide between which output path
+  // to use in the basic block.  It is used in a switch statement and only
+  // needs to be an integer.
+  if (OutputGVNCombinations.size() > 1)
+ArgumentTypes.push_back(Type::getInt32Ty(M.getContext()));
+}
+
 Function *IROutliner::createFunction(Module &M, OutlinableGroup &Group,
  unsigned FunctionNameSuffix) {
   assert(!Group.OutlinedFunction && "Function is already defined!");
@@ -655,7 +678,7 @@ CallInst *replaceCalledFunction(Module &M, OutlinableRegion 
&Region) {
   for (unsigned AggArgIdx = 0; AggArgIdx < AggFunc->arg_size(); AggArgIdx++) {
 
 if (AggArgIdx == AggFunc->arg_size() - 1 &&
-Group.ArgumentTypes.size() > Group.NumAggregateInputs) {
+Group.OutputGVNCombinations.size() > 1) {
   // If we are on the last argument, and we need to 
diff erentiate between
   // output blocks, add an integer to the argument list to determine
   // what block to take
@@ -703,9 +726,9 @@ CallInst *replaceCalledFunction(Module &M, OutlinableRegion 
&Region) {
   Call);
 
   // It is possible that the call to the outlined function is either the first
-  // instruction in the new block, the last instruction, or both.  If either of
-  // these is the case, we need to make sure that we replace the instruction in
-  // the IRInstructionData struct with the new call.
+  // instruction is in the new block, the last instruction, or both.  If either
+  // of these is the case, we need to make sure that we replace the instruction
+  // in the IRInstructionData struct with the new call.
   CallInst *OldCall = Region.Call;
   if (Region.NewFront->Inst == OldCall)
 Region.NewFront->Inst = Call;
@@ -831,8 +854,51 @@ collectRelevantInstructions(Function &F,
   return RelevantInstructions;
 }
 
+/// It is possible that there is a basic 

[llvm-branch-commits] [llvm] 1e3ed09 - [CodeGen] Use llvm::append_range (NFC)

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

Author: Kazu Hirata
Date: 2020-12-28T19:55:16-08:00
New Revision: 1e3ed09165cf89b7f87318b4a5f7cab484661d49

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

LOG: [CodeGen] Use llvm::append_range (NFC)

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/MachineModuleInfo.cpp
llvm/lib/CodeGen/MachineOutliner.cpp
llvm/lib/CodeGen/MachinePipeliner.cpp
llvm/lib/CodeGen/RDFLiveness.cpp
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
llvm/lib/CodeGen/RegAllocPBQP.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp 
b/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
index 609afed8fe9f..1e3f33e70715 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
@@ -38,8 +38,7 @@ void WinCFGuard::endFunction(const MachineFunction *MF) {
 return;
 
   // Copy the function's longjmp targets to a module-level list.
-  LongjmpTargets.insert(LongjmpTargets.end(), MF->getLongjmpTargets().begin(),
-MF->getLongjmpTargets().end());
+  llvm::append_range(LongjmpTargets, MF->getLongjmpTargets());
 }
 
 /// Returns true if this function's address is escaped in a way that might make

diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp 
b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index ec3a7e7982b2..0698c3c3b993 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -737,7 +737,7 @@ bool CodeGenPrepare::eliminateMostlyEmptyBlocks(Function 
&F) {
   SmallVector LoopList(LI->begin(), LI->end());
   while (!LoopList.empty()) {
 Loop *L = LoopList.pop_back_val();
-LoopList.insert(LoopList.end(), L->begin(), L->end());
+llvm::append_range(LoopList, *L);
 if (BasicBlock *Preheader = L->getLoopPreheader())
   Preheaders.insert(Preheader);
   }

diff  --git a/llvm/lib/CodeGen/MachineFunction.cpp 
b/llvm/lib/CodeGen/MachineFunction.cpp
index 2a9a88af3ad6..1eb191465ac9 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -868,7 +868,7 @@ try_next:;
   // Add the new filter.
   int FilterID = -(1 + FilterIds.size());
   FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
-  FilterIds.insert(FilterIds.end(), TyIds.begin(), TyIds.end());
+  llvm::append_range(FilterIds, TyIds);
   FilterEnds.push_back(FilterIds.size());
   FilterIds.push_back(0); // terminator
   return FilterID;

diff  --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp 
b/llvm/lib/CodeGen/MachineModuleInfo.cpp
index 5c2e2fb16b69..5565b9cededa 100644
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp
@@ -144,8 +144,7 @@ void MMIAddrLabelMap::UpdateForRAUWBlock(BasicBlock *Old, 
BasicBlock *New) {
   BBCallbacks[OldEntry.Index] = nullptr;// Update the callback.
 
   // Otherwise, we need to add the old symbols to the new block's set.
-  NewEntry.Symbols.insert(NewEntry.Symbols.end(), OldEntry.Symbols.begin(),
-  OldEntry.Symbols.end());
+  llvm::append_range(NewEntry.Symbols, OldEntry.Symbols);
 }
 
 void MMIAddrLabelMapCallbackPtr::deleted() {

diff  --git a/llvm/lib/CodeGen/MachineOutliner.cpp 
b/llvm/lib/CodeGen/MachineOutliner.cpp
index a94a6e29dab9..ec3668a7b505 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -307,10 +307,8 @@ struct InstructionMapper {
   // repeated substring.
   mapToIllegalUnsigned(It, CanOutlineWithPrevInstr, UnsignedVecForMBB,
InstrListForMBB);
-  InstrList.insert(InstrList.end(), InstrListForMBB.begin(),
-   InstrListForMBB.end());
-  UnsignedVec.insert(UnsignedVec.end(), UnsignedVecForMBB.begin(),
- UnsignedVecForMBB.end());
+  llvm::append_range(InstrList, InstrListForMBB);
+  llvm::append_range(UnsignedVec, UnsignedVecForMBB);
 }
   }
 

diff  --git a/llvm/lib/CodeGen/MachinePipeliner.cpp 
b/llvm/lib/CodeGen/MachinePipeliner.cpp
index c122800a196c..db4d78af5fa6 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -2953,7 +2953,7 @@ void SMSchedule::finalizeSchedule(SwingSchedulerDAG *SSD) 
{
 }
 // Replace the old order with the new order.
 cycleInstrs.swap(newOrderPhi);
-cycleInstrs.insert(cycleInstrs.end(), newOrderI.begin(), newOrderI.end());
+llvm::append_range(cycleInstrs, newOrderI);
 SSD->fixupRegisterOverlaps(

[llvm-branch-commits] [llvm] 5d2529f - [Scalar] Construct SmallVector with iterator ranges (NFC)

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

Author: Kazu Hirata
Date: 2020-12-28T19:55:18-08:00
New Revision: 5d2529f28f93a08c33bb3a22387e669075b66504

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

LOG: [Scalar] Construct SmallVector with iterator ranges (NFC)

Added: 


Modified: 
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/lib/Transforms/Scalar/Reassociate.cpp
llvm/lib/Transforms/Scalar/SROA.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/GVN.cpp 
b/llvm/lib/Transforms/Scalar/GVN.cpp
index 30d00758c662..448ff498b110 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2800,7 +2800,7 @@ void GVN::addDeadBlock(BasicBlock *BB) {
 
 // First, split the critical edges. This might also create additional 
blocks
 // to preserve LoopSimplify form and adjust edges accordingly.
-SmallVector Preds(pred_begin(B), pred_end(B));
+SmallVector Preds(predecessors(B));
 for (BasicBlock *P : Preds) {
   if (!DeadBlocks.count(P))
 continue;

diff  --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp 
b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index 0753a0c259ab..d7d8f780b125 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -597,7 +597,7 @@ Value 
*InferAddressSpaces::cloneInstructionWithNewAddressSpace(
 GetElementPtrInst *GEP = cast(I);
 GetElementPtrInst *NewGEP = GetElementPtrInst::Create(
 GEP->getSourceElementType(), NewPointerOperands[0],
-SmallVector(GEP->idx_begin(), GEP->idx_end()));
+SmallVector(GEP->indices()));
 NewGEP->setIsInBounds(GEP->isInBounds());
 return NewGEP;
   }

diff  --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp 
b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 0f82e196602f..7742ebafcac4 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -755,13 +755,13 @@ static int64_t ExtractImmediate(const SCEV *&S, 
ScalarEvolution &SE) {
   return C->getValue()->getSExtValue();
 }
   } else if (const SCEVAddExpr *Add = dyn_cast(S)) {
-SmallVector NewOps(Add->op_begin(), Add->op_end());
+SmallVector NewOps(Add->operands());
 int64_t Result = ExtractImmediate(NewOps.front(), SE);
 if (Result != 0)
   S = SE.getAddExpr(NewOps);
 return Result;
   } else if (const SCEVAddRecExpr *AR = dyn_cast(S)) {
-SmallVector NewOps(AR->op_begin(), AR->op_end());
+SmallVector NewOps(AR->operands());
 int64_t Result = ExtractImmediate(NewOps.front(), SE);
 if (Result != 0)
   S = SE.getAddRecExpr(NewOps, AR->getLoop(),
@@ -781,13 +781,13 @@ static GlobalValue *ExtractSymbol(const SCEV *&S, 
ScalarEvolution &SE) {
   return GV;
 }
   } else if (const SCEVAddExpr *Add = dyn_cast(S)) {
-SmallVector NewOps(Add->op_begin(), Add->op_end());
+SmallVector NewOps(Add->operands());
 GlobalValue *Result = ExtractSymbol(NewOps.back(), SE);
 if (Result)
   S = SE.getAddExpr(NewOps);
 return Result;
   } else if (const SCEVAddRecExpr *AR = dyn_cast(S)) {
-SmallVector NewOps(AR->op_begin(), AR->op_end());
+SmallVector NewOps(AR->operands());
 GlobalValue *Result = ExtractSymbol(NewOps.front(), SE);
 if (Result)
   S = SE.getAddRecExpr(NewOps, AR->getLoop(),

diff  --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp 
b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 4f774bed1472..04e7a59c0d0c 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -1993,7 +1993,7 @@ Value *ReassociatePass::OptimizeExpression(BinaryOperator 
*I,
 void ReassociatePass::RecursivelyEraseDeadInsts(Instruction *I,
 OrderedSet &Insts) {
   assert(isInstructionTriviallyDead(I) && "Trivially dead instructions only!");
-  SmallVector Ops(I->op_begin(), I->op_end());
+  SmallVector Ops(I->operands());
   ValueRankMap.erase(I);
   Insts.remove(I);
   RedoInsts.remove(I);
@@ -2010,7 +2010,7 @@ void ReassociatePass::EraseInst(Instruction *I) {
   assert(isInstructionTriviallyDead(I) && "Trivially dead instructions only!");
   LLVM_DEBUG(dbgs() << "Erasing dead inst: "; I->dump());
 
-  SmallVector Ops(I->op_begin(), I->op_end());
+  SmallVector Ops(I->operands());
   // Erase the dead instruction.
   ValueRankMap.erase(I);
   RedoInsts.remove(I);

diff  --git a/llvm/lib/Transforms/Scalar/SROA.cpp 
b/llvm/lib/Transforms/Scalar/SROA.cpp
index 7df98694c8b0..ed68ce6f8282 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3477,7 +3477,7 @@ 

[llvm-branch-commits] [llvm] 2883cd9 - [CFGPrinter] Use succ_empty (NFC)

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

Author: Kazu Hirata
Date: 2020-12-28T19:55:20-08:00
New Revision: 2883cd98f3c04b6ee804a5c3ad897f7f0acf0bfa

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

LOG: [CFGPrinter] Use succ_empty (NFC)

Added: 


Modified: 
llvm/lib/Analysis/CFGPrinter.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/CFGPrinter.cpp 
b/llvm/lib/Analysis/CFGPrinter.cpp
index 582e61b33f49..d41b0f8d48eb 100644
--- a/llvm/lib/Analysis/CFGPrinter.cpp
+++ b/llvm/lib/Analysis/CFGPrinter.cpp
@@ -272,7 +272,7 @@ FunctionPass *llvm::createCFGOnlyPrinterLegacyPassPass() {
 
 void DOTGraphTraits::computeHiddenNodes(const Function *F) {
   auto evaluateBB = [&](const BasicBlock *Node) {
-if (succ_begin(Node) == succ_end(Node)) {
+if (succ_empty(Node)) {
   const Instruction *TI = Node->getTerminator();
   isHiddenBasicBlock[Node] =
   (HideUnreachablePaths && isa(TI)) ||



___
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] 55d13e6 - [asan][test] Annotate glibc specific tests with REQUIRES: glibc-2.27

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

Author: Fangrui Song
Date: 2020-12-28T19:56:08-08:00
New Revision: 55d13e6a867450d4a131612e4e93d60458016c8d

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

LOG: [asan][test] Annotate glibc specific tests with REQUIRES: glibc-2.27

Added: 


Modified: 
compiler-rt/test/asan/TestCases/Linux/printf-fortify-1.c
compiler-rt/test/asan/TestCases/Linux/printf-fortify-2.c
compiler-rt/test/asan/TestCases/Linux/printf-fortify-3.c
compiler-rt/test/asan/TestCases/Linux/printf-fortify-4.c
compiler-rt/test/asan/TestCases/Linux/printf-fortify-5.c
compiler-rt/test/asan/TestCases/Linux/swapcontext_annotation.cpp
compiler-rt/test/asan/TestCases/Linux/swapcontext_test.cpp
compiler-rt/test/asan/TestCases/malloc-no-intercept.c

Removed: 




diff  --git a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-1.c 
b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-1.c
index 2e0c70c1e648..daa2f3993b26 100644
--- a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-1.c
+++ b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-1.c
@@ -1,7 +1,7 @@
 // RUN: %clang -fPIC -shared -O2 -D_FORTIFY_SOURCE=2 -D_DSO %s -o %t.so
 // RUN: %clang_asan -o %t %t.so %s
 // RUN: not %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: android
+// REQUIRES: glibc-2.27
 #ifdef _DSO
 #include 
 #include 

diff  --git a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-2.c 
b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-2.c
index 6ea1e00e4a66..a105fdda730e 100644
--- a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-2.c
+++ b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-2.c
@@ -1,7 +1,7 @@
 // RUN: %clang -fPIC -shared -O2 -D_FORTIFY_SOURCE=2 -D_DSO %s -o %t.so
 // RUN: %clang_asan %s -o %t %t.so
 // RUN: not %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: android
+// REQUIRES: glibc-2.27
 #ifdef _DSO
 #include 
 #include 

diff  --git a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-3.c 
b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-3.c
index a4b49dc98167..dcc12dd3c055 100644
--- a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-3.c
+++ b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-3.c
@@ -1,7 +1,7 @@
 // RUN: %clang -shared -fPIC -D_DSO -O2 -D_FORTIFY_SOURCE=2 %s -o %t.so
 // RUN: %clang_asan %s -o %t %t.so
 // RUN: not %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: android
+// REQUIRES: glibc-2.27
 #ifdef _DSO
 #include 
 #include 

diff  --git a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-4.c 
b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-4.c
index 57ec42f3823a..db89ca2037f6 100644
--- a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-4.c
+++ b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-4.c
@@ -1,7 +1,7 @@
 // RUN: %clang -fPIC -shared -O2 -D_FORTIFY_SOURCE=2 -D_DSO %s -o %t.so
 // RUN: %clang_asan %s -o %t %t.so
 // RUN: not %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: android
+// REQUIRES: glibc-2.27
 #ifdef _DSO
 #include 
 #include 

diff  --git a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-5.c 
b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-5.c
index 487457a90de1..c7522e4029ea 100644
--- a/compiler-rt/test/asan/TestCases/Linux/printf-fortify-5.c
+++ b/compiler-rt/test/asan/TestCases/Linux/printf-fortify-5.c
@@ -1,7 +1,7 @@
 // RUN: %clang -fPIC -shared -O2 -D_FORTIFY_SOURCE=2 -D_DSO %s -o %t.so
 // RUN: %clang_asan -o %t %t.so %s
 // RUN: not %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: android
+// REQUIRES: glibc-2.27
 #ifdef _DSO
 #include 
 #include 

diff  --git a/compiler-rt/test/asan/TestCases/Linux/swapcontext_annotation.cpp 
b/compiler-rt/test/asan/TestCases/Linux/swapcontext_annotation.cpp
index 5eae27a32167..2e4179a6e706 100644
--- a/compiler-rt/test/asan/TestCases/Linux/swapcontext_annotation.cpp
+++ b/compiler-rt/test/asan/TestCases/Linux/swapcontext_annotation.cpp
@@ -12,8 +12,8 @@
 
 //
 // This test is too subtle to try on non-x86 arch for now.
-// Android does not support swapcontext.
-// REQUIRES: x86-target-arch && !android
+// Android and musl do not support swapcontext.
+// REQUIRES: x86-target-arch && glibc-2.27
 
 #include 
 #include 

diff  --git a/compiler-rt/test/asan/TestCases/Linux/swapcontext_test.cpp 
b/compiler-rt/test/asan/TestCases/Linux/swapcontext_test.cpp
index 2660ffe3ba70..7478225899af 100644
--- a/compiler-rt/test/asan/TestCases/Linux/swapcontext_test.cpp
+++ b/compiler-rt/test/asan/TestCases/Linux/swapcontext_test.cpp
@@ -6,8 +6,8 @@
 // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1 | FileCheck %s
 //
 // This test is too sublte to try on non-x86 arch for now.
-// Android does not support swapcontext.
-// REQUIRES: x86-target-arch && !android
+// Android and musl do not support swapcontext.
+// REQUIRES: x86-target-arch && glibc-2.27
 
 #include 
 #in

[llvm-branch-commits] [llvm] c2ef06d - [NewPM] Port infer-address-spaces

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

Author: Arthur Eubanks
Date: 2020-12-28T19:58:12-08:00
New Revision: c2ef06d3dd09d4e4e9665ca9f61e7672ad937827

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

LOG: [NewPM] Port infer-address-spaces

And add it to the AMDGPU opt pipeline.

Reviewed By: arsenm

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

Added: 
llvm/include/llvm/Transforms/Scalar/InferAddressSpaces.h

Modified: 
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
llvm/test/CodeGen/AMDGPU/infer-addrpace-pipeline.ll
llvm/test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll
llvm/tools/opt/opt.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Scalar/InferAddressSpaces.h 
b/llvm/include/llvm/Transforms/Scalar/InferAddressSpaces.h
new file mode 100644
index ..9a56b073f1c6
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Scalar/InferAddressSpaces.h
@@ -0,0 +1,27 @@
+//===- InferAddressSpace.h - 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H
+#define LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+struct InferAddressSpacesPass : PassInfoMixin {
+  InferAddressSpacesPass();
+  InferAddressSpacesPass(unsigned AddressSpace);
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+private:
+  unsigned FlatAddrSpace = 0;
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_SCALAR_INFERADDRESSSPACES_H

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 1f1004c2c414..dad40a2f540f 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -102,10 +102,10 @@
 #include "llvm/Transforms/IPO/GlobalOpt.h"
 #include "llvm/Transforms/IPO/GlobalSplit.h"
 #include "llvm/Transforms/IPO/HotColdSplitting.h"
+#include "llvm/Transforms/IPO/IROutliner.h"
 #include "llvm/Transforms/IPO/InferFunctionAttrs.h"
 #include "llvm/Transforms/IPO/Inliner.h"
 #include "llvm/Transforms/IPO/Internalize.h"
-#include "llvm/Transforms/IPO/IROutliner.h"
 #include "llvm/Transforms/IPO/LoopExtractor.h"
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
 #include "llvm/Transforms/IPO/MergeFunctions.h"
@@ -154,6 +154,7 @@
 #include "llvm/Transforms/Scalar/IVUsersPrinter.h"
 #include "llvm/Transforms/Scalar/IndVarSimplify.h"
 #include "llvm/Transforms/Scalar/InductiveRangeCheckElimination.h"
+#include "llvm/Transforms/Scalar/InferAddressSpaces.h"
 #include "llvm/Transforms/Scalar/InstSimplifyPass.h"
 #include "llvm/Transforms/Scalar/JumpThreading.h"
 #include "llvm/Transforms/Scalar/LICM.h"

diff  --git a/llvm/lib/Passes/PassRegistry.def 
b/llvm/lib/Passes/PassRegistry.def
index b00a7bd14b4f..3db0cfffb059 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -227,6 +227,7 @@ FUNCTION_PASS("post-inline-ee-instrument", 
EntryExitInstrumenterPass(/*PostInlin
 FUNCTION_PASS("gvn-hoist", GVNHoistPass())
 FUNCTION_PASS("gvn-sink", GVNSinkPass())
 FUNCTION_PASS("helloworld", HelloWorldPass())
+FUNCTION_PASS("infer-address-spaces", InferAddressSpacesPass())
 FUNCTION_PASS("instcombine", InstCombinePass())
 FUNCTION_PASS("instcount", InstCountPass())
 FUNCTION_PASS("instsimplify", InstSimplifyPass())

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 89ae9d8029e0..26d76dd7fede 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -54,6 +54,7 @@
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
+#include "llvm/Transforms/Scalar/InferAddressSpaces.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/SimplifyLibCalls.h"
 #include "llvm/Transforms/Vectorize.h"
@@ -523,13 +524,20 @@ void 
AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB,
   PB.registerCGSCCOptimizerLateEPCallback(
   [this, DebugPassManager](CGSCCPassManager &PM,
PassBuilder::OptimizationLevel Level) {
-if (Level != PassBuilder::OptimizationLevel::O0) {
   FunctionPassManager FPM(DebugPassManager);
-  // Promote alloca to vector before SROA and loop unroll. If we manage
-  // to eliminate allocas before unr

[llvm-branch-commits] [clang] c5d100f - [test] Fix conditional-temporaries.cpp

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

Author: Arthur Eubanks
Date: 2020-12-28T20:17:31-08:00
New Revision: c5d100fdf2d782886215061e1ae0b4b072babce0

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

LOG: [test] Fix conditional-temporaries.cpp

Broken by https://reviews.llvm.org/D93880.
(but now the test is much better :) )

Added: 


Modified: 
clang/test/CodeGenCXX/conditional-temporaries.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/conditional-temporaries.cpp 
b/clang/test/CodeGenCXX/conditional-temporaries.cpp
index 8ea71dc3c3feb..65f977704d82f 100644
--- a/clang/test/CodeGenCXX/conditional-temporaries.cpp
+++ b/clang/test/CodeGenCXX/conditional-temporaries.cpp
@@ -1,10 +1,10 @@
 // REQUIRES: amdgpu-registered-target
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O2 
-fno-experimental-new-pass-manager -disable-llvm-passes | FileCheck %s 
--check-prefixes=CHECK,CHECK-NOOPT
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O2 
-fno-experimental-new-pass-manager | FileCheck %s 
--check-prefixes=CHECK,CHECK-OPT,CHECK-LEGACY-OPT
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=amdgcn-amd-amdhsa -O2 
-fno-experimental-new-pass-manager | FileCheck %s 
--check-prefixes=CHECK,CHECK-OPT,CHECK-LEGACY-OPT
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O2 
-fno-experimental-new-pass-manager | FileCheck %s 
--check-prefixes=CHECK,CHECK-OPT
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=amdgcn-amd-amdhsa -O2 
-fno-experimental-new-pass-manager | FileCheck %s 
--check-prefixes=CHECK,CHECK-OPT
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O2 
-fexperimental-new-pass-manager -disable-llvm-passes | FileCheck %s 
--check-prefixes=CHECK,CHECK-NOOPT
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O2 
-fexperimental-new-pass-manager | FileCheck %s 
--check-prefixes=CHECK,CHECK-OPT,X64-NEWPM-OPT
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=amdgcn-amd-amdhsa -O2 
-fexperimental-new-pass-manager | FileCheck %s 
--check-prefixes=CHECK,CHECK-OPT,AMDGCN-NEWPM-OPT
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O2 
-fexperimental-new-pass-manager | FileCheck %s --check-prefixes=CHECK,CHECK-OPT
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=amdgcn-amd-amdhsa -O2 
-fexperimental-new-pass-manager | FileCheck %s --check-prefixes=CHECK,CHECK-OPT
 
 namespace {
 
@@ -44,30 +44,19 @@ Checker c;
 
 // CHECK-OPT-LABEL: define i32 @_Z12getCtorCallsv()
 int getCtorCalls() {
-  // CHECK-LEGACY-OPT: ret i32 5
-  // X64-NEWPM-OPT: ret i32 5
-  // AMDGCN-NEWPM-OPT: [[RET:%.*]] = load i32, i32* addrspacecast (i32 
addrspace(1)* @_ZN12_GLOBAL__N_19ctorcallsE to i32*), align 4
-  // AMDGCN-NEWPM-OPT: ret i32 [[RET]]
+  // CHECK-OPT: ret i32 5
   return ctorcalls;
 }
 
 // CHECK-OPT-LABEL: define i32 @_Z12getDtorCallsv()
 int getDtorCalls() {
-  // CHECK-LEGACY-OPT: ret i32 5
-  // X64-NEWPM-OPT: ret i32 5
-  // AMDGCN-NEWPM-OPT: [[RET:%.*]] = load i32, i32* addrspacecast (i32 
addrspace(1)* @_ZN12_GLOBAL__N_19dtorcallsE to i32*), align 4
-  // AMDGCN-NEWPM-OPT: ret i32 [[RET]]
+  // CHECK-OPT: ret i32 5
   return dtorcalls;
 }
 
 // CHECK-OPT-LABEL: define zeroext i1 @_Z7successv()
 bool success() {
-  // CHECK-LEGACY-OPT: ret i1 true
-  // X64-NEWPM-OPT: ret i1 true
-  // AMDGCN-NEWPM-OPT: [[CTORS:%.*]] = load i32, i32* addrspacecast (i32 
addrspace(1)* @_ZN12_GLOBAL__N_19ctorcallsE to i32*), align 4, !tbaa !2
-  // AMDGCN-NEWPM-OPT: [[DTORS:%.*]] = load i32, i32* addrspacecast (i32 
addrspace(1)* @_ZN12_GLOBAL__N_19dtorcallsE to i32*), align 4, !tbaa !2
-  // AMDGCN-NEWPM-OPT: %cmp = icmp eq i32 [[CTORS]], [[DTORS]]
-  // AMDGCN-NEWPM-OPT: ret i1 %cmp
+  // CHECK-OPT: ret i1 true
   return ctorcalls == dtorcalls;
 }
 



___
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] a8970df - [ubsan][test] FLush stdout before checking interleaved stdout/stderr

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

Author: Fangrui Song
Date: 2020-12-28T20:30:32-08:00
New Revision: a8970dff1aece1f83e63f723847098ba992ef185

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

LOG: [ubsan][test] FLush stdout before checking interleaved stdout/stderr

Detected by musl.

Added: 


Modified: 
compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp

Removed: 




diff  --git a/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp 
b/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp
index c02702847afb..f3b13e33f123 100644
--- a/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp
+++ b/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp
@@ -29,6 +29,7 @@ void __ubsan_on_report(void) {
   printf("Issue: %s\n", IssueKind);
   printf("Location: %s:%u:%u\n", Filename, Line, Col);
   printf("Message: %s\n", Message);
+  fflush(stdout);
 
   (void)Addr;
 }



___
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] 53f80d6 - [lldb] Fix logging in lldb-server tests

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

Author: Pavel Labath
Date: 2020-12-29T08:33:12+01:00
New Revision: 53f80d6b3a01a79a9d448ad117c4b54a15ad08af

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

LOG: [lldb] Fix logging in lldb-server tests

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 71e75adbecb7..91509f609096 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -126,7 +126,7 @@ def setUp(self):
 if self.isVerboseLoggingRequested():
 # If requested, full logs go to a log file
 self._verbose_log_handler = logging.FileHandler(
-self.log_basename + "-host.log")
+self.getLogBasenameForCurrentTest() + "-host.log")
 self._verbose_log_handler.setFormatter(self._log_formatter)
 self._verbose_log_handler.setLevel(logging.DEBUG)
 self.logger.addHandler(self._verbose_log_handler)
@@ -166,7 +166,7 @@ def build(self, *args, **kwargs):
 self.buildDefault(*args, **kwargs)
 
 def getLocalServerLogFile(self):
-return self.log_basename + "-server.log"
+return self.getLogBasenameForCurrentTest() + "-server.log"
 
 def setUpServerLogging(self, is_llgs):
 if len(lldbtest_config.channels) == 0:



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


[llvm-branch-commits] [lld] ed146d6 - [LLD][ELF] - Use LLVM_ELF_IMPORT_TYPES_ELFT instead of multiple types definitions. NFCI.

2020-12-28 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-12-29T10:50:07+03:00
New Revision: ed146d6291ce510ef954d350e2ca5a107890c2d2

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

LOG: [LLD][ELF] - Use LLVM_ELF_IMPORT_TYPES_ELFT instead of multiple types 
definitions. NFCI.

We can reduce the number of "using" declarations.
`LLVM_ELF_IMPORT_TYPES_ELFT` was extended in D93801.

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

Added: 


Modified: 
lld/ELF/InputFiles.h
lld/ELF/SyntheticSections.h
lld/ELF/Writer.cpp

Removed: 




diff  --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 7ffe4c29cb87..cdd6b5c2ce99 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -189,12 +189,7 @@ class ELFFileBase : public InputFile {
 
 // .o file.
 template  class ObjFile : public ELFFileBase {
-  using Elf_Rel = typename ELFT::Rel;
-  using Elf_Rela = typename ELFT::Rela;
-  using Elf_Sym = typename ELFT::Sym;
-  using Elf_Shdr = typename ELFT::Shdr;
-  using Elf_Word = typename ELFT::Word;
-  using Elf_CGProfile = typename ELFT::CGProfile;
+  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
 
 public:
   static bool classof(const InputFile *f) { return f->kind() == ObjKind; }

diff  --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 8943596179c1..c20386cc20da 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -461,12 +461,7 @@ class DynamicReloc {
 };
 
 template  class DynamicSection final : public SyntheticSection {
-  using Elf_Dyn = typename ELFT::Dyn;
-  using Elf_Rel = typename ELFT::Rel;
-  using Elf_Rela = typename ELFT::Rela;
-  using Elf_Relr = typename ELFT::Relr;
-  using Elf_Shdr = typename ELFT::Shdr;
-  using Elf_Sym = typename ELFT::Sym;
+  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
 
   // finalizeContents() fills this vector with the section contents.
   std::vector>> entries;

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 98139b56b29b..0397dae8f891 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -45,10 +45,9 @@ namespace {
 // The writer writes a SymbolTable result to a file.
 template  class Writer {
 public:
+  LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
+
   Writer() : buffer(errorHandler().outputBuffer) {}
-  using Elf_Shdr = typename ELFT::Shdr;
-  using Elf_Ehdr = typename ELFT::Ehdr;
-  using Elf_Phdr = typename ELFT::Phdr;
 
   void run();
 



___
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] a485a59 - [benchmark] Fixed a build error when using CMake 3.15.1 + NDK-R20

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

Author: AnZhong Huang
Date: 2020-12-28T11:24:56+03:00
New Revision: a485a59d2172daaee1d5e734da54fbb243f7d54c

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

LOG: [benchmark] Fixed a build error when using CMake 3.15.1 + NDK-R20

std::decay_t used by llvm/utils/benchmark/include/benchmark/benchmark.h
is a c++14 feature, but the CMakelist uses c++11,
it's the root-cause of build error.

There are two options to fix the error.
1) change the CMakelist to support c++14.
2) change std::decay_t to std::decay, it's what the patch done.

This bug can only be reproduced by CMake 3.15, we didn't observer the bug
with CMake 3.16. But based on the code's logic, it's an obvious bug of LLVM.

The upstream code is fine, the problem was introduced by
rG1bd6123b781120c9190b9ba58b900cdcb718cdd1.

Reviewed By: lebedev.ri

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

Added: 


Modified: 
llvm/utils/benchmark/include/benchmark/benchmark.h

Removed: 




diff  --git a/llvm/utils/benchmark/include/benchmark/benchmark.h 
b/llvm/utils/benchmark/include/benchmark/benchmark.h
index ab61c46e9386..0b4baec41755 100644
--- a/llvm/utils/benchmark/include/benchmark/benchmark.h
+++ b/llvm/utils/benchmark/include/benchmark/benchmark.h
@@ -990,7 +990,7 @@ inline internal::Benchmark* RegisterBenchmark(const char* 
name,
 #ifdef BENCHMARK_HAS_CXX11
 template 
 internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn) {
-  using BenchType = internal::LambdaBenchmark>;
+  using BenchType = internal::LambdaBenchmark>;
   return internal::RegisterBenchmarkInternal(
   ::new BenchType(name, std::forward(fn)));
 }



___
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] 5b17263 - [AMDGPU][MC][NFC] Parser refactoring

2020-12-28 Thread Dmitry Preobrazhensky via llvm-branch-commits

Author: Dmitry Preobrazhensky
Date: 2020-12-28T14:59:49+03:00
New Revision: 5b17263b6b9d25d02581c2e44efa0c4dcad5ecf4

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

LOG: [AMDGPU][MC][NFC] Parser refactoring

See bug 48515 (https://bugs.llvm.org/show_bug.cgi?id=48515)

Reviewers: rampitec

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp 
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index f6b204f2415f..c04ea4c81032 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -2529,11 +2529,11 @@ bool 
AMDGPUAsmParser::updateGprCountSymbols(RegisterKind RegKind,
   int64_t OldCount;
 
   if (!Sym->isVariable())
-return !Error(getParser().getTok().getLoc(),
+return !Error(getLoc(),
   ".amdgcn.next_free_{v,s}gpr symbols must be variable");
   if (!Sym->getVariableValue(false)->evaluateAsAbsolute(OldCount))
 return !Error(
-getParser().getTok().getLoc(),
+getLoc(),
 ".amdgcn.next_free_{v,s}gpr symbols must be absolute expressions");
 
   if (OldCount <= NewMax)
@@ -2544,7 +2544,7 @@ bool AMDGPUAsmParser::updateGprCountSymbols(RegisterKind 
RegKind,
 
 std::unique_ptr
 AMDGPUAsmParser::parseRegister(bool RestoreOnFailure) {
-  const auto &Tok = Parser.getTok();
+  const auto &Tok = getToken();
   SMLoc StartLoc = Tok.getLoc();
   SMLoc EndLoc = Tok.getEndLoc();
   RegisterKind RegKind;
@@ -4058,7 +4058,7 @@ bool AMDGPUAsmParser::MatchAndEmitInstruction(SMLoc 
IDLoc, unsigned &Opcode,
 
 bool AMDGPUAsmParser::ParseAsAbsoluteExpression(uint32_t &Ret) {
   int64_t Tmp = -1;
-  if (getLexer().isNot(AsmToken::Integer) && 
getLexer().isNot(AsmToken::Identifier)) {
+  if (!isToken(AsmToken::Integer) && !isToken(AsmToken::Identifier)) {
 return true;
   }
   if (getParser().parseAbsoluteExpression(Tmp)) {
@@ -4088,25 +4088,24 @@ bool AMDGPUAsmParser::ParseDirectiveAMDGCNTarget() {
 
   std::string Target;
 
-  SMLoc TargetStart = getTok().getLoc();
+  SMLoc TargetStart = getLoc();
   if (getParser().parseEscapedString(Target))
 return true;
-  SMRange TargetRange = SMRange(TargetStart, getTok().getLoc());
+  SMRange TargetRange = SMRange(TargetStart, getLoc());
 
   std::string ExpectedTarget;
   raw_string_ostream ExpectedTargetOS(ExpectedTarget);
   IsaInfo::streamIsaVersion(&getSTI(), ExpectedTargetOS);
 
   if (Target != ExpectedTargetOS.str())
-return getParser().Error(TargetRange.Start, "target must match options",
- TargetRange);
+return Error(TargetRange.Start, "target must match options", TargetRange);
 
   getTargetStreamer().EmitDirectiveAMDGCNTarget(Target);
   return false;
 }
 
 bool AMDGPUAsmParser::OutOfRangeError(SMRange Range) {
-  return getParser().Error(Range.Start, "value out of range", Range);
+  return Error(Range.Start, "value out of range", Range);
 }
 
 bool AMDGPUAsmParser::calculateGPRBlocks(
@@ -4191,11 +4190,11 @@ bool AMDGPUAsmParser::ParseDirectiveAMDHSAKernel() {
   return TokError(".amdhsa_ directives cannot be repeated");
 Seen.insert(ID);
 
-SMLoc ValStart = getTok().getLoc();
+SMLoc ValStart = getLoc();
 int64_t IVal;
 if (getParser().parseAbsoluteExpression(IVal))
   return true;
-SMLoc ValEnd = getTok().getLoc();
+SMLoc ValEnd = getLoc();
 SMRange ValRange = SMRange(ValStart, ValEnd);
 
 if (IVal < 0)
@@ -4260,8 +4259,7 @@ bool AMDGPUAsmParser::ParseDirectiveAMDHSAKernel() {
 UserSGPRCount += 1;
 } else if (ID == ".amdhsa_wavefront_size32") {
   if (IVersion.Major < 10)
-return getParser().Error(IDRange.Start, "directive requires gfx10+",
- IDRange);
+return Error(IDRange.Start, "directive requires gfx10+", IDRange);
   EnableWavefrontSize32 = Val;
   PARSE_BITS_ENTRY(KD.kernel_code_properties,
KERNEL_CODE_PROPERTY_ENABLE_WAVEFRONT_SIZE32,
@@ -4303,15 +4301,13 @@ bool AMDGPUAsmParser::ParseDirectiveAMDHSAKernel() {
   ReserveVCC = Val;
 } else if (ID == ".amdhsa_reserve_flat_scratch") {
   if (IVersion.Major < 7)
-return getParser().Error(IDRange.Start, "directive requires gfx7+",
- IDRange);
+return Error(IDRange.Start, "directive requires gfx7+", IDRange);
   if (!isUInt<1>(Val))
 return OutOfRangeError(ValRange);
   ReserveFlatScr = Val;
 } else if (ID == ".amdhsa_reserve_xnack_mask") {
   if (IVersion.Major < 8)
-return getParser().Error(IDRange.Start, "directive requires gfx8+",
-   

[llvm-branch-commits] [llvm] 8c25bb3 - [AMDGPU][MC] Improved errors handling for v_interp* operands

2020-12-28 Thread Dmitry Preobrazhensky via llvm-branch-commits

Author: Dmitry Preobrazhensky
Date: 2020-12-28T16:15:48+03:00
New Revision: 8c25bb3d0d5e956a3dc3a8d26b2e7ab509d0b72c

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

LOG: [AMDGPU][MC] Improved errors handling for v_interp* operands

See bug 48596 (https://bugs.llvm.org/show_bug.cgi?id=48596)

Reviewers: rampitec

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/test/MC/AMDGPU/gfx10_err_pos.s
llvm/test/MC/AMDGPU/vintrp-err.s

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp 
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index c04ea4c81032..ae10b47d2e9b 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -5831,34 +5831,40 @@ bool AMDGPUOperand::isSendMsg() const {
 
//===--===//
 
 OperandMatchResultTy AMDGPUAsmParser::parseInterpSlot(OperandVector &Operands) 
{
-  if (!isToken(AsmToken::Identifier))
+  StringRef Str;
+  SMLoc S = getLoc();
+
+  if (!parseId(Str))
 return MatchOperand_NoMatch;
 
-  StringRef Str = getTokenStr();
   int Slot = StringSwitch(Str)
 .Case("p10", 0)
 .Case("p20", 1)
 .Case("p0", 2)
 .Default(-1);
 
-  SMLoc S = getLoc();
-  if (Slot == -1)
+  if (Slot == -1) {
+Error(S, "invalid interpolation slot");
 return MatchOperand_ParseFail;
+  }
 
-  Parser.Lex();
   Operands.push_back(AMDGPUOperand::CreateImm(this, Slot, S,
   AMDGPUOperand::ImmTyInterpSlot));
   return MatchOperand_Success;
 }
 
 OperandMatchResultTy AMDGPUAsmParser::parseInterpAttr(OperandVector &Operands) 
{
-  if (!isToken(AsmToken::Identifier))
-return MatchOperand_NoMatch;
+  StringRef Str;
+  SMLoc S = getLoc();
 
-  StringRef Str = getTokenStr();
-  if (!Str.startswith("attr"))
+  if (!parseId(Str))
 return MatchOperand_NoMatch;
 
+  if (!Str.startswith("attr")) {
+Error(S, "invalid interpolation attribute");
+return MatchOperand_ParseFail;
+  }
+
   StringRef Chan = Str.take_back(2);
   int AttrChan = StringSwitch(Chan)
 .Case(".x", 0)
@@ -5866,19 +5872,21 @@ OperandMatchResultTy 
AMDGPUAsmParser::parseInterpAttr(OperandVector &Operands) {
 .Case(".z", 2)
 .Case(".w", 3)
 .Default(-1);
-  if (AttrChan == -1)
+  if (AttrChan == -1) {
+Error(S, "invalid or missing interpolation attribute channel");
 return MatchOperand_ParseFail;
+  }
 
   Str = Str.drop_back(2).drop_front(4);
 
   uint8_t Attr;
-  if (Str.getAsInteger(10, Attr))
+  if (Str.getAsInteger(10, Attr)) {
+Error(S, "invalid or missing interpolation attribute number");
 return MatchOperand_ParseFail;
+  }
 
-  SMLoc S = getLoc();
-  Parser.Lex();
   if (Attr > 63) {
-Error(S, "out of bounds attr");
+Error(S, "out of bounds interpolation attribute number");
 return MatchOperand_ParseFail;
   }
 

diff  --git a/llvm/test/MC/AMDGPU/gfx10_err_pos.s 
b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
index 013dba641001..7f77a0da2a78 100644
--- a/llvm/test/MC/AMDGPU/gfx10_err_pos.s
+++ b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
@@ -443,21 +443,6 @@ v_ceil_f16 v0, abs(neg(1))
 // CHECK-NEXT:{{^}}v_ceil_f16 v0, abs(neg(1))
 // CHECK-NEXT:{{^}}   ^
 
-v_interp_mov_f32 v11, invalid_param_3, attr0.y
-// CHECK: error: failed parsing operand.
-// CHECK-NEXT:{{^}}v_interp_mov_f32 v11, invalid_param_3, attr0.y
-// CHECK-NEXT:{{^}}  ^
-
-v_interp_mov_f32 v8, foo, attr0.x
-// CHECK: error: failed parsing operand.
-// CHECK-NEXT:{{^}}v_interp_mov_f32 v8, foo, attr0.x
-// CHECK-NEXT:{{^}} ^
-
-v_interp_p2_f32 v0, v1, attr
-// CHECK: error: failed parsing operand.
-// CHECK-NEXT:{{^}}v_interp_p2_f32 v0, v1, attr
-// CHECK-NEXT:{{^}}^
-
 
//==
 // first register index should not exceed second index
 
@@ -588,6 +573,22 @@ v_dot_f32_f16 v0, v1, v2
 // CHECK-NEXT:{{^}}v_dot_f32_f16 v0, v1, v2
 // CHECK-NEXT:{{^}}^
 
+//==
+// invalid interpolation attribute
+
+v_interp_p2_f32 v0, v1, att
+// CHECK: error: invalid interpolation attribute
+// CHECK-NEXT:{{^}}v_interp_p2_f32 v0, v1, att
+// CHECK-NEXT:{{^}}^
+
+//==
+// invalid interpolation slot
+
+v_interp_mov_f32 v8, p1, attr0.x
+// CHECK: error: invalid interpolation slot
+// CHECK-NEXT:{{^}}v_interp_mov_f32 v8, p1, attr0.x
+// CHECK-NEXT:{{^}} ^
+
 
//===

[llvm-branch-commits] [llvm] 644da78 - [AMDGPU] Split edge to make si_if dominate end_cf

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

Author: alex-t
Date: 2020-12-28T17:14:02+03:00
New Revision: 644da789e364b338227a13b5cc11dd03c8ae5ba8

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

LOG: [AMDGPU] Split edge to make si_if dominate end_cf

Basic block containing "if" not necessarily dominates block that is the "false" 
target for the if.

That "false" target block may have another predecessor besides the "if" block. 
IR value corresponding to the Exec mask is generated by the

si_if intrinsic and then used by the end_cf intrinsic. In this case IR verifier 
complains that 'Def does not dominate all uses'.

This change split the edge between the "if" block and "false" target block to 
make it dominated by the "if" block.

Reviewed By: arsenm

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

Added: 
llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll

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

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp 
b/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
index 3c41bf1fef5e..016c3b2019fd 100644
--- a/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
+++ b/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
@@ -313,8 +313,15 @@ void SIAnnotateControlFlow::closeControlFlow(BasicBlock 
*BB) {
 
   Value *Exec = popSaved();
   Instruction *FirstInsertionPt = &*BB->getFirstInsertionPt();
-  if (!isa(Exec) && !isa(FirstInsertionPt))
+  if (!isa(Exec) && !isa(FirstInsertionPt)) {
+Instruction *ExecDef = cast(Exec);
+BasicBlock *DefBB = ExecDef->getParent();
+if (!DT->dominates(DefBB, BB)) {
+  // Split edge to make Def dominate Use
+  FirstInsertionPt = &*SplitEdge(DefBB, BB, DT, LI)->getFirstInsertionPt();
+}
 CallInst::Create(EndCf, Exec, "", FirstInsertionPt);
+  }
 }
 
 /// Annotate the control flow with intrinsics so the backend can
@@ -327,7 +334,6 @@ bool SIAnnotateControlFlow::runOnFunction(Function &F) {
   const TargetMachine &TM = TPC.getTM();
 
   initialize(*F.getParent(), TM.getSubtarget(F));
-
   for (df_iterator I = df_begin(&F.getEntryBlock()),
E = df_end(&F.getEntryBlock()); I != E; ++I) {
 BasicBlock *BB = *I;
@@ -344,7 +350,8 @@ bool SIAnnotateControlFlow::runOnFunction(Function &F) {
   if (isTopOfStack(BB))
 closeControlFlow(BB);
 
-  handleLoop(Term);
+  if (DT->dominates(Term->getSuccessor(1), BB))
+handleLoop(Term);
   continue;
 }
 

diff  --git a/llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll 
b/llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll
new file mode 100644
index ..60990267bd6c
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll
@@ -0,0 +1,333 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=amdgcn-amdhsa -verify-machineinstrs < %s | FileCheck 
-check-prefix=GCN -check-prefix=SI %s
+; RUN: opt -S -si-annotate-control-flow -mtriple=amdgcn-amdhsa 
-verify-machineinstrs < %s | FileCheck -check-prefix=SI-OPT %s
+
+define hidden void @widget() {
+; GCN-LABEL: widget:
+; GCN:   ; %bb.0: ; %bb
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:s_or_saveexec_b64 s[4:5], -1
+; GCN-NEXT:buffer_store_dword v40, off, s[0:3], s32 ; 4-byte Folded Spill
+; GCN-NEXT:s_mov_b64 exec, s[4:5]
+; GCN-NEXT:v_writelane_b32 v40, s33, 2
+; GCN-NEXT:s_mov_b32 s33, s32
+; GCN-NEXT:s_add_u32 s32, s32, 0x400
+; GCN-NEXT:v_mov_b32_e32 v0, 0
+; GCN-NEXT:v_mov_b32_e32 v1, 0
+; GCN-NEXT:flat_load_dword v0, v[0:1]
+; GCN-NEXT:s_waitcnt vmcnt(0)
+; GCN-NEXT:v_cmp_gt_i32_e32 vcc, 21, v0
+; GCN-NEXT:s_and_b64 vcc, exec, vcc
+; GCN-NEXT:v_writelane_b32 v40, s30, 0
+; GCN-NEXT:v_writelane_b32 v40, s31, 1
+; GCN-NEXT:s_cbranch_vccz BB0_3
+; GCN-NEXT:  ; %bb.1: ; %bb4
+; GCN-NEXT:v_cmp_ne_u32_e32 vcc, 9, v0
+; GCN-NEXT:s_and_b64 vcc, exec, vcc
+; GCN-NEXT:s_cbranch_vccnz BB0_4
+; GCN-NEXT:  ; %bb.2: ; %bb7
+; GCN-NEXT:s_getpc_b64 s[4:5]
+; GCN-NEXT:s_add_u32 s4, s4, wibble@rel32@lo+4
+; GCN-NEXT:s_addc_u32 s5, s5, wibble@rel32@hi+12
+; GCN-NEXT:s_swappc_b64 s[30:31], s[4:5]
+; GCN-NEXT:s_branch BB0_7
+; GCN-NEXT:  BB0_3: ; %bb2
+; GCN-NEXT:v_cmp_eq_u32_e32 vcc, 21, v0
+; GCN-NEXT:s_and_b64 vcc, exec, vcc
+; GCN-NEXT:s_cbranch_vccnz BB0_6
+; GCN-NEXT:  BB0_4: ; %bb9
+; GCN-NEXT:s_getpc_b64 s[4:5]
+; GCN-NEXT:s_add_u32 s4, s4, wibble@rel32@lo+4
+; GCN-NEXT:s_addc_u32 s5, s5, wibble@rel32@hi+12
+; GCN-NEXT:s_swappc_b64 s[30:31], s[4:5]
+; GCN-NEXT:v_cmp_lt_f32_e32 vcc, 0, v0
+; GCN-NEXT:s_and_saveexec_b64 s[4:5], vcc
+; GCN-NEXT:

[llvm-branch-commits] [clang-tools-extra] 0999408 - [clangd] Add error handling (elog) in code completion.

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

Author: Adam Czachorowski
Date: 2020-12-28T15:22:54+01:00
New Revision: 0999408aea79dd69f182cfcb618006f6cf2b6d4e

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

LOG: [clangd] Add error handling (elog) in code completion.

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index cc6b5dbc9904..ebdbd56c286a 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -182,12 +182,18 @@ struct CompletionCandidate {
 // strings (literal or URI) mapping to the same file. We still want to
 // bundle those, so we must resolve the header to be included here.
 std::string HeaderForHash;
-if (Inserter)
-  if (auto Header = headerToInsertIfAllowed(Opts))
-if (auto HeaderFile = toHeaderFile(*Header, FileName))
+if (Inserter) {
+  if (auto Header = headerToInsertIfAllowed(Opts)) {
+if (auto HeaderFile = toHeaderFile(*Header, FileName)) {
   if (auto Spelled =
   Inserter->calculateIncludePath(*HeaderFile, FileName))
 HeaderForHash = *Spelled;
+} else {
+  vlog("Code completion header path manipulation failed {0}",
+   HeaderFile.takeError());
+}
+  }
+}
 
 llvm::SmallString<256> Scratch;
 if (IndexResult) {



___
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] c3b9d85 - [clang-tidy][NFC] Remove unnecessary headers

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

Author: Nathan James
Date: 2020-12-28T15:01:51Z
New Revision: c3b9d85bd4b7249af9efe3594c6c152a032f83f8

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

LOG: [clang-tidy][NFC] Remove unnecessary headers

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyModule.h
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 633655e5e24a..12d2134026c4 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -22,13 +22,10 @@
 #include "ExpandModularHeadersPPCallbacks.h"
 #include "clang-tidy-config.h"
 #include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Format/Format.h"
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendActions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/MultiplexConsumer.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -43,7 +40,6 @@
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Process.h"
-#include "llvm/Support/Signals.h"
 #include 
 #include 
 

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 3567aac42c06..e1bea430a89a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -10,9 +10,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/WithColor.h"
 #include "llvm/Support/YAMLParser.h"
-#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 namespace tidy {

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 2c3f51a4034e..346fa66a662a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -23,7 +23,6 @@
 #include "clang/AST/Attr.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
 #include "clang/Tooling/Core/Diagnostic.h"
@@ -31,7 +30,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -39,6 +37,10 @@
 using namespace clang;
 using namespace tidy;
 
+#ifdef LLVM_CLANG_AST_ATTR_H
+//#error
+#endif
+
 namespace {
 class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
 public:

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyModule.h 
b/clang-tools-extra/clang-tidy/ClangTidyModule.h
index 7fd16c2a7b3c..dd21a8dbc6a4 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -13,9 +13,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
-#include 
 #include 
-#include 
 
 namespace clang {
 namespace tidy {

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 197552acf927..472123f8b306 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -16,7 +16,6 @@
 #include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/YAMLTraits.h"
-#include "llvm/Support/raw_ostream.h"
 #include 
 
 #define DEBUG_TYPE "clang-tidy-options"

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
index e60332d599a5..b107dd7385c6 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
@@ -7,11 +7,9 @@
 
//===--===//
 
 #include "ClangTidyProfiling.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 




[llvm-branch-commits] [llvm] e73f885 - [PowerPC] Remove redundant COPY_TO_REGCLASS introduced by 8a58f21f5b6c

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

Author: Nemanja Ivanovic
Date: 2020-12-28T09:26:51-06:00
New Revision: e73f885c988d7b94fcad64ddfa6a825e15e77a8f

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

LOG: [PowerPC] Remove redundant COPY_TO_REGCLASS introduced by 8a58f21f5b6c

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCInstrPrefix.td

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td 
b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
index e7fa2affb730..2f29811b20d8 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -2561,13 +2561,13 @@ let AddedComplexity = 400, Predicates = [IsISA3_1, 
IsLittleEndian] in {
   def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$src, 0)), xoaddr:$dst),
 (STXVRHX (COPY_TO_REGCLASS v8i16:$src, VSRC), xoaddr:$dst)>;
   def : Pat<(store (i32 (extractelt v4i32:$src, 0)), xoaddr:$dst),
-(STXVRWX (COPY_TO_REGCLASS v4i32:$src, VSRC), xoaddr:$dst)>;
+(STXVRWX $src, xoaddr:$dst)>;
   def : Pat<(store (f32 (extractelt v4f32:$src, 0)), xoaddr:$dst),
-(STXVRWX (COPY_TO_REGCLASS v4f32:$src, VSRC), xoaddr:$dst)>;
+(STXVRWX $src, xoaddr:$dst)>;
   def : Pat<(store (i64 (extractelt v2i64:$src, 0)), xoaddr:$dst),
-(STXVRDX (COPY_TO_REGCLASS v2i64:$src, VSRC), xoaddr:$dst)>;
+(STXVRDX $src, xoaddr:$dst)>;
   def : Pat<(store (f64 (extractelt v2f64:$src, 0)), xoaddr:$dst),
-(STXVRDX (COPY_TO_REGCLASS v2f64:$src, VSRC), xoaddr:$dst)>;
+(STXVRDX $src, xoaddr:$dst)>;
  }
 
 class xxevalPattern  imm> :



___
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] 496fb70 - [MachO] Fix enum-int mismatch warning

2020-12-28 Thread Mikael Holmen via llvm-branch-commits

Author: Gabriel Hjort Åkerlund
Date: 2020-12-28T17:39:41+01:00
New Revision: 496fb70b141ccbfaba9761294f3b4b97717096a3

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

LOG: [MachO] Fix enum-int mismatch warning

Change-Id: Ie637dc7761144e5552b05a9c286f1e736579823d

Reviewed By: arsenm

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

Added: 


Modified: 
lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp

Removed: 




diff  --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp 
b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index 42ac711bc9dc..ddfd1764f7e1 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -1561,7 +1561,7 @@ void Util::addExportInfo(const lld::File &atomFile, 
NormalizedFile &nFile) {
 uint32_t Util::fileFlags() {
   // FIXME: these need to determined at runtime.
   if (_ctx.outputMachOType() == MH_OBJECT) {
-return _subsectionsViaSymbols ? MH_SUBSECTIONS_VIA_SYMBOLS : 0;
+return _subsectionsViaSymbols ? (uint32_t)MH_SUBSECTIONS_VIA_SYMBOLS : 0;
   } else {
 uint32_t flags = MH_DYLDLINK;
 if (!_ctx.useFlatNamespace())



___
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] d55627d - [flang] Fix bugs in .mod file for abstract interface

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

Author: Tim Keith
Date: 2020-12-28T08:50:32-08:00
New Revision: d55627d221be8154cbdf454fa727afcc3f716b08

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

LOG: [flang] Fix bugs in .mod file for abstract interface

When an abstract interface is defined, add the ABSTRACT attribute to
subprogram symbols that define the interface body. Make use of that
when writing .mod files to include "abstract" on the interface statement.

Also, fix a problem with the order of symbols in a .mod file. Sometimes
a name is mentioned before the "real" declaration, e.g. in an access
statement. We want the order to be based on the real definitions. In
these cases we replace the symbol name with an identical name with a
different source location. Then by sorting based on the source location
we get symbols in the right order.

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

Added: 


Modified: 
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/modfile10.f90
flang/test/Semantics/procinterface01.f90
flang/test/Semantics/symbol15.f90

Removed: 




diff  --git a/flang/lib/Semantics/mod-file.cpp 
b/flang/lib/Semantics/mod-file.cpp
index 99ea65b753a6..f8e5889e4698 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -319,6 +319,10 @@ void ModFileWriter::PutSubprogram(const Symbol &symbol) {
 bindAttrs.set(Attr::BIND_C, true);
 attrs.set(Attr::BIND_C, false);
   }
+  bool isAbstract{attrs.test(Attr::ABSTRACT)};
+  if (isAbstract) {
+attrs.set(Attr::ABSTRACT, false);
+  }
   Attrs prefixAttrs{subprogramPrefixAttrs & attrs};
   // emit any non-prefix attributes in an attribute statement
   attrs &= ~subprogramPrefixAttrs;
@@ -331,7 +335,7 @@ void ModFileWriter::PutSubprogram(const Symbol &symbol) {
   bool isInterface{details.isInterface()};
   llvm::raw_ostream &os{isInterface ? decls_ : contains_};
   if (isInterface) {
-os << "interface\n";
+os << (isAbstract ? "abstract " : "") << "interface\n";
   }
   PutAttrs(os, prefixAttrs, std::nullopt, ""s, " "s);
   os << (details.isFunction() ? "function " : "subroutine ");
@@ -457,6 +461,11 @@ void CollectSymbols(
   }
 }
   }
+  // Sort most symbols by name: use of Symbol::ReplaceName ensures the source
+  // location of a symbol's name is the first "real" use.
+  std::sort(sorted.begin(), sorted.end(), [](SymbolRef x, SymbolRef y) {
+return x->name().begin() < y->name().begin();
+  });
   sorted.insert(sorted.end(), namelist.begin(), namelist.end());
   for (const auto &pair : scope.commonBlocks()) {
 sorted.push_back(*pair.second);

diff  --git a/flang/lib/Semantics/resolve-names.cpp 
b/flang/lib/Semantics/resolve-names.cpp
index 8d5284131cc0..73c624aefa22 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -3085,11 +3085,14 @@ Symbol &SubprogramVisitor::PushSubprogramScope(
 symbol = &MakeSymbol(name, SubprogramDetails{});
   }
   symbol->set(subpFlag);
+  symbol->ReplaceName(name.source);
   PushScope(Scope::Kind::Subprogram, symbol);
   auto &details{symbol->get()};
   if (inInterfaceBlock()) {
 details.set_isInterface();
-if (!isAbstract()) {
+if (isAbstract()) {
+  symbol->attrs().set(Attr::ABSTRACT);
+} else {
   MakeExternal(*symbol);
 }
 if (isGeneric()) {

diff  --git a/flang/test/Semantics/modfile10.f90 
b/flang/test/Semantics/modfile10.f90
index ef10f1f23e8e..996178f5896d 100644
--- a/flang/test/Semantics/modfile10.f90
+++ b/flang/test/Semantics/modfile10.f90
@@ -90,3 +90,40 @@ subroutine test
 !  subroutine test()
 !  end
 !end
+
+! Ensure the type is emitted before its use
+module m2
+  private s
+  type :: t
+  contains
+procedure :: foo
+  end type
+  abstract interface
+subroutine s(x)
+  import
+  type(t) :: x
+end subroutine
+  end interface
+contains
+  subroutine foo(x)
+class(t) :: x
+  end subroutine
+end module
+!Expect: m2.mod
+!module m2
+!  type::t
+!  contains
+!procedure::foo
+!  end type
+!  private::s
+!  abstract interface
+!subroutine s(x)
+!  import::t
+!  type(t)::x
+!end
+!  end interface
+!contains
+!  subroutine foo(x)
+!class(t)::x
+!  end
+!end

diff  --git a/flang/test/Semantics/procinterface01.f90 
b/flang/test/Semantics/procinterface01.f90
index a960922d5637..dd9fd3b66041 100644
--- a/flang/test/Semantics/procinterface01.f90
+++ b/flang/test/Semantics/procinterface01.f90
@@ -5,7 +5,7 @@
 !DEF: /module1 Module
 module module1
  abstract interface
-  !DEF: /module1/abstract1 PUBLIC (Function) Subprogram REAL(4)
+  !DEF: /module1/abstract1 ABSTRACT, PUBLIC (Function) Subprogram REAL(4)
   !DEF: /module1/abstract1/x INTENT(IN) ObjectEntity REAL(4)
   real functi

[llvm-branch-commits] [llvm] b9a7c89 - [MIRPrinter] Fix incorrect output of unnamed stack names

2020-12-28 Thread Mikael Holmen via llvm-branch-commits

Author: Gabriel Hjort Åkerlund
Date: 2020-12-28T18:01:40+01:00
New Revision: b9a7c89d4322b261b65eb96d678a9d38b776cb60

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

LOG: [MIRPrinter] Fix incorrect output of unnamed stack names

The MIRParser expects unnamed stack entries to have empty names ('').
In case of unnamed alloca instructions, the MIRPrinter would output
'', which caused the MIRParser to reject the generated
code.

Reviewed By: arsenm

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

Added: 
llvm/test/CodeGen/MIR/AArch64/unnamed-stack.ll

Modified: 
llvm/lib/CodeGen/MIRPrinter.cpp
llvm/test/CodeGen/PowerPC/alloca-crspill.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 25f785342d04..eae174019b56 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -415,7 +415,7 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction 
&YMF,
 YamlObject.ID = ID;
 if (const auto *Alloca = MFI.getObjectAllocation(I))
   YamlObject.Name.Value = std::string(
-  Alloca->hasName() ? Alloca->getName() : "");
+  Alloca->hasName() ? Alloca->getName() : "");
 YamlObject.Type = MFI.isSpillSlotObjectIndex(I)
   ? yaml::MachineStackObject::SpillSlot
   : MFI.isVariableSizedObjectIndex(I)

diff  --git a/llvm/test/CodeGen/MIR/AArch64/unnamed-stack.ll 
b/llvm/test/CodeGen/MIR/AArch64/unnamed-stack.ll
new file mode 100644
index ..c7e87e3f62a6
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/AArch64/unnamed-stack.ll
@@ -0,0 +1,23 @@
+; RUN: llc -O0 -march aarch64 -global-isel -stop-after=irtranslator -o - %s | 
llc -x mir -march aarch64 -run-pass=none -o - | FileCheck %s
+
+define i16 @unnamed_stack() {
+entry:
+  ; CHECK-NAME: unnamed_stack
+  ; CHECK:  stack:
+  ; CHECK-NEXT:   - { id: 0, name: '',
+  ; CHECK:  %0:_(p0) = G_FRAME_INDEX %stack.0
+  %0 = alloca i16
+  %1 = load i16, i16* %0
+  ret i16 %1
+}
+
+define i16 @named_stack() {
+entry:
+  ; CHECK-NAME: named_stack
+  ; CHECK:  stack:
+  ; CHECK-NEXT:   - { id: 0, name: ptr,
+  ; CHECK:  %0:_(p0) = G_FRAME_INDEX %stack.0.ptr
+  %ptr = alloca i16
+  %0 = load i16, i16* %ptr
+  ret i16 %0
+}

diff  --git a/llvm/test/CodeGen/PowerPC/alloca-crspill.ll 
b/llvm/test/CodeGen/PowerPC/alloca-crspill.ll
index f52e305fb05c..b71a9ff6d49b 100644
--- a/llvm/test/CodeGen/PowerPC/alloca-crspill.ll
+++ b/llvm/test/CodeGen/PowerPC/alloca-crspill.ll
@@ -49,8 +49,8 @@ declare signext i32 @do_something(double*)
 ; CHECK64-NEXT:   debug-info-variable: '', debug-info-expression: '', 
debug-info-location: '' }
 
 ; CHECK64-NEXT: stack:
-; CHECK64-NEXT:   - { id: 0, name: '', type: variable-sized, 
offset: -8,
-; CHECK64-NEXT:   alignment: 1, stack-id: default, callee-saved-register: 
'', callee-saved-restored: true,
+; CHECK64-NEXT:   - { id: 0, name: '', type: variable-sized, offset: -8, 
alignment: 1, 
+; CHECK64-NEXT:   stack-id: default, callee-saved-register: '', 
callee-saved-restored: true,
 ; CHECK64-NEXT:   local-offset: 0, debug-info-variable: '', 
debug-info-expression: '',
 ; CHECK64-NEXT:   debug-info-location: '' }
 ; CHECK64-NEXT:   - { id: 1, name: '', type: default, offset: -16, size: 8, 
alignment: 8,
@@ -68,8 +68,8 @@ declare signext i32 @do_something(double*)
 ; CHECK32-NEXT:   debug-info-variable: '', debug-info-expression: '', 
debug-info-location: '' }
 
 ; CHECK32-NEXT: stack:
-; CHECK32-NEXT:   - { id: 0, name: '', type: variable-sized, 
offset: -4,
-; CHECK32-NEXT:   alignment: 1, stack-id: default, callee-saved-register: 
'', callee-saved-restored: true,
+; CHECK32-NEXT:   - { id: 0, name: '', type: variable-sized, offset: -4, 
alignment: 1, 
+; CHECK32-NEXT:   stack-id: default, callee-saved-register: '', 
callee-saved-restored: true,
 ; CHECK32-NEXT:   local-offset: 0, debug-info-variable: '', 
debug-info-expression: '',
 ; CHECK32-NEXT:   debug-info-location: '' }
 ; CHECK32-NEXT:   - { id: 1, name: '', type: default, offset: -8, size: 4, 
alignment: 4,



___
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] d4ccef3 - [InstCombine] 'hoist xor-by-constant from xor-by-value': ignore constantexprs

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

Author: Roman Lebedev
Date: 2020-12-28T20:15:20+03:00
New Revision: d4ccef38d0bbcd70f56d586b4dfc988db863e388

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

LOG: [InstCombine] 'hoist xor-by-constant from xor-by-value': ignore 
constantexprs

As it is being reported (in post-commit review) in
https://reviews.llvm.org/D93857
this fold (as i expected, but failed to come up with test coverage
despite trying) has issues with constant expressions.
Since we only care about true constants, which constantexprs are not,
don't perform such hoisting for constant expressions.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 9d3b81a1cdd5..c0823c950368 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3458,11 +3458,11 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator 
&I) {
 return NewXor;
 
   // Otherwise, if all else failed, try to hoist the xor-by-constant:
-  // (X ^ C) ^ Y --> (X ^ Y) ^ C
-  // FIXME: does this need hardening against ConstantExpr's
-  //to prevent infinite combine loops?
-  if (match(&I,
-m_c_Xor(m_OneUse(m_Xor(m_Value(X), m_Constant(C1))), m_Value(Y
+  //   (X ^ C) ^ Y --> (X ^ Y) ^ C
+  // Just like we do in other places, we avoid the fold for constantexprs,
+  // at least to avoid endless combine loop.
+  if (match(&I, m_c_Xor(m_OneUse(m_Xor(m_Value(X), m_ImmConstant(C1))),
+m_Value(Y
 return BinaryOperator::CreateXor(Builder.CreateXor(X, Y), C1);
 
   return nullptr;

diff  --git 
a/llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll 
b/llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll
index e5ffb4622cbc..14227d304df7 100644
--- 
a/llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll
+++ 
b/llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll
@@ -73,3 +73,17 @@ define i8 @t5_commutativity(i8 %x) {
   %r = xor i8 %y, %i0
   ret i8 %r
 }
+
+@global_constant = internal global i32 0, align 4
+@global_constant2 = internal global i32 0, align 4
+
+define i8 @constantexpr(i8 %or) local_unnamed_addr #0 {
+; CHECK-LABEL: @constantexpr(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[R:%.*]] = xor i8 [[OR:%.*]], xor (i8 ptrtoint (i32* 
@global_constant to i8), i8 ptrtoint (i32* @global_constant2 to i8))
+; CHECK-NEXT:ret i8 [[R]]
+;
+entry:
+  %r = xor i8 %or, xor (i8 xor (i8 ptrtoint (i32* @global_constant to i8), i8 
-1), i8 xor (i8 ptrtoint (i32* @global_constant2 to i8), i8 -1))
+  ret i8 %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] 4820af9 - [TableGen] Fix bug in !interleave operator

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

Author: Paul C. Anagnostopoulos
Date: 2020-12-28T12:17:24-05:00
New Revision: 4820af99ddc3271198ee4fdd867dc65b11f5

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

LOG: [TableGen] Fix bug in !interleave operator

I forgot to account for unresolved elements of the list.

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

Added: 


Modified: 
llvm/lib/TableGen/Record.cpp
llvm/test/TableGen/interleave.td

Removed: 




diff  --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 9c0464d4e1bf..3e6daeb4d238 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -856,14 +856,19 @@ static StringInit *interleaveStringList(const ListInit 
*List,
 const StringInit *Delim) {
   if (List->size() == 0)
 return StringInit::get("");
-  SmallString<80> Result(cast(List->getElement(0))->getValue());
+  StringInit *Element = dyn_cast(List->getElement(0));
+  if (!Element)
+return nullptr;
+  SmallString<80> Result(Element->getValue());
   StringInit::StringFormat Fmt = StringInit::SF_String;
 
   for (unsigned I = 1, E = List->size(); I < E; ++I) {
 Result.append(Delim->getValue());
-auto *StrInit = cast(List->getElement(I));
-Result.append(StrInit->getValue());
-Fmt = StringInit::determineFormat(Fmt, StrInit->getFormat());
+StringInit *Element = dyn_cast(List->getElement(I));
+if (!Element)
+  return nullptr;
+Result.append(Element->getValue());
+Fmt = StringInit::determineFormat(Fmt, Element->getFormat());
   }
   return StringInit::get(Result, Fmt);
 }
@@ -872,14 +877,21 @@ static StringInit *interleaveIntList(const ListInit *List,
  const StringInit *Delim) {
   if (List->size() == 0)
 return StringInit::get("");
-  SmallString<80> Result(
-  cast(List->getElement(0)->getCastTo(IntRecTy::get()))
-  ->getAsString());
+  IntInit *Element =
+  dyn_cast_or_null(List->getElement(0)
+->convertInitializerTo(IntRecTy::get()));
+  if (!Element)
+return nullptr;
+  SmallString<80> Result(Element->getAsString());
 
   for (unsigned I = 1, E = List->size(); I < E; ++I) {
 Result.append(Delim->getValue());
-
Result.append(cast(List->getElement(I)->getCastTo(IntRecTy::get()))
-  ->getAsString());
+IntInit *Element =
+dyn_cast_or_null(List->getElement(I)
+  ->convertInitializerTo(IntRecTy::get()));
+if (!Element)
+  return nullptr;
+Result.append(Element->getAsString());
   }
   return StringInit::get(Result);
 }
@@ -975,10 +987,13 @@ Init *BinOpInit::Fold(Record *CurRec) const {
 ListInit *List = dyn_cast(LHS);
 StringInit *Delim = dyn_cast(RHS);
 if (List && Delim) {
+  StringInit *Result;
   if (isa(List->getElementType()))
-return interleaveStringList(List, Delim);
+Result = interleaveStringList(List, Delim);
   else
-return interleaveIntList(List, Delim);
+Result = interleaveIntList(List, Delim);
+  if (Result)
+return Result;
 }
 break;
   }

diff  --git a/llvm/test/TableGen/interleave.td 
b/llvm/test/TableGen/interleave.td
index 098542ab29a1..c4d5c825d0fc 100644
--- a/llvm/test/TableGen/interleave.td
+++ b/llvm/test/TableGen/interleave.td
@@ -77,6 +77,15 @@ def Rec6 {
   code OperatorList = !interleave(!listconcat(Operators, [[{;}]]), ", ");
 }
 
+// CHECK: def Rec7
+// CHECK:   str = "foo/bar/zoo";
+
+def Rec7 {
+  string foo = "foo";
+  string zoo = "oops, not zoo";
+  string str = !interleave([foo, "bar", zoo], "/");
+  let zoo = "zoo";
+}
 
 #ifdef ERROR1
 def op;



___
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] 38bfa25 - Revert "[benchmark] Fixed a build error when using CMake 3.15.1 + NDK-R20"

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

Author: Roman Lebedev
Date: 2020-12-28T20:19:08+03:00
New Revision: 38bfa25387f4d1292c12a574df6b3cd0f3c212d6

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

LOG: Revert "[benchmark] Fixed a build error when using CMake 3.15.1 + NDK-R20"

Temporairly revert until a consensus on post-commit comments is achieved.

This reverts commit a485a59d2172daaee1d5e734da54fbb243f7d54c.

Added: 


Modified: 
llvm/utils/benchmark/include/benchmark/benchmark.h

Removed: 




diff  --git a/llvm/utils/benchmark/include/benchmark/benchmark.h 
b/llvm/utils/benchmark/include/benchmark/benchmark.h
index 0b4baec41755..ab61c46e9386 100644
--- a/llvm/utils/benchmark/include/benchmark/benchmark.h
+++ b/llvm/utils/benchmark/include/benchmark/benchmark.h
@@ -990,7 +990,7 @@ inline internal::Benchmark* RegisterBenchmark(const char* 
name,
 #ifdef BENCHMARK_HAS_CXX11
 template 
 internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn) {
-  using BenchType = internal::LambdaBenchmark>;
+  using BenchType = internal::LambdaBenchmark>;
   return internal::RegisterBenchmarkInternal(
   ::new BenchType(name, std::forward(fn)));
 }



___
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] dcd2157 - [ValueTracking] Fix isKnownNonEqual() with constexpr mul

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

Author: Nikita Popov
Date: 2020-12-28T18:32:57+01:00
New Revision: dcd21572f971ae5b5f1bf1f1abefafa0085404e1

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

LOG: [ValueTracking] Fix isKnownNonEqual() with constexpr mul

Confusingly, BinaryOperator is not an Operator,
OverflowingBinaryOperator is... We were implicitly assuming that
the multiply is an Instruction here.

This fixes the assertion failure reported in
https://reviews.llvm.org/D92726#2472827.

Added: 


Modified: 
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/known-non-equal.ll

Removed: 




diff  --git a/llvm/lib/Analysis/ValueTracking.cpp 
b/llvm/lib/Analysis/ValueTracking.cpp
index 25f6be2b10dd..0e32e7f4b102 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2529,14 +2529,14 @@ static bool isKnownNonEqual(const Value *V1, const 
Value *V2, unsigned Depth,
 return isKnownNonEqual(O1->getOperand(0), O2->getOperand(0),
Depth + 1, Q);
   break;
-case Instruction::Mul:
+case Instruction::Mul: {
   // invertible if A * B == (A * B) mod 2^N where A, and B are integers
   // and N is the bitwdith.  The nsw case is non-obvious, but proven by
   // alive2: https://alive2.llvm.org/ce/z/Z6D5qK
-  if ((!cast(O1)->hasNoUnsignedWrap() ||
-   !cast(O2)->hasNoUnsignedWrap()) &&
-  (!cast(O1)->hasNoSignedWrap() ||
-   !cast(O2)->hasNoSignedWrap()))
+  auto *OBO1 = cast(O1);
+  auto *OBO2 = cast(O2);
+  if ((!OBO1->hasNoUnsignedWrap() || !OBO2->hasNoUnsignedWrap()) &&
+  (!OBO1->hasNoSignedWrap() || !OBO2->hasNoSignedWrap()))
 break;
 
   // Assume operand order has been canonicalized
@@ -2546,6 +2546,7 @@ static bool isKnownNonEqual(const Value *V1, const Value 
*V2, unsigned Depth,
 return isKnownNonEqual(O1->getOperand(0), O2->getOperand(0),
Depth + 1, Q);
   break;
+}
 case Instruction::SExt:
 case Instruction::ZExt:
   if (O1->getOperand(0)->getType() == O2->getOperand(0)->getType())

diff  --git a/llvm/test/Analysis/ValueTracking/known-non-equal.ll 
b/llvm/test/Analysis/ValueTracking/known-non-equal.ll
index 8bc9a86c9a93..197088a85e81 100644
--- a/llvm/test/Analysis/ValueTracking/known-non-equal.ll
+++ b/llvm/test/Analysis/ValueTracking/known-non-equal.ll
@@ -201,5 +201,17 @@ define i1 @mul5(i8 %B, i8 %C) {
   ret i1 %cmp
 }
 
+@g = external global i16, align 1
+
+define i1 @mul_constantexpr(i16 %a) {
+; CHECK-LABEL: @mul_constantexpr(
+; CHECK-NEXT:[[MUL:%.*]] = mul nsw i16 [[A:%.*]], 3
+; CHECK-NEXT:[[CMP:%.*]] = icmp eq i16 mul nsw (i16 ptrtoint (i16* @g to 
i16), i16 -1), [[MUL]]
+; CHECK-NEXT:ret i1 [[CMP]]
+;
+  %mul = mul nsw i16 %a, 3
+  %cmp = icmp eq i16 mul nsw (i16 ptrtoint (i16* @g to i16), i16 -1), %mul
+  ret i1 %cmp
+}
 
 !0 = !{ i8 1, i8 5 }



___
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] e4df6a4 - [LV] Vectorize (some) early and multiple exit loops

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

Author: Philip Reames
Date: 2020-12-28T09:40:42-08:00
New Revision: e4df6a40dad66e989a4333c11d39cf3ed9635135

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

LOG: [LV] Vectorize (some) early and multiple exit loops

This patch is a major step towards supporting multiple exit loops in the 
vectorizer. This patch on it's own extends the loop forms allowed in two ways:

single exit loops which are not bottom tested
multiple exit loops w/ a single exit block reached from all exits and no 
phis in the exit block (because of LCSSA this implies no values defined in the 
loop used later)

The restrictions on multiple exit loop structures will be removed in follow up 
patches; disallowing cases for now makes the code changes smaller and more 
obvious. As before, we can only handle loops with entirely analyzable exits. 
Removing that restriction is much harder, and is not part of currently planned 
efforts.

The basic idea here is that we can force the last iteration to run in the 
scalar epilogue loop (if we have one). From the definition of SCEV's backedge 
taken count, we know that no earlier iteration can exit the vector body. As 
such, we can leave the decision on which exit to be taken to the scalar code 
and generate a bottom tested vector loop which runs all but the last iteration.

The existing code already had the notion of requiring one iteration in the 
scalar epilogue, this patch is mainly about generalizing that support slightly, 
making sure we don't try to use this mechanism when tail folding, and updating 
the code to reflect the difference between a single exit block and a unique 
exit block (very mechanical).

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/control-flow.ll
llvm/test/Transforms/LoopVectorize/loop-form.ll
llvm/test/Transforms/LoopVectorize/loop-legality-checks.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 60e1cc9a4a59..911309c9421c 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -1095,9 +1095,15 @@ bool LoopVectorizationLegality::canVectorizeLoopCFG(Loop 
*Lp,
   return false;
   }
 
-  // We must have a single exiting block.
-  if (!Lp->getExitingBlock()) {
-reportVectorizationFailure("The loop must have an exiting block",
+  // We currently must have a single "exit block" after the loop. Note that
+  // multiple "exiting blocks" inside the loop are allowed, provided they all
+  // reach the single exit block.
+  // TODO: This restriction can be relaxed in the near future, it's here solely
+  // to allow separation of changes for review. We need to generalize the phi
+  // update logic in a number of places.
+  BasicBlock *ExitBB = Lp->getUniqueExitBlock();
+  if (!ExitBB) {
+reportVectorizationFailure("The loop must have a unique exit block",
 "loop control flow is not understood by vectorizer",
 "CFGNotUnderstood", ORE, TheLoop);
 if (DoExtraAnalysis)
@@ -1106,11 +1112,14 @@ bool 
LoopVectorizationLegality::canVectorizeLoopCFG(Loop *Lp,
   return false;
   }
 
-  // We only handle bottom-tested loops, i.e. loop in which the condition is
-  // checked at the end of each iteration. With that we can assume that all
-  // instructions in the loop are executed the same number of times.
-  if (Lp->getExitingBlock() != Lp->getLoopLatch()) {
-reportVectorizationFailure("The exiting block is not the loop latch",
+  // The existing code assumes that LCSSA implies that phis are single entry
+  // (which was true when we had at most a single exiting edge from the latch).
+  // In general, there's nothing which prevents an LCSSA phi in exit block from
+  // having two or more values if there are multiple exiting edges leading to
+  // the exit block.  (TODO: implement general case)
+  if (!empty(ExitBB->phis()) && !ExitBB->getSinglePredecessor()) {
+reportVectorizationFailure("The loop must have no live-out values if "
+   "it has more than one exiting block",
 "loop control flow is not understood by vectorizer",
 "CFGNotUnderstood", ORE, TheLoop);
 if (DoExtraAnalysis)

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5889d5e55339..c48b650c3c3e 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -837,7 +837,8 @@ class InnerLoopVectorizer {