[llvm-branch-commits] [lld] 248e345 - [LLD] [MinGW] Pass the --demangle and --no-demangle options to the COFF linker

2021-01-07 Thread Martin Storsjö via llvm-branch-commits

Author: Martin Storsjö
Date: 2021-01-07T10:02:19+02:00
New Revision: 248e3450fb8a1ab7146c0cbe8f0ea7204782f542

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

LOG: [LLD] [MinGW] Pass the --demangle and --no-demangle options to the COFF 
linker

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

Added: 


Modified: 
lld/MinGW/Driver.cpp
lld/MinGW/Options.td
lld/test/MinGW/driver.test

Removed: 




diff  --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index fae5cb77ec5d..f8eb4e76b7f9 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -320,6 +320,11 @@ bool mingw::link(ArrayRef argsArr, bool 
canExitEarly,
   else
 add("-opt:noref");
 
+  if (args.hasFlag(OPT_demangle, OPT_no_demangle, true))
+add("-demangle");
+  else
+add("-demangle:no");
+
   if (args.hasFlag(OPT_enable_auto_import, OPT_disable_auto_import, true))
 add("-auto-import");
   else

diff  --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td
index 7bc5936d58d6..95b61952fc5e 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -28,6 +28,9 @@ defm allow_multiple_definition: B<"allow-multiple-definition",
 "Do not allow multiple definitions (default)">;
 def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
 def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
+defm demangle: B<"demangle",
+"Demangle symbol names (default)",
+"Do not demangle symbol names">;
 def disable_auto_import: F<"disable-auto-import">,
 HelpText<"Don't automatically import data symbols from other DLLs without 
dllimport">;
 def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">,

diff  --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 015c26963923..33503d45189e 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -285,3 +285,12 @@ NO_ALLOW_MULTIPLE_DEFINITION-NOT: -force:multiple
 RUN: ld.lld -### -m i386pep foo.o -wrap foo1 --wrap foo2 | FileCheck 
-check-prefix WRAP %s
 RUN: ld.lld -### -m i386pep foo.o -wrap=foo1 --wrap=foo2 | FileCheck 
-check-prefix WRAP %s
 WRAP: -wrap:foo1 -wrap:foo2
+
+RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEMANGLE %s
+RUN: ld.lld -### -m i386pep foo.o -demangle | FileCheck -check-prefix DEMANGLE 
%s
+RUN: ld.lld -### -m i386pep foo.o --demangle | FileCheck -check-prefix 
DEMANGLE %s
+DEMANGLE: -demangle{{ }}
+
+RUN: ld.lld -### -m i386pep foo.o -no-demangle | FileCheck -check-prefix 
NO-DEMANGLE %s
+RUN: ld.lld -### -m i386pep foo.o --no-demangle | FileCheck -check-prefix 
NO-DEMANGLE %s
+NO-DEMANGLE: -demangle:no



___
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] f448524 - [libcxx] Handle backslash as path separator on windows

2021-01-07 Thread Martin Storsjö via llvm-branch-commits

Author: Martin Storsjö
Date: 2021-01-07T10:02:47+02:00
New Revision: f4485240a2182050d6417947a407fe4c551e2011

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

LOG: [libcxx] Handle backslash as path separator on windows

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

Added: 


Modified: 
libcxx/include/filesystem
libcxx/src/filesystem/operations.cpp

Removed: 




diff  --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index e39790c50955..c60020a3e893 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -1116,7 +1116,12 @@ public:
   _LIBCPP_INLINE_VISIBILITY
   void clear() noexcept { __pn_.clear(); }
 
-  path& make_preferred() { return *this; }
+  path& make_preferred() {
+#if defined(_LIBCPP_WIN32API)
+_VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');
+#endif
+return *this;
+  }
 
   _LIBCPP_INLINE_VISIBILITY
   path& remove_filename() {

diff  --git a/libcxx/src/filesystem/operations.cpp 
b/libcxx/src/filesystem/operations.cpp
index 4d585af78f98..7db2d1ff0074 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -51,6 +51,17 @@
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
 namespace {
+
+bool isSeparator(path::value_type C) {
+  if (C == '/')
+return true;
+#if defined(_LIBCPP_WIN32API)
+  if (C == '\\')
+return true;
+#endif
+  return false;
+}
+
 namespace parser {
 
 using string_view_t = path::__string_view;
@@ -271,21 +282,21 @@ struct PathParser {
   }
 
   PosPtr consumeSeparator(PosPtr P, PosPtr End) const noexcept {
-if (P == End || *P != '/')
+if (P == End || !isSeparator(*P))
   return nullptr;
 const int Inc = P < End ? 1 : -1;
 P += Inc;
-while (P != End && *P == '/')
+while (P != End && isSeparator(*P))
   P += Inc;
 return P;
   }
 
   PosPtr consumeName(PosPtr P, PosPtr End) const noexcept {
-if (P == End || *P == '/')
+if (P == End || isSeparator(*P))
   return nullptr;
 const int Inc = P < End ? 1 : -1;
 P += Inc;
-while (P != End && *P != '/')
+while (P != End && !isSeparator(*P))
   P += Inc;
 return P;
   }
@@ -1393,7 +1404,7 @@ string_view_t path::__root_path_raw() const {
   auto PP = PathParser::CreateBegin(__pn_);
   if (PP.State == PathParser::PS_InRootName) {
 auto NextCh = PP.peek();
-if (NextCh && *NextCh == '/') {
+if (NextCh && isSeparator(*NextCh)) {
   ++PP;
   return createView(__pn_.data(), &PP.RawEntry.back());
 }
@@ -1491,6 +1502,10 @@ static PathPartKind ClassifyPathPart(string_view_t Part) 
{
 return PK_DotDot;
   if (Part == PS("/"))
 return PK_RootSep;
+#if defined(_LIBCPP_WIN32API)
+  if (Part == PS("\\"))
+return PK_RootSep;
+#endif
   return PK_Filename;
 }
 



___
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] c3529a5 - [mlir] Mark methods from mlir::OpState that just forward to mlir::Operation as deprecated.

2021-01-07 Thread Christian Sigg via llvm-branch-commits

Author: Christian Sigg
Date: 2021-01-07T09:08:47+01:00
New Revision: c3529a5b0806843e75f0b6d9a83bb36de70b5ae6

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

LOG: [mlir] Mark methods from mlir::OpState that just forward to 
mlir::Operation as deprecated.

The functions will be removed by January 20th.

All call sites within MLIR have been converted in previous changes.

Reviewed By: rriddle

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

Added: 


Modified: 
mlir/include/mlir/IR/OpDefinition.h
mlir/lib/IR/Operation.cpp

Removed: 




diff  --git a/mlir/include/mlir/IR/OpDefinition.h 
b/mlir/include/mlir/IR/OpDefinition.h
index 11dc4b77b677..e698ced314a1 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -105,26 +105,32 @@ class OpState {
   Operation *getOperation() { return state; }
 
   /// Return the dialect that this refers to.
-  Dialect *getDialect() { return getOperation()->getDialect(); }
+  LLVM_ATTRIBUTE_DEPRECATED(
+  Dialect *getDialect(),
+  "Use Operation::getDialect() instead (replace '.' with '->').");
 
   /// Return the parent Region of this operation.
-  Region *getParentRegion() { return getOperation()->getParentRegion(); }
+  LLVM_ATTRIBUTE_DEPRECATED(
+  Region *getParentRegion(),
+  "Use Operation::getParentRegion() instead (replace '.' with '->').");
 
   /// Returns the closest surrounding operation that contains this operation
   /// or nullptr if this is a top-level operation.
-  Operation *getParentOp() { return getOperation()->getParentOp(); }
+  LLVM_ATTRIBUTE_DEPRECATED(
+  Operation *getParentOp(),
+  "Use Operation::getParentOp() instead (replace '.' with '->').");
 
   /// Return the closest surrounding parent operation that is of type 'OpTy'.
   template 
-  OpTy getParentOfType() {
-return getOperation()->getParentOfType();
-  }
+  LLVM_ATTRIBUTE_DEPRECATED(
+  OpTy getParentOfType(),
+  "Use Operation::getParentOfType() instead (replace '.' with '->').");
 
   /// Returns the closest surrounding parent operation with trait `Trait`.
   template  class Trait>
-  Operation *getParentWithTrait() {
-return getOperation()->getParentWithTrait();
-  }
+  LLVM_ATTRIBUTE_DEPRECATED(
+  Operation *getParentWithTrait(),
+  "Use Operation::getParentWithTrait() instead (replace '.' with '->').");
 
   /// Return the context this operation belongs to.
   MLIRContext *getContext() { return getOperation()->getContext(); }
@@ -153,35 +159,43 @@ class OpState {
   using dialect_attr_range = Operation::dialect_attr_range;
 
   /// Return a range corresponding to the dialect attributes for this 
operation.
-  dialect_attr_range getDialectAttrs() { return state->getDialectAttrs(); }
-  dialect_attr_iterator dialect_attr_begin() {
-return state->dialect_attr_begin();
-  }
-  dialect_attr_iterator dialect_attr_end() { return state->dialect_attr_end(); 
}
+  LLVM_ATTRIBUTE_DEPRECATED(
+  dialect_attr_range getDialectAttrs(),
+  "Use Operation::getDialectAttrs() instead (replace '.' with '->').");
+  LLVM_ATTRIBUTE_DEPRECATED(
+  dialect_attr_iterator dialect_attr_begin(),
+  "Use Operation::dialect_attr_begin() instead (replace '.' with '->').");
+  LLVM_ATTRIBUTE_DEPRECATED(
+  dialect_attr_iterator dialect_attr_end(),
+  "Use Operation::dialect_attr_end() instead (replace '.' with '->').");
 
   /// Return an attribute with the specified name.
-  Attribute getAttr(StringRef name) { return state->getAttr(name); }
+  LLVM_ATTRIBUTE_DEPRECATED(
+  Attribute getAttr(StringRef name),
+  "Use Operation::getAttr() instead (replace '.' with '->').");
 
   /// If the operation has an attribute of the specified type, return it.
   template 
-  AttrClass getAttrOfType(StringRef name) {
-return getAttr(name).dyn_cast_or_null();
-  }
+  LLVM_ATTRIBUTE_DEPRECATED(
+  AttrClass getAttrOfType(StringRef name),
+  "Use Operation::getAttrOfType() instead (replace '.' with '->').");
 
   /// 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.
-  void setAttr(Identifier name, Attribute value) {
-state->setAttr(name, value);
-  }
-  void setAttr(StringRef name, Attribute value) {
-setAttr(Identifier::get(name, getContext()), value);
-  }
+  LLVM_ATTRIBUTE_DEPRECATED(
+  void setAttr(Identifier name, Attribute value),
+  "Use Operation::setAttr() instead (replace '.' with '->').");
+  LLVM_ATTRIBUTE_DEPRECATED(
+  void setAttr(StringRef name, Attribute value),
+  "Use Operation::setAttr() instead (replace '.' with '->').");
 
   /// Set the attributes held by this operation.
-  void setAttrs(ArrayRef attributes) {
-

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

2021-01-07 Thread Artem Dergachev via llvm-branch-commits

Author: Artem Dergachev
Date: 2021-01-07T00:28:22-08:00
New Revision: d2ddc694ff94743d9735aaf07edcaf6db8aaca04

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

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

This reverts commit 5663bf201f5c444d6fb56fb1bd471bc53c17d837.

The cyclic dependency problem is addressed now.
This is the ~fifth attempt to land this change.

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

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

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



diff  --git a/clang/include/clang/Analysis/CrossTUAnalysisHelper.h 
b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
new file mode 100644
index ..500e78ddedcf
--- /dev/null
+++ b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
@@ -0,0 +1,41 @@
+//===- CrossTUAnalysisHelper.h - Abstraction layer for CTU --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#ifndef LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
+#define LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
+
+#include "llvm/ADT/Optional.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+
+class ASTUnit;
+
+/// This class is an abstract interface acting as a bridge between
+/// an analysis that requires lookups across translation units (a user
+/// of that interface) and the facility that implements such lookups
+/// (an implementation of that interface). This is useful to break direct
+/// link-time dependencies between the (possibly shared) libraries in which
+/// the user and the implementation live.
+class CrossTUAnalysisHelper {
+public:
+  /// Determine the original source location in the original TU for an
+  /// imported source location.
+  /// \p ToLoc Source location in the imported-to AST.
+  /// \return Source location in the imported-from AST and the corresponding
+  /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit
+  /// object that is returned here).
+  /// If any error happens (ToLoc is a non-imported source location) empty is
+  /// returned.
+  virtual llvm::Optional>
+  getImportedFromSourceLocationWithPreprocessor(SourceLocation ToLoc) const = 
0;
+
+  virtual ~CrossTUAnalysisHelper() {}
+};
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H

diff  --git a/clang/include/clang/Analysis/PathDiagnosticConsumers.def 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
new file mode 100644
index ..33d2072fcf31
--- /dev/null
+++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
@@ -0,0 +1,50 @@
+//===-- PathDiagnosticConsumers.def - Visualizing warnings --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines the set of path diagnostic consumers - objects that
+// implement 
diff erent representations of static analysis results.
+//
+//===--===//
+
+#ifndef ANALYSIS_DIAGNOSTICS
+#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
+#endif
+
+ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML",

[llvm-branch-commits] [llvm] 5471b1f - [gn build] Port d2ddc694ff9

2021-01-07 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2021-01-07T08:29:23Z
New Revision: 5471b1fa4013f463ad40abd61fa7f04500aaf7fd

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

LOG: [gn build] Port d2ddc694ff9

Added: 


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

Removed: 




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

diff  --git a/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
index c16c37d47b28..44be3eee1310 100644
--- a/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
@@ -39,11 +39,9 @@ static_library("Core") {
 "ExprEngineCallAndReturn.cpp",
 "ExprEngineObjC.cpp",
 "FunctionSummary.cpp",
-"HTMLDiagnostics.cpp",
 "LoopUnrolling.cpp",
 "LoopWidening.cpp",
 "MemRegion.cpp",
-"PlistDiagnostics.cpp",
 "ProgramState.cpp",
 "RangeConstraintManager.cpp",
 "RangedConstraintManager.cpp",
@@ -51,12 +49,10 @@ static_library("Core") {
 "SMTConstraintManager.cpp",
 "SValBuilder.cpp",
 "SVals.cpp",
-"SarifDiagnostics.cpp",
 "SimpleConstraintManager.cpp",
 "SimpleSValBuilder.cpp",
 "Store.cpp",
 "SymbolManager.cpp",
-"TextDiagnostics.cpp",
 "WorkList.cpp",
   ]
 }



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


[llvm-branch-commits] [clang] 77db83a - [clang][cli] Allow users to specify a conditional to prevent parsing options with MarshallingInfo

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T10:01:49+01:00
New Revision: 77db83ae997767400ffcbe0101f8ee867ebaa111

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

LOG: [clang][cli] Allow users to specify a conditional to prevent parsing 
options with MarshallingInfo

Depends on D84189 & D93540.

Reviewed By: Bigcheese

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 428c14a7d9bb..33b5cd09004e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4091,7 +4091,9 @@ defm sycl : BoolOption<"sycl",
   BothFlags<[CoreOption], " SYCL kernels compilation for device">, "f">,
   Group;
 def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
-  HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 
1.2.1, sycl-1.2.1">;
+  HelpText<"SYCL language standard to compile for.">, 
Values<"2017,121,1.2.1,sycl-1.2.1">,
+  NormalizedValues<["SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, 
NormalizedValuesScope<"LangOptions">,
+  MarshallingInfoString<"LangOpts->SYCLVersion", "SYCL_None">, 
ShouldParseIf, AutoNormalizeEnum;
 
 
//===--===//
 // FlangOption and FC1 Options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 57027cea5659..962f72963cd2 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2282,23 +2282,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   }
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-  if (Opts.SYCL) {
-// -sycl-std applies to any SYCL source, not only those containing kernels,
-// but also those using the SYCL API
-if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
-  Opts.setSYCLVersion(
-  llvm::StringSwitch(A->getValue())
-  .Cases("2017", "1.2.1", "121", "sycl-1.2.1",
- LangOptions::SYCL_2017)
-  .Default(LangOptions::SYCL_None));
-
-  if (Opts.getSYCLVersion() == LangOptions::SYCL_None) {
-// User has passed an invalid value to the flag, this is an error
-Diags.Report(diag::err_drv_invalid_value)
-<< A->getAsString(Args) << A->getValue();
-  }
-}
-  }
 
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
@@ -3003,16 +2986,17 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList 
&Args,
  DiagnosticsEngine &Diags) {
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
-IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
-TABLE_INDEX)   
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  
\
-  this->KEYPATH = MERGER(  
\
-  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
+if (SHOULD_PARSE)  
\
+  if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))
\
+this->KEYPATH = MERGER(
\
+this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
   }
 
 #include "clang/Driver/Options.inc"
@@ -3265,9 +3249,9 @@ void CompilerInvocation::generateCC1CommandLine(
   // with lifetime extension of the reference.
 #define OPTION_WITH_MARSHALLING(  

[llvm-branch-commits] [clang] c6ea4d5 - [clang][cli] Implement ContainsN Google Test matcher

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T10:01:49+01:00
New Revision: c6ea4d5b2c0054f3e2fa06b911ed3933fe59bc5b

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

LOG: [clang][cli] Implement ContainsN Google Test matcher

This allows us to verify that we don't emit options multiple times.

In most cases, that would be benign, but for options with 
`MarshallingInfoVectorString`, emitting wrong number of arguments might change 
the semantics.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 89d9c88cc604..8fcf34d5c874 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -39,6 +39,61 @@ class CommandLineTest : public ::testing::Test {
   }
 };
 
+template 
+std::string describeContainsN(M InnerMatcher, unsigned N, bool Negation) {
+  StringRef Contains = Negation ? "doesn't contain" : "contains";
+  StringRef Instance = N == 1 ? " instance " : " instances ";
+  StringRef Element = "of element that ";
+
+  std::ostringstream Inner;
+  InnerMatcher.impl().DescribeTo(&Inner);
+
+  return (Contains + " exactly " + Twine(N) + Instance + Element + Inner.str())
+  .str();
+}
+
+MATCHER_P2(ContainsN, InnerMatcher, N,
+   describeContainsN(InnerMatcher, N, negation)) {
+  auto InnerMatches = [this](const auto &Element) {
+::testing::internal::DummyMatchResultListener InnerListener;
+return InnerMatcher.impl().MatchAndExplain(Element, &InnerListener);
+  };
+
+  return count_if(arg, InnerMatches) == N;
+}
+
+TEST(ContainsN, Empty) {
+  const char *Array[] = {""};
+
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 0));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, Zero) {
+  const char *Array[] = {"y"};
+
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 0));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, One) {
+  const char *Array[] = {"a", "b", "x", "z"};
+
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 0)));
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 1));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 2)));
+}
+
+TEST(ContainsN, Two) {
+  const char *Array[] = {"x", "a", "b", "x"};
+
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 0)));
+  ASSERT_THAT(Array, Not(ContainsN(StrEq("x"), 1)));
+  ASSERT_THAT(Array, ContainsN(StrEq("x"), 2));
+}
+
 // Boolean option with a keypath that defaults to true.
 // The only flag with a negative spelling can set the keypath to false.
 
@@ -270,7 +325,7 @@ TEST_F(CommandLineTest, BoolOptionCC1ViaLetPresentPos) {
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
 
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fdebug-pass-manager")), 1);
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fdebug-pass-manager"), 1));
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager";
 }
 
@@ -418,7 +473,8 @@ TEST_F(CommandLineTest, StringVectorEmpty) {
   ASSERT_TRUE(Invocation.getFrontendOpts().ModuleMapFiles.empty());
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file=";
+
+  ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-fmodule-map-file";
 }
 
 TEST_F(CommandLineTest, StringVectorSingle) {
@@ -431,7 +487,9 @@ TEST_F(CommandLineTest, StringVectorSingle) {
 std::vector({"a"}));
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=a"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 1));
 }
 
 TEST_F(CommandLineTest, StringVectorMultiple) {
@@ -444,8 +502,10 @@ TEST_F(CommandLineTest, StringVectorMultiple) {
   std::vector({"a", "b"}));
 
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=a")), 1);
-  ASSERT_EQ(count(GeneratedArgs, StringRef("-fmodule-map-file=b")), 1);
+
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=a"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(StrEq("-fmodule-map-file=b"), 1));
+  ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 2));
 }
 
 // A flag that should be parsed only if a condition is met.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https

[llvm-branch-commits] [clang] d0fa7a0 - Revert "[clang][cli] Allow users to specify a conditional to prevent parsing options with MarshallingInfo"

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T10:12:53+01:00
New Revision: d0fa7a05be92617a0262ec8b622f158971a54c54

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

LOG: Revert "[clang][cli] Allow users to specify a conditional to prevent 
parsing options with MarshallingInfo"

This reverts commit 77db83ae

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 33b5cd09004e..428c14a7d9bb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4091,9 +4091,7 @@ defm sycl : BoolOption<"sycl",
   BothFlags<[CoreOption], " SYCL kernels compilation for device">, "f">,
   Group;
 def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
-  HelpText<"SYCL language standard to compile for.">, 
Values<"2017,121,1.2.1,sycl-1.2.1">,
-  NormalizedValues<["SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, 
NormalizedValuesScope<"LangOptions">,
-  MarshallingInfoString<"LangOpts->SYCLVersion", "SYCL_None">, 
ShouldParseIf, AutoNormalizeEnum;
+  HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 
1.2.1, sycl-1.2.1">;
 
 
//===--===//
 // FlangOption and FC1 Options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 962f72963cd2..57027cea5659 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2282,6 +2282,23 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   }
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL) {
+// -sycl-std applies to any SYCL source, not only those containing kernels,
+// but also those using the SYCL API
+if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
+  Opts.setSYCLVersion(
+  llvm::StringSwitch(A->getValue())
+  .Cases("2017", "1.2.1", "121", "sycl-1.2.1",
+ LangOptions::SYCL_2017)
+  .Default(LangOptions::SYCL_None));
+
+  if (Opts.getSYCLVersion() == LangOptions::SYCL_None) {
+// User has passed an invalid value to the flag, this is an error
+Diags.Report(diag::err_drv_invalid_value)
+<< A->getAsString(Args) << A->getValue();
+  }
+}
+  }
 
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
@@ -2986,17 +3003,16 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList 
&Args,
  DiagnosticsEngine &Diags) {
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
-MERGER, EXTRACTOR, TABLE_INDEX)
\
+HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
+TABLE_INDEX)   
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (SHOULD_PARSE)  
\
-  if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))
\
-this->KEYPATH = MERGER(
\
-this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
+if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  
\
+  this->KEYPATH = MERGER(  
\
+  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
   }
 
 #include "clang/Driver/Options.inc"
@@ -3249,9 +3265,9 @@ void CompilerInvocation::generateCC1CommandLine(
   // with lifetime extension of the reference.
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, A

[llvm-branch-commits] [llvm] 76f6b12 - Revert "[llvm] Use BasicBlock::phis() (NFC)"

2021-01-07 Thread Oliver Stannard via llvm-branch-commits

Author: Oliver Stannard
Date: 2021-01-07T09:43:33Z
New Revision: 76f6b125cef1f5d949cd8f4049b14f572ecd9ee6

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

LOG: Revert "[llvm] Use BasicBlock::phis() (NFC)"

Reverting because this causes crashes on the 2-stage buildbots, for
example http://lab.llvm.org:8011/#/builders/7/builds/1140.

This reverts commit 9b228f107d43341ef73af92865f73a9a076c5a76.

Added: 


Modified: 
llvm/lib/IR/BasicBlock.cpp
llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 688211877d18..7f34565f5cd8 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -440,8 +440,12 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, 
const Twine &BBName) {
 void BasicBlock::replacePhiUsesWith(BasicBlock *Old, BasicBlock *New) {
   // N.B. This might not be a complete BasicBlock, so don't assume
   // that it ends with a non-phi instruction.
-  for (PHINode &PN : phis())
-PN.replaceIncomingBlockWith(Old, New);
+  for (iterator II = begin(), IE = end(); II != IE; ++II) {
+PHINode *PN = dyn_cast(II);
+if (!PN)
+  break;
+PN->replaceIncomingBlockWith(Old, New);
+  }
 }
 
 void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *Old,

diff  --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp 
b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
index 273d3ab97c7b..68c79d2a113f 100644
--- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
@@ -2199,10 +2199,13 @@ bool 
HexagonLoopIdiomRecognize::processCopyingStore(Loop *CurLoop,
 if (ParentL)
   ParentL->addBasicBlockToLoop(NewPreheader, *LF);
 IRBuilder<>(NewPreheader).CreateBr(Header);
-for (PHINode &PN : Header->phis()) {
-  int bx = PN.getBasicBlockIndex(Preheader);
+for (auto &In : *Header) {
+  PHINode *PN = dyn_cast(&In);
+  if (!PN)
+break;
+  int bx = PN->getBasicBlockIndex(Preheader);
   if (bx >= 0)
-PN.setIncomingBlock(bx, NewPreheader);
+PN->setIncomingBlock(bx, NewPreheader);
 }
 DT->addNewBlock(NewPreheader, Preheader);
 DT->changeImmediateDominator(Header, NewPreheader);

diff  --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp 
b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 060ca4bcd8ee..4cce05d595a8 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -483,20 +483,24 @@ static Optional 
analyzeLoopUnrollCost(
 
 // Prepare for the iteration by collecting any simplified entry or backedge
 // inputs.
-for (PHINode &PHI : L->getHeader()->phis()) {
+for (Instruction &I : *L->getHeader()) {
+  auto *PHI = dyn_cast(&I);
+  if (!PHI)
+break;
+
   // The loop header PHI nodes must have exactly two input: one from the
   // loop preheader and one from the loop latch.
   assert(
-  PHI.getNumIncomingValues() == 2 &&
+  PHI->getNumIncomingValues() == 2 &&
   "Must have an incoming value only for the preheader and the latch.");
 
-  Value *V = PHI.getIncomingValueForBlock(
+  Value *V = PHI->getIncomingValueForBlock(
   Iteration == 0 ? L->getLoopPreheader() : L->getLoopLatch());
   Constant *C = dyn_cast(V);
   if (Iteration != 0 && !C)
 C = SimplifiedValues.lookup(V);
   if (C)
-SimplifiedInputValues.push_back({&PHI, C});
+SimplifiedInputValues.push_back({PHI, C});
 }
 
 // Now clear and re-populate the map for the next iteration.
@@ -621,8 +625,12 @@ static Optional analyzeLoopUnrollCost(
 BasicBlock *ExitingBB, *ExitBB;
 std::tie(ExitingBB, ExitBB) = ExitWorklist.pop_back_val();
 
-for (PHINode &PN : ExitBB->phis()) {
-  Value *Op = PN.getIncomingValueForBlock(ExitingBB);
+for (Instruction &I : *ExitBB) {
+  auto *PN = dyn_cast(&I);
+  if (!PN)
+break;
+
+  Value *Op = PN->getIncomingValueForBlock(ExitingBB);
   if (auto *OpI = dyn_cast(Op))
 if (L->contains(OpI))
   AddCostRecursively(*OpI, TripCount - 1);

diff  --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp 
b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index ed3f87a7d0e7..68ddebf113d1 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -2843,8 +2843,12 @@ static void 
computeLiveInValues(Basic

[llvm-branch-commits] [llvm] c9154e8 - [RISCV] Add vector mask arithmetic ISel patterns

2021-01-07 Thread Fraser Cormack via llvm-branch-commits

Author: Fraser Cormack
Date: 2021-01-07T09:43:25Z
New Revision: c9154e8fa377d1621e20482dda8a8bb2439a39c4

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

LOG: [RISCV] Add vector mask arithmetic ISel patterns

The patterns that want to use 'vnot' use a custom PatFrag. This is
because 'vnot' uses immAllOnesV which implicitly uses BUILD_VECTOR
rather than SPLAT_VECTOR.

Reviewed By: craig.topper

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

Added: 
llvm/test/CodeGen/RISCV/rvv/vmarith-sdnode.ll
llvm/test/CodeGen/RISCV/rvv/vsplats-i1.ll

Modified: 
llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
index fa2236cef874..208e50168897 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
@@ -35,6 +35,11 @@ def SplatPat   : ComplexPattern;
 def SplatPat_simm5 : ComplexPattern;
 def SplatPat_uimm5 : ComplexPattern;
 
+// A mask-vector version of the standard 'vnot' fragment but using splat_vector
+// rather than (the implicit) build_vector
+def riscv_m_vnot : PatFrag<(ops node:$in),
+   (xor node:$in, (splat_vector (XLenVT 1)))>;
+
 multiclass VPatUSLoadStoreSDNode;
 defm "" : VPatBinarySDNode_VV_VX;
 defm "" : VPatBinarySDNode_VV_VX;
 
+// 16.1. Vector Mask-Register Logical Instructions
+foreach mti = AllMasks in {
+  def : Pat<(mti.Mask (and VR:$rs1, VR:$rs2)),
+(!cast("PseudoVMAND_MM_"#mti.LMul.MX)
+ VR:$rs1, VR:$rs2, VLMax, mti.SEW)>;
+  def : Pat<(mti.Mask (or VR:$rs1, VR:$rs2)),
+(!cast("PseudoVMOR_MM_"#mti.LMul.MX)
+ VR:$rs1, VR:$rs2, VLMax, mti.SEW)>;
+  def : Pat<(mti.Mask (xor VR:$rs1, VR:$rs2)),
+(!cast("PseudoVMXOR_MM_"#mti.LMul.MX)
+ VR:$rs1, VR:$rs2, VLMax, mti.SEW)>;
+
+  def : Pat<(mti.Mask (riscv_m_vnot (and VR:$rs1, VR:$rs2))),
+(!cast("PseudoVMNAND_MM_"#mti.LMul.MX)
+ VR:$rs1, VR:$rs2, VLMax, mti.SEW)>;
+  def : Pat<(mti.Mask (riscv_m_vnot (or VR:$rs1, VR:$rs2))),
+(!cast("PseudoVMNOR_MM_"#mti.LMul.MX)
+ VR:$rs1, VR:$rs2, VLMax, mti.SEW)>;
+  def : Pat<(mti.Mask (riscv_m_vnot (xor VR:$rs1, VR:$rs2))),
+(!cast("PseudoVMXNOR_MM_"#mti.LMul.MX)
+ VR:$rs1, VR:$rs2, VLMax, mti.SEW)>;
+
+  def : Pat<(mti.Mask (and VR:$rs1, (riscv_m_vnot VR:$rs2))),
+(!cast("PseudoVMANDNOT_MM_"#mti.LMul.MX)
+ VR:$rs1, VR:$rs2, VLMax, mti.SEW)>;
+  def : Pat<(mti.Mask (or VR:$rs1, (riscv_m_vnot VR:$rs2))),
+(!cast("PseudoVMORNOT_MM_"#mti.LMul.MX)
+ VR:$rs1, VR:$rs2, VLMax, mti.SEW)>;
+}
+
 } // Predicates = [HasStdExtV]
 
 
//===--===//
@@ -196,6 +231,13 @@ foreach vti = AllIntegerVectors in {
 (!cast("PseudoVMV_V_I_" # vti.LMul.MX)
   simm5:$rs1, VLMax, vti.SEW)>;
 }
+
+foreach mti = AllMasks in {
+  def : Pat<(mti.Mask (splat_vector (XLenVT 1))),
+(!cast("PseudoVMSET_M_"#mti.BX) VLMax, mti.SEW)>;
+  def : Pat<(mti.Mask (splat_vector (XLenVT 0))),
+(!cast("PseudoVMCLR_M_"#mti.BX) VLMax, mti.SEW)>;
+}
 } // Predicates = [HasStdExtV]
 
 let Predicates = [HasStdExtV, IsRV32] in {

diff  --git a/llvm/test/CodeGen/RISCV/rvv/vmarith-sdnode.ll 
b/llvm/test/CodeGen/RISCV/rvv/vmarith-sdnode.ll
new file mode 100644
index ..cd75d6e50033
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/rvv/vmarith-sdnode.ll
@@ -0,0 +1,479 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-v -verify-machineinstrs < %s 
| FileCheck %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs < %s 
| FileCheck %s
+
+define  @vmand_vv_nxv1i1( %va,  %vb) {
+; CHECK-LABEL: vmand_vv_nxv1i1:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli a0, zero, e8,mf8,ta,mu
+; CHECK-NEXT:vmand.mm v0, v0, v16
+; CHECK-NEXT:ret
+  %vc = and  %va, %vb
+  ret  %vc
+}
+
+define  @vmand_vv_nxv2i1( %va,  %vb) {
+; CHECK-LABEL: vmand_vv_nxv2i1:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli a0, zero, e8,mf4,ta,mu
+; CHECK-NEXT:vmand.mm v0, v0, v16
+; CHECK-NEXT:ret
+  %vc = and  %va, %vb
+  ret  %vc
+}
+
+define  @vmand_vv_nxv4i1( %va,  %vb) {
+; CHECK-LABEL: vmand_vv_nxv4i1:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vsetvli a0, zero, e8,mf2,ta,mu
+; CHECK-NEXT:vmand.mm v0, v0, v16
+; CHECK-NEXT:ret
+  %vc = and  %va, %vb
+  ret  %vc
+}
+
+define  @vmand_vv_nxv8i1( %va,  %vb) {
+; CHECK-LABEL: vmand_vv_nxv8i1:
+; CHECK:   # %bb.0:
+; CHECK-

[llvm-branch-commits] [llvm] 67a4c67 - Reapply "[clang][cli] Allow users to specify a conditional to prevent parsing options with MarshallingInfo"

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T11:11:47+01:00
New Revision: 67a4c672b02359fa6f723249f633ffc76aff2174

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

LOG: Reapply "[clang][cli] Allow users to specify a conditional to prevent 
parsing options with MarshallingInfo"

This reverts commit d0fa7a05 and fixes failing OptionMarshallingTest by adding 
the SHOULD_PARSE macro argument

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 428c14a7d9bb..33b5cd09004e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4091,7 +4091,9 @@ defm sycl : BoolOption<"sycl",
   BothFlags<[CoreOption], " SYCL kernels compilation for device">, "f">,
   Group;
 def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
-  HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 
1.2.1, sycl-1.2.1">;
+  HelpText<"SYCL language standard to compile for.">, 
Values<"2017,121,1.2.1,sycl-1.2.1">,
+  NormalizedValues<["SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, 
NormalizedValuesScope<"LangOptions">,
+  MarshallingInfoString<"LangOpts->SYCLVersion", "SYCL_None">, 
ShouldParseIf, AutoNormalizeEnum;
 
 
//===--===//
 // FlangOption and FC1 Options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 57027cea5659..962f72963cd2 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2282,23 +2282,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   }
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-  if (Opts.SYCL) {
-// -sycl-std applies to any SYCL source, not only those containing kernels,
-// but also those using the SYCL API
-if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
-  Opts.setSYCLVersion(
-  llvm::StringSwitch(A->getValue())
-  .Cases("2017", "1.2.1", "121", "sycl-1.2.1",
- LangOptions::SYCL_2017)
-  .Default(LangOptions::SYCL_None));
-
-  if (Opts.getSYCLVersion() == LangOptions::SYCL_None) {
-// User has passed an invalid value to the flag, this is an error
-Diags.Report(diag::err_drv_invalid_value)
-<< A->getAsString(Args) << A->getValue();
-  }
-}
-  }
 
   llvm::Triple T(TargetOpts.Triple);
   CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
@@ -3003,16 +2986,17 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList 
&Args,
  DiagnosticsEngine &Diags) {
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
-IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
-TABLE_INDEX)   
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  
\
-  this->KEYPATH = MERGER(  
\
-  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
+if (SHOULD_PARSE)  
\
+  if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))
\
+this->KEYPATH = MERGER(
\
+this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
   }
 
 #include "clang/Driver/Options.inc"
@@ -3265,9 +3249,9 @@ void CompilerInvocation::generateCC1CommandLine(
   // with lifetime extension of the 

[llvm-branch-commits] [clang] 0877b96 - [clang][ASTImporter] Fix a possible assertion failure `NeedsInjectedClassNameType(Decl)'.

2021-01-07 Thread Balázs Kéri via llvm-branch-commits

Author: Balázs Kéri
Date: 2021-01-07T11:28:11+01:00
New Revision: 0877b963ef2d3c384b47f7a6161c9d9ab106a7f2

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

LOG: [clang][ASTImporter] Fix a possible assertion failure 
`NeedsInjectedClassNameType(Decl)'.

The assertion can happen if ASTImporter imports a CXXRecordDecl in a template
and then imports another redeclaration of this declaration, while the first 
import is in progress.
The process of first import did not set the "described template" yet
and the second import finds the first declaration at setting the injected types.
Setting the injected type requires in the assertion that the described template 
is set.
The exact assertion was:
clang/lib/AST/ASTContext.cpp:4411:
clang::QualType 
clang::ASTContext::getInjectedClassNameType(clang::CXXRecordDecl*, 
clang::QualType) const:
Assertion `NeedsInjectedClassNameType(Decl)' failed.

Reviewed By: shafik

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 54816b721a4a..5c6aa5d3c015 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -5393,16 +5393,16 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
 
   CXXRecordDecl *FromTemplated = D->getTemplatedDecl();
 
+  auto TemplateParamsOrErr = import(D->getTemplateParameters());
+  if (!TemplateParamsOrErr)
+return TemplateParamsOrErr.takeError();
+
   // Create the declaration that is being templated.
   CXXRecordDecl *ToTemplated;
   if (Error Err = importInto(ToTemplated, FromTemplated))
 return std::move(Err);
 
   // Create the class template declaration itself.
-  auto TemplateParamsOrErr = import(D->getTemplateParameters());
-  if (!TemplateParamsOrErr)
-return TemplateParamsOrErr.takeError();
-
   ClassTemplateDecl *D2;
   if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
   *TemplateParamsOrErr, ToTemplated))

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 2472fa265589..8a07a5b8e0df 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -6141,6 +6141,41 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
TypedefWithAttribute) {
   EXPECT_EQ(ToAttr->getAnnotation(), "A");
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportOfTemplatedDeclWhenPreviousDeclHasNoDescribedTemplateSet) {
+  Decl *FromTU = getTuDecl(
+  R"(
+
+  namespace std {
+template
+class basic_stringbuf;
+  }
+  namespace std {
+class char_traits;
+template
+class basic_stringbuf;
+  }
+  namespace std {
+template
+class basic_stringbuf {};
+  }
+
+  )",
+  Lang_CXX11);
+
+  auto *From1 = FirstDeclMatcher().match(
+  FromTU,
+  classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit(;
+  auto *To1 = cast_or_null(Import(From1, Lang_CXX11));
+  EXPECT_TRUE(To1);
+
+  auto *From2 = LastDeclMatcher().match(
+  FromTU,
+  classTemplateDecl(hasName("basic_stringbuf"), unless(isImplicit(;
+  auto *To2 = cast_or_null(Import(From2, Lang_CXX11));
+  EXPECT_TRUE(To2);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 



___
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] 801c786 - [lldb][ARM/AArch64] Update disasm flags to latest v8.7a ISA

2021-01-07 Thread David Spickett via llvm-branch-commits

Author: David Spickett
Date: 2021-01-07T10:51:47Z
New Revision: 801c7866e6d4fba81c97d27ca56c9e05ba7b157a

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

LOG: [lldb][ARM/AArch64] Update disasm flags to latest v8.7a ISA

Add optional memory tagging extension on AArch64.

Use isAArch64() instead of listing the AArch64 triples,
which fixes us not recognising aarch64_be.

Reviewed By: omjavaid

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

Added: 


Modified: 
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index 6427d8d176c8..8a2d3232a39a 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -1056,7 +1056,7 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
   thumb_arch_name.erase(0, 3);
   thumb_arch_name.insert(0, "thumb");
 } else {
-  thumb_arch_name = "thumbv8.2a";
+  thumb_arch_name = "thumbv8.7a";
 }
 thumb_arch.GetTriple().setArchName(llvm::StringRef(thumb_arch_name));
   }
@@ -1068,7 +1068,7 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
   // specified)
   if (triple.getArch() == llvm::Triple::arm &&
   triple.getSubArch() == llvm::Triple::NoSubArch)
-triple.setArchName("armv8.2a");
+triple.setArchName("armv8.7a");
 
   std::string features_str = "";
   const char *triple_str = triple.getTriple().c_str();
@@ -1137,16 +1137,13 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec 
&arch,
   features_str += "+dspr2,";
   }
 
-  // If any AArch64 variant, enable the ARMv8.5 ISA with SVE extensions so we
-  // can disassemble newer instructions.
-  if (triple.getArch() == llvm::Triple::aarch64 || 
-  triple.getArch() == llvm::Triple::aarch64_32)
-features_str += "+v8.5a,+sve2";
+  // If any AArch64 variant, enable latest ISA with any optional
+  // extensions like SVE.
+  if (triple.isAArch64()) {
+features_str += "+v8.7a,+sve2,+mte";
 
-  if ((triple.getArch() == llvm::Triple::aarch64 ||
-   triple.getArch() == llvm::Triple::aarch64_32)
-  && triple.getVendor() == llvm::Triple::Apple) {
-cpu = "apple-latest";
+if (triple.getVendor() == llvm::Triple::Apple)
+  cpu = "apple-latest";
   }
 
   // We use m_disasm_up.get() to tell whether we are valid or not, so if this



___
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] a828fb4 - [clang][cli] Port a CommaJoined option to the marshalling infrastructure

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T11:52:06+01:00
New Revision: a828fb463ed9f6085849bb3a4f225b3c84e7cf29

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

LOG: [clang][cli] Port a CommaJoined option to the marshalling infrastructure

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 33b5cd09004e..6b5ae35ad7e0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1201,7 +1201,7 @@ def fansi_escape_codes : Flag<["-"], 
"fansi-escape-codes">, Group,
   MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes">;
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation 
comment block command">,
-  MetaVarName<"">;
+  MetaVarName<"">, 
MarshallingInfoStringVector<"LangOpts->CommentOpts.BlockCommandNames">;
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>,
   MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
 def frecord_command_line : Flag<["-"], "frecord-command-line">,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 962f72963cd2..da4213e8952e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -328,8 +328,20 @@ static void denormalizeStringVector(SmallVectorImpl &Args,
 Option::OptionClass OptClass,
 unsigned TableIndex,
 const std::vector &Values) {
-  for (const std::string &Value : Values) {
-denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
+  if (OptClass == Option::OptionClass::CommaJoinedClass) {
+std::string CommaJoinedValue;
+if (!Values.empty()) {
+  CommaJoinedValue.append(Values.front());
+  for (const std::string &Value : llvm::drop_begin(Values, 1)) {
+CommaJoinedValue.append(",");
+CommaJoinedValue.append(Value);
+  }
+}
+denormalizeString(Args, Spelling, SA, Option::OptionClass::JoinedClass,
+  TableIndex, CommaJoinedValue);
+  } else if (OptClass == Option::OptionClass::JoinedClass) {
+for (const std::string &Value : Values)
+  denormalizeString(Args, Spelling, SA, OptClass, TableIndex, Value);
   }
 }
 
@@ -785,7 +797,6 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
 }
 
 static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
-  Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);
   Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
 }
 

diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 8fcf34d5c874..7b8efb9af2e2 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -508,6 +508,53 @@ TEST_F(CommandLineTest, StringVectorMultiple) {
   ASSERT_THAT(GeneratedArgs, ContainsN(HasSubstr("-fmodule-map-file"), 2));
 }
 
+// CommaJoined option with MarshallingInfoStringVector.
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedNone) {
+  const char *Args[] = {""};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_TRUE(Invocation.getLangOpts()->CommentOpts.BlockCommandNames.empty());
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs,
+  Not(Contains(HasSubstr("-fcomment-block-commands";
+}
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedSingle) {
+  const char *Args[] = {"-fcomment-block-commands=x,y"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames,
+std::vector({"x", "y"}));
+
+  Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+  ASSERT_THAT(GeneratedArgs,
+  ContainsN(StrEq("-fcomment-block-commands=x,y"), 1));
+}
+
+TEST_F(CommandLineTest, StringVectorCommaJoinedMultiple) {
+  const char *Args[] = {"-fcomment-block-commands=x,y",
+"-fcomment-block-commands=a,b"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getLangOpts()->Co

[llvm-branch-commits] [flang] e5cdb6c - [flang][driver] Add support for `-c` and `-emit-obj`

2021-01-07 Thread Andrzej Warzynski via llvm-branch-commits

Author: Andrzej Warzynski
Date: 2021-01-07T10:52:38Z
New Revision: e5cdb6c56edf656d03f57c5c285cfa8c6b7b6f57

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

LOG: [flang][driver] Add support for `-c` and `-emit-obj`

This patch adds a frontend action for emitting object files. While Flang
does not support code-generation, this action remains a placeholder.
This patch simply provides glue-code to connect the compiler driver
with the appropriate frontend action.

The new action is triggered with the `-c` compiler driver flag, i.e.
`flang-new -c`. This is then translated to `flang-new -fc1 -emit-obj`,
so `-emit-obj` has to be marked as supported as well.

As code-generation is not available yet, `flang-new -c` results in a
driver error:
```
error: code-generation is not available yet
```
Hopefully this will help communicating the level of available
functionality within Flang.

The definition of `emit-obj` is updated so that it can be shared between
Clang and Flang. As the original definition was enclosed within a
Clang-specific TableGen `let` statement, it is extracted into a new `let`
statement. That felt like the cleanest option.

I also commented out `-triple` in Flang::ConstructJob and updated some
comments there. This is similar to https://reviews.llvm.org/D93027. I
wanted to make sure that it's clear that we can't support `-triple`
until we have code-generation. However, once code-generation is
available we _will need_ `-triple`.

As this patch adds `-emit-obj`, the emit-obj.f90 becomes irrelevant and
is deleted. Instead, phases.f90 is added to demonstrate that users can
control compilation phases (indeed, `-c` is a phase control flag).

Reviewed By: SouraVX, clementval

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

Added: 
flang/test/Flang-Driver/code-gen.f90
flang/test/Flang-Driver/phases.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/FrontendActions.h
flang/include/flang/Frontend/FrontendOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
flang/test/Flang-Driver/driver-help-hidden.f90
flang/test/Flang-Driver/driver-help.f90

Removed: 
flang/test/Flang-Driver/emit-obj.f90



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6b5ae35ad7e0..ffa7fbd84df9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -857,7 +857,7 @@ def current__version : JoinedOrSeparate<["-"], 
"current_version">;
 def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group,
   HelpText<"Add directory to the C++ SYSTEM include search path">, 
Flags<[CC1Option]>,
   MetaVarName<"">;
-def c : Flag<["-"], "c">, Flags<[NoXarchOption]>, Group,
+def c : Flag<["-"], "c">, Flags<[NoXarchOption, FlangOption]>, 
Group,
   HelpText<"Only run preprocess, compile, and assemble steps">;
 def fconvergent_functions : Flag<["-"], "fconvergent-functions">, 
Group, Flags<[CC1Option]>,
   HelpText<"Assume functions may be convergent">;
@@ -4854,8 +4854,6 @@ def emit_llvm_only : Flag<["-"], "emit-llvm-only">,
   HelpText<"Build ASTs and convert to LLVM, discarding output">;
 def emit_codegen_only : Flag<["-"], "emit-codegen-only">,
   HelpText<"Generate machine code, but discard output">;
-def emit_obj : Flag<["-"], "emit-obj">,
-  HelpText<"Emit native object files">;
 def rewrite_test : Flag<["-"], "rewrite-test">,
   HelpText<"Rewriter playground">;
 def rewrite_macros : Flag<["-"], "rewrite-macros">,
@@ -5229,6 +5227,18 @@ def fsycl_is_device : Flag<["-"], "fsycl-is-device">,
 
 } // let Flags = [CC1Option, NoDriverOption]
 
+//===--===//
+// Frontend Options - cc1 + fc1
+//===--===//
+let Flags = [CC1Option, FC1Option, NoDriverOption] in {
+let Group = Action_Group in {
+
+def emit_obj : Flag<["-"], "emit-obj">,
+  HelpText<"Emit native object files">;
+
+} // let Group = Action_Group
+} // let Flags = [CC1Option, FC1Option, NoDriverOption]
+
 
//===--===//
 // cc1as-only Options
 
//===--===//

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 69f0841bb0c5..bf300d737991 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -28,17 +28,22 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
  const InputInfo &Output, co

[llvm-branch-commits] [clang] b6ba598 - [clang][cli] Port getAllArgumentValues to the marshalling infrastructure

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T12:02:07+01:00
New Revision: b6ba59830796b4efad69a3d3c1fae56c20029f30

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

LOG: [clang][cli] Port getAllArgumentValues to the marshalling infrastructure

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ffa7fbd84df93..6585fd1ceb013 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -679,7 +679,8 @@ def MP : Flag<["-"], "MP">, Group, 
Flags<[CC1Option]>,
 def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>,
 HelpText<"Specify name of main file output to quote in depfile">;
 def MT : JoinedOrSeparate<["-"], "MT">, Group, Flags<[CC1Option]>,
-HelpText<"Specify name of main file output in depfile">;
+HelpText<"Specify name of main file output in depfile">,
+MarshallingInfoStringVector<"DependencyOutputOpts.Targets">;
 def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>,
 HelpText<"Use NMake/Jom format for the depfile">,
 MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", 
"DependencyOutputFormat::Make">,
@@ -753,7 +754,8 @@ def Wp_COMMA : CommaJoined<["-"], "Wp,">,
   MetaVarName<"">, Group;
 def Wundef_prefix_EQ : CommaJoined<["-"], "Wundef-prefix=">, 
Group,
   Flags<[CC1Option, CoreOption, HelpHidden]>, MetaVarName<"">,
-  HelpText<"Enable warnings for undefined macros with a prefix in the comma 
separated list ">;
+  HelpText<"Enable warnings for undefined macros with a prefix in the comma 
separated list ">,
+  MarshallingInfoStringVector<"DiagnosticOpts->UndefPrefixes">;
 def Wwrite_strings : Flag<["-"], "Wwrite-strings">, Group, 
Flags<[CC1Option, HelpHidden]>;
 def Wno_write_strings : Flag<["-"], "Wno-write-strings">, Group, 
Flags<[CC1Option, HelpHidden]>;
 def W_Joined : Joined<["-"], "W">, Group, Flags<[CC1Option, 
CoreOption]>,
@@ -1387,7 +1389,8 @@ def fno_sanitize_EQ : CommaJoined<["-"], 
"fno-sanitize=">, Group,
   Flags<[CoreOption, NoXarchOption]>;
 def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
   Group,
-  HelpText<"Path to blacklist file for sanitizers">;
+  HelpText<"Path to blacklist file for sanitizers">,
+  
MarshallingInfoStringVector<"LangOpts->SanitizerBlacklistFiles">;
 def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">,
   HelpText<"Path to system blacklist file for sanitizers">,
   Flags<[CC1Option]>;
@@ -1405,13 +1408,15 @@ def fno_sanitize_coverage
"Sanitizers">, 
Values<"func,bb,edge,indirect-calls,trace-bb,trace-cmp,trace-div,trace-gep,8bit-counters,trace-pc,trace-pc-guard,no-prune,inline-8bit-counters,inline-bool-flag">;
 def fsanitize_coverage_allowlist : Joined<["-"], 
"fsanitize-coverage-allowlist=">,
 Group, Flags<[CoreOption, NoXarchOption]>,
-HelpText<"Restrict sanitizer coverage instrumentation exclusively to 
modules and functions that match the provided special case list, except the 
blocked ones">;
+HelpText<"Restrict sanitizer coverage instrumentation exclusively to 
modules and functions that match the provided special case list, except the 
blocked ones">,
+MarshallingInfoStringVector<"CodeGenOpts.SanitizeCoverageAllowlistFiles">;
 def : Joined<["-"], "fsanitize-coverage-whitelist=">,
   Group, Flags<[CoreOption, HelpHidden]>, 
Alias,
   HelpText<"Deprecated, use -fsanitize-coverage-allowlist= instead">;
 def fsanitize_coverage_blocklist : Joined<["-"], 
"fsanitize-coverage-blocklist=">,
 Group, Flags<[CoreOption, NoXarchOption]>,
-HelpText<"Disable sanitizer coverage instrumentation for modules and 
functions that match the provided special case list, even the allowed ones">;
+HelpText<"Disable sanitizer coverage instrumentation for modules and 
functions that match the provided special case list, even the allowed ones">,
+MarshallingInfoStringVector<"CodeGenOpts.SanitizeCoverageBlocklistFiles">;
 def : Joined<["-"], "fsanitize-coverage-blacklist=">,
   Group, Flags<[CoreOption, HelpHidden]>, 
Alias,
   HelpText<"Deprecated, use -fsanitize-coverage-blocklist= instead">;
@@ -1616,7 +1621,8 @@ defm delete_null_pointer_checks : 
BoolFOption<"delete-null-pointer-checks",
 
 def frewrite_map_file : Separate<["-"], "frewrite-map-file">,
 Group,
-Flags<[ NoXarchOption, CC1Option ]>;
+Flags<[ NoXarchOption, CC1Option ]>,
+
M

[llvm-branch-commits] [libcxx] b6fb020 - [libc++] [CI] Install Tip-of-Trunk clang.

2021-01-07 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2021-01-07T12:04:09+01:00
New Revision: b6fb0209b6d4e93126f613eca335db84886bf939

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

LOG: [libc++] [CI] Install Tip-of-Trunk clang.

* Check created symlinks.

Reviewed By: ldionne, #libc

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

Added: 


Modified: 
libcxx/utils/ci/Dockerfile

Removed: 




diff  --git a/libcxx/utils/ci/Dockerfile b/libcxx/utils/ci/Dockerfile
index fea46d8cd81e..63f747203796 100644
--- a/libcxx/utils/ci/Dockerfile
+++ b/libcxx/utils/ci/Dockerfile
@@ -50,19 +50,28 @@ RUN apt-get update && apt-get install -y libc6-dev-i386 # 
Required to cross-comp
 
 # Install the most recently released LLVM
 RUN apt-get update && apt-get install -y lsb-release wget 
software-properties-common
-RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
-RUN ln -s $(find /usr/bin -regex '^.+/clang\+\+-[0-9.]+$') /usr/bin/clang++
-RUN ln -s $(find /usr/bin -regex '^.+/clang-[0-9.]+$') /usr/bin/clang
+RUN wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
+RUN bash /tmp/llvm.sh
+RUN LLVM_VERSION=$(find /usr/bin -regex '^.+/clang-[0-9.]+$') && 
LLVM_VERSION=${LLVM_VERSION#*clang-} && echo "LLVM_VERSION=$LLVM_VERSION" > 
/tmp/env.sh
+RUN ln -s $(find /usr/bin -regex '^.+/clang\+\+-[0-9.]+$') /usr/bin/clang++ && 
[ -e $(readlink /usr/bin/clang++) ]
+RUN ln -s $(find /usr/bin -regex '^.+/clang-[0-9.]+$') /usr/bin/clang && [ -e 
$(readlink /usr/bin/clang) ]
 
-RUN apt-get update && apt-get install -y clang-format-11
-# Make a symbolic link to git-clang-format (pointing to 
git-clang-format-), if it doesn't exist.
-RUN which git-clang-format || $(cd /usr/bin/ && ln -s $(ls git-clang-format-* 
| sort -rV | head -n 1) git-clang-format)
+# Install the not-yet-released LLVM
+RUN . /tmp/env.sh && echo "LLVM_TOT_VERSION=$(($LLVM_VERSION + 1))" >> 
/tmp/env.sh
+RUN . /tmp/env.sh && bash /tmp/llvm.sh ${LLVM_TOT_VERSION}
+RUN . /tmp/env.sh && ln -s /usr/bin/clang++-${LLVM_TOT_VERSION} 
/usr/bin/clang++-tot && [ -e $(readlink /usr/bin/clang++-tot) ]
+RUN . /tmp/env.sh && ln -s /usr/bin/clang-${LLVM_TOT_VERSION} 
/usr/bin/clang-tot && [ -e $(readlink /usr/bin/clang-tot) ]
+
+# Install clang-format
+RUN . /tmp/env.sh && apt-get install -y clang-format-$LLVM_VERSION
+RUN ln -s $(find /usr/bin -regex '^.+/clang-format-[0-9.]+$') 
/usr/bin/clang-format && [ -e $(readlink /usr/bin/clang-format) ]
+RUN ln -s $(find /usr/bin -regex '^.+/git-clang-format-[0-9.]+$') 
/usr/bin/git-clang-format && [ -e $(readlink /usr/bin/git-clang-format) ]
 
 # Install a recent GCC
 RUN add-apt-repository ppa:ubuntu-toolchain-r/test
 RUN apt-get update && apt install -y gcc-10 g++-10
-RUN ln -f -s /usr/bin/g++-10 /usr/bin/g++
-RUN ln -f -s /usr/bin/gcc-10 /usr/bin/gcc
+RUN ln -f -s /usr/bin/g++-10 /usr/bin/g++ && [ -e $(readlink /usr/bin/g++) ]
+RUN ln -f -s /usr/bin/gcc-10 /usr/bin/gcc && [ -e $(readlink /usr/bin/gcc) ]
 
 # Install a recent CMake
 RUN wget 
https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-Linux-x86_64.sh
 -O /tmp/install-cmake.sh



___
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] 33f90f3 - [clang][cli] Report the actual argument parsing result

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T12:37:04+01:00
New Revision: 33f90f38e11c7c23d6e2a23ca526f8b0d8f53771

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

LOG: [clang][cli] Report the actual argument parsing result

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 49447f16637f..7fb7ec896e64 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -129,10 +129,9 @@ CompilerInvocationBase::~CompilerInvocationBase() = 
default;
 #include "clang/Driver/Options.inc"
 #undef SIMPLE_ENUM_VALUE_TABLE
 
-static llvm::Optional normalizeSimpleFlag(OptSpecifier Opt,
-unsigned TableIndex,
-const ArgList &Args,
-DiagnosticsEngine &Diags) {
+static llvm::Optional
+normalizeSimpleFlag(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
+DiagnosticsEngine &Diags, bool &Success) {
   if (Args.hasArg(Opt))
 return true;
   return None;
@@ -140,7 +139,8 @@ static llvm::Optional 
normalizeSimpleFlag(OptSpecifier Opt,
 
 static Optional normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
   const ArgList &Args,
-  DiagnosticsEngine &) {
+  DiagnosticsEngine &,
+  bool &Success) {
   if (Args.hasArg(Opt))
 return false;
   return None;
@@ -166,7 +166,7 @@ template (), bool> = false>
 static auto makeFlagToValueNormalizer(T Value) {
   return [Value](OptSpecifier Opt, unsigned, const ArgList &Args,
- DiagnosticsEngine &) -> Optional {
+ DiagnosticsEngine &, bool &Success) -> Optional {
 if (Args.hasArg(Opt))
   return Value;
 return None;
@@ -182,8 +182,8 @@ static auto makeFlagToValueNormalizer(T Value) {
 static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,
 OptSpecifier OtherOpt) {
   return [Value, OtherValue, OtherOpt](OptSpecifier Opt, unsigned,
-   const ArgList &Args,
-   DiagnosticsEngine &) -> Optional {
+   const ArgList &Args, DiagnosticsEngine 
&,
+   bool &Success) -> Optional {
 if (const Arg *A = Args.getLastArg(Opt, OtherOpt)) {
   return A->getOption().matches(Opt) ? Value : OtherValue;
 }
@@ -246,10 +246,9 @@ findValueTableByValue(const SimpleEnumValueTable &Table, 
unsigned Value) {
   return None;
 }
 
-static llvm::Optional normalizeSimpleEnum(OptSpecifier Opt,
-unsigned TableIndex,
-const ArgList &Args,
-DiagnosticsEngine &Diags) {
+static llvm::Optional
+normalizeSimpleEnum(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
+DiagnosticsEngine &Diags, bool &Success) {
   assert(TableIndex < SimpleEnumValueTablesSize);
   const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
 
@@ -261,6 +260,7 @@ static llvm::Optional 
normalizeSimpleEnum(OptSpecifier Opt,
   if (auto MaybeEnumVal = findValueTableByName(Table, ArgValue))
 return MaybeEnumVal->Value;
 
+  Success = false;
   Diags.Report(diag::err_drv_invalid_value)
   << Arg->getAsString(Args) << ArgValue;
   return None;
@@ -294,7 +294,8 @@ static void denormalizeSimpleEnum(SmallVectorImpl &Args,
 
 static Optional normalizeString(OptSpecifier Opt, int TableIndex,
  const ArgList &Args,
- DiagnosticsEngine &Diags) {
+ DiagnosticsEngine &Diags,
+ bool &Success) {
   auto *Arg = Args.getLastArg(Opt);
   if (!Arg)
 return None;
@@ -302,14 +303,15 @@ static Optional normalizeString(OptSpecifier 
Opt, int TableIndex,
 }
 
 template 
-static Optional normalizeStringIntegral(OptSpecifier Opt, int,
-   const ArgList &Args,
-   DiagnosticsEngine &Diags) {
+static Optional
+normalizeStringIntegral(OptSpecifier Opt, int, const ArgList

[llvm-branch-commits] [llvm] 350ab7a - [DAG] Simplify OR(X, SHL(Y, BW/2)) eq/ne 0/-1 'all/any-of' style patterns

2021-01-07 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-07T12:03:19Z
New Revision: 350ab7aa1c6735c0a136c118f7b43773fd74bf2d

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

LOG: [DAG] Simplify OR(X,SHL(Y,BW/2)) eq/ne 0/-1 'all/any-of' style patterns

Attempt to simplify all/any-of style patterns that concatenate 2 smaller 
integers together into an and(x,y)/or(x,y) + icmp 0/-1 instead.

This is mainly to help some bool predicate reduction patterns where we end up 
concatenating bool vectors that have been bitcasted to integers.

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/X86/avx512-mask-op.ll
llvm/test/CodeGen/X86/cmp-concat.ll
llvm/test/CodeGen/X86/movmsk-cmp.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index f5abb2c513fb..1bf9840995b0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -3956,6 +3956,67 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue 
N0, SDValue N1,
 if (SDValue CC = optimizeSetCCByHoistingAndByConstFromLogicalShift(
 VT, N0, N1, Cond, DCI, dl))
   return CC;
+
+  // For all/any comparisons, replace or(x,shl(y,bw/2)) with and/or(x,y).
+  // For example, when high 32-bits of i64 X are known clear:
+  // all bits clear: (X | (Y<<32)) ==  0 --> (X | Y) ==  0
+  // all bits set:   (X | (Y<<32)) == -1 --> (X & Y) == -1
+  bool CmpZero = N1C->getAPIntValue().isNullValue();
+  bool CmpNegOne = N1C->getAPIntValue().isAllOnesValue();
+  if ((CmpZero || CmpNegOne) && N0.hasOneUse()) {
+// Match or(lo,shl(hi,bw/2)) pattern.
+auto IsConcat = [&](SDValue V, SDValue &Lo, SDValue &Hi) {
+  unsigned EltBits = V.getScalarValueSizeInBits();
+  if (V.getOpcode() != ISD::OR || (EltBits % 2) != 0)
+return false;
+  SDValue LHS = V.getOperand(0);
+  SDValue RHS = V.getOperand(1);
+  APInt HiBits = APInt::getHighBitsSet(EltBits, EltBits / 2);
+  // Unshifted element must have zero upperbits.
+  if (RHS.getOpcode() == ISD::SHL &&
+  isa(RHS.getOperand(1)) &&
+  RHS.getConstantOperandAPInt(1) == (EltBits / 2) &&
+  DAG.MaskedValueIsZero(LHS, HiBits)) {
+Lo = LHS;
+Hi = RHS.getOperand(0);
+return true;
+  }
+  if (LHS.getOpcode() == ISD::SHL &&
+  isa(LHS.getOperand(1)) &&
+  LHS.getConstantOperandAPInt(1) == (EltBits / 2) &&
+  DAG.MaskedValueIsZero(RHS, HiBits)) {
+Lo = RHS;
+Hi = LHS.getOperand(0);
+return true;
+  }
+  return false;
+};
+
+auto MergeConcat = [&](SDValue Lo, SDValue Hi) {
+  unsigned EltBits = N0.getScalarValueSizeInBits();
+  unsigned HalfBits = EltBits / 2;
+  APInt HiBits = APInt::getHighBitsSet(EltBits, HalfBits);
+  SDValue LoBits = DAG.getConstant(~HiBits, dl, OpVT);
+  SDValue HiMask = DAG.getNode(ISD::AND, dl, OpVT, Hi, LoBits);
+  SDValue NewN0 =
+  DAG.getNode(CmpZero ? ISD::OR : ISD::AND, dl, OpVT, Lo, HiMask);
+  SDValue NewN1 = CmpZero ? DAG.getConstant(0, dl, OpVT) : LoBits;
+  return DAG.getSetCC(dl, VT, NewN0, NewN1, Cond);
+};
+
+SDValue Lo, Hi;
+if (IsConcat(N0, Lo, Hi))
+  return MergeConcat(Lo, Hi);
+
+if (N0.getOpcode() == ISD::AND || N0.getOpcode() == ISD::OR) {
+  SDValue Lo0, Lo1, Hi0, Hi1;
+  if (IsConcat(N0.getOperand(0), Lo0, Hi0) &&
+  IsConcat(N0.getOperand(1), Lo1, Hi1)) {
+return MergeConcat(DAG.getNode(N0.getOpcode(), dl, OpVT, Lo0, Lo1),
+   DAG.getNode(N0.getOpcode(), dl, OpVT, Hi0, 
Hi1));
+  }
+}
+  }
 }
 
 // If we have "setcc X, C0", check to see if we can shrink the immediate

diff  --git a/llvm/test/CodeGen/X86/avx512-mask-op.ll 
b/llvm/test/CodeGen/X86/avx512-mask-op.ll
index 5df6842994f0..684bebaa85dd 100644
--- a/llvm/test/CodeGen/X86/avx512-mask-op.ll
+++ b/llvm/test/CodeGen/X86/avx512-mask-op.ll
@@ -2148,18 +2148,15 @@ define void @ktest_2(<32 x float> %in, float * %base) {
 ;
 ; KNL-LABEL: ktest_2:
 ; KNL:   ## %bb.0:
-; KNL-NEXT:vcmpgtps 64(%rdi), %zmm1, %k1
-; KNL-NEXT:vcmpgtps (%rdi), %zmm0, %k2
-; KNL-NEXT:vmovups 4(%rdi), %zmm2 {%k2} {z}
-; KNL-NEXT:vmovups 68(%rdi), %zmm3 {%k1} {z}
-; KNL-NEXT:vcmpltps %zmm3, %zmm1, %k0
-; KNL-NEXT:vcmpltps %zmm2, %zmm0, %k3
+; KNL-NEXT:vcmpgtps (%rdi), %zmm

[llvm-branch-commits] [libcxx] 7da3e3a - [libcxx] Mark a test as unsupported for C++03

2021-01-07 Thread Mikhail Maltsev via llvm-branch-commits

Author: Mikhail Maltsev
Date: 2021-01-07T12:06:08Z
New Revision: 7da3e3a8983a079cbed874b924dd34dd6b6a4001

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

LOG: [libcxx] Mark a test as unsupported for C++03

The nullptr_t_integral_cast.pass.cpp test is currently xfailed for
C++03, but actually, it only fails with the first version of libc++
ABI.

This patch changes XFAIL to UNSUPPORTED to avoid unexpected passes
with ABI v2 or later.

Reviewed By: ldionne, #libc

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

Added: 


Modified: 

libcxx/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp

Removed: 




diff  --git 
a/libcxx/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp
 
b/libcxx/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp
index 4c39f4c532b8..779905659e6c 100644
--- 
a/libcxx/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp
+++ 
b/libcxx/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp
@@ -6,9 +6,9 @@
 //
 
//===--===//
 
-// NOTE: nullptr_t emulation cannot handle a reinterpret_cast to an
-// integral type
-// XFAIL: c++03
+// NOTE: nullptr_t emulation (used in libc++ ABI v.1) cannot handle a
+// reinterpret_cast to an integral type
+// UNSUPPORTED: c++03
 
 // typedef decltype(nullptr) nullptr_t;
 



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


[llvm-branch-commits] [mlir] 10164a2 - [mlir] Refactor translation of OpenMP dialect ops to LLVM IR

2021-01-07 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2021-01-07T13:33:50+01:00
New Revision: 10164a2e50b4d7064bd02e7403aae6dd319cdd64

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

LOG: [mlir] Refactor translation of OpenMP dialect ops to LLVM IR

The original implementation of the OpenMP dialect to LLVM IR translation has
been relying on a stack of insertion points for delayed insertion of branch
instructions that correspond to terminator ops. This is an intrusive into
ModuleTranslation and makes the translation non-local. A recent addition of the
WsLoop translation exercised another approach where the parent op is
responsible for converting terminators of all blocks in its regions. Use this
approach for other OpenMP dialect operations with regions, remove the stack and
deduplicate the code for converting such regions.

Reviewed By: kiranchandramohan

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

Added: 


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

Removed: 




diff  --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h 
b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index 7691adfeef14..4a1871cac4dc 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -93,11 +93,11 @@ class ModuleTranslation {
llvm::IRBuilder<> &builder);
   virtual LogicalResult convertOmpMaster(Operation &op,
  llvm::IRBuilder<> &builder);
-  void convertOmpOpRegions(Region ®ion,
+  void convertOmpOpRegions(Region ®ion, StringRef blockName,
DenseMap &valueMapping,
DenseMap &blockMapping,
-   llvm::Instruction *codeGenIPBBTI,
-   llvm::BasicBlock &continuationIP,
+   llvm::BasicBlock &sourceBlock,
+   llvm::BasicBlock &continuationBlock,
llvm::IRBuilder<> &builder,
LogicalResult &bodyGenStatus);
   virtual LogicalResult convertOmpWsLoop(Operation &opInst,
@@ -121,7 +121,8 @@ class ModuleTranslation {
   LogicalResult convertFunctions();
   LogicalResult convertGlobals();
   LogicalResult convertOneFunction(LLVMFuncOp func);
-  LogicalResult convertBlock(Block &bb, bool ignoreArguments);
+  LogicalResult convertBlock(Block &bb, bool ignoreArguments,
+ llvm::IRBuilder<> &builder);
 
   llvm::Constant *getLLVMConstant(llvm::Type *llvmType, Attribute attr,
   Location loc);
@@ -134,14 +135,11 @@ class ModuleTranslation {
 
   /// Builder for LLVM IR generation of OpenMP constructs.
   std::unique_ptr ompBuilder;
+
   /// Precomputed pointer to OpenMP dialect. Note this can be nullptr if the
   /// OpenMP dialect hasn't been loaded (it is always loaded if there are 
OpenMP
   /// operations in the module though).
   const Dialect *ompDialect;
-  /// Stack which stores the target block to which a branch a must be added 
when
-  /// a terminator is seen. A stack is required to handle nested OpenMP 
parallel
-  /// regions.
-  SmallVector ompContinuationIPStack;
 
   /// Mappings between llvm.mlir.global definitions and corresponding globals.
   DenseMap globalsMapping;

diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp 
b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index da9c734fbd80..5ffb11e76a93 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -413,24 +413,11 @@ ModuleTranslation::convertOmpParallel(Operation &opInst,
 
   auto bodyGenCB = [&](InsertPointTy allocaIP, InsertPointTy codeGenIP,
llvm::BasicBlock &continuationIP) {
-llvm::LLVMContext &llvmContext = llvmModule->getContext();
-
-llvm::BasicBlock *codeGenIPBB = codeGenIP.getBlock();
-llvm::Instruction *codeGenIPBBTI = codeGenIPBB->getTerminator();
-ompContinuationIPStack.push_back(&continuationIP);
-
-// ParallelOp has only `1` region associated with it.
+// ParallelOp has only one region associated with it.
 auto ®ion = cast(opInst).getRegion();
-for (auto &bb : region) {
-  auto *llvmBB = llvm::BasicBlock::Create(
-  llvmContext, "omp.par.region", codeGenIP.getBlock()->getParent());
-  blockMapping[&bb] = llvmBB;
-}
-
-convertOmpOpRegions(region, valueMapping, blockMapping, codeGenIPBBTI,
-continuationIP, builder, bodyGenStatus);
-ompContinuationIPStack.pop_back();
-
+convertOmpOpRegions(region, "omp.par.region", valueMapping, blockMapping,
+*codeGenIP.getBlock(

[llvm-branch-commits] [clang-tools-extra] 213329d - [clangd] Add server capability advertising hot-reloading of CDBs.

2021-01-07 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2021-01-07T13:39:21+01:00
New Revision: 213329d7c64f9710f23a78596255509b147b37c6

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

LOG: [clangd] Add server capability advertising hot-reloading of CDBs.

Currently some clients watch for CDB changes and restart clangd, now that we
can reload compile_commands.json ourselves this is counterproductive.
The capability allows this behavior to be phased out.

This is going to be a mild regression, as we do not actually watch for files on
disk and so new diagnostics need to wait until a rebuild is requested e.g. due
to file change (and the internal caches have expired).
However this is still a better tradeoff (and if it's important, we can request
the client to watch files for us in the future).

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/test/initialize-params.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index c606ccae4fdc..4e5d9f8bf0fa 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -620,7 +620,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
 {"documentSymbolProvider", true},
 {"workspaceSymbolProvider", true},
 {"referencesProvider", true},
-{"astProvider", true},
+{"astProvider", true}, // clangd extension
 {"executeCommandProvider",
  llvm::json::Object{
  {"commands",
@@ -628,7 +628,9 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
ExecuteCommandParams::CLANGD_APPLY_TWEAK}},
  }},
 {"typeHierarchyProvider", true},
-{"memoryUsageProvider", true}, // clangd extension.
+{"memoryUsageProvider", true}, // clangd extension
+{"compilationDatabase",// clangd extension
+ llvm::json::Object{{"automaticReload", true}}},
 {"callHierarchyProvider", true},
 ;
   if (Opts.Encoding)

diff  --git a/clang-tools-extra/clangd/test/initialize-params.test 
b/clang-tools-extra/clangd/test/initialize-params.test
index e4f4bf18dee4..907ab0ade420 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -8,6 +8,9 @@
 # CHECK-NEXT:  "astProvider": true,
 # CHECK-NEXT:  "callHierarchyProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
+# CHECK-NEXT:  "compilationDatabase": {
+# CHECK-NEXT:"automaticReload": true
+# CHECK-NEXT:  },
 # CHECK-NEXT:  "completionProvider": {
 # CHECK-NEXT:"allCommitCharacters": [
 # CHECK-NEXT:  " ",



___
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] 4284afd - [SLP]Need shrink the load vector after reordering.

2021-01-07 Thread Alexey Bataev via llvm-branch-commits

Author: Alexey Bataev
Date: 2021-01-07T04:50:48-08:00
New Revision: 4284afdf9432f7d756f56b0ab21d69191adefa8d

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

LOG: [SLP]Need shrink the load vector after reordering.

After merging the shuffles, we cannot rely on the previous shuffle
anymore and need to shrink the final shuffle, if it is required.

Reported in D92668

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index abd0470270d5..8d6453f277ea 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4260,18 +4260,13 @@ Value *BoUpSLP::vectorizeTree(ArrayRef VL) {
   if (E->isSame(VL)) {
 Value *V = vectorizeTree(E);
 if (VL.size() == E->Scalars.size() && !E->ReuseShuffleIndices.empty()) 
{
-  // We need to get the vectorized value but without shuffle.
-  if (auto *SV = dyn_cast(V)) {
-V = SV->getOperand(0);
-  } else {
-// Reshuffle to get only unique values.
-SmallVector UniqueIdxs;
-SmallSet UsedIdxs;
-for (int Idx : E->ReuseShuffleIndices)
-  if (UsedIdxs.insert(Idx).second)
-UniqueIdxs.emplace_back(Idx);
-V = Builder.CreateShuffleVector(V, UniqueIdxs);
-  }
+  // Reshuffle to get only unique values.
+  SmallVector UniqueIdxs;
+  SmallSet UsedIdxs;
+  for (int Idx : E->ReuseShuffleIndices)
+if (UsedIdxs.insert(Idx).second)
+  UniqueIdxs.emplace_back(Idx);
+  V = Builder.CreateShuffleVector(V, UniqueIdxs, "shrink.shuffle");
 }
 return V;
   }

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll
index 110e114b..533b48eec295 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll
@@ -10,7 +10,8 @@ define void @wombat(i32* %ptr, i32* %ptr1) {
 ; CHECK-NEXT:[[TMP1:%.*]] = load <2 x i32>, <2 x i32>* [[TMP0]], align 8
 ; CHECK-NEXT:[[SHUFFLE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> 
poison, <4 x i32> 
 ; CHECK-NEXT:[[TMP27:%.*]] = getelementptr inbounds i32, i32* 
[[PTR1:%.*]], i32 3
-; CHECK-NEXT:[[TMP2:%.*]] = add nsw <2 x i32> [[TMP1]], 
+; CHECK-NEXT:[[SHRINK_SHUFFLE:%.*]] = shufflevector <4 x i32> [[SHUFFLE]], 
<4 x i32> poison, <2 x i32> 
+; CHECK-NEXT:[[TMP2:%.*]] = add nsw <2 x i32> [[SHRINK_SHUFFLE]], 
 ; CHECK-NEXT:[[SHUFFLE1:%.*]] = shufflevector <2 x i32> [[TMP2]], <2 x 
i32> poison, <4 x i32> 
 ; CHECK-NEXT:[[TMP34:%.*]] = getelementptr inbounds i32, i32* [[PTR1]], 
i32 4
 ; CHECK-NEXT:[[TMP40:%.*]] = getelementptr inbounds i32, i32* [[PTR1]], 
i32 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] [clang] 236129f - [CompilationDatabase] Pass Twine by const reference instead of by value. NFCI.

2021-01-07 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-07T12:53:28Z
New Revision: 236129fb4460a4030eee685abc2f02b32458e775

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

LOG: [CompilationDatabase] Pass Twine by const reference instead of by value. 
NFCI.

Added: 


Modified: 
clang/include/clang/Tooling/CompilationDatabase.h
clang/lib/Tooling/CompilationDatabase.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/CompilationDatabase.h 
b/clang/include/clang/Tooling/CompilationDatabase.h
index cbd57e9609aa..44af236347b3 100644
--- a/clang/include/clang/Tooling/CompilationDatabase.h
+++ b/clang/include/clang/Tooling/CompilationDatabase.h
@@ -43,10 +43,10 @@ namespace tooling {
 /// Specifies the working directory and command of a compilation.
 struct CompileCommand {
   CompileCommand() = default;
-  CompileCommand(Twine Directory, Twine Filename,
- std::vector CommandLine, Twine Output)
+  CompileCommand(const Twine &Directory, const Twine &Filename,
+ std::vector CommandLine, const Twine &Output)
   : Directory(Directory.str()), Filename(Filename.str()),
-CommandLine(std::move(CommandLine)), Output(Output.str()){}
+CommandLine(std::move(CommandLine)), Output(Output.str()) {}
 
   /// The working directory the command was executed from.
   std::string Directory;
@@ -180,9 +180,9 @@ class FixedCompilationDatabase : public CompilationDatabase 
{
   /// \param Argv Points to the command line arguments.
   /// \param ErrorMsg Contains error text if the function returns null pointer.
   /// \param Directory The base directory used in the FixedCompilationDatabase.
-  static std::unique_ptr loadFromCommandLine(
-  int &Argc, const char *const *Argv, std::string &ErrorMsg,
-  Twine Directory = ".");
+  static std::unique_ptr
+  loadFromCommandLine(int &Argc, const char *const *Argv, std::string 
&ErrorMsg,
+  const Twine &Directory = ".");
 
   /// Reads flags from the given file, one-per-line.
   /// Returns nullptr and sets ErrorMessage if we can't read the file.
@@ -196,7 +196,8 @@ class FixedCompilationDatabase : public CompilationDatabase 
{
 
   /// Constructs a compilation data base from a specified directory
   /// and command line.
-  FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine);
+  FixedCompilationDatabase(const Twine &Directory,
+   ArrayRef CommandLine);
 
   /// Returns the given compile command.
   ///

diff  --git a/clang/lib/Tooling/CompilationDatabase.cpp 
b/clang/lib/Tooling/CompilationDatabase.cpp
index d339fd044c02..1e19e68633d2 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -323,7 +323,7 @@ std::unique_ptr
 FixedCompilationDatabase::loadFromCommandLine(int &Argc,
   const char *const *Argv,
   std::string &ErrorMsg,
-  Twine Directory) {
+  const Twine &Directory) {
   ErrorMsg.clear();
   if (Argc == 0)
 return nullptr;
@@ -368,8 +368,8 @@ FixedCompilationDatabase::loadFromBuffer(StringRef 
Directory, StringRef Data,
   return std::make_unique(Directory, 
std::move(Args));
 }
 
-FixedCompilationDatabase::
-FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine) {
+FixedCompilationDatabase::FixedCompilationDatabase(
+const Twine &Directory, ArrayRef CommandLine) {
   std::vector ToolCommandLine(1, GetClangToolCommand());
   ToolCommandLine.insert(ToolCommandLine.end(),
  CommandLine.begin(), CommandLine.end());



___
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] 0280911 - [DWARF] DWARFDebugLoc::dumpRawEntry - remove dead stores. NFCI.

2021-01-07 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-07T12:53:28Z
New Revision: 028091195d763190d9b57ae316c8601fe223c02c

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

LOG: [DWARF] DWARFDebugLoc::dumpRawEntry - remove dead stores. NFCI.

Don't bother zeroing local (unused) variables just before returning.

Fixes clang static analyzer warning.

Added: 


Modified: 
llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp

Removed: 




diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp 
b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
index 44b410778146..cdffb36741c8 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
@@ -260,7 +260,6 @@ void DWARFDebugLoc::dumpRawEntry(const DWARFLocationEntry 
&Entry,
 Value1 = Entry.Value1;
 break;
   case dwarf::DW_LLE_end_of_list:
-Value0 = Value1 = 0;
 return;
   default:
 llvm_unreachable("Not possible in DWARF4!");



___
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] a9a8caf - [llvm-objdump] Pass Twine by const reference instead of by value. NFCI.

2021-01-07 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-07T12:53:29Z
New Revision: a9a8caf2ce2ff08a20cc145d23270e6c91709baa

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

LOG: [llvm-objdump] Pass Twine by const reference instead of by value. NFCI.

Added: 


Modified: 
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-objdump/llvm-objdump.h

Removed: 




diff  --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp 
b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 5ac25d7e57be..3134f989603a 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -29,6 +29,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/CodeGen/FaultMaps.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
@@ -448,7 +449,7 @@ std::string objdump::getFileNameForError(const 
object::Archive::Child &C,
   return "";
 }
 
-void objdump::reportWarning(Twine Message, StringRef File) {
+void objdump::reportWarning(const Twine &Message, StringRef File) {
   // Output order between errs() and outs() matters especially for archive
   // files where the output is per member object.
   outs().flush();
@@ -457,7 +458,7 @@ void objdump::reportWarning(Twine Message, StringRef File) {
 }
 
 LLVM_ATTRIBUTE_NORETURN void objdump::reportError(StringRef File,
-  Twine Message) {
+  const Twine &Message) {
   outs().flush();
   WithColor::error(errs(), ToolName) << "'" << File << "': " << Message << 
"\n";
   exit(1);
@@ -480,11 +481,11 @@ LLVM_ATTRIBUTE_NORETURN void objdump::reportError(Error 
E, StringRef FileName,
   exit(1);
 }
 
-static void reportCmdLineWarning(Twine Message) {
+static void reportCmdLineWarning(const Twine &Message) {
   WithColor::warning(errs(), ToolName) << Message << "\n";
 }
 
-LLVM_ATTRIBUTE_NORETURN static void reportCmdLineError(Twine Message) {
+LLVM_ATTRIBUTE_NORETURN static void reportCmdLineError(const Twine &Message) {
   WithColor::error(errs(), ToolName) << Message << "\n";
   exit(1);
 }

diff  --git a/llvm/tools/llvm-objdump/llvm-objdump.h 
b/llvm/tools/llvm-objdump/llvm-objdump.h
index 4cee35484105..99bf191a301e 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.h
+++ b/llvm/tools/llvm-objdump/llvm-objdump.h
@@ -18,6 +18,7 @@
 
 namespace llvm {
 class StringRef;
+class Twine;
 
 namespace object {
 class ELFObjectFileBase;
@@ -127,11 +128,11 @@ void printSymbolTable(const object::ObjectFile *O, 
StringRef ArchiveName,
 void printSymbol(const object::ObjectFile *O, const object::SymbolRef &Symbol,
  StringRef FileName, StringRef ArchiveName,
  StringRef ArchitectureName, bool DumpDynamic);
-LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Twine Message);
+LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, const Twine &Message);
 LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef FileName,
  StringRef ArchiveName = "",
  StringRef ArchitectureName = "");
-void reportWarning(Twine Message, StringRef File);
+void reportWarning(const Twine &Message, StringRef File);
 
 template 
 T unwrapOrError(Expected EO, Ts &&... Args) {



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


[llvm-branch-commits] [mlir] c1d58c2 - [mlir] Add fastmath flags support to some LLVM dialect ops

2021-01-07 Thread Alex Zinenko via llvm-branch-commits

Author: Ivan Butygin
Date: 2021-01-07T14:00:09+01:00
New Revision: c1d58c2b0023cd41f0da128f5190fa887d8f6c69

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

LOG: [mlir] Add fastmath flags support to some LLVM dialect ops

Add fastmath enum, attributes to some llvm dialect ops, 
`FastmathFlagsInterface` op interface, and `translateModuleToLLVMIR` support.

Reviewed By: ftynse

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

Added: 
mlir/include/mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td

Modified: 
mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Dialect/LLVMIR/CMakeLists.txt
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Dialect/LLVMIR/roundtrip.mlir
mlir/test/Target/llvmir.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt 
b/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
index 6166f3632607..29cef3f0032d 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
@@ -10,6 +10,8 @@ add_public_tablegen_target(MLIRLLVMOpsIncGen)
 
 add_mlir_doc(LLVMOps -gen-op-doc LLVMOps Dialects/)
 
+add_mlir_interface(LLVMOpsInterfaces)
+
 set(LLVM_TARGET_DEFINITIONS LLVMOps.td)
 mlir_tablegen(LLVMConversions.inc -gen-llvmir-conversions)
 mlir_tablegen(LLVMConversionEnumsToLLVM.inc -gen-enum-to-llvmir-conversions)

diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
index 630bad4914b1..22ff1517f77b 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
@@ -29,6 +29,7 @@
 #include "llvm/IR/Type.h"
 
 #include "mlir/Dialect/LLVMIR/LLVMOpsEnums.h.inc"
+#include "mlir/Dialect/LLVMIR/LLVMOpsInterfaces.h.inc"
 
 namespace llvm {
 class Type;
@@ -46,8 +47,23 @@ class LLVMDialect;
 namespace detail {
 struct LLVMTypeStorage;
 struct LLVMDialectImpl;
+struct BitmaskEnumStorage;
 } // namespace detail
 
+/// An attribute that specifies LLVM instruction fastmath flags.
+class FMFAttr : public Attribute::AttrBase {
+public:
+  using Base::Base;
+
+  static FMFAttr get(FastmathFlags flags, MLIRContext *context);
+
+  FastmathFlags getFlags() const;
+
+  void print(DialectAsmPrinter &p) const;
+  static Attribute parse(DialectAsmParser &parser);
+};
+
 } // namespace LLVM
 } // namespace mlir
 

diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 428ca6783afd..53c42540aa48 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -14,10 +14,39 @@
 #define LLVMIR_OPS
 
 include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
+include "mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td"
 include "mlir/IR/SymbolInterfaces.td"
 include "mlir/Interfaces/ControlFlowInterfaces.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
+def FMFnnan : BitEnumAttrCase<"nnan", 0x1>;
+def FMFninf : BitEnumAttrCase<"ninf", 0x2>;
+def FMFnsz  : BitEnumAttrCase<"nsz", 0x4>;
+def FMFarcp : BitEnumAttrCase<"arcp", 0x8>;
+def FMFcontract : BitEnumAttrCase<"contract", 0x10>;
+def FMFafn  : BitEnumAttrCase<"afn", 0x20>;
+def FMFreassoc  : BitEnumAttrCase<"reassoc", 0x40>;
+def FMFfast : BitEnumAttrCase<"fast", 0x80>;
+
+def FastmathFlags : BitEnumAttr<
+"FastmathFlags",
+"LLVM fastmath flags",
+[FMFnnan, FMFninf, FMFnsz, FMFarcp, FMFcontract, FMFafn, FMFreassoc, 
FMFfast
+]> {
+  let cppNamespace = "::mlir::LLVM";
+}
+
+def LLVM_FMFAttr : DialectAttr<
+LLVM_Dialect,
+CPred<"$_self.isa<::mlir::LLVM::FMFAttr>()">,
+"LLVM fastmath flags"> {
+  let storageType = "::mlir::LLVM::FMFAttr";
+  let returnType = "::mlir::LLVM::FastmathFlags";
+  let convertFromStorage = "$_self.getFlags()";
+  let constBuilderCall =
+  "::mlir::LLVM::FMFAttr::get($0, $_builder.getContext())";
+}
+
 class LLVM_Builder {
   string llvmBuilder = builder;
 }
@@ -77,29 +106,35 @@ class LLVM_ArithmeticOpBase,
 LLVM_Builder<"$res = builder." # builderFunc # "($lhs, $rhs);"> {
-  let arguments = (ins LLVM_ScalarOrVectorOf:$lhs,
-   LLVM_ScalarOrVectorOf:$rhs);
+  dag commonArgs = (ins LLVM_ScalarOrVectorOf:$lhs,
+LLVM_ScalarOrVectorOf:$rhs);
   let results = (outs LLVM_ScalarOrVectorOf:$res);
   let builders = [LLVM_OneResultOpBuilder];
-  let assemblyFormat = "$lhs `,` $rhs attr-dict `:` type($res)";
+  let assemblyFormat = "$lhs `,` $rhs custom(attr-dict) `:` 
type($res)";
 }
 class LLV

[llvm-branch-commits] [clang] e72cdc5 - [clang][cli] NFC: Ensure non-null DiagnosticsEngine in ParseDiagnosticArgs

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T14:15:08+01:00
New Revision: e72cdc5ba1e65ecd8632663b6604eb9be8d1a162

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

LOG: [clang][cli] NFC: Ensure non-null DiagnosticsEngine in ParseDiagnosticArgs

Before this patch, ParseDiagnosticArgs can be called with a nullptr 
DiagnosticsEngine *. This happens early on in the compilation process, where no 
proper DiagnosticEngine exists, because the diagnostic options (passed through 
command line) are not known yet.

This patch ensures nullptr is replaced by an ignoring DiagnosticEngine in 
ParseDiagnosticArgs, which allows to switch from pointer to a reference in some 
utility functions.

Besides simplifying the code, this patch enables a future patch (D84673) that 
ports diagnostic options to the new marshalling infrastructure.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 7fb7ec896e64..7f3e39ede281 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -830,7 +830,7 @@ GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, 
ArgList &Args,
 
 static bool parseDiagnosticLevelMask(StringRef FlagName,
  const std::vector &Levels,
- DiagnosticsEngine *Diags,
+ DiagnosticsEngine &Diags,
  DiagnosticLevelMask &M) {
   bool Success = true;
   for (const auto &Level : Levels) {
@@ -843,8 +843,7 @@ static bool parseDiagnosticLevelMask(StringRef FlagName,
 .Default(DiagnosticLevelMask::None);
 if (PM == DiagnosticLevelMask::None) {
   Success = false;
-  if (Diags)
-Diags->Report(diag::err_drv_invalid_value) << FlagName << Level;
+  Diags.Report(diag::err_drv_invalid_value) << FlagName << Level;
 }
 M = M | PM;
   }
@@ -1383,7 +1382,7 @@ static bool parseShowColorsArgs(const ArgList &Args, bool 
DefaultColor) {
 }
 
 static bool checkVerifyPrefixes(const std::vector &VerifyPrefixes,
-DiagnosticsEngine *Diags) {
+DiagnosticsEngine &Diags) {
   bool Success = true;
   for (const auto &Prefix : VerifyPrefixes) {
 // Every prefix must start with a letter and contain only alphanumeric
@@ -1393,10 +1392,8 @@ static bool checkVerifyPrefixes(const 
std::vector &VerifyPrefixes,
 });
 if (BadChar != Prefix.end() || !isLetter(Prefix[0])) {
   Success = false;
-  if (Diags) {
-Diags->Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
-Diags->Report(diag::note_drv_verify_prefix_spelling);
-  }
+  Diags.Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
+  Diags.Report(diag::note_drv_verify_prefix_spelling);
 }
   }
   return Success;
@@ -1405,6 +1402,13 @@ static bool checkVerifyPrefixes(const 
std::vector &VerifyPrefixes,
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {
+  Optional IgnoringDiags;
+  if (!Diags) {
+IgnoringDiags.emplace(new DiagnosticIDs(), new DiagnosticOptions(),
+  new IgnoringDiagConsumer());
+Diags = &*IgnoringDiags;
+  }
+
   bool Success = true;
 
   Opts.DiagnosticLogFile =
@@ -1439,10 +1443,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, 
ArgList &Args,
 Opts.setShowOverloads(Ovl_All);
   else {
 Success = false;
-if (Diags)
-  Diags->Report(diag::err_drv_invalid_value)
-  << Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
-  << ShowOverloads;
+Diags->Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
+<< ShowOverloads;
   }
 
   StringRef ShowCategory =
@@ -1455,10 +1458,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, 
ArgList &Args,
 Opts.ShowCategories = 2;
   else {
 Success = false;
-if (Diags)
-  Diags->Report(diag::err_drv_invalid_value)
-  << Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
-  << ShowCategory;
+Diags->Report(diag::err_drv_invalid_value)
+<< Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
+<< ShowCategory;
   }
 
   StringRef Format =
@@ -1474,10 +1476,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, 
ArgList &Args,
 Opts.setFormat(DiagnosticOptions::Vi);
   else {
 Success = false;
-

[llvm-branch-commits] [clang] 75d6363 - [clang][cli] NFC: Move parseSimpleArgs

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T14:15:08+01:00
New Revision: 75d63630ebb197c338801d6b100ae2e06800c4ce

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

LOG: [clang][cli] NFC: Move parseSimpleArgs

This patch moves `parseSimpleArgs` closer to `ParseDiagnosticArgs` so that 
sharing the parsing macro between them can be done more locally in a future 
patch.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 7f3e39ede281..8b641aabd1af 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1399,6 +1399,32 @@ static bool checkVerifyPrefixes(const 
std::vector &VerifyPrefixes,
   return Success;
 }
 
+bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  bool Success = true;
+
+#define OPTION_WITH_MARSHALLING(   
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  if ((FLAGS)&options::CC1Option) {
\
+this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
+if (IMPLIED_CHECK) 
\
+  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
+if (SHOULD_PARSE)  
\
+  if (auto MaybeValue =
\
+  NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success)) 
\
+this->KEYPATH = MERGER(
\
+this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
+  }
+
+#include "clang/Driver/Options.inc"
+#undef OPTION_WITH_MARSHALLING
+
+  return Success;
+}
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {
@@ -2971,32 +2997,6 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList 
&Args,
   }
 }
 
-bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  bool Success = true;
-
-#define OPTION_WITH_MARSHALLING(   
\
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
-MERGER, EXTRACTOR, TABLE_INDEX)
\
-  if ((FLAGS)&options::CC1Option) {
\
-this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
-if (IMPLIED_CHECK) 
\
-  this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
-if (SHOULD_PARSE)  
\
-  if (auto MaybeValue = \
-NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success))\
-this->KEYPATH = MERGER(
\
-this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
-  }
-
-#include "clang/Driver/Options.inc"
-#undef OPTION_WITH_MARSHALLING
-
-  return Success;
-}
-
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 ArrayRef CommandLineArgs,
 DiagnosticsEngine &Diags,



___
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] a7cbc32 - [mlir] remove a use of deprecated OpState::setAttr

2021-01-07 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2021-01-07T14:20:36+01:00
New Revision: a7cbc32a916a64e9f61106956ed3866a6086ae6b

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

LOG: [mlir] remove a use of deprecated OpState::setAttr

Added: 


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

Removed: 




diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp 
b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 5e270881656c..51f34661bece 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1894,7 +1894,7 @@ struct ConstantOpLowering : public 
ConvertOpToLLVMPattern {
   for (const NamedAttribute &attr : op->getAttrs()) {
 if (attr.first.strref() == "value")
   continue;
-newOp.setAttr(attr.first, attr.second);
+newOp->setAttr(attr.first, attr.second);
   }
   rewriter.replaceOp(op, newOp->getResults());
   return success();



___
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] fcd1e35 - [clang][cli] NFC: Make parsing macro reusable

2021-01-07 Thread Jan Svoboda via llvm-branch-commits

Author: Jan Svoboda
Date: 2021-01-07T14:25:48+01:00
New Revision: fcd1e35e4cc6887c3fb880126e60676458e60680

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

LOG: [clang][cli] NFC: Make parsing macro reusable

This is necessary for a future patch, where we start using this macro in 
another function.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 8b641aabd1af..348f5582bde2 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1399,32 +1399,42 @@ static bool checkVerifyPrefixes(const 
std::vector &VerifyPrefixes,
   return Success;
 }
 
-bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  bool Success = true;
-
-#define OPTION_WITH_MARSHALLING(   
\
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
-MERGER, EXTRACTOR, TABLE_INDEX)
\
+#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\
+  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,
\
+  IMPLIED_CHECK, IMPLIED_VALUE,
\
+  NORMALIZER, MERGER, TABLE_INDEX) 
\
   if ((FLAGS)&options::CC1Option) {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
   this->KEYPATH = MERGER(this->KEYPATH, IMPLIED_VALUE);
\
 if (SHOULD_PARSE)  
\
   if (auto MaybeValue =
\
-  NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags, Success)) 
\
+  NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) 
\
 this->KEYPATH = MERGER(
\
 this->KEYPATH, static_castKEYPATH)>(*MaybeValue)); 
\
   }
 
+bool CompilerInvocation::parseSimpleArgs(const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  bool Success = true;
+
+#define OPTION_WITH_MARSHALLING(   
\
+PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
+HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, 
\
+MERGER, EXTRACTOR, TABLE_INDEX)
\
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM,
\
+SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,  
\
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  
\
+MERGER, TABLE_INDEX)
 #include "clang/Driver/Options.inc"
 #undef OPTION_WITH_MARSHALLING
 
   return Success;
 }
 
+#undef PARSE_OPTION_WITH_MARSHALLING
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {



___
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] 01c190e - [AArch64][CostModel]Fix gather scatter cost model

2021-01-07 Thread Caroline Concatto via llvm-branch-commits

Author: Caroline Concatto
Date: 2021-01-07T14:02:08Z
New Revision: 01c190e907ca4752f7ba2a1390a8c91a48b322d1

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

LOG: [AArch64][CostModel]Fix gather scatter cost model

This patch fixes a bug introduced in the patch:
https://reviews.llvm.org/D93030

This patch pulls the test for scalable vector to be the first instruction
to be checked. This avoids the Gather and Scatter cost model for AArch64 to
compute the number of vector elements for something that is not a vector and
therefore crashing.

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-gather.ll
llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-scatter.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index aaf7371c7933..68d382fb784b 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -773,13 +773,13 @@ AArch64TTIImpl::enableMemCmpExpansion(bool OptSize, bool 
IsZeroCmp) const {
 unsigned AArch64TTIImpl::getGatherScatterOpCost(
 unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask,
 Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I) {
+
+  if (!isa(DataTy))
+return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
+ Alignment, CostKind, I);
   auto *VT = cast(DataTy);
   auto LT = TLI->getTypeLegalizationCost(DL, DataTy);
   ElementCount LegalVF = LT.second.getVectorElementCount();
-  if (!LegalVF.isScalable())
-return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
- Alignment, CostKind, I);
-
   Optional MaxNumVScale = getMaxVScale();
   assert(MaxNumVScale && "Expected valid max vscale value");
 

diff  --git 
a/llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-gather.ll 
b/llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-gather.ll
index 38b41b731dd0..83e6ab9932b0 100644
--- a/llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-gather.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-gather.ll
@@ -32,6 +32,18 @@ define <4 x i32> @masked_gather_v4i32(<4 x i32*> %ld, <4 x 
i1> %masks, <4 x i32>
   ret <4 x i32> %res
 }
 
+; Check it properly falls back to BasicTTIImpl when legalized MVT is not a 
vector
+define <1 x i128> @masked_gather_v1i128(<1 x i128*> %ld, <1 x i1> %masks, <1 x 
i128> %passthru) {
+; CHECK-LABEL: 'masked_gather_v1i128'
+; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction:   %res 
= call <1 x i128> @llvm.masked.gather.v1i128.v1p0i128(<1 x i128*> %ld, i32 0, 
<1 x i1> %masks, <1 x i128> %passthru)
+; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret 
<1 x i128> %res
+
+  %res = call <1 x i128> @llvm.masked.gather.v1i128.v1p0i128(<1 x i128*> %ld, 
i32 0, <1 x i1> %masks, <1 x i128> %passthru)
+  ret <1 x i128> %res
+}
+
 declare  @llvm.masked.gather.nxv4i32( 
%ptrs, i32 %align,  %masks,  %passthru)
 declare  @llvm.masked.gather.nxv8i32( 
%ptrs, i32 %align,  %masks,  %passthru)
 declare <4 x i32> @llvm.masked.gather.v4i32(<4 x i32*> %ptrs, i32 %align, <4 x 
i1> %masks, <4 x i32> %passthru)
+declare <1 x i128> @llvm.masked.gather.v1i128.v1p0i128(<1 x i128*>, i32, <1 x 
i1>, <1 x i128>)
+

diff  --git 
a/llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-scatter.ll 
b/llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-scatter.ll
index 4370922e4bf7..fa0002483a1f 100644
--- a/llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-scatter.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/sve-getIntrinsicInstrCost-scatter.ll
@@ -35,6 +35,17 @@ define void @masked_scatter_v4i32(<4 x i32> %data, <4 x 
i32*> %ptrs, <4 x i1> %m
   ret void
 }
 
+; Check it properly falls back to BasicTTIImpl when legalized MVT is not a 
vector
+define void @masked_scatter_v1i128(<1 x i128> %data, <1 x i128*> %ptrs, <1 x 
i1> %masks) {
+; CHECK-LABEL: 'masked_scatter_v1i128'
+; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction:   call 
void @llvm.masked.scatter.v1i128.v1p0i128(<1 x i128> %data, <1 x i128*> %ptrs, 
i32 0, <1 x i1> %masks)
+; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction:   ret 
void
+
+  call void @llvm.masked.scatter.v1i128.v1p0i128(<1 x i128> %data, <1 x i128*> 
%ptrs, i32 0, <1 x i1> %masks)
+  ret void
+}
+
 declare void @llvm.masked.scatter.nxv4i32( %data,  %ptrs, i32 %align,  %masks)
 declare void @llvm.masked.scatter.nxv8i32( %data,  %ptrs, i32 %align,  %ma

[llvm-branch-commits] [flang] a2957f8 - [flang][driver] Rename driver tests (nfc)

2021-01-07 Thread Andrzej Warzynski via llvm-branch-commits

Author: Andrzej Warzynski
Date: 2021-01-07T14:05:48Z
New Revision: a2957f80f87f36ac8cfca06dec1c2defbe709876

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

LOG: [flang][driver] Rename driver tests (nfc)

As per [1]:
```
File names should use dashes, not underscores.
```

This patch updates the names of Flang driver tests accordingly.

[1] https://github.com/llvm/llvm-project/blob/main/flang/docs/C%2B%2Bstyle.md

Added: 
flang/test/Driver/no-files.f90
flang/test/Driver/version-test.f90
flang/test/Flang-Driver/macro-def-undef.f90
flang/test/Flang-Driver/macro-multiline.f90

Modified: 


Removed: 
flang/test/Driver/no_files.f90
flang/test/Driver/version_test.f90
flang/test/Flang-Driver/macro_def_undef.f90
flang/test/Flang-Driver/macro_multiline.f90



diff  --git a/flang/test/Driver/no_files.f90 b/flang/test/Driver/no-files.f90
similarity index 100%
rename from flang/test/Driver/no_files.f90
rename to flang/test/Driver/no-files.f90

diff  --git a/flang/test/Driver/version_test.f90 
b/flang/test/Driver/version-test.f90
similarity index 100%
rename from flang/test/Driver/version_test.f90
rename to flang/test/Driver/version-test.f90

diff  --git a/flang/test/Flang-Driver/macro_def_undef.f90 
b/flang/test/Flang-Driver/macro-def-undef.f90
similarity index 100%
rename from flang/test/Flang-Driver/macro_def_undef.f90
rename to flang/test/Flang-Driver/macro-def-undef.f90

diff  --git a/flang/test/Flang-Driver/macro_multiline.f90 
b/flang/test/Flang-Driver/macro-multiline.f90
similarity index 100%
rename from flang/test/Flang-Driver/macro_multiline.f90
rename to flang/test/Flang-Driver/macro-multiline.f90



___
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] fa6d897 - [Analysis] MemoryDepChecker::couldPreventStoreLoadForward - remove dead store. NFCI.

2021-01-07 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-07T14:21:54Z
New Revision: fa6d8977999096b2a3ae1357aa38ddf73abaf414

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

LOG: [Analysis] MemoryDepChecker::couldPreventStoreLoadForward - remove dead 
store. NFCI.

As we're breaking from the loop when clamping MaxVF, clang static analyzer was 
warning that the VF iterator was being updated and never used.

Added: 


Modified: 
llvm/lib/Analysis/LoopAccessAnalysis.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp 
b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index be340a3b3130..76e172534176 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1338,7 +1338,7 @@ bool 
MemoryDepChecker::couldPreventStoreLoadForward(uint64_t Distance,
 // If the number of vector iteration between the store and the load are
 // small we could incur conflicts.
 if (Distance % VF && Distance / VF < NumItersForStoreLoadThroughMemory) {
-  MaxVFWithoutSLForwardIssues = (VF >>= 1);
+  MaxVFWithoutSLForwardIssues = (VF >> 1);
   break;
 }
   }



___
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] 037b058 - [AArch64] SVEIntrinsicOpts - use range loop and cast<> instead of dyn_cast<> for dereferenced pointer. NFCI.

2021-01-07 Thread Simon Pilgrim via llvm-branch-commits

Author: Simon Pilgrim
Date: 2021-01-07T14:21:55Z
New Revision: 037b058e41979fa5e6ffd209033dfe72abb97b53

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

LOG: [AArch64] SVEIntrinsicOpts - use range loop and cast<> instead of 
dyn_cast<> for dereferenced pointer. NFCI.

Don't directly dereference a dyn_cast<> - use cast<> so we assert for the 
correct type.

Also, simplify the for loop to a range loop.

Fixes clang static analyzer warning.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp 
b/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
index 67fc4ee0a29d..8e8b12c07bbf 100644
--- a/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
+++ b/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
@@ -248,10 +248,8 @@ bool SVEIntrinsicOpts::runOnModule(Module &M) {
 case Intrinsic::aarch64_sve_ptest_any:
 case Intrinsic::aarch64_sve_ptest_first:
 case Intrinsic::aarch64_sve_ptest_last:
-  for (auto I = F.user_begin(), E = F.user_end(); I != E;) {
-auto *Inst = dyn_cast(*I++);
-Functions.insert(Inst->getFunction());
-  }
+  for (User *U : F.users())
+Functions.insert(cast(U)->getFunction());
   break;
 default:
   break;



___
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] b73736a - [flang][openacc] Enforce delcare directive restriction

2021-01-07 Thread via llvm-branch-commits

Author: Valentin Clement
Date: 2021-01-07T09:28:55-05:00
New Revision: b73736a4048172c48b6b5c23d1321f230d442306

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

LOG: [flang][openacc] Enforce delcare directive restriction

Add semantic check for most of the restrictions for the declare directive.

Reviewed By: kiranktp

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

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

Modified: 
flang/lib/Semantics/check-acc-structure.cpp
flang/lib/Semantics/resolve-directives.cpp
flang/test/Semantics/acc-clause-validity.f90

Removed: 




diff  --git a/flang/lib/Semantics/check-acc-structure.cpp 
b/flang/lib/Semantics/check-acc-structure.cpp
index 45499a69e604..2f3138d11f80 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -134,9 +134,30 @@ void AccStructureChecker::Enter(
 }
 
 void AccStructureChecker::Leave(
-const parser::OpenACCStandaloneDeclarativeConstruct &) {
+const parser::OpenACCStandaloneDeclarativeConstruct &x) {
   // Restriction - line 2409
   CheckAtLeastOneClause();
+
+  // Restriction - line 2417-2418 - In a Fortran module declaration section,
+  // only create, copyin, device_resident, and link clauses are allowed.
+  const auto &declarativeDir{std::get(x.t)};
+  const auto &scope{context_.FindScope(declarativeDir.source)};
+  const Scope &containingScope{GetProgramUnitContaining(scope)};
+  if (containingScope.kind() == Scope::Kind::Module) {
+for (auto cl : GetContext().actualClauses) {
+  if (cl != llvm::acc::Clause::ACCC_create &&
+  cl != llvm::acc::Clause::ACCC_copyin &&
+  cl != llvm::acc::Clause::ACCC_device_resident &&
+  cl != llvm::acc::Clause::ACCC_link)
+context_.Say(GetContext().directiveSource,
+"%s clause is not allowed on the %s directive in module "
+"declaration "
+"section"_err_en_US,
+parser::ToUpperCaseLetters(
+llvm::acc::getOpenACCClauseName(cl).str()),
+ContextDirectiveAsFortran());
+}
+  }
   dirContext_.pop_back();
 }
 

diff  --git a/flang/lib/Semantics/resolve-directives.cpp 
b/flang/lib/Semantics/resolve-directives.cpp
index e10d797d0308..81e0ee61df4a 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -124,6 +124,7 @@ class AccAttributeVisitor : 
DirectiveAttributeVisitor {
 
   bool Pre(const parser::OpenACCRoutineConstruct &);
   bool Pre(const parser::AccBindClause &);
+  void Post(const parser::OpenACCStandaloneDeclarativeConstruct &);
 
   void Post(const parser::AccBeginBlockDirective &) {
 GetContext().withinConstruct = true;
@@ -215,6 +216,7 @@ class AccAttributeVisitor : 
DirectiveAttributeVisitor {
   void CheckMultipleAppearances(
   const parser::Name &, const Symbol &, Symbol::Flag);
   void AllowOnlyArrayAndSubArray(const parser::AccObjectList &objectList);
+  void DoNotAllowAssumedSizedArray(const parser::AccObjectList &objectList);
 };
 
 // Data-sharing and Data-mapping attributes for data-refs in OpenMP construct
@@ -470,6 +472,60 @@ bool AccAttributeVisitor::Pre(const 
parser::OpenACCDeclarativeConstruct &x) {
   return true;
 }
 
+static const parser::AccObjectList &GetAccObjectList(
+const parser::AccClause &clause) {
+  if (const auto *copyClause =
+  std::get_if(&clause.u)) {
+return copyClause->v;
+  } else if (const auto *createClause =
+ std::get_if(&clause.u)) {
+const Fortran::parser::AccObjectListWithModifier &listWithModifier =
+createClause->v;
+const Fortran::parser::AccObjectList &accObjectList =
+std::get(listWithModifier.t);
+return accObjectList;
+  } else if (const auto *copyinClause =
+ std::get_if(&clause.u)) {
+const Fortran::parser::AccObjectListWithModifier &listWithModifier =
+copyinClause->v;
+const Fortran::parser::AccObjectList &accObjectList =
+std::get(listWithModifier.t);
+return accObjectList;
+  } else if (const auto *copyoutClause =
+ std::get_if(&clause.u)) {
+const Fortran::parser::AccObjectListWithModifier &listWithModifier =
+copyoutClause->v;
+const Fortran::parser::AccObjectList &accObjectList =
+std::get(listWithModifier.t);
+return accObjectList;
+  } else if (const auto *presentClause =
+ std::get_if(&clause.u)) {
+return presentClause->v;
+  } else if (const auto *deviceptrClause =
+ std::get_if(
+ &clause.u)) {
+return deviceptrClause->v;
+  } else if (const auto *deviceResidentClause =
+ std::get_if(
+ &clause.u)) {
+retur

[llvm-branch-commits] [llvm] aa7968a - [TableGen] Add field kind to the RecordVal class.

2021-01-07 Thread Paul C. Anagnostopoulos via llvm-branch-commits

Author: Paul C. Anagnostopoulos
Date: 2021-01-07T09:31:27-05:00
New Revision: aa7968a87b65f97c1245348f6c2a75fc9e420bb5

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

LOG: [TableGen] Add field kind to the RecordVal class.

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

Added: 


Modified: 
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/JSONBackend.cpp
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGParser.cpp
llvm/utils/TableGen/CodeEmitterGen.cpp
llvm/utils/TableGen/FixedLenDecoderEmitter.cpp

Removed: 




diff  --git a/llvm/include/llvm/TableGen/Record.h 
b/llvm/include/llvm/TableGen/Record.h
index a0c5b2778547..8dea76fb64a2 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1369,14 +1369,22 @@ class DagInit final : public TypedInit, public 
FoldingSetNode,
 class RecordVal {
   friend class Record;
 
+public:
+  enum FieldKind {
+FK_Normal,// A normal record field.
+FK_NonconcreteOK, // A field that can be nonconcrete ('field' keyword).
+FK_TemplateArg,   // A template argument.
+  };
+
+private:
   Init *Name;
   SMLoc Loc; // Source location of definition of name.
-  PointerIntPair TyAndPrefix;
+  PointerIntPair TyAndKind;
   Init *Value;
 
 public:
-  RecordVal(Init *N, RecTy *T, bool P);
-  RecordVal(Init *N, SMLoc Loc, RecTy *T, bool P);
+  RecordVal(Init *N, RecTy *T, FieldKind K);
+  RecordVal(Init *N, SMLoc Loc, RecTy *T, FieldKind K);
 
   /// Get the name of the field as a StringRef.
   StringRef getName() const;
@@ -1392,10 +1400,18 @@ class RecordVal {
   /// Get the source location of the point where the field was defined.
   const SMLoc &getLoc() const { return Loc; }
 
-  bool getPrefix() const { return TyAndPrefix.getInt(); }
+  /// Is this a field where nonconcrete values are okay?
+  bool isNonconcreteOK() const {
+return TyAndKind.getInt() == FK_NonconcreteOK;
+  }
+
+  /// Is this a template argument?
+  bool isTemplateArg() const {
+return TyAndKind.getInt() == FK_TemplateArg;
+  }
 
   /// Get the type of the field value as a RecTy.
-  RecTy *getType() const { return TyAndPrefix.getPointer(); }
+  RecTy *getType() const { return TyAndKind.getPointer(); }
 
   /// Get the type of the field for printing purposes.
   std::string getPrintType() const;

diff  --git a/llvm/lib/TableGen/JSONBackend.cpp 
b/llvm/lib/TableGen/JSONBackend.cpp
index 131650f987fb..8ddfd9f04524 100644
--- a/llvm/lib/TableGen/JSONBackend.cpp
+++ b/llvm/lib/TableGen/JSONBackend.cpp
@@ -144,7 +144,7 @@ void JSONEmitter::run(raw_ostream &OS) {
 for (const RecordVal &RV : Def.getValues()) {
   if (!Def.isTemplateArg(RV.getNameInit())) {
 auto Name = RV.getNameInitAsString();
-if (RV.getPrefix())
+if (RV.isNonconcreteOK())
   fields.push_back(Name);
 obj[Name] = translateInit(*RV.getValue());
   }

diff  --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 6b19454e95d9..d047b7bdf1cd 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -2141,16 +2141,16 @@ std::string DagInit::getAsString() const {
 //Other implementations
 
//===--===//
 
-RecordVal::RecordVal(Init *N, RecTy *T, bool P)
-  : Name(N), TyAndPrefix(T, P) {
+RecordVal::RecordVal(Init *N, RecTy *T, FieldKind K)
+: Name(N), TyAndKind(T, K) {
   setValue(UnsetInit::get());
   assert(Value && "Cannot create unset value for current type!");
 }
 
 // This constructor accepts the same arguments as the above, but also
 // a source location.
-RecordVal::RecordVal(Init *N, SMLoc Loc, RecTy *T, bool P)
-: Name(N), Loc(Loc), TyAndPrefix(T, P) {
+RecordVal::RecordVal(Init *N, SMLoc Loc, RecTy *T, FieldKind K)
+: Name(N), Loc(Loc), TyAndKind(T, K) {
   setValue(UnsetInit::get());
   assert(Value && "Cannot create unset value for current type!");
 }
@@ -2170,7 +2170,7 @@ std::string RecordVal::getPrintType() const {
   return "string";
 }
   } else {
-return TyAndPrefix.getPointer()->getAsString();
+return TyAndKind.getPointer()->getAsString();
   }
 }
 
@@ -2227,7 +2227,7 @@ LLVM_DUMP_METHOD void RecordVal::dump() const { errs() << 
*this; }
 #endif
 
 void RecordVal::print(raw_ostream &OS, bool PrintSem) const {
-  if (getPrefix()) OS << "field ";
+  if (isNonconcreteOK()) OS << "field ";
   OS << getPrintType() << " " << getNameInitAsString();
 
   if (getValue())
@@ -2368,10 +2368,10 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const 
Record &R) {
   OS << "\n";
 
   for (const RecordVal &Val : R.getValues())
-if (Val.getPrefix() && !R.isTemplateArg(Val.getNameInit()))
+if (Val.isNonconcreteOK() && !R.isTemplateArg(Val

[llvm-branch-commits] [llvm] 048f184 - [SplitEdge] Add new parameter to SplitEdge to name the newly created basic block

2021-01-07 Thread Sidharth Baveja via llvm-branch-commits

Author: Sidharth Baveja
Date: 2021-01-07T14:49:23Z
New Revision: 048f184ee488cdc8dadc0b8f9d1def9e6b469a73

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

LOG: [SplitEdge] Add new parameter to SplitEdge to name the newly created basic 
block

Summary:
Currently SplitEdge does not support passing in parameter which allows you to
name the newly created BasicBlock.

This patch updates the function such that the name of the block can be passed
in, if users of this utility decide to do so.

Reviewed By: Whitney, bmahjour, asbirlea, jamieschmeiser

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

Added: 


Modified: 
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h 
b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
index 64c569de1f58..a1d5ee8fb91b 100644
--- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -196,7 +196,8 @@ struct CriticalEdgeSplittingOptions {
 /// to.
 BasicBlock *SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
   const CriticalEdgeSplittingOptions &Options =
-  CriticalEdgeSplittingOptions());
+  CriticalEdgeSplittingOptions(),
+  const Twine &BBName = "");
 
 inline BasicBlock *
 SplitCriticalEdge(BasicBlock *BB, succ_iterator SI,
@@ -248,7 +249,8 @@ unsigned SplitAllCriticalEdges(Function &F,
 /// basic block between \p From and \p To.
 BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
   DominatorTree *DT = nullptr, LoopInfo *LI = nullptr,
-  MemorySSAUpdater *MSSAU = nullptr);
+  MemorySSAUpdater *MSSAU = nullptr,
+  const Twine &BBName = "");
 
 /// Split the specified block at the specified instruction.
 ///

diff  --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp 
b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 5b8bc184daca..09888db063e2 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -495,14 +495,16 @@ void llvm::ReplaceInstWithInst(Instruction *From, 
Instruction *To) {
 }
 
 BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, DominatorTree 
*DT,
-LoopInfo *LI, MemorySSAUpdater *MSSAU) {
+LoopInfo *LI, MemorySSAUpdater *MSSAU,
+const Twine &BBName) {
   unsigned SuccNum = GetSuccessorNumber(BB, Succ);
 
   // If this is a critical edge, let SplitCriticalEdge do it.
   Instruction *LatchTerm = BB->getTerminator();
   if (SplitCriticalEdge(
   LatchTerm, SuccNum,
-  CriticalEdgeSplittingOptions(DT, LI, MSSAU).setPreserveLCSSA()))
+  CriticalEdgeSplittingOptions(DT, LI, MSSAU).setPreserveLCSSA(),
+  BBName))
 return LatchTerm->getSuccessor(SuccNum);
 
   // If the edge isn't critical, then BB has a single successor or Succ has a
@@ -512,14 +514,15 @@ BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock 
*Succ, DominatorTree *DT,
 // block.
 assert(SP == BB && "CFG broken");
 SP = nullptr;
-return SplitBlock(Succ, &Succ->front(), DT, LI, MSSAU, "", 
/*Before=*/true);
+return SplitBlock(Succ, &Succ->front(), DT, LI, MSSAU, BBName,
+  /*Before=*/true);
   }
 
   // Otherwise, if BB has a single successor, split it at the bottom of the
   // block.
   assert(BB->getTerminator()->getNumSuccessors() == 1 &&
  "Should have a single succ!");
-  return SplitBlock(BB, BB->getTerminator(), DT, LI, MSSAU);
+  return SplitBlock(BB, BB->getTerminator(), DT, LI, MSSAU, BBName);
 }
 
 unsigned

diff  --git a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp 
b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
index e42f469ad32c..c9f08e5a9ed5 100644
--- a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
+++ b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
@@ -134,9 +134,9 @@ static void createPHIsForSplitLoopExit(ArrayRef Preds,
   }
 }
 
-BasicBlock *
-llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
-const CriticalEdgeSplittingOptions &Options) {
+BasicBlock *llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
+const CriticalEdgeSplittingOptions 
&Options,
+const Twine &BBName) {
   if (!isCriticalEdge(TI, SuccNum, Options.MergeIdenticalEdges))
 return nullptr;
 
@@ -196,8 +196,13 @@ llvm::SplitCriticalEdge(Instruction *TI, unsigned Suc

[llvm-branch-commits] [llvm] 8dee0b4 - [llvm-reduce] ReduceGlobalVarInitializers delta pass: fix handling of globals w/ comdat/non-external linkage

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-07T18:05:03+03:00
New Revision: 8dee0b4bd6376f5518accf45e9ecc4a44a4c8481

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

LOG: [llvm-reduce] ReduceGlobalVarInitializers delta pass: fix handling of 
globals w/ comdat/non-external linkage

Much like with ReduceFunctionBodies delta pass,
we need to remove comdat and set linkage to external,
else verifier will complain, and our deltas are invalid.

Added: 


Modified: 
llvm/test/Reduce/remove-global-vars.ll
llvm/tools/llvm-reduce/deltas/ReduceGlobalVarInitializers.cpp

Removed: 




diff  --git a/llvm/test/Reduce/remove-global-vars.ll 
b/llvm/test/Reduce/remove-global-vars.ll
index d078cad6b995..e791fd50bf7c 100644
--- a/llvm/test/Reduce/remove-global-vars.ll
+++ b/llvm/test/Reduce/remove-global-vars.ll
@@ -4,16 +4,25 @@
 ; RUN: llvm-reduce --test FileCheck --test-arg 
--check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg 
--input-file %s -o %t
 ; RUN: cat %t | FileCheck --check-prefixes=CHECK-ALL,CHECK-FINAL 
--implicit-check-not=uninteresting %s
 
+$interesting5 = comdat any
+
 ; CHECK-INTERESTINGNESS: @interesting = {{.*}}global i32{{.*}}, align 4
 ; CHECK-INTERESTINGNESS: @interesting2 = global i32 0, align 4
 ; CHECK-INTERESTINGNESS: @interesting3 = {{.*}}global i32{{.*}}, align 4
+; CHECK-INTERESTINGNESS: @interesting4 = {{.*}}constant i32{{.*}}, align 4
+; CHECK-INTERESTINGNESS: @interesting5 = {{.*}}global i32{{.*}}, align 4
 
 ; CHECK-FINAL: @interesting = external global i32, align 4
 ; CHECK-FINAL: @interesting2 = global i32 0, align 4
 ; CHECK-FINAL: @interesting3 = external global i32, align 4
+; CHECK-FINAL: @interesting4 = external dso_local constant i32, align 4
+; CHECK-FINAL: @interesting5 = external global i32, align 4
 @interesting = global i32 0, align 4
 @interesting2 = global i32 0, align 4
 @interesting3 = external global i32, align 4
+@interesting4 = private constant i32 2, align 4
+@interesting5 = global i32 2, align 4, comdat
+
 @uninteresting = global i32 1, align 4
 @uninteresting2 = external global i32, align 4
 

diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceGlobalVarInitializers.cpp 
b/llvm/tools/llvm-reduce/deltas/ReduceGlobalVarInitializers.cpp
index 1128710f64c4..fd5a5d1f02c6 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceGlobalVarInitializers.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceGlobalVarInitializers.cpp
@@ -13,6 +13,7 @@
 
 #include "ReduceGlobalVarInitializers.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/GlobalValue.h"
 
 using namespace llvm;
 
@@ -23,8 +24,11 @@ static void extractGVsFromModule(std::vector 
ChunksToKeep,
 
   // Drop initializers of out-of-chunk GVs
   for (auto &GV : Program->globals())
-if (GV.hasInitializer() && !O.shouldKeep())
+if (GV.hasInitializer() && !O.shouldKeep()) {
   GV.setInitializer(nullptr);
+  GV.setLinkage(GlobalValue::LinkageTypes::ExternalLinkage);
+  GV.setComdat(nullptr);
+}
 }
 
 /// Counts the amount of initialized GVs and displays their



___
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] 6be1fd6 - [SimplifyCFG] FoldValueComparisonIntoPredecessors(): drop reachable errneous assert

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-07T18:05:04+03:00
New Revision: 6be1fd6b20f3418543a50ce9b04ab4a49585a7eb

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

LOG: [SimplifyCFG] FoldValueComparisonIntoPredecessors(): drop reachable 
errneous assert

I have added it in d15d81c because it *seemed* correct, was holding
for all the tests so far, and was validating the fix added in the same
commit, but as David Major is pointing out (with a reproducer),
the assertion isn't really correct after all. So remove it.

Note that the d15d81c still fine.

Added: 

llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-no-new-successors.ll

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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 3fbc22a85be4..9aedb918ac32 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1261,7 +1261,6 @@ bool 
SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI,
   // Okay, at this point, we know which new successor Pred will get.  Make
   // sure we update the number of entries in the PHI nodes for these
   // successors.
-  assert(!NewSuccessors.empty() && "Should be adding some new 
successors.");
   for (const std::pair &NewSuccessor :
NewSuccessors) {
 for (auto I : seq(0, NewSuccessor.second)) {

diff  --git 
a/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-no-new-successors.ll
 
b/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-no-new-successors.ll
new file mode 100644
index ..03490c9ac34b
--- /dev/null
+++ 
b/llvm/test/Transforms/SimplifyCFG/FoldValueComparisonIntoPredecessors-no-new-successors.ll
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | 
FileCheck %s
+
+define void @widget(i32 %arg) {
+; CHECK-LABEL: @widget(
+; CHECK-NEXT:  bb:
+; CHECK-NEXT:[[SWITCH:%.*]] = icmp ult i32 [[ARG:%.*]], 2
+; CHECK-NEXT:br i1 [[SWITCH]], label [[BB2:%.*]], label [[INFLOOP:%.*]]
+; CHECK:   bb2:
+; CHECK-NEXT:ret void
+; CHECK:   infloop:
+; CHECK-NEXT:br label [[INFLOOP]]
+;
+bb:
+  %tmp = icmp eq i32 %arg, 0
+  br i1 %tmp, label %bb2, label %bb1
+
+bb1:  ; preds = %bb1
+  %tmp4 = icmp eq i32 %arg, 1
+  br i1 %tmp4, label %bb6, label %bb5
+
+bb5:  ; preds = %bb5, %bb5
+  switch i32 %arg, label %bb5 [
+  i32 0, label %bb9
+  ]
+
+bb2:
+  ret void
+
+bb6:  ; preds = %bb1
+  ret void
+
+bb9:  ; preds = %bb5
+  ret void
+}



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


[llvm-branch-commits] [llvm] ebfe4de - [DDG] Fix duplicate edge removal during pi-block formation

2021-01-07 Thread Bardia Mahjour via llvm-branch-commits

Author: Bardia Mahjour
Date: 2021-01-07T10:31:11-05:00
New Revision: ebfe4de2c04b09d3ae935325e6c02c68f2965b00

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

LOG: [DDG] Fix duplicate edge removal during pi-block formation

When creating pi-blocks we try to avoid creating duplicate edges
between outside nodes and the pi-block when an edge is of the
same kind and direction as another one that has already been
created. We do this by keeping track of the edges in an
enumerated array called EdgeAlreadyCreated. The problem is that
this array is declared local to the loop that iterates over the
nodes in the pi-block, so the information gets lost every time a
new inside-node is iterated over. The fix is to move the
declaration to the outer loop.

Reviewed By: Meinersbur

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

Added: 


Modified: 
llvm/lib/Analysis/DependenceGraphBuilder.cpp
llvm/unittests/Analysis/DDGTest.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/DependenceGraphBuilder.cpp 
b/llvm/lib/Analysis/DependenceGraphBuilder.cpp
index fbf0f6651599..04a34472659c 100644
--- a/llvm/lib/Analysis/DependenceGraphBuilder.cpp
+++ b/llvm/lib/Analysis/DependenceGraphBuilder.cpp
@@ -140,75 +140,74 @@ template  void 
AbstractDependenceGraphBuilder::createPiBlocks() {
   if (*N == PiNode || NodesInSCC.count(N))
 continue;
 
-  for (NodeType *SCCNode : NL) {
-
-enum Direction {
-  Incoming,  // Incoming edges to the SCC
-  Outgoing,  // Edges going ot of the SCC
-  DirectionCount // To make the enum usable as an array index.
-};
-
-// Use these flags to help us avoid creating redundant edges. If there
-// are more than one edges from an outside node to inside nodes, we 
only
-// keep one edge from that node to the pi-block node. Similarly, if
-// there are more than one edges from inside nodes to an outside node,
-// we only keep one edge from the pi-block node to the outside node.
-// There is a flag defined for each direction (incoming vs outgoing) 
and
-// for each type of edge supported, using a two-dimensional boolean
-// array.
-using EdgeKind = typename EdgeType::EdgeKind;
-EnumeratedArray EdgeAlreadyCreated[DirectionCount]{
-false, false};
-
-auto createEdgeOfKind = [this](NodeType &Src, NodeType &Dst,
-   const EdgeKind K) {
-  switch (K) {
-  case EdgeKind::RegisterDefUse:
-createDefUseEdge(Src, Dst);
-break;
-  case EdgeKind::MemoryDependence:
-createMemoryEdge(Src, Dst);
-break;
-  case EdgeKind::Rooted:
-createRootedEdge(Src, Dst);
-break;
-  default:
-llvm_unreachable("Unsupported type of edge.");
-  }
-};
-
-auto reconnectEdges = [&](NodeType *Src, NodeType *Dst, NodeType *New,
-  const Direction Dir) {
-  if (!Src->hasEdgeTo(*Dst))
-return;
-  LLVM_DEBUG(dbgs()
- << "reconnecting("
- << (Dir == Direction::Incoming ? "incoming)" : 
"outgoing)")
- << ":\nSrc:" << *Src << "\nDst:" << *Dst
- << "\nNew:" << *New << "\n");
-  assert((Dir == Direction::Incoming || Dir == Direction::Outgoing) &&
- "Invalid direction.");
-
-  SmallVector EL;
-  Src->findEdgesTo(*Dst, EL);
-  for (EdgeType *OldEdge : EL) {
-EdgeKind Kind = OldEdge->getKind();
-if (!EdgeAlreadyCreated[Dir][Kind]) {
-  if (Dir == Direction::Incoming) {
-createEdgeOfKind(*Src, *New, Kind);
-LLVM_DEBUG(dbgs() << "created edge from Src to New.\n");
-  } else if (Dir == Direction::Outgoing) {
-createEdgeOfKind(*New, *Dst, Kind);
-LLVM_DEBUG(dbgs() << "created edge from New to Dst.\n");
-  }
-  EdgeAlreadyCreated[Dir][Kind] = true;
+  enum Direction {
+Incoming,  // Incoming edges to the SCC
+Outgoing,  // Edges going ot of the SCC
+DirectionCount // To make the enum usable as an array index.
+  };
+
+  // Use these flags to help us avoid creating redundant edges. If there
+  // are more than one edges from an outside node to inside nodes, we only
+  // keep one edge from that node to the pi-block node. Similarly, if
+  // there are more than one edges from inside nodes to an outside node,
+  // we only keep one edge from the pi-block node to the outside node.
+  // There is a flag defined

[llvm-branch-commits] [llvm] 6b7d5a9 - AMDGPU/GlobalISel: Start cleaning up calling convention lowering

2021-01-07 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2021-01-07T10:36:45-05:00
New Revision: 6b7d5a928f5e0d5321b641909f84cb238e8194b8

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

LOG: AMDGPU/GlobalISel: Start cleaning up calling convention lowering

There are various hacks working around limitations in
handleAssignments, and the logical split between different parts isn't
correct. Start separating the type legalization to satisfy going
through the DAG infrastructure from the code required to split into
register types. The type splitting should be moved to generic code.

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.h
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call-non-fixed.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
index bf8e57d591e1..a6790c9ac975 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -248,18 +248,18 @@ struct AMDGPUOutgoingArgHandler : public 
AMDGPUValueHandler {
   }
 
   void assignValueToAddress(const CallLowering::ArgInfo &Arg, Register Addr,
-uint64_t Size, MachinePointerInfo &MPO,
+uint64_t MemSize, MachinePointerInfo &MPO,
 CCValAssign &VA) override {
 Register ValVReg = VA.getLocInfo() != CCValAssign::LocInfo::FPExt
? extendRegister(Arg.Regs[0], VA)
: Arg.Regs[0];
 
-// If we extended we might need to adjust the MMO's Size.
+// If we extended the value type we might need to adjust the MMO's
+// Size. This happens if ComputeValueVTs widened a small type value to a
+// legal register type (e.g. s8->s16)
 const LLT RegTy = MRI.getType(ValVReg);
-if (RegTy.getSizeInBytes() > Size)
-  Size = RegTy.getSizeInBytes();
-
-assignValueToAddress(ValVReg, Addr, Size, MPO, VA);
+MemSize = std::min(MemSize, (uint64_t)RegTy.getSizeInBytes());
+assignValueToAddress(ValVReg, Addr, MemSize, MPO, VA);
   }
 };
 }
@@ -282,49 +282,64 @@ static ISD::NodeType extOpcodeToISDExtOpcode(unsigned 
MIOpc) {
   }
 }
 
-void AMDGPUCallLowering::splitToValueTypes(
-  MachineIRBuilder &B,
-  const ArgInfo &OrigArg,
-  SmallVectorImpl &SplitArgs,
-  const DataLayout &DL, CallingConv::ID CallConv,
-  bool IsOutgoing,
-  SplitArgTy PerformArgSplit) const {
+// FIXME: This should move to generic code.
+void AMDGPUCallLowering::splitToValueTypes(MachineIRBuilder &B,
+   const ArgInfo &OrigArg,
+   SmallVectorImpl &SplitArgs,
+   const DataLayout &DL,
+   CallingConv::ID CallConv) const {
   const SITargetLowering &TLI = *getTLI();
   LLVMContext &Ctx = OrigArg.Ty->getContext();
 
-  if (OrigArg.Ty->isVoidTy())
-return;
-
   SmallVector SplitVTs;
   ComputeValueVTs(TLI, DL, OrigArg.Ty, SplitVTs);
 
   assert(OrigArg.Regs.size() == SplitVTs.size());
 
-  int SplitIdx = 0;
-  for (EVT VT : SplitVTs) {
-Register Reg = OrigArg.Regs[SplitIdx];
-Type *Ty = VT.getTypeForEVT(Ctx);
-LLT LLTy = getLLTForType(*Ty, DL);
+  if (SplitVTs.size() == 0)
+return;
 
-if (IsOutgoing && VT.isScalarInteger()) {
-  unsigned ExtendOp = TargetOpcode::G_ANYEXT;
-  if (OrigArg.Flags[0].isSExt()) {
-assert(OrigArg.Regs.size() == 1 && "expect only simple return values");
-ExtendOp = TargetOpcode::G_SEXT;
-  } else if (OrigArg.Flags[0].isZExt()) {
-assert(OrigArg.Regs.size() == 1 && "expect only simple return values");
-ExtendOp = TargetOpcode::G_ZEXT;
-  }
+  if (SplitVTs.size() == 1) {
+// No splitting to do, but we want to replace the original type (e.g. [1 x
+// double] -> double).
+SplitArgs.emplace_back(OrigArg.Regs[0], SplitVTs[0].getTypeForEVT(Ctx),
+   OrigArg.Flags[0], OrigArg.IsFixed);
+return;
+  }
 
-  EVT ExtVT = TLI.getTypeForExtReturn(Ctx, VT,
-  extOpcodeToISDExtOpcode(ExtendOp));
-  if (ExtVT.getSizeInBits() != VT.getSizeInBits()) {
-VT = ExtVT;
-Ty = ExtVT.getTypeForEVT(Ctx);
-LLTy = getLLTForType(*Ty, DL);
-Reg = B.buildInstr(ExtendOp, {LLTy}, {Reg}).getReg(0);
-  }
-}
+  // Create one ArgInfo for each virtual register in the original ArgInfo.
+  assert(OrigArg.Regs.size() == SplitVTs.size() && "Regs / types mismatch");
+
+  bool NeedsRegBlock = TLI.functionArgumentNeedsConsecutiveRegisters(
+  OrigArg.Ty

[llvm-branch-commits] [llvm] 573d578 - [DDG] Data Dependence Graph - DOT printer tests

2021-01-07 Thread Bardia Mahjour via llvm-branch-commits

Author: Bardia Mahjour
Date: 2021-01-07T10:51:14-05:00
New Revision: 573d5782482841e16588e81be687ea6bcf3624fa

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

LOG: [DDG] Data Dependence Graph - DOT printer tests

Adds some tests to check the formatting of the dot
file produced when using -dot-ddg.

Reviewed By: Meinersbur

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

Added: 
llvm/test/Analysis/DDG/print-dot-ddg.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Analysis/DDG/print-dot-ddg.ll 
b/llvm/test/Analysis/DDG/print-dot-ddg.ll
new file mode 100644
index ..8a4d55bc2e8b
--- /dev/null
+++ b/llvm/test/Analysis/DDG/print-dot-ddg.ll
@@ -0,0 +1,74 @@
+; RUN: opt -aa-pipeline=basic-aa -passes=dot-ddg 
-dot-ddg-filename-prefix=out.full < %s 2>&1 > /dev/null
+; RUN: FileCheck %s -input-file=out.full.foo.for.body.dot
+; RUN: opt -aa-pipeline=basic-aa -passes=dot-ddg 
-dot-ddg-filename-prefix=out.only -dot-ddg-only < %s 2>&1 > /dev/null
+; RUN: FileCheck %s -input-file=out.only.foo.for.body.dot 
-check-prefix=CHECK-ONLY
+
+target datalayout = "e-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
+
+; Test the dot graph printer for a non-trivial DDG graph generated from
+; the following test case. In particular it tests that pi-blocks are
+; printed properly and that multiple memory dependencies on a single edge
+; are shown in the full dot graph.
+;
+; void foo(float * restrict A, float * restrict B, int n) {
+;   for (int i = 0; i < n; i++) {
+; A[i] = A[i] + B[i];
+; B[i+1] = A[i] + 1;
+;   }
+; }
+
+
+; CHECK: digraph "DDG for 'foo.for.body'"
+; CHECK-NEXT: label="DDG for 'foo.for.body'";
+; CHECK: {{Node0x.*}} [shape=record,label="{\\nroot\n}"]
+; CHECK: {{Node0x.*}} -> {{Node0x.*}}[label="[rooted]"]
+; CHECK-COUNT-6: {{Node0x.*}} -> {{Node0x.*}}[label="[def-use]"]
+; CHECK-NOT: {{Node0x.*}} -> {{Node0x.*}}[label="[def-use]"]
+; CHECK: [shape=record,label="{\\n  %arrayidx10 = 
getelementptr inbounds float, float* %B, i64 %indvars.iv.next\n}"];
+; CHECK: [shape=record,label="{\\n  %arrayidx = 
getelementptr inbounds float, float* %A, i64 %indvars.iv\n  %0 = load float, 
float* %arrayidx, align 4\n}"];
+; CHECK: {{Node0x.*}} -> {{Node0x.*}}[label="[consistent anti [0|<]!, 
consistent input [0|<]!]"]
+; CHECK: [shape=record,label="{\\n--- start of nodes in 
pi-block ---\n\\n  %1 = load float, float* 
%arrayidx2, align 4\n\n\\n  %add = fadd fast float 
%0, %1\n\n\\n  store float %add, float* %arrayidx4, 
align 4\n\n\\n  %2 = load float, float* %arrayidx6, 
align 4\n  %add7 = fadd fast float %2, 
1.00e+00\n\n\\n  store float %add7, float* 
%arrayidx10, align 4\n--- end of nodes in pi-block ---\n}"];
+
+; CHECK-ONLY: digraph "DDG for 'foo.for.body'"
+; CHECK-ONLY-NEXT: label="DDG for 'foo.for.body'";
+; CHECK-ONLY: [shape=record,label="{pi-block\nwith\n2 nodes\n}"];
+; CHECK-ONLY-COUNT-6: {{Node0x.*}} -> {{Node0x.*}}[label="[def-use]"];
+; CHECK-NOT: {{Node0x.*}} -> {{Node0x.*}}[label="[def-use]"];
+; CHECK-ONLY: [shape=record,label="{  %arrayidx10 = getelementptr inbounds 
float, float* %B, i64 %indvars.iv.next\n}"];
+; CHECK-ONLY: [shape=record,label="{  %arrayidx = getelementptr inbounds 
float, float* %A, i64 %indvars.iv\n  %0 = load float, float* %arrayidx, align 
4\n}"];
+; CHECK-ONLY: {{Node0x.*}} -> {{Node0x.*}}[label="[memory]"]
+; CHECK-ONLY: [shape=record,label="{pi-block\nwith\n5 nodes\n}"];
+
+define void @foo(float* noalias %A, float* noalias %B, i32 signext %n) {
+entry:
+  %cmp1 = icmp sgt i32 %n, 0
+  br i1 %cmp1, label %for.body.preheader, label %for.end
+
+for.body.preheader:   ; preds = %entry
+  %wide.trip.count = zext i32 %n to i64
+  br label %for.body
+
+for.body: ; preds = 
%for.body.preheader, %for.body
+  %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, 
%for.body ]
+  %arrayidx = getelementptr inbounds float, float* %A, i64 %indvars.iv
+  %0 = load float, float* %arrayidx, align 4
+  %arrayidx2 = getelementptr inbounds float, float* %B, i64 %indvars.iv
+  %1 = load float, float* %arrayidx2, align 4
+  %add = fadd fast float %0, %1
+  %arrayidx4 = getelementptr inbounds float, float* %A, i64 %indvars.iv
+  store float %add, float* %arrayidx4, align 4
+  %arrayidx6 = getelementptr inbounds float, float* %A, i64 %indvars.iv
+  %2 = load float, float* %arrayidx6, align 4
+  %add7 = fadd fast float %2, 1.00e+00
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %arrayidx10 = getelementptr inbounds float, float* %B, i64 %indvars.iv.next
+  store float %add7, float* %arrayidx10, align 4
+  %exitcond = icmp ne i64 %indvars.iv.next, %wide.trip.count
+  br i1 %exitcond, label %for.body, label %for.end.loopexit
+
+for.end.loopexit:

[llvm-branch-commits] [llvm] f401335 - [SVE] Add unpacked scalable floating point ZIP/UZP/TRN patterns

2021-01-07 Thread Cameron McInally via llvm-branch-commits

Author: Cameron McInally
Date: 2021-01-07T09:56:53-06:00
New Revision: f4013359b3da2c78e94a64245de8638460f96c1a

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

LOG: [SVE] Add unpacked scalable floating point ZIP/UZP/TRN patterns

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

Added: 


Modified: 
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td 
b/llvm/lib/Target/AArch64/SVEInstrFormats.td
index 1020a81a3494..b4416135eeb5 100644
--- a/llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -2270,6 +2270,8 @@ multiclass sve_int_perm_bin_perm_zz opc, string 
asm,
   def : SVE_2_Op_Pat(NAME # 
_H)>;
   def : SVE_2_Op_Pat(NAME # 
_S)>;
   def : SVE_2_Op_Pat(NAME # 
_S)>;
+  def : SVE_2_Op_Pat(NAME # 
_D)>;
+  def : SVE_2_Op_Pat(NAME # 
_D)>;
   def : SVE_2_Op_Pat(NAME # 
_D)>;
 
   def : SVE_2_Op_Pat(NAME 
# _H)>;

diff  --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll 
b/llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
index b248d209f44a..9f0d71e6a7b6 100644
--- a/llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -1277,6 +1277,15 @@ define  @trn1_i64( 
%a,  %b
   ret  %out
 }
 
+define  @trn1_f16_v2( %a,  %b) {
+; CHECK-LABEL: trn1_f16_v2:
+; CHECK: trn1 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.trn1.nxv2f16( %a,
+  %b)
+  ret  %out
+}
+
 define  @trn1_f16_v4( %a,  %b) {
 ; CHECK-LABEL: trn1_f16_v4:
 ; CHECK: trn1 z0.s, z0.s, z1.s
@@ -1304,6 +1313,15 @@ define  @trn1_f16( 
%a, 
   ret  %out
 }
 
+define  @trn1_f32_v2( %a,  %b) {
+; CHECK-LABEL: trn1_f32_v2:
+; CHECK: trn1 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.trn1.nxv2f32( %a,
+   %b)
+  ret  %out
+}
+
 define  @trn1_f32( %a,  %b) {
 ; CHECK-LABEL: trn1_f32:
 ; CHECK: trn1 z0.s, z0.s, z1.s
@@ -1398,6 +1416,15 @@ define  @trn2_i64( 
%a,  %b
   ret  %out
 }
 
+define  @trn2_f16_v2( %a,  %b) {
+; CHECK-LABEL: trn2_f16_v2:
+; CHECK: trn2 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.trn2.nxv2f16( %a,
+  %b)
+  ret  %out
+}
+
 define  @trn2_f16_v4( %a,  %b) {
 ; CHECK-LABEL: trn2_f16_v4:
 ; CHECK: trn2 z0.s, z0.s, z1.s
@@ -1425,6 +1452,15 @@ define  @trn2_f16( 
%a, 
   ret  %out
 }
 
+define  @trn2_f32_v2( %a,  %b) {
+; CHECK-LABEL: trn2_f32_v2:
+; CHECK: trn2 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.trn2.nxv2f32( %a,
+   %b)
+  ret  %out
+}
+
 define  @trn2_f32( %a,  %b) {
 ; CHECK-LABEL: trn2_f32:
 ; CHECK: trn2 z0.s, z0.s, z1.s
@@ -1519,6 +1555,15 @@ define  @uzp1_i64( 
%a,  %b
   ret  %out
 }
 
+define  @uzp1_f16_v2( %a,  %b) {
+; CHECK-LABEL: uzp1_f16_v2:
+; CHECK: uzp1 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uzp1.nxv2f16( %a,
+  %b)
+  ret  %out
+}
+
 define  @uzp1_f16_v4( %a,  %b) {
 ; CHECK-LABEL: uzp1_f16_v4:
 ; CHECK: uzp1 z0.s, z0.s, z1.s
@@ -1546,6 +1591,15 @@ define  @uzp1_f16( 
%a, 
   ret  %out
 }
 
+define  @uzp1_f32_v2( %a,  %b) {
+; CHECK-LABEL: uzp1_f32_v2:
+; CHECK: uzp1 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uzp1.nxv2f32( %a,
+   %b)
+  ret  %out
+}
+
 define  @uzp1_f32( %a,  %b) {
 ; CHECK-LABEL: uzp1_f32:
 ; CHECK: uzp1 z0.s, z0.s, z1.s
@@ -1640,6 +1694,15 @@ define  @uzp2_i64( 
%a,  %b
   ret  %out
 }
 
+define  @uzp2_f16_v2( %a,  %b) {
+; CHECK-LABEL: uzp2_f16_v2:
+; CHECK: uzp2 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uzp2.nxv2f16( %a,
+  %b)
+  ret  %out
+}
+
 define  @uzp2_f16_v4( %a,  %b) {
 ; CHECK-LABEL: uzp2_f16_v4:
 ; CHECK: uzp2 z0.s, z0.s, z1.s
@@ -1667,6 +1730,15 @@ define  @uzp2_f16( 
%a, 
   ret  %out
 }
 
+define  @uzp2_f32_v2( %a,  %b) {
+; CHECK-LABEL: uzp2_f32_v2:
+; CHECK: uzp2 z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uzp2.nxv2f32( %a,
+   %b)
+  ret  %out
+}
+
 define  @uzp2_f32( %a,  %b) {
 ; CHECK-LABEL: uzp2_f32:
 ; CHECK: uzp2 z0.s, z0.s, z1.s
@@ -1761,6 +1833,15 @@ define  @zip1_i64( 
%a,  %b
   ret  %out
 }
 
+define  @zip1_f16_v2( %a,  %b) {
+; CHECK-LABEL: zip1_f16_v2:
+; CHECK: zip1 z0.d, z

[llvm-branch-commits] [llvm] e881a25 - [NFC] Removed unused prefixes in CodeGen/AMDGPU

2021-01-07 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2021-01-07T08:00:11-08:00
New Revision: e881a25f1e110b259030745b3592418ea0c8efe8

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

LOG: [NFC] Removed unused prefixes in CodeGen/AMDGPU

This covers tests starting with s.

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

Added: 


Modified: 
llvm/test/CodeGen/AMDGPU/s_code_end.ll
llvm/test/CodeGen/AMDGPU/saddo.ll
llvm/test/CodeGen/AMDGPU/saddsat.ll
llvm/test/CodeGen/AMDGPU/scalar_to_vector.ll
llvm/test/CodeGen/AMDGPU/schedule-regpressure-limit2.ll
llvm/test/CodeGen/AMDGPU/scratch-simple.ll
llvm/test/CodeGen/AMDGPU/sdiv.ll
llvm/test/CodeGen/AMDGPU/sdwa-vop2-64bit.mir
llvm/test/CodeGen/AMDGPU/select-fabs-fneg-extract-legacy.ll
llvm/test/CodeGen/AMDGPU/select.f16.ll
llvm/test/CodeGen/AMDGPU/sendmsg-m0-hazard.mir
llvm/test/CodeGen/AMDGPU/setcc-fneg-constant.ll
llvm/test/CodeGen/AMDGPU/setcc64.ll
llvm/test/CodeGen/AMDGPU/sext-in-reg.ll
llvm/test/CodeGen/AMDGPU/shift-i64-opts.ll
llvm/test/CodeGen/AMDGPU/shl.ll
llvm/test/CodeGen/AMDGPU/shl.v2i16.ll
llvm/test/CodeGen/AMDGPU/shl_add_ptr_csub.ll
llvm/test/CodeGen/AMDGPU/shl_add_ptr_global.ll
llvm/test/CodeGen/AMDGPU/shrink-add-sub-constant.ll
llvm/test/CodeGen/AMDGPU/sibling-call.ll
llvm/test/CodeGen/AMDGPU/sign_extend.ll
llvm/test/CodeGen/AMDGPU/sint_to_fp.i64.ll
llvm/test/CodeGen/AMDGPU/skip-branch-trap.ll
llvm/test/CodeGen/AMDGPU/smrd.ll
llvm/test/CodeGen/AMDGPU/spill-agpr-partially-undef.mir
llvm/test/CodeGen/AMDGPU/spill-scavenge-offset.ll
llvm/test/CodeGen/AMDGPU/spill-special-sgpr.mir
llvm/test/CodeGen/AMDGPU/ssubsat.ll
llvm/test/CodeGen/AMDGPU/store-local.128.ll
llvm/test/CodeGen/AMDGPU/store-local.96.ll
llvm/test/CodeGen/AMDGPU/store-weird-sizes.ll
llvm/test/CodeGen/AMDGPU/sub.v2i16.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AMDGPU/s_code_end.ll 
b/llvm/test/CodeGen/AMDGPU/s_code_end.ll
index 80f49427f56e..2c7ce12f8f30 100644
--- a/llvm/test/CodeGen/AMDGPU/s_code_end.ll
+++ b/llvm/test/CodeGen/AMDGPU/s_code_end.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -asm-verbose=0 < %s | 
FileCheck -check-prefixes=GCN,GCN-ASM,GFX10END,GFX10END-ASM %s
-; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -filetype=obj < %s | 
llvm-objdump --arch=amdgcn --mcpu=gfx1010 -d - | FileCheck 
--check-prefixes=GCN,GCN-OBJ,GFX10END,GFX10END-OBJ %s
-; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1010 -asm-verbose=0 < %s | 
FileCheck -check-prefixes=GCN,GCN-ASM,GFX10END,GFX10END-ASM %s
-; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1010 -asm-verbose=0 < %s | 
FileCheck -check-prefixes=GCN,GCN-ASM,GFX10NOEND,GFX10NOEND-ASM %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -asm-verbose=0 < %s | 
FileCheck -check-prefixes=GCN,GCN-ASM,GFX10END-ASM %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -filetype=obj < %s | 
llvm-objdump --arch=amdgcn --mcpu=gfx1010 -d - | FileCheck 
--check-prefixes=GCN,GCN-OBJ,GFX10END-OBJ %s
+; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1010 -asm-verbose=0 < %s | 
FileCheck -check-prefixes=GCN,GCN-ASM,GFX10END-ASM %s
+; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1010 -asm-verbose=0 < %s | 
FileCheck -check-prefixes=GCN,GCN-ASM,GFX10NOEND %s
 ; RUN: llc -mtriple=amdgcn-- -mcpu=gfx1010 -filetype=obj < %s | llvm-objdump 
--arch=amdgcn --mcpu=gfx1010 -d - | FileCheck 
--check-prefixes=GCN,GCN-OBJ,GFX10NOEND,GFX10NOEND-OBJ %s
 
 ; GCN:a_kernel1{{>?}}:

diff  --git a/llvm/test/CodeGen/AMDGPU/saddo.ll 
b/llvm/test/CodeGen/AMDGPU/saddo.ll
index d01dbbfce000..0a223e8ba2c2 100644
--- a/llvm/test/CodeGen/AMDGPU/saddo.ll
+++ b/llvm/test/CodeGen/AMDGPU/saddo.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -amdgpu-scalarize-global-loads=false -march=amdgcn 
-mcpu=tahiti -verify-machineinstrs | FileCheck %s 
-check-prefixes=FUNC,GCN,SICIVI,SI
-; RUN: llc < %s -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tonga 
-verify-machineinstrs | FileCheck %s -check-prefixes=FUNC,GCN,SICIVI,VI
-; RUN: llc < %s -amdgpu-scalarize-global-loads=false -march=amdgcn 
-mcpu=gfx900 -verify-machineinstrs | FileCheck %s -check-prefixes=FUNC,GCN,GFX9
+; RUN: llc < %s -amdgpu-scalarize-global-loads=false -march=amdgcn 
-mcpu=tahiti -verify-machineinstrs | FileCheck %s --check-prefix=SI
+; RUN: llc < %s -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tonga 
-verify-machineinstrs | FileCheck %s --check-prefix=VI
+; RUN: llc < %s -amdgpu-scalarize-global-loads=false -march=amdgcn 
-mcpu=gfx900 -verify-machineinstrs | FileCheck %s --check-prefix=GFX9
 
 
 declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32)

[llvm-branch-commits] [llvm] db33f85 - [IR] Use LLVM_ENABLE_ABI_BREAKING_CHECKS to guard ABI changes.

2021-01-07 Thread Varun Gandhi via llvm-branch-commits

Author: Varun Gandhi
Date: 2021-01-07T08:42:00-08:00
New Revision: db33f85c7124443e140d0118289fc141bab0c68d

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

LOG: [IR] Use LLVM_ENABLE_ABI_BREAKING_CHECKS to guard ABI changes.

Incorrect usage of NDEBUG to guard ABI changes can prevent clients
from enabling assertions for their C++ code while having assertions in
LLVM turned off. So we use LLVM_ENABLE_ABI_BREAKING_CHECKS instead, as
described in llvm/docs/ProgrammersManual.rst. Most types already use this
macro, however, there were a couple of stragglers in ValueHandle.h, which
are fixed by this revision.

Reviewed By: dblaikie, dexonsmith

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

Added: 


Modified: 
llvm/include/llvm/IR/ValueHandle.h

Removed: 




diff  --git a/llvm/include/llvm/IR/ValueHandle.h 
b/llvm/include/llvm/IR/ValueHandle.h
index badc1ca8d1f6..1324053800c7 100644
--- a/llvm/include/llvm/IR/ValueHandle.h
+++ b/llvm/include/llvm/IR/ValueHandle.h
@@ -258,13 +258,13 @@ template <> struct simplify_type {
 /// class turns into a trivial wrapper around a pointer.
 template 
 class AssertingVH
-#ifndef NDEBUG
-  : public ValueHandleBase
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+: public ValueHandleBase
 #endif
-  {
+{
   friend struct DenseMapInfo>;
 
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   Value *getRawValPtr() const { return ValueHandleBase::getValPtr(); }
   void setRawValPtr(Value *P) { ValueHandleBase::operator=(P); }
 #else
@@ -280,7 +280,7 @@ class AssertingVH
   void setValPtr(ValueTy *P) { setRawValPtr(GetAsValue(P)); }
 
 public:
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   AssertingVH() : ValueHandleBase(Assert) {}
   AssertingVH(ValueTy *P) : ValueHandleBase(Assert, GetAsValue(P)) {}
   AssertingVH(const AssertingVH &RHS) : ValueHandleBase(Assert, RHS) {}
@@ -443,7 +443,7 @@ class CallbackVH : public ValueHandleBase {
 /// class turns into a trivial wrapper around a pointer.
 template 
 class PoisoningVH
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
 final : public CallbackVH
 #endif
 {
@@ -453,7 +453,7 @@ class PoisoningVH
   static Value *GetAsValue(Value *V) { return V; }
   static Value *GetAsValue(const Value *V) { return const_cast(V); }
 
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   /// A flag tracking whether this value has been poisoned.
   ///
   /// On delete and RAUW, we leave the value pointer alone so that as a raw
@@ -478,7 +478,7 @@ class PoisoningVH
 Poisoned = true;
 RemoveFromUseList();
   }
-#else // NDEBUG
+#else // LLVM_ENABLE_ABI_BREAKING_CHECKS
   Value *ThePtr = nullptr;
 
   Value *getRawValPtr() const { return ThePtr; }
@@ -493,7 +493,7 @@ class PoisoningVH
 
 public:
   PoisoningVH() = default;
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   PoisoningVH(ValueTy *P) : CallbackVH(GetAsValue(P)) {}
   PoisoningVH(const PoisoningVH &RHS)
   : CallbackVH(RHS), Poisoned(RHS.Poisoned) {}



___
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] 82f5ee3 - Adds argument attributes for using LLVM's sret and byval attributes to

2021-01-07 Thread Eric Schweitz via llvm-branch-commits

Author: Eric Schweitz
Date: 2021-01-07T09:03:16-08:00
New Revision: 82f5ee3c3e601daad546c320a98d9e7860d6347d

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

LOG: Adds argument attributes for using LLVM's sret and byval attributes to
the conversion of LLVM IR dialect. These attributes are used in FIR to
support the lowering of Fortran using target-specific calling
conventions.

Add roundtrip tests. Add changes per review comments/concerns.

Reviewed By: ftynse

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

Added: 


Modified: 
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Dialect/LLVMIR/func.mlir
mlir/test/Target/llvmir-invalid.mlir

Removed: 




diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp 
b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 7700867bb461..86f4e7e3e2c4 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1102,6 +1102,22 @@ LogicalResult 
ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
   llvm::AttrBuilder().addAlignmentAttr(llvm::Align(attr.getInt(;
 }
 
+if (auto attr = func.getArgAttrOfType(argIdx, "llvm.sret")) {
+  auto argTy = mlirArg.getType().dyn_cast();
+  if (!argTy.isa())
+return func.emitError(
+"llvm.sret attribute attached to LLVM non-pointer argument");
+  llvmArg.addAttr(llvm::Attribute::AttrKind::StructRet);
+}
+
+if (auto attr = func.getArgAttrOfType(argIdx, "llvm.byval")) {
+  auto argTy = mlirArg.getType().dyn_cast();
+  if (!argTy.isa())
+return func.emitError(
+"llvm.byval attribute attached to LLVM non-pointer argument");
+  llvmArg.addAttr(llvm::Attribute::AttrKind::ByVal);
+}
+
 valueMapping[mlirArg] = &llvmArg;
 argIdx++;
   }

diff  --git a/mlir/test/Dialect/LLVMIR/func.mlir 
b/mlir/test/Dialect/LLVMIR/func.mlir
index 65dc33cc1c4f..2cec1bca1f74 100644
--- a/mlir/test/Dialect/LLVMIR/func.mlir
+++ b/mlir/test/Dialect/LLVMIR/func.mlir
@@ -87,6 +87,16 @@ module {
 llvm.return
   }
 
+  // CHECK: llvm.func @byvalattr(%{{.*}}: !llvm.ptr {llvm.byval})
+  llvm.func @byvalattr(%arg0: !llvm.ptr {llvm.byval}) {
+llvm.return
+  }
+
+  // CHECK: llvm.func @sretattr(%{{.*}}: !llvm.ptr {llvm.sret})
+  llvm.func @sretattr(%arg0: !llvm.ptr {llvm.sret}) {
+llvm.return
+  }
+
   // CHECK: llvm.func @variadic(...)
   llvm.func @variadic(...)
 

diff  --git a/mlir/test/Target/llvmir-invalid.mlir 
b/mlir/test/Target/llvmir-invalid.mlir
index 14117594e2f8..fcd98ef4b143 100644
--- a/mlir/test/Target/llvmir-invalid.mlir
+++ b/mlir/test/Target/llvmir-invalid.mlir
@@ -14,6 +14,19 @@ llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.noalias 
= true}) -> !llvm.f
 
 // -
 
+// expected-error @+1 {{llvm.sret attribute attached to LLVM non-pointer 
argument}}
+llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.sret}) -> !llvm.float {
+  llvm.return %arg0 : !llvm.float
+}
+// -
+
+// expected-error @+1 {{llvm.byval attribute attached to LLVM non-pointer 
argument}}
+llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.byval}) -> !llvm.float {
+  llvm.return %arg0 : !llvm.float
+}
+
+// -
+
 // expected-error @+1 {{llvm.align attribute attached to LLVM non-pointer 
argument}}
 llvm.func @invalid_align(%arg0 : !llvm.float {llvm.align = 4}) -> !llvm.float {
   llvm.return %arg0 : !llvm.float



___
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] 59fce6b - [NFC] make clang/test/CodeGen/arm_neon_intrinsics.c resistent to function attribute id changes

2021-01-07 Thread Lucas Prates via llvm-branch-commits

Author: Jeroen Dobbelaere
Date: 2021-01-07T17:08:15Z
New Revision: 59fce6b0661647062918a47bdb1874950d3938d5

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

LOG: [NFC] make clang/test/CodeGen/arm_neon_intrinsics.c resistent to function 
attribute id changes

When introducing support for @llvm.experimental.noalias.scope.decl, this tests 
started failing because it checks
(for no good reason) for a function attribute id of '#8' which now becomes '#9'

Reviewed By: pratlucas

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

Added: 


Modified: 
clang/test/CodeGen/arm_neon_intrinsics.c

Removed: 




diff  --git a/clang/test/CodeGen/arm_neon_intrinsics.c 
b/clang/test/CodeGen/arm_neon_intrinsics.c
index 9d3f35f48bb76..56e105a41962e 100644
--- a/clang/test/CodeGen/arm_neon_intrinsics.c
+++ b/clang/test/CodeGen/arm_neon_intrinsics.c
@@ -7114,7 +7114,7 @@ uint64x2_t test_vmlal_u32(uint64x2_t a, uint32x2_t b, 
uint32x2_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> 
[[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[ADD]]
 int32x4_t test_vmlal_lane_s16(int32x4_t a, int16x4_t b, int16x4_t c) {
@@ -7127,7 +7127,7 @@ int32x4_t test_vmlal_lane_s16(int32x4_t a, int16x4_t b, 
int16x4_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> 
[[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <2 x i32> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmulls.v2i64(<2 x 
i32> [[B]], <2 x i32> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmulls.v2i64(<2 x 
i32> [[B]], <2 x i32> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <2 x i64> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <2 x i64> [[ADD]]
 int64x2_t test_vmlal_lane_s32(int64x2_t a, int32x2_t b, int32x2_t c) {
@@ -7140,7 +7140,7 @@ int64x2_t test_vmlal_lane_s32(int64x2_t a, int32x2_t b, 
int32x2_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> 
[[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[ADD]]
 uint32x4_t test_vmlal_lane_u16(uint32x4_t a, uint16x4_t b, uint16x4_t c) {
@@ -7153,7 +7153,7 @@ uint32x4_t test_vmlal_lane_u16(uint32x4_t a, uint16x4_t 
b, uint16x4_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> 
[[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <2 x i32> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmullu.v2i64(<2 x 
i32> [[B]], <2 x i32> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <2 x i64> @llvm.arm.neon.vmullu.v2i64(<2 x 
i32> [[B]], <2 x i32> [[LANE]])
 // CHECK:   [[ADD:%.*]] = add <2 x i64> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <2 x i64> [[ADD]]
 uint64x2_t test_vmlal_lane_u32(uint64x2_t a, uint32x2_t b, uint32x2_t c) {
@@ -7618,7 +7618,7 @@ uint64x2_t test_vmlsl_u32(uint64x2_t a, uint32x2_t b, 
uint32x2_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <4 x i16> [[TMP1]], <4 x i16> 
[[TMP1]], <4 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitcast <4 x i16> [[LANE]] to <8 x i8>
-// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]]) #8
+// CHECK:   [[VMULL2_I:%.*]] = call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x 
i16> [[B]], <4 x i16> [[LANE]])
 // CHECK:   [[SUB:%.*]] = sub <4 x i32> [[A:%.*]], [[VMULL2_I]]
 // CHECK:   ret <4 x i32> [[SUB]]
 int32x4_t test_vmlsl_lane_s16(int32x4_t a, int16x4_t b, int16x4_t c) {
@@ -7631,7 +7631,7 @@ int32x4_t test_vmlsl_lane_s16(int32x4_t a, int16x4_t b, 
int16x4_t c) {
 // CHECK:   [[LANE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> 
[[TMP1]], <2 x i32> 
 // CHECK:   [[TMP2:%.*]] = bitcast <2 x i32> [[B:%.*]] to <8 x i8>
 // CHECK:   [[TMP3:%.*]] = bitca

[llvm-branch-commits] [mlir] f88fab5 - [mlir] NFC: fix trivial typos

2021-01-07 Thread Kazuaki Ishizaki via llvm-branch-commits

Author: Kazuaki Ishizaki
Date: 2021-01-08T02:10:12+09:00
New Revision: f88fab500689852d06dd6e30ea1a8425ed7fd0e4

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

LOG: [mlir] NFC: fix trivial typos

fix typo under include and lib directories

Reviewed By: antiagainst

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

Added: 


Modified: 
mlir/include/mlir-c/Support.h
mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td
mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
mlir/include/mlir/Dialect/SCF/SCFOps.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td
mlir/include/mlir/Dialect/Tosa/Utils/QuantUtils.h
mlir/include/mlir/Dialect/Vector/VectorOps.td
mlir/include/mlir/IR/ImplicitLocOpBuilder.h
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/Pass/PassRegistry.h
mlir/include/mlir/Support/IndentedOstream.h
mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
mlir/include/mlir/Target/LLVMIR/TypeTranslation.h
mlir/include/mlir/Transforms/Bufferize.h
mlir/lib/Analysis/AffineStructures.cpp
mlir/lib/Bindings/Python/IRModules.cpp
mlir/lib/CAPI/Transforms/Passes.cpp
mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
mlir/lib/Conversion/PDLToPDLInterp/Predicate.h
mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
mlir/lib/Dialect/LLVMIR/IR/TypeDetail.h
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp
mlir/lib/Dialect/PDL/IR/PDL.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/StandardOps/Transforms/ExpandOps.cpp
mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/Rewrite/ByteCode.h
mlir/lib/Target/SPIRV/Serialization.cpp
mlir/lib/Transforms/BufferUtils.cpp
mlir/lib/Transforms/Utils/FoldUtils.cpp
mlir/lib/Transforms/Utils/LoopUtils.cpp
mlir/lib/Transforms/Utils/RegionUtils.cpp

Removed: 




diff  --git a/mlir/include/mlir-c/Support.h b/mlir/include/mlir-c/Support.h
index 072b96051e01..6b5927afc431 100644
--- a/mlir/include/mlir-c/Support.h
+++ b/mlir/include/mlir-c/Support.h
@@ -76,7 +76,7 @@ mlirStringRefCreateFromCString(const char *str);
  *
  * This function is called back by the functions that need to return a 
reference
  * to the portion of the string with the following arguments:
- *   - an MlirStringRef represening the current portion of the string
+ *   - an MlirStringRef representing the current portion of the string
  *   - a pointer to user data forwarded from the printing call.
  */
 typedef void (*MlirStringCallback)(MlirStringRef, void *);

diff  --git a/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h 
b/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
index bc70736c7d3b..859eadadd7a8 100644
--- a/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
+++ b/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
@@ -24,7 +24,7 @@ class OperationPass;
 /// the host module code to LLVM.
 ///
 /// This transformation creates a sequence of global variables that are later
-/// linked to the varables in the kernel module, and a series of copies to/from
+/// linked to the variables in the kernel module, and a series of copies 
to/from
 /// them to emulate the memory transfer from the host or to the device sides. 
It
 /// also converts the remaining Standard dialect into LLVM dialect, emitting C
 /// wrappers.

diff  --git a/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td 
b/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td
index 6353a0001d4c..b1a42e99126c 100644
--- a/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td
+++ b/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td
@@ -165,7 +165,7 @@ def SmmlaOp : ArmSVE_Op<"smmla",
 AllTypesMatch<["src1", "src2"]>,
 AllTypesMatch<["acc", "dst"]>,
   ]> {
-  let summary = "Matrix-matrix mutiply and accumulate op";
+  let summary = "Matrix-matrix multiply and accumulate op";
   let description = [{
 SMMLA: Signed integer matrix multiply-accumulate.
 
@@ -228,7 +228,7 @@ def UmmlaOp : ArmSVE_Op<"ummla",
 AllTypesMatch<["src1", "src2"]>,
 AllTypesMatch<["acc", "dst"]>,
   ]> {
-  let summary = "Matrix-matrix mutiply and accumulate op";
+  let summary = "Matrix-matrix multiply and accumulate op";
   let descripti

[llvm-branch-commits] [clang] acbb365 - [AST][NFC] Silence GCC warning about multiline comments

2021-01-07 Thread Thomas Preud'homme via llvm-branch-commits

Author: Thomas Preud'homme
Date: 2021-01-07T17:11:49Z
New Revision: acbb3652931a735a861b756075b1cc86fd041761

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

LOG: [AST][NFC] Silence GCC warning about multiline comments

Remove continuation line in code snippet to prevent GCC warning about
multiline comments (-Wcomment) when building a project using libclang
with GCC.

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/include/clang/AST/DeclOpenMP.h

Removed: 




diff  --git a/clang/include/clang/AST/DeclOpenMP.h 
b/clang/include/clang/AST/DeclOpenMP.h
index e595ec98d914..4aa5bde92e12 100644
--- a/clang/include/clang/AST/DeclOpenMP.h
+++ b/clang/include/clang/AST/DeclOpenMP.h
@@ -163,7 +163,7 @@ class OMPThreadPrivateDecl final : public 
OMPDeclarativeDirective {
 /// 'float':
 ///
 /// \code
-/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \
+/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in)
 /// initializer (omp_priv = 0)
 /// \endcode
 ///



___
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] 43043ad - Add element-type to the Vector TypeLoc types.

2021-01-07 Thread Erich Keane via llvm-branch-commits

Author: Erich Keane
Date: 2021-01-07T09:14:36-08:00
New Revision: 43043adcfbc60945646b791d7162e5a1307a5318

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

LOG: Add element-type to the Vector TypeLoc types.

As shown by bug 48540, GCC vector types would cause a crash when the
declaration hada ParenType. This was because the walking of the
declaration would try to expand the 'inner' type, but there was no
ability to get it from the vector type.  This patch adds that element
type access to the vector type loc objects.

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

Added: 


Modified: 
clang/include/clang/AST/TypeLoc.h
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/vector.cpp

Removed: 




diff  --git a/clang/include/clang/AST/TypeLoc.h 
b/clang/include/clang/AST/TypeLoc.h
index 4c320ce26e4f..65e95d52c303 100644
--- a/clang/include/clang/AST/TypeLoc.h
+++ b/clang/include/clang/AST/TypeLoc.h
@@ -1749,30 +1749,79 @@ class DependentAddressSpaceTypeLoc
 
 // FIXME: size expression and attribute locations (or keyword if we
 // ever fully support altivec syntax).
-class VectorTypeLoc : public InheritingConcreteTypeLoc {
+struct VectorTypeLocInfo {
+  SourceLocation NameLoc;
+};
+
+class VectorTypeLoc : public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
+
+  void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
+
+  SourceRange getLocalSourceRange() const {
+return SourceRange(getNameLoc(), getNameLoc());
+  }
+
+  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
+setNameLoc(Loc);
+  }
+
+  TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
+
+  QualType getInnerType() const { return this->getTypePtr()->getElementType(); 
}
 };
 
 // FIXME: size expression and attribute locations (or keyword if we
 // ever fully support altivec syntax).
 class DependentVectorTypeLoc
-: public InheritingConcreteTypeLoc {};
+: public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
 
-// FIXME: size expression and attribute locations.
-class ExtVectorTypeLoc : public InheritingConcreteTypeLoc {
+  void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
+
+  SourceRange getLocalSourceRange() const {
+return SourceRange(getNameLoc(), getNameLoc());
+  }
+
+  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
+setNameLoc(Loc);
+  }
+
+  TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
+
+  QualType getInnerType() const { return this->getTypePtr()->getElementType(); 
}
 };
 
+// FIXME: size expression and attribute locations.
+class ExtVectorTypeLoc
+: public InheritingConcreteTypeLoc {};
+
 // FIXME: attribute locations.
 // For some reason, this isn't a subtype of VectorType.
-class DependentSizedExtVectorTypeLoc :
-public InheritingConcreteTypeLoc {
+class DependentSizedExtVectorTypeLoc
+: public ConcreteTypeLoc {
+public:
+  SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
+
+  void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
+
+  SourceRange getLocalSourceRange() const {
+return SourceRange(getNameLoc(), getNameLoc());
+  }
+
+  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
+setNameLoc(Loc);
+  }
+
+  TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
+
+  QualType getInnerType() const { return this->getTypePtr()->getElementType(); 
}
 };
 
 struct MatrixTypeLocInfo {

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index f51c616169f5..fe775b82a1d6 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -6135,6 +6135,17 @@ namespace {
 void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
   TL.setExpansionLoc(Chunk.Loc);
 }
+void VisitVectorTypeLoc(VectorTypeLoc TL) { TL.setNameLoc(Chunk.Loc); }
+void VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
+void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
+void
+VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
+  TL.setNameLoc(Chunk.Loc);
+}
 
 void VisitTypeLoc(TypeLoc TL) {
   llvm_unreachable("unsupported TypeLoc kind in declarator!");

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 2cc8b9c8324f..0a596e50658b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -5178,7 +5178,7 @@ template 
 QualType TreeTransform::TransformDependentVectorType(
 TypeLocBuilder &TLB, DependentVectorTypeLoc TL) {

[llvm-branch-commits] [llvm] ebcc8dc - [Coverage] Refactor three tests from commit rG9f2967bcfe2f

2021-01-07 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2021-01-07T11:18:31-06:00
New Revision: ebcc8dcb68aa37f34a87641b0c8b73086712a3cf

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

LOG: [Coverage] Refactor three tests from commit rG9f2967bcfe2f

Refactor three tests to not depend on other test files as input but to instead
refer to "Inputs" subdirectory.

Added: 
llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
llvm/test/tools/llvm-cov/branch-c-general.test

Modified: 
llvm/test/tools/llvm-cov/branch-export-json.test
llvm/test/tools/llvm-cov/branch-export-lcov.test
llvm/test/tools/llvm-cov/branch-noShowBranch.test

Removed: 
llvm/test/tools/llvm-cov/branch-c-general.c



diff  --git a/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c 
b/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
new file mode 100644
index ..2e7e773e5c39
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
@@ -0,0 +1,260 @@
+// Test visualization of general branch constructs in C.
+
+
+
+
+
+void simple_loops() {
+  int i;
+  for (i = 0; i < 100; ++i) {
+  }
+  while (i > 0)
+i--;
+  do {} while (i++ < 75);
+
+}
+
+void conditionals() {
+  for (int i = 0; i < 100; ++i) {
+if (i % 2) {
+  if (i) {}
+} else if (i % 3) {
+  if (i) {}
+} else {
+  if (i) {}
+}
+
+if (1 && i) {}
+if (0 || i) {}
+  }
+
+}
+
+void early_exits() {
+  int i = 0;
+
+  if (i) {}
+
+  while (i < 100) {
+i++;
+if (i > 50)
+  break;
+if (i % 2)
+  continue;
+  }
+
+  if (i) {}
+
+  do {
+if (i > 75)
+  return;
+else
+  i++;
+  } while (i < 100);
+
+  if (i) {}
+
+}
+
+void jumps() {
+  int i;
+
+  for (i = 0; i < 2; ++i) {
+goto outofloop;
+// Never reached -> no weights
+if (i) {}
+  }
+
+outofloop:
+  if (i) {}
+
+  goto loop1;
+
+  while (i) {
+  loop1:
+if (i) {}
+  }
+
+  goto loop2;
+first:
+second:
+third:
+  i++;
+  if (i < 3)
+goto loop2;
+
+  while (i < 3) {
+  loop2:
+switch (i) {
+case 0:
+  goto first;
+case 1:
+  goto second;
+case 2:
+  goto third;
+}
+  }
+
+  for (i = 0; i < 10; ++i) {
+goto withinloop;
+// never reached -> no weights
+if (i) {}
+  withinloop:
+if (i) {}
+  }
+
+}
+
+void switches() {
+  static int weights[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5};
+
+  // No cases -> no weights
+  switch (weights[0]) {
+  default:
+break;
+  }
+
+  for (int i = 0, len = sizeof(weights) / sizeof(weights[0]); i < len; ++i) {
+switch (i[weights]) {
+case 1:
+  if (i) {}
+  // fallthrough
+case 2:
+  if (i) {}
+  break;
+case 3:
+  if (i) {}
+  continue;
+case 4:
+  if (i) {}
+  switch (i) {
+  case 6 ... 9:
+if (i) {}
+continue;
+  }
+
+default:
+  if (i == len - 1)
+return;
+}
+  }
+
+  // Never reached -> no weights
+  if (weights[0]) {}
+
+}
+
+void big_switch() {
+  for (int i = 0; i < 32; ++i) {
+switch (1 << i) {
+case (1 << 0):
+  if (i) {}
+  // fallthrough
+case (1 << 1):
+  if (i) {}
+  break;
+case (1 << 2) ... (1 << 12):
+  if (i) {}
+  break;
+  // The branch for the large case range above appears after the case body.
+
+case (1 << 13):
+  if (i) {}
+  break;
+case (1 << 14) ... (1 << 28):
+  if (i) {}
+  break;
+// The branch for the large case range above appears after the case body.
+
+case (1 << 29) ... ((1 << 29) + 1):
+  if (i) {}
+  break;
+default:
+  if (i) {}
+  break;
+}
+  }
+
+}
+
+void boolean_operators() {
+  int v;
+  for (int i = 0; i < 100; ++i) {
+v = i % 3 || i;
+
+v = i % 3 && i;
+
+v = i % 3 || i % 2 || i;
+
+v = i % 2 && i % 3 && i;
+  }
+
+}
+
+void boolop_loops() {
+  int i = 100;
+
+  while (i && i > 50)
+i--;
+
+  while ((i % 2) || (i > 0))
+i--;
+
+  for (i = 100; i && i > 50; --i);
+
+  for (; (i % 2) || (i > 0); --i);
+
+}
+
+void conditional_operator() {
+  int i = 100;
+
+  int j = i < 50 ? i : 1;
+
+  int k = i ?: 0;
+
+}
+
+void do_fallthrough() {
+  for (int i = 0; i < 10; ++i) {
+int j = 0;
+do {
+  // The number of exits out of this do-loop via the break statement
+  // exceeds the counter value for the loop (which does not include the
+  // fallthrough count). Make sure that does not violate any assertions.
+  if (i < 8) break;
+  j++;
+} while (j < 2);
+  }
+}
+
+static void static_func() {
+  for (int i = 0; i < 10; ++i) {
+  }
+}
+
+
+
+
+
+
+
+
+
+
+int main(int argc, const char *argv[]) {
+  simple_loops();
+  conditionals();
+  early_exits();
+  jumps();
+  switches();
+  big_switch();
+  boolean_operators();
+  boolop_loops();
+  conditional_

[llvm-branch-commits] [mlir] bd78f4e - [mlir] revert 82f5ee3c3e601daad5

2021-01-07 Thread Eric Schweitz via llvm-branch-commits

Author: Eric Schweitz
Date: 2021-01-07T09:38:21-08:00
New Revision: bd78f4e93212f2b9bea233905faa2a85bf7bdba7

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

LOG: [mlir] revert 82f5ee3c3e601daad5

Added: 


Modified: 
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Dialect/LLVMIR/func.mlir
mlir/test/Target/llvmir-invalid.mlir

Removed: 




diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp 
b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 86f4e7e3e2c4..7700867bb461 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1102,22 +1102,6 @@ LogicalResult 
ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
   llvm::AttrBuilder().addAlignmentAttr(llvm::Align(attr.getInt(;
 }
 
-if (auto attr = func.getArgAttrOfType(argIdx, "llvm.sret")) {
-  auto argTy = mlirArg.getType().dyn_cast();
-  if (!argTy.isa())
-return func.emitError(
-"llvm.sret attribute attached to LLVM non-pointer argument");
-  llvmArg.addAttr(llvm::Attribute::AttrKind::StructRet);
-}
-
-if (auto attr = func.getArgAttrOfType(argIdx, "llvm.byval")) {
-  auto argTy = mlirArg.getType().dyn_cast();
-  if (!argTy.isa())
-return func.emitError(
-"llvm.byval attribute attached to LLVM non-pointer argument");
-  llvmArg.addAttr(llvm::Attribute::AttrKind::ByVal);
-}
-
 valueMapping[mlirArg] = &llvmArg;
 argIdx++;
   }

diff  --git a/mlir/test/Dialect/LLVMIR/func.mlir 
b/mlir/test/Dialect/LLVMIR/func.mlir
index 2cec1bca1f74..65dc33cc1c4f 100644
--- a/mlir/test/Dialect/LLVMIR/func.mlir
+++ b/mlir/test/Dialect/LLVMIR/func.mlir
@@ -87,16 +87,6 @@ module {
 llvm.return
   }
 
-  // CHECK: llvm.func @byvalattr(%{{.*}}: !llvm.ptr {llvm.byval})
-  llvm.func @byvalattr(%arg0: !llvm.ptr {llvm.byval}) {
-llvm.return
-  }
-
-  // CHECK: llvm.func @sretattr(%{{.*}}: !llvm.ptr {llvm.sret})
-  llvm.func @sretattr(%arg0: !llvm.ptr {llvm.sret}) {
-llvm.return
-  }
-
   // CHECK: llvm.func @variadic(...)
   llvm.func @variadic(...)
 

diff  --git a/mlir/test/Target/llvmir-invalid.mlir 
b/mlir/test/Target/llvmir-invalid.mlir
index fcd98ef4b143..14117594e2f8 100644
--- a/mlir/test/Target/llvmir-invalid.mlir
+++ b/mlir/test/Target/llvmir-invalid.mlir
@@ -14,19 +14,6 @@ llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.noalias 
= true}) -> !llvm.f
 
 // -
 
-// expected-error @+1 {{llvm.sret attribute attached to LLVM non-pointer 
argument}}
-llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.sret}) -> !llvm.float {
-  llvm.return %arg0 : !llvm.float
-}
-// -
-
-// expected-error @+1 {{llvm.byval attribute attached to LLVM non-pointer 
argument}}
-llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.byval}) -> !llvm.float {
-  llvm.return %arg0 : !llvm.float
-}
-
-// -
-
 // expected-error @+1 {{llvm.align attribute attached to LLVM non-pointer 
argument}}
 llvm.func @invalid_align(%arg0 : !llvm.float {llvm.align = 4}) -> !llvm.float {
   llvm.return %arg0 : !llvm.float



___
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] 41e31ea - Fix GCC5 build, require explicit this->... in this call inside a lambda (NFC)

2021-01-07 Thread Mehdi Amini via llvm-branch-commits

Author: Mehdi Amini
Date: 2021-01-07T17:44:42Z
New Revision: 41e31eac14c239970a220f81de5fdd3b231b5184

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

LOG: Fix GCC5 build, require explicit this->... in this call inside a lambda 
(NFC)

Error was:

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp:2247:36: error: cannot call member 
function 'mlir::LLVM::FastmathFlags mlir::LLVM::FMFAttr::getFlags() const' 
without object
 return bitEnumContains(getFlags(), flag);
^

Added: 


Modified: 
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 




diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index b7f7789ee44b..cc57b1803f26 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -2244,7 +2244,7 @@ static constexpr const FastmathFlags FastmathFlagsList[] 
= {
 void FMFAttr::print(DialectAsmPrinter &printer) const {
   printer << "fastmath<";
   auto flags = llvm::make_filter_range(FastmathFlagsList, [&](auto flag) {
-return bitEnumContains(getFlags(), flag);
+return bitEnumContains(this->getFlags(), flag);
   });
   llvm::interleaveComma(flags, printer,
 [&](auto flag) { printer << stringifyEnum(flag); });



___
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] ee57d30 - [NFC] Removed unused prefixes from CodeGen/AMDGPU

2021-01-07 Thread Mircea Trofin via llvm-branch-commits

Author: Mircea Trofin
Date: 2021-01-07T09:48:14-08:00
New Revision: ee57d30f4487548d844cc3ffa5895bd3c6b38585

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

LOG: [NFC] Removed unused prefixes from CodeGen/AMDGPU

Last bulk batch.

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

Added: 


Modified: 
llvm/test/CodeGen/AMDGPU/trunc-store-i1.ll
llvm/test/CodeGen/AMDGPU/uaddsat.ll
llvm/test/CodeGen/AMDGPU/uint_to_fp.i64.ll
llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll
llvm/test/CodeGen/AMDGPU/unsupported-calls.ll
llvm/test/CodeGen/AMDGPU/usubsat.ll
llvm/test/CodeGen/AMDGPU/v_mac.ll
llvm/test/CodeGen/AMDGPU/v_madak_f16.ll
llvm/test/CodeGen/AMDGPU/vccz-corrupt-bug-workaround.mir
llvm/test/CodeGen/AMDGPU/vector-alloca.ll
llvm/test/CodeGen/AMDGPU/vgpr-spill.mir
llvm/test/CodeGen/AMDGPU/widen-smrd-loads.ll
llvm/test/CodeGen/AMDGPU/wqm.ll
llvm/test/CodeGen/AMDGPU/xnor.ll
llvm/test/CodeGen/AMDGPU/zero_extend.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AMDGPU/trunc-store-i1.ll 
b/llvm/test/CodeGen/AMDGPU/trunc-store-i1.ll
index 112c49953561..8027c89ef374 100644
--- a/llvm/test/CodeGen/AMDGPU/trunc-store-i1.ll
+++ b/llvm/test/CodeGen/AMDGPU/trunc-store-i1.ll
@@ -1,5 +1,5 @@
-; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck 
-enable-var-scope -check-prefixes=GCN,SI %s
-; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global 
-verify-machineinstrs< %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI 
%s
+; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck 
-enable-var-scope --check-prefix=GCN %s
+; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global 
-verify-machineinstrs< %s | FileCheck -enable-var-scope --check-prefix=GCN %s
 
 
 ; GCN-LABEL: {{^}}global_truncstore_i32_to_i1:

diff  --git a/llvm/test/CodeGen/AMDGPU/uaddsat.ll 
b/llvm/test/CodeGen/AMDGPU/uaddsat.ll
index 56e4123e182a..5447d5ea0b75 100644
--- a/llvm/test/CodeGen/AMDGPU/uaddsat.ll
+++ b/llvm/test/CodeGen/AMDGPU/uaddsat.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=tahiti < %s | FileCheck 
-check-prefixes=GCN,GFX6 %s
-; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=fiji < %s | FileCheck 
-check-prefixes=GCN,GFX8 %s
-; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 < %s | FileCheck 
-check-prefixes=GCN,GFX9 %s
+; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=tahiti < %s | FileCheck 
--check-prefix=GFX6 %s
+; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=fiji < %s | FileCheck 
--check-prefix=GFX8 %s
+; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 < %s | FileCheck 
--check-prefix=GFX9 %s
 
 define i8 @v_uaddsat_i8(i8 %lhs, i8 %rhs) {
 ; GFX6-LABEL: v_uaddsat_i8:

diff  --git a/llvm/test/CodeGen/AMDGPU/uint_to_fp.i64.ll 
b/llvm/test/CodeGen/AMDGPU/uint_to_fp.i64.ll
index d2799d731752..aa1971a3fdbe 100644
--- a/llvm/test/CodeGen/AMDGPU/uint_to_fp.i64.ll
+++ b/llvm/test/CodeGen/AMDGPU/uint_to_fp.i64.ll
@@ -1,5 +1,5 @@
-; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck 
-check-prefix=GCN -check-prefix=SI -check-prefix=FUNC %s
-; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global 
-verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI 
-check-prefix=FUNC %s
+; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck 
--check-prefixes=GCN,FUNC %s
+; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global 
-verify-machineinstrs < %s | FileCheck --check-prefixes=GCN,FUNC %s
 
 ; FIXME: This should be merged with uint_to_fp.ll, but s_uint_to_fp_v2i64 
crashes on r600
 

diff  --git a/llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll 
b/llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll
index 562c63ecdb56..8fd7c2070fda 100644
--- a/llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll
+++ b/llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll
@@ -1,6 +1,5 @@
 ; 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 
-simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck -check-prefix=GCN 
-check-prefix=SI %s
+; RUN: llc -mtriple=amdgcn-amdhsa -verify-machineinstrs 
-simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck -check-prefix=GCN 
%s
 ; RUN: opt -S -si-annotate-control-flow -mtriple=amdgcn-amdhsa 
-verify-machineinstrs -simplifycfg-require-and-preserve-domtree=1 < %s | 
FileCheck -check-prefix=SI-OPT %s
 
 define hidden void @widget() {

diff  --git a/llvm/test/CodeGen/AMDGPU/unsupported-calls.ll 
b/llvm/test/CodeGen/AMDGPU/unsupported-calls.ll
index 44c33347c9b5..62a2c1348c41 10064

[llvm-branch-commits] [clang] d015445 - Silence warning: comparison of integers of different signs: 'const unsigned int' and 'const long' [-Wsign-compare]

2021-01-07 Thread Alexandre Ganea via llvm-branch-commits

Author: Alexandre Ganea
Date: 2021-01-07T13:01:06-05:00
New Revision: d0154456e61c5ab79e25fc9b8bb684ebdca3a7c2

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

LOG: Silence warning: comparison of integers of different signs: 'const 
unsigned int' and 'const long' [-Wsign-compare]

(off_t being a signed type)

Added: 


Modified: 
clang/unittests/Basic/FileEntryTest.cpp

Removed: 




diff  --git a/clang/unittests/Basic/FileEntryTest.cpp 
b/clang/unittests/Basic/FileEntryTest.cpp
index a3e03e6c7c29..16c8e57d9a17 100644
--- a/clang/unittests/Basic/FileEntryTest.cpp
+++ b/clang/unittests/Basic/FileEntryTest.cpp
@@ -57,7 +57,7 @@ struct RefMaps {
 
 TEST(FileEntryTest, Constructor) {
   FileEntry FE;
-  EXPECT_EQ(0U, FE.getSize());
+  EXPECT_EQ(0, FE.getSize());
   EXPECT_EQ(0, FE.getModificationTime());
   EXPECT_EQ(nullptr, FE.getDir());
   EXPECT_EQ(0U, FE.getUniqueID().getDevice());



___
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] cf5415c - [PGO][PGSO] Let unroll hints take precedence over PGSO.

2021-01-07 Thread Hiroshi Yamauchi via llvm-branch-commits

Author: Hiroshi Yamauchi
Date: 2021-01-07T10:10:31-08:00
New Revision: cf5415c727dda0ea4b27ee16347d170f118b037b

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

LOG: [PGO][PGSO] Let unroll hints take precedence over PGSO.

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/test/Transforms/LoopUnroll/unroll-opt-attribute.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp 
b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 4cce05d595a8..d09f1ee22a75 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -218,8 +218,10 @@ TargetTransformInfo::UnrollingPreferences 
llvm::gatherUnrollingPreferences(
 
   // Apply size attributes
   bool OptForSize = L->getHeader()->getParent()->hasOptSize() ||
-llvm::shouldOptimizeForSize(L->getHeader(), PSI, BFI,
-PGSOQueryType::IRPass);
+// Let unroll hints / pragmas take precedence over PGSO.
+(hasUnrollTransformation(L) != TM_ForcedByUser &&
+ llvm::shouldOptimizeForSize(L->getHeader(), PSI, BFI,
+ PGSOQueryType::IRPass));
   if (OptForSize) {
 UP.Threshold = UP.OptSizeThreshold;
 UP.PartialThreshold = UP.PartialOptSizeThreshold;

diff  --git a/llvm/test/Transforms/LoopUnroll/unroll-opt-attribute.ll 
b/llvm/test/Transforms/LoopUnroll/unroll-opt-attribute.ll
index e219349fb093..884981bf8bf0 100644
--- a/llvm/test/Transforms/LoopUnroll/unroll-opt-attribute.ll
+++ b/llvm/test/Transforms/LoopUnroll/unroll-opt-attribute.ll
@@ -158,6 +158,38 @@ for.end:  ; preds 
= %for.body
 ; NPGSO-NOT:  phi
 ; NPGSO-NOT:  icmp
 
+;/ TEST 6 //
+
+; This test tests that unroll hints take precedence over PGSO and that this 
loop
+; gets unrolled even though it's cold.
+
+define i32 @Test6() !prof !14 {
+entry:
+  br label %for.body
+
+for.body: ; preds = %for.body, %entry
+  %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+  %arrayidx = getelementptr inbounds [24 x i32], [24 x i32]* @tab, i32 0, i32 
%i.05
+  store i32 %i.05, i32* %arrayidx, align 4
+  %inc = add nuw nsw i32 %i.05, 1
+  %exitcond = icmp eq i32 %inc, 24
+  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !15
+
+for.end:  ; preds = %for.body
+  ret i32 42
+}
+
+; PGSO-LABEL: @Test6
+; PGSO:  store
+; PGSO:  store
+; PGSO:  store
+; PGSO:  store
+; NPGSO-LABEL: @Test6
+; NPGSO:  store
+; NPGSO:  store
+; NPGSO:  store
+; NPGSO:  store
+
 !llvm.module.flags = !{!0}
 !0 = !{i32 1, !"ProfileSummary", !1}
 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
@@ -174,3 +206,5 @@ for.end:  ; preds = 
%for.body
 !12 = !{i32 999000, i64 100, i32 1}
 !13 = !{i32 99, i64 1, i32 2}
 !14 = !{!"function_entry_count", i64 0}
+!15 = !{!15, !16}
+!16 = !{!"llvm.loop.unroll.count", i32 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] c9122dd - CodeGen: Refactor regallocator command line and target selection

2021-01-07 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2021-01-07T13:13:25-05:00
New Revision: c9122ddef5213fbdd2d82c473a74e1742010f62f

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

LOG: CodeGen: Refactor regallocator command line and target selection

Make the sequence of passes to select and rewrite instructions to
physical registers be a target callback. This is to prepare to allow
targets to split register allocation into multiple phases.

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetPassConfig.h
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h 
b/llvm/include/llvm/CodeGen/TargetPassConfig.h
index 0cbb758a7ee8..b4787710379f 100644
--- a/llvm/include/llvm/CodeGen/TargetPassConfig.h
+++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h
@@ -460,10 +460,10 @@ class TargetPassConfig : public ImmutablePass {
   /// regalloc pass.
   virtual FunctionPass *createRegAllocPass(bool Optimized);
 
-  /// Add core register alloator passes which do the actual register assignment
+  /// Add core register allocator passes which do the actual register 
assignment
   /// and rewriting. \returns true if any passes were added.
-  virtual bool addRegAssignmentFast();
-  virtual bool addRegAssignmentOptimized();
+  virtual bool addRegAssignAndRewriteFast();
+  virtual bool addRegAssignAndRewriteOptimized();
 };
 
 void registerCodeGenCallback(PassInstrumentationCallbacks &PIC,

diff  --git a/llvm/lib/CodeGen/TargetPassConfig.cpp 
b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 41d96b9e6016..e844d03854e2 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -1308,7 +1308,7 @@ FunctionPass *TargetPassConfig::createRegAllocPass(bool 
Optimized) {
   return createTargetRegisterAllocator(Optimized);
 }
 
-bool TargetPassConfig::addRegAssignmentFast() {
+bool TargetPassConfig::addRegAssignAndRewriteFast() {
   if (RegAlloc != &useDefaultRegisterAllocator &&
   RegAlloc != &createFastRegisterAllocator)
 report_fatal_error("Must use fast (default) register allocator for 
unoptimized regalloc.");
@@ -1317,7 +1317,7 @@ bool TargetPassConfig::addRegAssignmentFast() {
   return true;
 }
 
-bool TargetPassConfig::addRegAssignmentOptimized() {
+bool TargetPassConfig::addRegAssignAndRewriteOptimized() {
   // Add the selected register allocation pass.
   addPass(createRegAllocPass(true));
 
@@ -1327,12 +1327,6 @@ bool TargetPassConfig::addRegAssignmentOptimized() {
   // Finally rewrite virtual registers.
   addPass(&VirtRegRewriterID);
 
-  // Perform stack slot coloring and post-ra machine LICM.
-  //
-  // FIXME: Re-enable coloring with register when it's capable of adding
-  // kill markers.
-  addPass(&StackSlotColoringID);
-
   return true;
 }
 
@@ -1348,7 +1342,7 @@ void TargetPassConfig::addFastRegAlloc() {
   addPass(&PHIEliminationID, false);
   addPass(&TwoAddressInstructionPassID, false);
 
-  addRegAssignmentFast();
+  addRegAssignAndRewriteFast();
 }
 
 /// Add standard target-independent passes that are tightly coupled with
@@ -1391,7 +1385,13 @@ void TargetPassConfig::addOptimizedRegAlloc() {
   // PreRA instruction scheduling.
   addPass(&MachineSchedulerID);
 
-  if (addRegAssignmentOptimized()) {
+  if (addRegAssignAndRewriteOptimized()) {
+// Perform stack slot coloring and post-ra machine LICM.
+//
+// FIXME: Re-enable coloring with register when it's capable of adding
+// kill markers.
+addPass(&StackSlotColoringID);
+
 // Allow targets to expand pseudo instructions depending on the choice of
 // registers before MachineCopyPropagation.
 addPostRewrite();

diff  --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp 
b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
index 85709eb731e2..21da566b639f 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -170,11 +170,11 @@ class NVPTXPassConfig : public TargetPassConfig {
   void addFastRegAlloc() override;
   void addOptimizedRegAlloc() override;
 
-  bool addRegAssignmentFast() override {
+  bool addRegAssignAndRewriteFast() override {
 llvm_unreachable("should not be used");
   }
 
-  bool addRegAssignmentOptimized() override {
+  bool addRegAssignAndRewriteOptimized() override {
 llvm_unreachable("should not be used");
   }
 

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 71e8e1485b75..af16d799d1dc 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -326,10 +326,10 @@ 

[llvm-branch-commits] [lld] 5c38ae3 - [WebAssembly] Fixed byval args missing DWARF DW_AT_LOCATION

2021-01-07 Thread Wouter van Oortmerssen via llvm-branch-commits

Author: Wouter van Oortmerssen
Date: 2021-01-07T10:31:38-08:00
New Revision: 5c38ae36c58f5b6bb4a32e9ec2187fde86cf94b8

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

LOG: [WebAssembly] Fixed byval args missing DWARF DW_AT_LOCATION

A struct in C passed by value did not get debug information. Such values are 
currently
lowered to a Wasm local even in -O0 (not to an alloca like on other archs), 
which becomes
a Target Index operand (TI_LOCAL). The DWARF writing code was not emitting 
locations
in for TI's specifically if the location is a single range (not a list).

In addition, the ExplicitLocals pass which removes the ARGUMENT pseudo 
instructions did
not update the associated DBG_VALUEs, and couldn't even find these values since 
the code
assumed such instructions are adjacent, which is not the case here.

Also fixed asm printing of TIs needed by a test.

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

Added: 
llvm/test/MC/WebAssembly/debug-byval-struct.ll

Modified: 
lld/test/wasm/debuginfo.test
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/Target/WebAssembly/WebAssemblyDebugValueManager.cpp
llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
llvm/test/CodeGen/WebAssembly/dbgvalue.ll

Removed: 




diff  --git a/lld/test/wasm/debuginfo.test b/lld/test/wasm/debuginfo.test
index 94d183a3c1d4..9cb1cc31e515 100644
--- a/lld/test/wasm/debuginfo.test
+++ b/lld/test/wasm/debuginfo.test
@@ -21,6 +21,7 @@ CHECK-NEXT:DW_AT_decl_line(3)
 CHECK-NEXT:DW_AT_prototyped(true)
 
 CHECK: DW_TAG_formal_parameter
+CHECK-NEXT:  DW_AT_location (DW_OP_WASM_location 0x0 0x0, 
DW_OP_stack_value)
 CHECK-NEXT:  DW_AT_name("t")
 CHECK-NEXT:  DW_AT_decl_file   
("/Users/yury/llvmwasm{{(/|\\)}}hi.c")
 CHECK-NEXT:  DW_AT_decl_line   (3)
@@ -45,7 +46,7 @@ CHECK-NEXT:  DW_AT_name   ("hi_foo.c")
 
 CHECK:   DW_TAG_variable
 CHECK-NEXT:DW_AT_name  ("y")
-CHECK-NEXT:DW_AT_type  (0x00a7 "int[2]")
+CHECK-NEXT:DW_AT_type  (0x00ac "int[2]")
 CHECK-NEXT:DW_AT_external  (true)
 CHECK-NEXT:DW_AT_decl_file ("{{.*}}hi_foo.c")
 CHECK-NEXT:DW_AT_decl_line (1)
@@ -67,7 +68,7 @@ CHECK-NEXT:DW_AT_encoding 
(DW_ATE_unsigned)
 
 CHECK:   DW_TAG_variable
 CHECK-NEXT:DW_AT_name  ("z")
-CHECK-NEXT:DW_AT_type  (0x00a7 "int[2]")
+CHECK-NEXT:DW_AT_type  (0x00ac "int[2]")
 CHECK-NEXT:DW_AT_external  (true)
 CHECK-NEXT:DW_AT_decl_file ("{{.*}}hi_foo.c")
 CHECK-NEXT:DW_AT_decl_line (8)
@@ -82,6 +83,7 @@ CHECK-NEXT:DW_AT_decl_file
("{{.*}}hi_foo.c")
 CHECK-NEXT:DW_AT_decl_line (3)
 
 CHECK: DW_TAG_formal_parameter
+CHECK-NEXT:  DW_AT_location (DW_OP_WASM_location 0x0 0x0, 
DW_OP_stack_value)
 CHECK-NEXT:  DW_AT_name("p")
 CHECK-NEXT:  DW_AT_decl_file   ("{{.*}}hi_foo.c")
 CHECK-NEXT:  DW_AT_decl_line   (3)

diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 85a5d0c59b83..d72a91825061 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -948,6 +948,8 @@ static bool emitDebugValueComment(const MachineInstr *MI, 
AsmPrinter &AP) {
   } else if (MI->getDebugOperand(0).isTargetIndex()) {
 auto Op = MI->getDebugOperand(0);
 OS << "!target-index(" << Op.getIndex() << "," << Op.getOffset() << ")";
+// NOTE: Want this comment at start of line, don't emit with AddComment.
+AP.OutStreamer->emitRawComment(OS.str());
 return true;
   } else {
 Register Reg;

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index ea279e4914b0..befc4bba19a2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -720,6 +720,13 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const 
DbgVariable &DV,
   addConstantFPValue(*VariableDie, DVal->getConstantFP());
 } else if (DVal->isConstantInt()) {
   addConstantValue(*VariableDie, DVal->getConstantInt(), DV.getType());
+} else if (DVal->isTargetIndexLocation()) {
+  DIELoc *Loc = new (DIEValueAllocator) DIELoc;
+  DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
+  const DIBasicType *BT = dyn_cast(
+ 

[llvm-branch-commits] [mlir] 906efee - [mlir] don't match the text produced only in debug mode in Python tests

2021-01-07 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2021-01-07T19:57:28+01:00
New Revision: 906efeec0a471be522588bd7cbb7f61459b2b437

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

LOG: [mlir] don't match the text produced only in debug mode in Python tests

Some Python bindings tests were using FileCheck to match parts of the
error description produced only in the debug compilation mode. Remove
these parts (but keep the main message) to ensure tests also pass when
running them in the release compilation mode.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/test/Bindings/Python/ir_attributes.py
mlir/test/Bindings/Python/ir_operation.py

Removed: 




diff  --git a/mlir/test/Bindings/Python/ir_attributes.py 
b/mlir/test/Bindings/Python/ir_attributes.py
index ce85dc3cf87a..91b0a92e989f 100644
--- a/mlir/test/Bindings/Python/ir_attributes.py
+++ b/mlir/test/Bindings/Python/ir_attributes.py
@@ -371,7 +371,7 @@ def testArrayAttr():
 try:
   ArrayAttr.get([42])
 except RuntimeError as e:
-  # CHECK: Error: Invalid attribute when attempting to create an 
ArrayAttribute (Unable to cast Python instance of type  to C++ 
type 'mlir::python::PyAttribute')
+  # CHECK: Error: Invalid attribute when attempting to create an 
ArrayAttribute
   print("Error: ", e)
 run(testArrayAttr)
 

diff  --git a/mlir/test/Bindings/Python/ir_operation.py 
b/mlir/test/Bindings/Python/ir_operation.py
index ba54e83f65e8..034b28ec25bf 100644
--- a/mlir/test/Bindings/Python/ir_operation.py
+++ b/mlir/test/Bindings/Python/ir_operation.py
@@ -566,17 +566,17 @@ def testCreateWithInvalidAttributes():
 try:
   Operation.create("module", attributes={None:StringAttr.get("name")})
 except Exception as e:
-  # CHECK: Invalid attribute key (not a string) when attempting to create 
the operation "module" (Unable to cast Python instance of type  to C++ type
+  # CHECK: Invalid attribute key (not a string) when attempting to create 
the operation "module"
   print(e)
 try:
   Operation.create("module", attributes={42:StringAttr.get("name")})
 except Exception as e:
-  # CHECK: Invalid attribute key (not a string) when attempting to create 
the operation "module" (Unable to cast Python instance of type  to 
C++ type
+  # CHECK: Invalid attribute key (not a string) when attempting to create 
the operation "module"
   print(e)
 try:
   Operation.create("module", attributes={"some_key":ctx})
 except Exception as e:
-  # CHECK: Invalid attribute value for the key "some_key" when attempting 
to create the operation "module" (Unable to cast Python instance of type  to C++ type 'mlir::python::PyAttribute')
+  # CHECK: Invalid attribute value for the key "some_key" when attempting 
to create the operation "module"
   print(e)
 try:
   Operation.create("module", attributes={"some_key":None})



___
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] 4c7148d - [SLP] remove opcode identifier for reduction; NFC

2021-01-07 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2021-01-07T14:07:27-05:00
New Revision: 4c7148d75cd7e75f169251cdab3e013819344cfd

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

LOG: [SLP] remove opcode identifier for reduction; NFC

Another step towards allowing intrinsics in reduction matching.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 8d6453f277ea..c8e5fdb458ff 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -772,7 +772,7 @@ class BoUpSLP {
   /// effectively impossible for the backend to undo.
   /// TODO: If load combining is allowed in the IR optimizer, this analysis
   ///   may not be necessary.
-  bool isLoadCombineReductionCandidate(unsigned ReductionOpcode) const;
+  bool isLoadCombineReductionCandidate(RecurKind RdxKind) const;
 
   /// Assume that a vector of stores of bitwise-or/shifted/zexted loaded values
   /// can be load combined in the backend. Load combining may not be allowed in
@@ -3896,8 +3896,8 @@ static bool isLoadCombineCandidateImpl(Value *Root, 
unsigned NumElts,
   return true;
 }
 
-bool BoUpSLP::isLoadCombineReductionCandidate(unsigned RdxOpcode) const {
-  if (RdxOpcode != Instruction::Or)
+bool BoUpSLP::isLoadCombineReductionCandidate(RecurKind RdxKind) const {
+  if (RdxKind != RecurKind::Or)
 return false;
 
   unsigned NumElts = VectorizableTree[0]->Scalars.size();
@@ -6987,7 +6987,7 @@ class HorizontalReduction {
   }
   if (V.isTreeTinyAndNotFullyVectorizable())
 break;
-  if (V.isLoadCombineReductionCandidate(RdxTreeInst.getOpcode()))
+  if (V.isLoadCombineReductionCandidate(RdxTreeInst.getKind()))
 break;
 
   V.computeMinimumValueSizes();



___
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] ad55d5c - Simplify vectorcall argument classification of HVAs, NFC

2021-01-07 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2021-01-07T11:14:18-08:00
New Revision: ad55d5c3f32f6598f8ac30b68f4961d82cdb1fed

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

LOG: Simplify vectorcall argument classification of HVAs, NFC

This reduces the number of `WinX86_64ABIInfo::classify` call sites from
3 to 1. The call sites were similar, but passed different values for
FreeSSERegs. Use variables instead of `if`s to manage that argument.

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index c6d8942208e8..d36c7344e284 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -1089,11 +1089,6 @@ struct CCState {
   unsigned FreeSSERegs = 0;
 };
 
-enum {
-  // Vectorcall only allows the first 6 parameters to be passed in registers.
-  VectorcallMaxParamNumAsReg = 6
-};
-
 /// X86_32ABIInfo - The X86-32 ABI information.
 class X86_32ABIInfo : public SwiftABIInfo {
   enum Class {
@@ -2405,10 +2400,8 @@ class WinX86_64ABIInfo : public SwiftABIInfo {
 private:
   ABIArgInfo classify(QualType Ty, unsigned &FreeSSERegs, bool IsReturnType,
   bool IsVectorCall, bool IsRegCall) const;
-  ABIArgInfo reclassifyHvaArgType(QualType Ty, unsigned &FreeSSERegs,
-  const ABIArgInfo ¤t) const;
-  void computeVectorCallArgs(CGFunctionInfo &FI, unsigned FreeSSERegs,
- bool IsVectorCall, bool IsRegCall) const;
+  ABIArgInfo reclassifyHvaArgForVectorCall(QualType Ty, unsigned &FreeSSERegs,
+   const ABIArgInfo ¤t) const;
 
   X86AVXABILevel AVXLevel;
 
@@ -4163,10 +4156,8 @@ Address X86_64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, 
Address VAListAddr,
   /*allowHigherAlign*/ false);
 }
 
-ABIArgInfo
-WinX86_64ABIInfo::reclassifyHvaArgType(QualType Ty, unsigned &FreeSSERegs,
-const ABIArgInfo ¤t) const {
-  // Assumes vectorCall calling convention.
+ABIArgInfo WinX86_64ABIInfo::reclassifyHvaArgForVectorCall(
+QualType Ty, unsigned &FreeSSERegs, const ABIArgInfo ¤t) const {
   const Type *Base = nullptr;
   uint64_t NumElts = 0;
 
@@ -4299,31 +4290,6 @@ ABIArgInfo WinX86_64ABIInfo::classify(QualType Ty, 
unsigned &FreeSSERegs,
   return ABIArgInfo::getDirect();
 }
 
-void WinX86_64ABIInfo::computeVectorCallArgs(CGFunctionInfo &FI,
- unsigned FreeSSERegs,
- bool IsVectorCall,
- bool IsRegCall) const {
-  unsigned Count = 0;
-  for (auto &I : FI.arguments()) {
-// Vectorcall in x64 only permits the first 6 arguments to be passed
-// as XMM/YMM registers.
-if (Count < VectorcallMaxParamNumAsReg)
-  I.info = classify(I.type, FreeSSERegs, false, IsVectorCall, IsRegCall);
-else {
-  // Since these cannot be passed in registers, pretend no registers
-  // are left.
-  unsigned ZeroSSERegsAvail = 0;
-  I.info = classify(I.type, /*FreeSSERegs=*/ZeroSSERegsAvail, false,
-IsVectorCall, IsRegCall);
-}
-++Count;
-  }
-
-  for (auto &I : FI.arguments()) {
-I.info = reclassifyHvaArgType(I.type, FreeSSERegs, I.info);
-  }
-}
-
 void WinX86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
   const unsigned CC = FI.getCallingConvention();
   bool IsVectorCall = CC == llvm::CallingConv::X86_VectorCall;
@@ -4358,13 +4324,25 @@ void WinX86_64ABIInfo::computeInfo(CGFunctionInfo &FI) 
const {
 FreeSSERegs = 16;
   }
 
+  unsigned ArgNum = 0;
+  unsigned ZeroSSERegs = 0;
+  for (auto &I : FI.arguments()) {
+// Vectorcall in x64 only permits the first 6 arguments to be passed as
+// XMM/YMM registers. After the sixth argument, pretend no vector
+// registers are left.
+unsigned *MaybeFreeSSERegs =
+(IsVectorCall && ArgNum >= 6) ? &ZeroSSERegs : &FreeSSERegs;
+I.info =
+classify(I.type, *MaybeFreeSSERegs, false, IsVectorCall, IsRegCall);
+++ArgNum;
+  }
+
   if (IsVectorCall) {
-computeVectorCallArgs(FI, FreeSSERegs, IsVectorCall, IsRegCall);
-  } else {
+// For vectorcall, assign aggregate HVAs to any free vector registers in a
+// second pass.
 for (auto &I : FI.arguments())
-  I.info = classify(I.type, FreeSSERegs, false, IsVectorCall, IsRegCall);
+  I.info = reclassifyHvaArgForVectorCall(I.type, FreeSSERegs, I.info);
   }
-
 }
 
 Address WinX86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,



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

[llvm-branch-commits] [openmp] abb174b - [OpenMP] Add example in Libomptarget Information docs

2021-01-07 Thread Joseph Huber via llvm-branch-commits

Author: Joseph Huber
Date: 2021-01-07T15:00:51-05:00
New Revision: abb174bbc100437556fd386d920a9939723e0647

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

LOG: [OpenMP] Add example in Libomptarget Information docs

Add an example to the OpenMP Documentation on the LIBOMPTARGET_INFO environment 
variable

Reviewed By: jdoerfert

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

Added: 


Modified: 
openmp/docs/design/Runtimes.rst

Removed: 




diff  --git a/openmp/docs/design/Runtimes.rst b/openmp/docs/design/Runtimes.rst
index c9f3a55c0067..1d52b6b8378c 100644
--- a/openmp/docs/design/Runtimes.rst
+++ b/openmp/docs/design/Runtimes.rst
@@ -98,6 +98,85 @@ Or, to enable every flag run with every bit set.
 
$ env LIBOMPTARGET_INFO=-1 ./your-application
 
+For example, given a small application implementing the ``ZAXPY`` BLAS routine,
+``Libomptarget`` can provide useful information about data mappings and thread
+usages.
+
+.. code-block:: c++
+
+#include 
+
+using complex = std::complex;
+
+void zaxpy(complex *X, complex *Y, complex D, std::size_t N) {
+#pragma omp target teams distribute parallel for
+  for (std::size_t i = 0; i < N; ++i)
+Y[i] = D * X[i] + Y[i];
+}
+
+int main() {
+  const std::size_t N = 1024;
+  complex X[N], Y[N], D;
+#pragma omp target data map(to:X[0 : N]) map(tofrom:Y[0 : N])
+  zaxpy(X, Y, D, N);
+}
+
+Compiling this code targeting ``nvptx64`` with all information enabled will
+provide the following output from the runtime library.
+
+.. code-block:: console
+
+$ clang++ -fopenmp -fopenmp-targets=nvptx64 -O3 -gline-tables-only 
zaxpy.cpp -o zaxpy
+$ env LIBOMPTARGET_INFO=-1 ./zaxpy
+
+.. code-block:: text
+
+Info: Device supports up to 65536 CUDA blocks and 1024 threads with a warp 
size of 32
+Info: Entering OpenMP data region at zaxpy.cpp:14:1 with 2 arguments:
+Info: to(X[0:N])[16384] 
+Info: tofrom(Y[0:N])[16384] 
+Info: OpenMP Host-Device pointer mappings after block at zaxpy.cpp:14:1:
+Info: Host Ptr   Target Ptr Size (B) RefCount Declaration
+Info: 0x7fff963f4000 0x7fd225004000 163841Y[0:N] at 
zaxpy.cpp:13:17
+Info: 0x7fff963f8000 0x7fd22500 163841X[0:N] at 
zaxpy.cpp:13:11
+Info: Entering OpenMP kernel at zaxpy.cpp:6:1 with 4 arguments:
+Info: firstprivate(N)[8] (implicit)
+Info: use_address(Y)[0] (implicit)
+Info: tofrom(D)[16] (implicit)
+Info: use_address(X)[0] (implicit)
+Info: Mapping exists (implicit) with HstPtrBegin=0x7ffe37d8be80, 
+  TgtPtrBegin=0x7f90ff004000, Size=0, updated RefCount=2, Name=Y
+Info: Mapping exists (implicit) with HstPtrBegin=0x7ffe37d8fe80, 
+  TgtPtrBegin=0x7f90ff00, Size=0, updated RefCount=2, Name=X
+Info: Launching kernel 
__omp_offloading_fd02_c2c4ac1a__Z5daxpyPNSt3__17complexIdEES2_S1_m_l6
+  with 8 blocks and 128 threads in SPMD mode
+Info: OpenMP Host-Device pointer mappings after block at zaxpy.cpp:6:1:
+Info: Host Ptr   Target Ptr Size (B) RefCount Declaration
+Info: 0x7fff963f4000 0x7fd225004000 163841Y[0:N] at 
zaxpy.cpp:13:17
+Info: 0x7fff963f8000 0x7fd22500 163841X[0:N] at 
zaxpy.cpp:13:11
+Info: Exiting OpenMP data region at zaxpy.cpp:14:1 with 2 arguments:
+Info: to(X[0:N])[16384] 
+Info: tofrom(Y[0:N])[16384] 
+
+From this information, we can see the OpenMP kernel being launched on the CUDA
+device with enough threads and blocks for all ``1024`` iterations of the loop 
in
+simplified :doc:`SPMD Mode `. The information from the OpenMP data
+region shows the two arrays ``X`` and ``Y`` being copied from the host to the
+device. This creates an entry in the host-device mapping table associating the
+host pointers to the newly created device data. The data mappings in the OpenMP
+device kernel show the default mappings being used for all the variables used
+implicitly on the device. Because ``X`` and ``Y`` are already mapped in the
+device's table, no new entries are created. Additionally, the default mapping
+shows that ``D`` will be copied back from the device once the OpenMP device
+kernel region ends even though it isn't written to. Finally, at the end of the
+OpenMP data region the entries for ``X`` and ``Y`` are removed from the table.
+
+.. toctree::
+   :hidden:
+   :maxdepth: 1
+
+   Offloading
+
 LLVM/OpenMP Target Host Runtime Plugins (``libomptarget.rtl.``)
 ---
 



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

[llvm-branch-commits] [llvm] 467e916 - Fix gcc5 build failure (NFC)

2021-01-07 Thread Mehdi Amini via llvm-branch-commits

Author: Mehdi Amini
Date: 2021-01-07T20:11:57Z
New Revision: 467e916d3032bc068995aa1b6b16655eb573e750

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

LOG: Fix gcc5 build failure (NFC)

The loop index was shadowing the container name.
It seems that we can just not use a for-range loop here since there is
an induction variable anyway.

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

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
index 12b9688c2ee0..3b6e263ee6d8 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -330,11 +330,11 @@ void AMDGPUCallLowering::processSplitArgs(
   // FIXME: This is mostly nasty pre-processing before handleAssignments. Most
   // of this should be performed by handleAssignments.
 
-  int SplitIdx = 0;
-  for (const ArgInfo &SplitArg : SplitArg) {
+  for (int SplitIdx = 0, e = SplitArg.size(); SplitIdx != e; ++SplitIdx) {
+const ArgInfo &CurSplitArg = SplitArg[SplitIdx];
 Register Reg = OrigArg.Regs[SplitIdx];
-EVT VT = EVT::getEVT(SplitArg.Ty);
-LLT LLTy = getLLTForType(*SplitArg.Ty, DL);
+EVT VT = EVT::getEVT(CurSplitArg.Ty);
+LLT LLTy = getLLTForType(*CurSplitArg.Ty, DL);
 
 unsigned NumParts = TLI.getNumRegistersForCallingConv(Ctx, CallConv, VT);
 MVT RegVT = TLI.getRegisterTypeForCallingConv(Ctx, CallConv, VT);
@@ -342,9 +342,8 @@ void AMDGPUCallLowering::processSplitArgs(
 if (NumParts == 1) {
   // No splitting to do, but we want to replace the original type (e.g. [1 
x
   // double] -> double).
-  SplitArgs.emplace_back(Reg, SplitArg.Ty, OrigArg.Flags, OrigArg.IsFixed);
-
-  ++SplitIdx;
+  SplitArgs.emplace_back(Reg, CurSplitArg.Ty, OrigArg.Flags,
+ OrigArg.IsFixed);
   continue;
 }
 
@@ -362,8 +361,6 @@ void AMDGPUCallLowering::processSplitArgs(
 }
 
 PerformArgSplit(SplitRegs, Reg, LLTy, PartLLT, SplitIdx);
-
-++SplitIdx;
   }
 }
 



___
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] 3854b81 - [Clang][Driver] Fix read-after-free when using /clang:

2021-01-07 Thread Alexandre Ganea via llvm-branch-commits

Author: Alexandre Ganea
Date: 2021-01-07T15:15:13-05:00
New Revision: 3854b81b0fd23adc9bab91bf68918d102dc31f51

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

LOG: [Clang][Driver] Fix read-after-free when using /clang:

Fixes PR42501.

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5c3ce478053a..418e1d3e8ec9 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1009,13 +1009,15 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   // objects than Args. This copies an Arg from one of those other 
InputArgLists
   // to the ownership of Args.
   auto appendOneArg = [&Args](const Arg *Opt, const Arg *BaseArg) {
-  unsigned Index = Args.MakeIndex(Opt->getSpelling());
-  Arg *Copy = new llvm::opt::Arg(Opt->getOption(), Opt->getSpelling(),
- Index, BaseArg);
-  Copy->getValues() = Opt->getValues();
-  if (Opt->isClaimed())
-Copy->claim();
-  Args.append(Copy);
+unsigned Index = Args.MakeIndex(Opt->getSpelling());
+Arg *Copy = new llvm::opt::Arg(Opt->getOption(), Args.getArgString(Index),
+   Index, BaseArg);
+Copy->getValues() = Opt->getValues();
+if (Opt->isClaimed())
+  Copy->claim();
+Copy->setOwnsValues(Opt->getOwnsValues());
+Opt->setOwnsValues(false);
+Args.append(Copy);
   };
 
   if (HasConfigFile)

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index db70fca5222c..4b6d71ed7b6d 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -686,6 +686,11 @@
 // CLANG-NOT: "--dependent-lib=libcmt"
 // CLANG-NOT: "-vectorize-slp"
 
+// Cover PR42501: clang-cl /clang: pass-through causes read-after-free with 
aliased options.
+// RUN: %clang_cl /clang:-save-temps /clang:-Wl,test1,test2 -### -- %s 2>&1 | 
FileCheck -check-prefix=SAVETEMPS %s
+// SAVETEMPS: "-save-temps=cwd"
+// SAVETEMPS: "test1" "test2"
+
 // Validate that the default triple is used when run an empty tools dir is 
specified
 // RUN: %clang_cl -vctoolsdir "" -### -- %s 2>&1 | FileCheck %s --check-prefix 
VCTOOLSDIR
 // VCTOOLSDIR: "-triple" "{{[a-zA-Z0-9_-]*}}-pc-windows-msvc19.11.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] [openmp] 9ae171b - [OpenMP][Docs] Add remarks intro section

2021-01-07 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2021-01-07T14:31:17-06:00
New Revision: 9ae171bcd38cdefa64c9dd5d763d16007eebcd0d

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

LOG: [OpenMP][Docs] Add remarks intro section

Reviewed By: jhuber6

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

Added: 


Modified: 
openmp/docs/remarks/OptimizationRemarks.rst

Removed: 




diff  --git a/openmp/docs/remarks/OptimizationRemarks.rst 
b/openmp/docs/remarks/OptimizationRemarks.rst
index 997a9a6d98c2..4c256fd99694 100644
--- a/openmp/docs/remarks/OptimizationRemarks.rst
+++ b/openmp/docs/remarks/OptimizationRemarks.rst
@@ -1,6 +1,31 @@
 OpenMP Optimization Remarks
 ===
 
+The :doc:`OpenMP-Aware optimization pass ` is able to
+generate compiler remarks for performed and missed optimisations. To emit them,
+pass ``-Rpass=openmp-opt``, ``-Rpass-analysis=openmp-opt``, and
+``-Rpass-missed=openmp-opt`` to the Clang invocation.  For more information and
+features of the remark system the clang documentation should be consulted:
+
++ `Clang options to emit optimization reports 
`_
++ `Clang diagnostic and remark flags 
`_
++ The `-foptimization-record-file flag
+  
`_
+  and the `-fsave-optimization-record flag
+  
`_
+
+
+.. _ompXXX:
+
+Some OpenMP remarks start with a "tag", like `[OMP100]`, which indicates that
+there is further information about them on this page. To directly jump to the
+respective entry, navigate to
+`https://openmp.llvm.org/docs/remarks/OptimizationRemarks.html#ompXXX 
`_ where 
`XXX` is
+the three digit code shown in the tag.
+
+
+
+
 
 .. _omp100:
 .. _omp_no_external_caller_in_target_region:



___
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] d970a28 - [OpenMP][Fix] Make the arch selector for x86_64 work

2021-01-07 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2021-01-07T14:31:18-06:00
New Revision: d970a285b8567b93aea39e7e4d10965fe8b7340c

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

LOG: [OpenMP][Fix] Make the arch selector for x86_64 work

The triple uses a bar "x86-64" instead of an underscore. Since we
have troubles accepting x86-64 as an identifier, we stick with
x86_64 in the frontend and translate it explicitly.

Reviewed By: tianshilei1992

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

Added: 
clang/test/OpenMP/declare_variant_ast_x86_64.c

Modified: 
llvm/lib/Frontend/OpenMP/OMPContext.cpp

Removed: 




diff  --git a/clang/test/OpenMP/declare_variant_ast_x86_64.c 
b/clang/test/OpenMP/declare_variant_ast_x86_64.c
new file mode 100644
index 0..c0be89a1c6127
--- /dev/null
+++ b/clang/test/OpenMP/declare_variant_ast_x86_64.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown %s 
-ast-dump | FileCheck %s
+// expected-no-diagnostics
+
+#pragma omp begin declare variant match(device={arch(x86_64)})
+
+void bar() {}
+
+// CHECK: FunctionDecl {{.*}} bar[device={arch(x86_64)}] 'void ()'
+
+#pragma omp end declare variant

diff  --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp 
b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
index e252c964e647c..39f047015d192 100644
--- a/llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -14,7 +14,9 @@
 
 #include "llvm/Frontend/OpenMP/OMPContext.h"
 #include "llvm/ADT/SetOperations.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -58,9 +60,12 @@ OMPContext::OMPContext(bool IsDeviceCompilation, Triple 
TargetTriple) {
 
   // Add the appropriate device architecture trait based on the triple.
 #define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) 
\
-  if (TraitSelector::TraitSelectorEnum == TraitSelector::device_arch)  
\
+  if (TraitSelector::TraitSelectorEnum == TraitSelector::device_arch) {
\
 if (TargetTriple.getArch() == TargetTriple.getArchTypeForLLVMName(Str))
\
-  ActiveTraits.set(unsigned(TraitProperty::Enum));
+  ActiveTraits.set(unsigned(TraitProperty::Enum)); 
\
+if (Str == "x86_64" && TargetTriple.getArch() == Triple::x86_64)   
\
+  ActiveTraits.set(unsigned(TraitProperty::Enum)); 
\
+  }
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
 
   // TODO: What exactly do we want to see as device ISA trait?



___
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] 36c4dc9 - [OpenMP][FIX] Ensure the isa trait is evaluated last

2021-01-07 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2021-01-07T14:31:20-06:00
New Revision: 36c4dc9b42fe2e6af4ab488b7c4013d5082b67f6

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

LOG: [OpenMP][FIX] Ensure the isa trait is evaluated last

Since isa can cause diagnostics we want it to be evaluated last to avoid
the "unknown isa" warning if the rest of the selector wouldn't match
anyway. That allows us to guard isa with arch properly.

Reviewed By: jhuber6

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

Added: 


Modified: 
clang/test/OpenMP/begin_declare_variant_messages.c
clang/test/OpenMP/declare_variant_messages.c
clang/test/OpenMP/declare_variant_messages.cpp
clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Removed: 




diff  --git a/clang/test/OpenMP/begin_declare_variant_messages.c 
b/clang/test/OpenMP/begin_declare_variant_messages.c
index a6ed043de102..5922153b2445 100644
--- a/clang/test/OpenMP/begin_declare_variant_messages.c
+++ b/clang/test/OpenMP/begin_declare_variant_messages.c
@@ -70,7 +70,7 @@ const int var;
 #pragma omp end declare variant
 #pragma omp begin declare variant match(implementation={vendor(score(5): ibm), 
kind(cpu)}) // expected-warning {{the context selector 'kind' is not valid for 
the context set 'implementation'; selector ignored}} expected-note {{the 
context selector 'kind' can be nested in the context set 'device'; try 
'match(device={kind(property)})'}} expected-note {{the ignored selector spans 
until here}}
 #pragma omp end declare variant
-#pragma omp begin declare variant match(device={xxx}) // expected-warning 
{{'xxx' is not a valid context selector for the context set 'device'; selector 
ignored}} expected-note {{context selector options are: 'kind' 'isa' 'arch'}} 
expected-note {{the ignored selector spans until here}}
+#pragma omp begin declare variant match(device={xxx}) // expected-warning 
{{'xxx' is not a valid context selector for the context set 'device'; selector 
ignored}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} 
expected-note {{the ignored selector spans until here}}
 #pragma omp end declare variant
 #pragma omp begin declare variant match(device={kind}) // expected-warning 
{{the context selector 'kind' in context set 'device' requires a context 
property defined in parentheses; selector ignored}} expected-note {{the ignored 
selector spans until here}}
 #pragma omp end declare variant

diff  --git a/clang/test/OpenMP/declare_variant_messages.c 
b/clang/test/OpenMP/declare_variant_messages.c
index 18bb7e331f27..1fad74b12d1e 100644
--- a/clang/test/OpenMP/declare_variant_messages.c
+++ b/clang/test/OpenMP/declare_variant_messages.c
@@ -36,7 +36,7 @@ int foo(void);
 #pragma omp declare variant(foo) match(implementation={vendor(score(foo()) 
ibm)}) // expected-warning {{expected '':'' after the score expression; '':'' 
assumed}} expected-warning {{score expressions in the OpenMP context selector 
need to be constant; foo() is not and will be ignored}}
 #pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm), 
vendor(llvm)}) // expected-warning {{the context selector 'vendor' was used 
already in the same 'omp declare variant' directive; selector ignored}} 
expected-note {{the previous context selector 'vendor' used here}} 
expected-note {{the ignored selector spans until here}}
 #pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm), 
kind(cpu)}) // expected-warning {{the context selector 'kind' is not valid for 
the context set 'implementation'; selector ignored}} expected-note {{the 
context selector 'kind' can be nested in the context set 'device'; try 
'match(device={kind(property)})'}} expected-note {{the ignored selector spans 
until here}}
-#pragma omp declare variant(foo) match(device={xxx}) // expected-warning 
{{'xxx' is not a valid context selector for the context set 'device'; selector 
ignored}} expected-note {{context selector options are: 'kind' 'isa' 'arch'}} 
expected-note {{the ignored selector spans until here}}
+#pragma omp declare variant(foo) match(device={xxx}) // expected-warning 
{{'xxx' is not a valid context selector for the context set 'device'; selector 
ignored}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} 
expected-note {{the ignored selector spans until here}}
 #pragma omp declare variant(foo) match(device={kind}) // expected-warning 
{{the context selector 'kind' in context set 'device' requires a context 
property defined in parentheses; selector ignored}} expected-note {{the ignored 
selector spans until here}}
 #pragma omp declare variant(foo) match(device={kind(}) // expected-error 
{{expected ')'}} expected-warning {{expected ide

[llvm-branch-commits] [clang] 275f30d - [clang] Change builtin object size when subobject is invalid

2021-01-07 Thread George Burgess IV via llvm-branch-commits

Author: Jeffrey T Mott
Date: 2021-01-07T12:34:07-08:00
New Revision: 275f30df8ad6de75e1f29e4b33eaeb67686caf0d

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

LOG: [clang] Change builtin object size when subobject is invalid

Motivating example:

```
  struct { int v[10]; } t[10];

  __builtin_object_size(
  &t[0].v[11], // access past end of subobject
  1// request remaining bytes of closest surrounding
   // subobject
  );
```

In GCC, this returns 0. https://godbolt.org/z/7TeGs7

In current clang, however, this returns 356, the number of bytes
remaining in the whole variable, as if the `type` was 0 instead of 1.
https://godbolt.org/z/6Kffox

This patch checks for the specific case where we're requesting a
subobject's size (type 1) but the subobject is invalid.

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

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGen/object-size.c

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 56181bbe1166..b153e22259f7 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11408,9 +11408,9 @@ static bool tryEvaluateBuiltinObjectSize(const Expr *E, 
unsigned Type,
   return false;
   }
 
-  // If we point to before the start of the object, there are no accessible
-  // bytes.
-  if (LVal.getLValueOffset().isNegative()) {
+  // If we point outside of the object, there are no accessible bytes.
+  if (LVal.getLValueOffset().isNegative() ||
+  ((Type & 1) && !LVal.Designator.isValidSubobject())) {
 Size = 0;
 return true;
   }

diff  --git a/clang/test/CodeGen/object-size.c 
b/clang/test/CodeGen/object-size.c
index ff54b11a0f04..dbf286138454 100644
--- a/clang/test/CodeGen/object-size.c
+++ b/clang/test/CodeGen/object-size.c
@@ -310,7 +310,7 @@ void test24() {
 void test25() {
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false, i1 true, 
i1
   gi = OBJECT_SIZE_BUILTIN((void*)0x1000, 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false, i1 true, 
i1
+  // CHECK: store i32 0
   gi = OBJECT_SIZE_BUILTIN((void*)0x1000, 1);
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 true, i1 true, i1
   gi = OBJECT_SIZE_BUILTIN((void*)0x1000, 2);
@@ -321,7 +321,7 @@ void test25() {
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false, i1 true, 
i1
   gi = OBJECT_SIZE_BUILTIN((void*)0 + 0x1000, 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 false, i1 true, 
i1
+  // CHECK: store i32 0
   gi = OBJECT_SIZE_BUILTIN((void*)0 + 0x1000, 1);
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* {{.*}}, i1 true, i1 true, i1
   gi = OBJECT_SIZE_BUILTIN((void*)0 + 0x1000, 2);
@@ -337,7 +337,7 @@ void test26() {
 
   // CHECK: store i32 316
   gi = OBJECT_SIZE_BUILTIN(&t[1].v[11], 0);
-  // CHECK: store i32 312
+  // CHECK: store i32 0
   gi = OBJECT_SIZE_BUILTIN(&t[1].v[12], 1);
   // CHECK: store i32 308
   gi = OBJECT_SIZE_BUILTIN(&t[1].v[13], 2);
@@ -433,7 +433,7 @@ void test29(struct DynStructVar *dv, struct DynStruct0 *d0,
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, 
i1
   gi = OBJECT_SIZE_BUILTIN(d0->snd, 0);
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, 
i1
+  // CHECK: store i32 0
   gi = OBJECT_SIZE_BUILTIN(d0->snd, 1);
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true, i1 true, 
i1
   gi = OBJECT_SIZE_BUILTIN(d0->snd, 2);
@@ -518,7 +518,7 @@ void test31() {
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, 
i1
   gi = OBJECT_SIZE_BUILTIN(&ds1[9].snd[0], 1);
 
-  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, 
i1
+  // CHECK: store i32 0
   gi = OBJECT_SIZE_BUILTIN(&ds0[9].snd[0], 1);
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true, 
i1



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


[llvm-branch-commits] [clang] 6e71015 - [OpenMP][Docs] Mark finished features as done

2021-01-07 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2021-01-07T14:39:18-06:00
New Revision: 6e7101530dae78efd7b5cdffc1338790ed3e5705

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

LOG: [OpenMP][Docs] Mark finished features as done

Reviewed By: ABataev

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index afa357a4d873..f0d8e8741304 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -193,7 +193,7 @@ implementation.
 
+--+--+--+---+
 | device extension | implicitly map 'this' (this[:1])  
   | :good:`done` | D55982  
  |
 
+--+--+--+---+
-| device extension | allow access to the reference count 
(omp_target_is_present)  | :part:`worked on`|   
|
+| device extension | allow access to the reference count 
(omp_target_is_present)  | :part:`done` |   
|
 
+--+--+--+---+
 | device extension | requires directive
   | :part:`partial`  | 
  |
 
+--+--+--+---+
@@ -215,7 +215,7 @@ implementation.
 
+--+--+--+---+
 | device extension | support close modifier on map clause  
   | :good:`done` | D55719,D55892   
  |
 
+--+--+--+---+
-| device extension | teams construct on the host device
   | :part:`worked on`| Clang part is done, r371553.
  |
+| device extension | teams construct on the host device
   | :part:`done` | r371553 
  |
 
+--+--+--+---+
 | device extension | support non-contiguous array sections for 
target update  | :good:`done` | 
  |
 
+--+--+--+---+



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


[llvm-branch-commits] [llvm] ce7f30b - [llvm-pdbutil] Don't crash when printing unknown CodeView type records

2021-01-07 Thread Alexandre Ganea via llvm-branch-commits

Author: Alexandre Ganea
Date: 2021-01-07T15:44:55-05:00
New Revision: ce7f30b2a874386a0ce089c98327acb65e87b04d

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

LOG: [llvm-pdbutil] Don't crash when printing unknown CodeView type records

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

Added: 
llvm/test/tools/llvm-pdbutil/Inputs/unknown-record.obj
llvm/test/tools/llvm-pdbutil/unknown-records.test

Modified: 
llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
llvm/tools/llvm-pdbutil/FormatUtil.cpp
llvm/tools/llvm-pdbutil/FormatUtil.h

Removed: 




diff  --git a/llvm/test/tools/llvm-pdbutil/Inputs/unknown-record.obj 
b/llvm/test/tools/llvm-pdbutil/Inputs/unknown-record.obj
new file mode 100644
index ..0be00ffdd922
Binary files /dev/null and 
b/llvm/test/tools/llvm-pdbutil/Inputs/unknown-record.obj 
diff er

diff  --git a/llvm/test/tools/llvm-pdbutil/unknown-records.test 
b/llvm/test/tools/llvm-pdbutil/unknown-records.test
new file mode 100644
index ..9773b85a0cd7
--- /dev/null
+++ b/llvm/test/tools/llvm-pdbutil/unknown-records.test
@@ -0,0 +1,3 @@
+; REQUIRES: diasdk
+; RUN: llvm-pdbutil dump -all %p/Inputs/unknown-record.obj | FileCheck %s
+; CHECK: UNKNOWN RECORD (0x1609)

diff  --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp 
b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
index aa185e8a2f22..3d8a86f34922 100644
--- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
@@ -738,21 +738,17 @@ namespace {
 constexpr uint32_t kNoneUdtKind = 0;
 constexpr uint32_t kSimpleUdtKind = 1;
 constexpr uint32_t kUnknownUdtKind = 2;
-const StringRef NoneLabel("");
-const StringRef SimpleLabel("");
-const StringRef UnknownLabel("");
-
 } // namespace
 
-static StringRef getUdtStatLabel(uint32_t Kind) {
+static std::string getUdtStatLabel(uint32_t Kind) {
   if (Kind == kNoneUdtKind)
-return NoneLabel;
+return "";
 
   if (Kind == kSimpleUdtKind)
-return SimpleLabel;
+return "";
 
   if (Kind == kUnknownUdtKind)
-return UnknownLabel;
+return "";
 
   return formatTypeLeafKind(static_cast(Kind));
 }
@@ -760,7 +756,7 @@ static StringRef getUdtStatLabel(uint32_t Kind) {
 static uint32_t getLongestTypeLeafName(const StatCollection &Stats) {
   size_t L = 0;
   for (const auto &Stat : Stats.Individual) {
-StringRef Label = getUdtStatLabel(Stat.first);
+std::string Label = getUdtStatLabel(Stat.first);
 L = std::max(L, Label.size());
   }
   return static_cast(L);
@@ -869,7 +865,7 @@ Error DumpOutputStyle::dumpUdtStats() {
 
   P.formatLine("{0}", fmt_repeat('-', TableWidth));
   for (const auto &Stat : UdtTargetStats.getStatsSortedBySize()) {
-StringRef Label = getUdtStatLabel(Stat.first);
+std::string Label = getUdtStatLabel(Stat.first);
 P.formatLine("{0} | {1:N}  {2:N}",
  fmt_align(Label, AlignStyle::Right, FieldWidth),
  fmt_align(Stat.second.Count, AlignStyle::Right, CD),

diff  --git a/llvm/tools/llvm-pdbutil/FormatUtil.cpp 
b/llvm/tools/llvm-pdbutil/FormatUtil.cpp
index c9ef19609496..b4837398f1d0 100644
--- a/llvm/tools/llvm-pdbutil/FormatUtil.cpp
+++ b/llvm/tools/llvm-pdbutil/FormatUtil.cpp
@@ -156,16 +156,17 @@ std::string llvm::pdb::formatSymbolKind(SymbolKind K) {
   return formatUnknownEnum(K);
 }
 
-StringRef llvm::pdb::formatTypeLeafKind(TypeLeafKind K) {
+std::string llvm::pdb::formatTypeLeafKind(TypeLeafKind K) {
   switch (K) {
 #define TYPE_RECORD(EnumName, value, name) 
\
   case EnumName:   
\
 return #EnumName;
 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
   default:
-llvm_unreachable("Unknown type leaf kind!");
+return formatv("UNKNOWN RECORD ({0:X})",
+   static_cast>(K))
+.str();
   }
-  return "";
 }
 
 std::string llvm::pdb::formatSegmentOffset(uint16_t Segment, uint32_t Offset) {

diff  --git a/llvm/tools/llvm-pdbutil/FormatUtil.h 
b/llvm/tools/llvm-pdbutil/FormatUtil.h
index 133a0eb40e12..b99ccec215b5 100644
--- a/llvm/tools/llvm-pdbutil/FormatUtil.h
+++ b/llvm/tools/llvm-pdbutil/FormatUtil.h
@@ -66,7 +66,7 @@ std::string typesetStringList(uint32_t IndentLevel,
 std::string formatChunkKind(codeview::DebugSubsectionKind Kind,
 bool Friendly = true);
 std::string formatSymbolKind(codeview::SymbolKind K);
-StringRef formatTypeLeafKind(codeview::TypeLeafKind K);
+std::string formatTypeLeafKind(codeview::TypeLeafKind K);
 
 /// Returns the number of digits in the given integer.
 inline int NumDigits(uint64_t N) {



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

[llvm-branch-commits] [mlir] 70b841a - [mlir] Adds argument attributes for using LLVM's sret and byval attributes

2021-01-07 Thread Eric Schweitz via llvm-branch-commits

Author: Eric Schweitz
Date: 2021-01-07T12:52:14-08:00
New Revision: 70b841ac317765c5c504334f7a22ac085f14ac2d

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

LOG: [mlir] Adds argument attributes for using LLVM's sret and byval attributes
to the conversion of LLVM IR dialect. These attributes are used in FIR to
support the lowering of Fortran using target-specific calling conventions.

Add roundtrip tests.

Add changes per review comments/concerns.

Reviewed By: ftynse

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

Added: 


Modified: 
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Dialect/LLVMIR/func.mlir
mlir/test/Target/llvmir-invalid.mlir

Removed: 




diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp 
b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 7700867bb461..492025ba37b4 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1102,6 +1102,22 @@ LogicalResult 
ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
   llvm::AttrBuilder().addAlignmentAttr(llvm::Align(attr.getInt(;
 }
 
+if (auto attr = func.getArgAttrOfType(argIdx, "llvm.sret")) {
+  auto argTy = mlirArg.getType();
+  if (!argTy.isa())
+return func.emitError(
+"llvm.sret attribute attached to LLVM non-pointer argument");
+  llvmArg.addAttr(llvm::Attribute::AttrKind::StructRet);
+}
+
+if (auto attr = func.getArgAttrOfType(argIdx, "llvm.byval")) {
+  auto argTy = mlirArg.getType();
+  if (!argTy.isa())
+return func.emitError(
+"llvm.byval attribute attached to LLVM non-pointer argument");
+  llvmArg.addAttr(llvm::Attribute::AttrKind::ByVal);
+}
+
 valueMapping[mlirArg] = &llvmArg;
 argIdx++;
   }

diff  --git a/mlir/test/Dialect/LLVMIR/func.mlir 
b/mlir/test/Dialect/LLVMIR/func.mlir
index 72e117d57a91..d9d7e17a9b50 100644
--- a/mlir/test/Dialect/LLVMIR/func.mlir
+++ b/mlir/test/Dialect/LLVMIR/func.mlir
@@ -87,6 +87,16 @@ module {
 llvm.return
   }
 
+  // CHECK: llvm.func @byvalattr(%{{.*}}: !llvm.ptr {llvm.byval})
+  llvm.func @byvalattr(%arg0: !llvm.ptr {llvm.byval}) {
+llvm.return
+  }
+
+  // CHECK: llvm.func @sretattr(%{{.*}}: !llvm.ptr {llvm.sret})
+  llvm.func @sretattr(%arg0: !llvm.ptr {llvm.sret}) {
+llvm.return
+  }
+
   // CHECK: llvm.func @variadic(...)
   llvm.func @variadic(...)
 

diff  --git a/mlir/test/Target/llvmir-invalid.mlir 
b/mlir/test/Target/llvmir-invalid.mlir
index 14117594e2f8..fcd98ef4b143 100644
--- a/mlir/test/Target/llvmir-invalid.mlir
+++ b/mlir/test/Target/llvmir-invalid.mlir
@@ -14,6 +14,19 @@ llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.noalias 
= true}) -> !llvm.f
 
 // -
 
+// expected-error @+1 {{llvm.sret attribute attached to LLVM non-pointer 
argument}}
+llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.sret}) -> !llvm.float {
+  llvm.return %arg0 : !llvm.float
+}
+// -
+
+// expected-error @+1 {{llvm.byval attribute attached to LLVM non-pointer 
argument}}
+llvm.func @invalid_noalias(%arg0 : !llvm.float {llvm.byval}) -> !llvm.float {
+  llvm.return %arg0 : !llvm.float
+}
+
+// -
+
 // expected-error @+1 {{llvm.align attribute attached to LLVM non-pointer 
argument}}
 llvm.func @invalid_align(%arg0 : !llvm.float {llvm.align = 4}) -> !llvm.float {
   llvm.return %arg0 : !llvm.float



___
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] 0b0f2e6 - [OpenMP][FIX] Avoid string literal comparison, use `StringRef::equal`

2021-01-07 Thread Johannes Doerfert via llvm-branch-commits

Author: Johannes Doerfert
Date: 2021-01-07T14:53:20-06:00
New Revision: 0b0f2e6ee0c3e52398a0d0c4a5131d4a23d8b1ee

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

LOG: [OpenMP][FIX] Avoid string literal comparison, use `StringRef::equal`

Added: 


Modified: 
llvm/lib/Frontend/OpenMP/OMPContext.cpp

Removed: 




diff  --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp 
b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
index 39f047015d19..11d8da097c6c 100644
--- a/llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -63,7 +63,8 @@ OMPContext::OMPContext(bool IsDeviceCompilation, Triple 
TargetTriple) {
   if (TraitSelector::TraitSelectorEnum == TraitSelector::device_arch) {
\
 if (TargetTriple.getArch() == TargetTriple.getArchTypeForLLVMName(Str))
\
   ActiveTraits.set(unsigned(TraitProperty::Enum)); 
\
-if (Str == "x86_64" && TargetTriple.getArch() == Triple::x86_64)   
\
+if (StringRef(Str) == StringRef("x86_64") &&   
\
+TargetTriple.getArch() == Triple::x86_64)  
\
   ActiveTraits.set(unsigned(TraitProperty::Enum)); 
\
   }
 #include "llvm/Frontend/OpenMP/OMPKinds.def"



___
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] [debuginfo-tests] 476db17 - Fix include path for check-gdb-mlir-support to include the MLIR binary dir

2021-01-07 Thread Mehdi Amini via llvm-branch-commits

Author: Mehdi Amini
Date: 2021-01-07T21:29:09Z
New Revision: 476db17dcb64ef3ec6e247f4b1c673b57f61a367

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

LOG: Fix include path for check-gdb-mlir-support to include the MLIR binary dir

This fixes a build failure:

fatal error: 'mlir/IR/BuiltinTypes.h.inc' file not found

Added: 


Modified: 
debuginfo-tests/CMakeLists.txt

Removed: 




diff  --git a/debuginfo-tests/CMakeLists.txt b/debuginfo-tests/CMakeLists.txt
index 4b6af5212fc8..0abbe4604a79 100644
--- a/debuginfo-tests/CMakeLists.txt
+++ b/debuginfo-tests/CMakeLists.txt
@@ -26,7 +26,9 @@ if ("mlir" IN_LIST LLVM_ENABLE_PROJECTS)
   add_llvm_executable(check-gdb-mlir-support
 llvm-prettyprinters/gdb/mlir-support.cpp
   )
-  target_include_directories(check-gdb-mlir-support PRIVATE 
${LLVM_EXTERNAL_MLIR_SOURCE_DIR}/include)
+  target_include_directories(check-gdb-mlir-support PRIVATE
+   ${LLVM_EXTERNAL_MLIR_SOURCE_DIR}/include
+   ${LLVM_BINARY_DIR}/tools/mlir/include)
   target_link_libraries(check-gdb-mlir-support PRIVATE MLIRIR)
   list(APPEND DEBUGINFO_TEST_DEPS check-gdb-mlir-support)
   set(MLIR_SOURCE_DIR  ${LLVM_EXTERNAL_MLIR_SOURCE_DIR})



___
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] [debuginfo-tests] 9e1aaa9 - Fix check-gdb-mlir-support build after MLIR API changed to take Context as first argument

2021-01-07 Thread Mehdi Amini via llvm-branch-commits

Author: Mehdi Amini
Date: 2021-01-07T21:30:39Z
New Revision: 9e1aaa9943b814c22ae03f4abb3171dac8062801

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

LOG: Fix check-gdb-mlir-support build after MLIR API changed to take Context as 
first argument

Added: 


Modified: 
debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp

Removed: 




diff  --git a/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp 
b/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp
index a65f62404de8..629ef1668c8f 100644
--- a/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp
+++ b/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp
@@ -15,13 +15,13 @@ mlir::Value Value({reinterpret_cast(0x8),
 mlir::Type Type(nullptr);
 mlir::Type IndexType = mlir::IndexType::get(&Context);
 mlir::Type IntegerType =
-mlir::IntegerType::get(3, mlir::IntegerType::Unsigned, &Context);
+mlir::IntegerType::get(&Context, 3, mlir::IntegerType::Unsigned);
 mlir::Type FloatType = mlir::Float32Type::get(&Context);
 mlir::Type MemRefType = mlir::MemRefType::get({4, 5}, FloatType);
 mlir::Type UnrankedMemRefType = mlir::UnrankedMemRefType::get(IntegerType, 6);
 mlir::Type VectorType = mlir::VectorType::get({1, 2}, FloatType);
 mlir::Type TupleType =
-mlir::TupleType::get(mlir::TypeRange({IndexType, FloatType}), &Context);
+mlir::TupleType::get(&Context, mlir::TypeRange({IndexType, FloatType}));
 
 auto UnknownLoc = mlir::UnknownLoc::get(&Context);
 auto FileLineColLoc = mlir::FileLineColLoc::get("file", 7, 8, &Context);



___
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] 1f9b6ef - GlobalISel: Add combine for G_UREM by power of 2

2021-01-07 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2021-01-07T16:36:35-05:00
New Revision: 1f9b6ef91ffd8ea487aa083d146c7568e7243457

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

LOG: GlobalISel: Add combine for G_UREM by power of 2

Really I want this in the legalizer, but this is a start.

Added: 
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-urem-pow-2.mir

Modified: 
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
llvm/include/llvm/Target/GlobalISel/Combine.td
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/urem.i32.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/urem.i64.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h 
b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index 432587ea46c4..0d240e90820f 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -400,6 +400,9 @@ class CombinerHelper {
   /// Check if operand \p OpIdx is undef.
   bool matchOperandIsUndef(MachineInstr &MI, unsigned OpIdx);
 
+  /// Check if operand \p OpIdx is known to be a power of 2.
+  bool matchOperandIsKnownToBeAPowerOfTwo(MachineInstr &MI, unsigned OpIdx);
+
   /// Erase \p MI
   bool eraseInst(MachineInstr &MI);
 
@@ -459,6 +462,9 @@ class CombinerHelper {
   bool matchPtrAddZero(MachineInstr &MI);
   bool applyPtrAddZero(MachineInstr &MI);
 
+  /// Combine G_UREM x, (known power of 2) to an add and bitmasking.
+  bool applySimplifyURemByPow2(MachineInstr &MI);
+
   bool matchCombineInsertVecElts(MachineInstr &MI,
  SmallVectorImpl &MatchInfo);
 

diff  --git a/llvm/include/llvm/Target/GlobalISel/Combine.td 
b/llvm/include/llvm/Target/GlobalISel/Combine.td
index 32aec75af1fa..e352e499d47c 100644
--- a/llvm/include/llvm/Target/GlobalISel/Combine.td
+++ b/llvm/include/llvm/Target/GlobalISel/Combine.td
@@ -296,6 +296,13 @@ def binop_left_to_zero: GICombineRule<
   (apply [{ return Helper.replaceSingleDefInstWithOperand(*${root}, 1); }])
 >;
 
+def urem_pow2_to_mask : GICombineRule<
+  (defs root:$root),
+  (match (wip_match_opcode G_UREM):$root,
+[{ return Helper.matchOperandIsKnownToBeAPowerOfTwo(*${root}, 2); }]),
+  (apply [{ return Helper.applySimplifyURemByPow2(*${root}); }])
+>;
+
 // Fold (x op 0) - > 0
 def binop_right_to_zero: GICombineRule<
   (defs root:$root),
@@ -560,7 +567,7 @@ def identity_combines : GICombineGroup<[select_same_val, 
right_identity_zero,
 def const_combines : GICombineGroup<[constant_fp_op, const_ptradd_to_i2p]>;
 
 def known_bits_simplifications : GICombineGroup<[
-  redundant_and, redundant_sext_inreg, redundant_or]>;
+  redundant_and, redundant_sext_inreg, redundant_or, urem_pow2_to_mask]>;
 
 def width_reduction_combines : GICombineGroup<[reduce_shl_of_extend]>;
 

diff  --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp 
b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index abc23da3d418..bbcf32a73fe0 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -2580,6 +2580,12 @@ bool CombinerHelper::matchOperandIsUndef(MachineInstr 
&MI, unsigned OpIdx) {
  getOpcodeDef(TargetOpcode::G_IMPLICIT_DEF, MO.getReg(), MRI);
 }
 
+bool CombinerHelper::matchOperandIsKnownToBeAPowerOfTwo(MachineInstr &MI,
+unsigned OpIdx) {
+  MachineOperand &MO = MI.getOperand(OpIdx);
+  return isKnownToBeAPowerOfTwo(MO.getReg(), MRI, KB);
+}
+
 bool CombinerHelper::replaceInstWithFConstant(MachineInstr &MI, double C) {
   assert(MI.getNumDefs() == 1 && "Expected only one def?");
   Builder.setInstr(MI);
@@ -3130,6 +3136,22 @@ bool CombinerHelper::applyPtrAddZero(MachineInstr &MI) {
   return true;
 }
 
+/// The second source operand is known to be a power of 2.
+bool CombinerHelper::applySimplifyURemByPow2(MachineInstr &MI) {
+  Register DstReg = MI.getOperand(0).getReg();
+  Register Src0 = MI.getOperand(1).getReg();
+  Register Pow2Src1 = MI.getOperand(2).getReg();
+  LLT Ty = MRI.getType(DstReg);
+  Builder.setInstrAndDebugLoc(MI);
+
+  // Fold (urem x, pow2) -> (and x, pow2-1)
+  auto NegOne = Builder.buildConstant(Ty, -1);
+  auto Add = Builder.buildAdd(Ty, Pow2Src1, NegOne);
+  Builder.buildAnd(DstReg, Src0, Add);
+  MI.eraseFromParent();
+  return true;
+}
+
 bool CombinerHelper::tryCombine(MachineInstr &MI) {
   if (tryCombineCopy(MI))
 return true;

diff  --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-urem-pow-2.mir 
b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-urem-pow-2.mir
new file mode 100644
index ..f92e32dab08f
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-urem-pow-2.mir
@@ -0,0 +1,156 @@
+# NOTE: Assertions have been autogene

[llvm-branch-commits] [clang] 63b42a0 - [NFC] clang/test/openMP/target_codegen.cpp should not depend on ssa name

2021-01-07 Thread Shilei Tian via llvm-branch-commits

Author: Jeroen Dobbelaere
Date: 2021-01-07T16:39:17-05:00
New Revision: 63b42a0514567d24df617e4587e80e4564ebf120

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

LOG: [NFC] clang/test/openMP/target_codegen.cpp should not depend on ssa name

This makes the test more robust to other changes.

Reviewed By: tianshilei1992

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

Added: 


Modified: 
clang/test/OpenMP/target_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_codegen.cpp 
b/clang/test/OpenMP/target_codegen.cpp
index c504ff6b7ac6..7dafa6ba13d4 100644
--- a/clang/test/OpenMP/target_codegen.cpp
+++ b/clang/test/OpenMP/target_codegen.cpp
@@ -397,7 +397,7 @@ int foo(int n) {
 // CHECK-DAG: [[RET:%.+]] = call i32 
@__tgt_target_nowait_mapper(%struct.ident_t* @{{.+}}, i64 [[DEVICE:%.+]], i8* 
@{{[^,]+}}, i32 2, i8** [[BPR:%[^,]+]], i8** [[PR:%[^,]+]], i64* [[SIZE:%.+]], 
i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT]], i32 0, i32 0), 
i8** null, i8** null)
 // CHECK-DAG: [[DEVICE]] = sext i32 [[DEV:%.+]] to i64
 // CHECK-DAG: [[DEV]] = load i32, i32* [[DEVADDR:%.+]], align
-// CHECK-DAG: [[DEVADDR]] = getelementptr inbounds [[ANON_T]], [[ANON_T]]* 
%12, i32 0, i32 2
+// CHECK-DAG: [[DEVADDR]] = getelementptr inbounds [[ANON_T]], [[ANON_T]]* 
{{%.+}}, i32 0, i32 2
 // CHECK-DAG: [[BPR]] = getelementptr inbounds [2 x i8*], [2 x i8*]* 
[[BPRADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
 // CHECK-DAG: [[PR]] = getelementptr inbounds [2 x i8*], [2 x i8*]* 
[[PRADDR:%.+]], i[[SZ]] 0, i[[SZ]] 0
 // CHECK-DAG: [[SIZE]] = getelementptr inbounds [2 x i64], [2 x i64]* 
[[SIZEADDR:%.+]], i[[SZ]] 0, i[[SZ]] 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] [libcxxabi] 85f86e8 - [libc++abi] Simplify __gxx_personality_v0

2021-01-07 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-01-07T14:05:46-08:00
New Revision: 85f86e8a3cf9e05347691fdde30e9e98a6657d92

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

LOG: [libc++abi] Simplify __gxx_personality_v0

In three cases we call `scan_eh_tab` to parse LSDA:

* `actions & _UA_SEARCH_PHASE`
* `actions & _UA_CLEANUP_PHASE && actions & _UA_HANDLER_FRAME && 
!native_exception`
* `actions & _UA_CLEANUP_PHASE && !(actions & _UA_HANDLER_FRAME)`

Check
`actions & _UA_CLEANUP_PHASE && actions & _UA_HANDLER_FRAME && 
native_exception` first,
then we can move three `scan_eh_tab` into one place.

Another simplification is that we can check whether the result of `scan_eh_tab`
is `_UA_CONTINUE_UNWIND` or `_UA_FATAL_PHASE1_ERROR` first. Then many of the
original checks will be dead and can thus be deleted.

Reviewed By: #libc_abi, ldionne

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

Added: 


Modified: 
libcxxabi/src/cxa_personality.cpp

Removed: 




diff  --git a/libcxxabi/src/cxa_personality.cpp 
b/libcxxabi/src/cxa_personality.cpp
index f27625776111..45639ec03bcd 100644
--- a/libcxxabi/src/cxa_personality.cpp
+++ b/libcxxabi/src/cxa_personality.cpp
@@ -962,78 +962,51 @@ __gxx_personality_v0
 bool native_exception = (exceptionClass & get_vendor_and_language) ==
 (kOurExceptionClass & get_vendor_and_language);
 scan_results results;
+// Process a catch handler for a native exception first.
+if (actions == (_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME) &&
+native_exception) {
+// Reload the results from the phase 1 cache.
+__cxa_exception* exception_header =
+(__cxa_exception*)(unwind_exception + 1) - 1;
+results.ttypeIndex = exception_header->handlerSwitchValue;
+results.actionRecord = exception_header->actionRecord;
+results.languageSpecificData = exception_header->languageSpecificData;
+results.landingPad =
+reinterpret_cast(exception_header->catchTemp);
+results.adjustedPtr = exception_header->adjustedPtr;
+
+// Jump to the handler.
+set_registers(unwind_exception, context, results);
+return _URC_INSTALL_CONTEXT;
+}
+
+// In other cases we need to scan LSDA.
+scan_eh_tab(results, actions, native_exception, unwind_exception, context);
+if (results.reason == _URC_CONTINUE_UNWIND ||
+results.reason == _URC_FATAL_PHASE1_ERROR)
+return results.reason;
+
 if (actions & _UA_SEARCH_PHASE)
 {
 // Phase 1 search:  All we're looking for in phase 1 is a handler that
 //   halts unwinding
-scan_eh_tab(results, actions, native_exception, unwind_exception, 
context);
-if (results.reason == _URC_HANDLER_FOUND)
-{
-// Found one.  Can we cache the results somewhere to optimize 
phase 2?
-if (native_exception)
-{
-__cxa_exception* exception_header = 
(__cxa_exception*)(unwind_exception+1) - 1;
-exception_header->handlerSwitchValue = 
static_cast(results.ttypeIndex);
-exception_header->actionRecord = results.actionRecord;
-exception_header->languageSpecificData = 
results.languageSpecificData;
-exception_header->catchTemp = 
reinterpret_cast(results.landingPad);
-exception_header->adjustedPtr = results.adjustedPtr;
-}
-return _URC_HANDLER_FOUND;
+assert(results.reason == _URC_HANDLER_FOUND);
+if (native_exception) {
+// For a native exception, cache the LSDA result.
+__cxa_exception* exc = (__cxa_exception*)(unwind_exception + 1) - 
1;
+exc->handlerSwitchValue = static_cast(results.ttypeIndex);
+exc->actionRecord = results.actionRecord;
+exc->languageSpecificData = results.languageSpecificData;
+exc->catchTemp = reinterpret_cast(results.landingPad);
+exc->adjustedPtr = results.adjustedPtr;
 }
-// Did not find a catching-handler.  Return the results of the scan
-//(normally _URC_CONTINUE_UNWIND, but could have been 
_URC_FATAL_PHASE1_ERROR
-// if we were called improperly).
-return results.reason;
+return _URC_HANDLER_FOUND;
 }
-if (actions & _UA_CLEANUP_PHASE)
-{
-// Phase 2 search:
-//  Did we find a catching handler in phase 1?
-if (actions & _UA_HANDLER_FRAME)
-{
-// Yes, phase 1 said we have a catching handler here.
-// Did we cache the results of the scan?
-if (native_exception)
-{
-// Yes, reload the results from the cache.
-__cxa_exc

[llvm-branch-commits] [llvm] d002cd4 - [test] Move coro-retcon-unreachable.ll into llvm/test

2021-01-07 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2021-01-07T14:06:01-08:00
New Revision: d002cd4e0f10f20c4f8b419ffa23d782636e46d8

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

LOG: [test] Move coro-retcon-unreachable.ll into llvm/test

Reviewed By: rjmccall

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

Added: 
llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll

Modified: 


Removed: 
clang/test/CodeGenCoroutines/coro-retcon-unreachable.ll



diff  --git a/clang/test/CodeGenCoroutines/coro-retcon-unreachable.ll 
b/llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
similarity index 100%
rename from clang/test/CodeGenCoroutines/coro-retcon-unreachable.ll
rename to llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll



___
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] 1a2eaeb - [CoroSplit][NewPM] Don't call LazyCallGraph functions to split when no clones

2021-01-07 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2021-01-07T14:06:35-08:00
New Revision: 1a2eaebc09c6a200f93b8beb37130c8b8aab3934

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

LOG: [CoroSplit][NewPM] Don't call LazyCallGraph functions to split when no 
clones

Apparently there can be no clones, as happens in
coro-retcon-unreachable.ll.

The alternative is to allow no split functions in
addSplitRefRecursiveFunctions(), but it seems better to have the caller
make sure it's not accidentally splitting no functions out.

Reviewed By: rnk

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

Added: 


Modified: 
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp 
b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 6fd894d4bcfa..e0bee13d83b4 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -1748,24 +1748,26 @@ static void updateCallGraphAfterCoroutineSplit(
 End->eraseFromParent();
   }
 
-  switch (Shape.ABI) {
-  case coro::ABI::Switch:
-// Each clone in the Switch lowering is independent of the other clones. 
Let
-// the LazyCallGraph know about each one separately.
-for (Function *Clone : Clones)
-  CG.addSplitFunction(N.getFunction(), *Clone);
-break;
-  case coro::ABI::Async:
-  case coro::ABI::Retcon:
-  case coro::ABI::RetconOnce:
-// Each clone in the Async/Retcon lowering references of the other clones.
-// Let the LazyCallGraph know about all of them at once.
-CG.addSplitRefRecursiveFunctions(N.getFunction(), Clones);
-break;
-  }
+  if (!Clones.empty()) {
+switch (Shape.ABI) {
+case coro::ABI::Switch:
+  // Each clone in the Switch lowering is independent of the other clones.
+  // Let the LazyCallGraph know about each one separately.
+  for (Function *Clone : Clones)
+CG.addSplitFunction(N.getFunction(), *Clone);
+  break;
+case coro::ABI::Async:
+case coro::ABI::Retcon:
+case coro::ABI::RetconOnce:
+  // Each clone in the Async/Retcon lowering references of the other 
clones.
+  // Let the LazyCallGraph know about all of them at once.
+  CG.addSplitRefRecursiveFunctions(N.getFunction(), Clones);
+  break;
+}
 
-  // Let the CGSCC infra handle the changes to the original function.
-  updateCGAndAnalysisManagerForCGSCCPass(CG, C, N, AM, UR, FAM);
+// Let the CGSCC infra handle the changes to the original function.
+updateCGAndAnalysisManagerForCGSCCPass(CG, C, N, AM, UR, FAM);
+  }
 
   // Do some cleanup and let the CGSCC infra see if we've cleaned up any edges
   // to the split functions.

diff  --git a/llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll 
b/llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
index 27ee2fd540a4..4a1c44061b48 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -coro-early -coro-split -S | FileCheck %s
+; RUN: opt < %s -passes='function(coro-early),cgscc(coro-split)' -S | 
FileCheck %s
 target datalayout = "E-p:64:64"
 
 %swift.type = type { i64 }



___
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] 3503c85 - Fixup Asserts+!AbiBreakingChecks fallout from db33f85c7124

2021-01-07 Thread David Blaikie via llvm-branch-commits

Author: David Blaikie
Date: 2021-01-07T14:18:19-08:00
New Revision: 3503c856819efc01ce210fa56e597ddfb7a4c1a1

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

LOG: Fixup Asserts+!AbiBreakingChecks fallout from db33f85c7124

Added: 


Modified: 
llvm/include/llvm/IR/ValueHandle.h
llvm/unittests/IR/ValueHandleTest.cpp
llvm/unittests/Support/DataExtractorTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/ValueHandle.h 
b/llvm/include/llvm/IR/ValueHandle.h
index 1324053800c7..a88b28ac7e62 100644
--- a/llvm/include/llvm/IR/ValueHandle.h
+++ b/llvm/include/llvm/IR/ValueHandle.h
@@ -486,7 +486,9 @@ class PoisoningVH
 #endif
 
   ValueTy *getValPtr() const {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
 assert(!Poisoned && "Accessed a poisoned value handle!");
+#endif
 return static_cast(getRawValPtr());
   }
   void setValPtr(ValueTy *P) { setRawValPtr(GetAsValue(P)); }

diff  --git a/llvm/unittests/IR/ValueHandleTest.cpp 
b/llvm/unittests/IR/ValueHandleTest.cpp
index 1aed8e1a1ee7..8eb6b5f89a40 100644
--- a/llvm/unittests/IR/ValueHandleTest.cpp
+++ b/llvm/unittests/IR/ValueHandleTest.cpp
@@ -186,7 +186,7 @@ TEST_F(ValueHandle, AssertingVH_ReducesToPointer) {
   EXPECT_EQ(sizeof(CastInst *), sizeof(AssertingVH));
 }
 
-#else  // !NDEBUG
+#elif LLVM_ENABLE_ABI_BREAKING_CHECKS // && !NDEBUG
 
 #ifdef GTEST_HAS_DEATH_TEST
 
@@ -530,6 +530,7 @@ TEST_F(ValueHandle, TrackingVH_Tracks) {
 }
 
 #ifdef GTEST_HAS_DEATH_TEST
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
 
 TEST_F(ValueHandle, PoisoningVH_Asserts) {
   PoisoningVH VH(BitcastV.get());
@@ -549,6 +550,8 @@ TEST_F(ValueHandle, PoisoningVH_Asserts) {
   // Don't clear anything out here as destroying the handles should be fine.
 }
 
+#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS
+
 TEST_F(ValueHandle, TrackingVH_Asserts) {
   {
 TrackingVH VH(BitcastV.get());

diff  --git a/llvm/unittests/Support/DataExtractorTest.cpp 
b/llvm/unittests/Support/DataExtractorTest.cpp
index 278e5885916c..41c40648b85e 100644
--- a/llvm/unittests/Support/DataExtractorTest.cpp
+++ b/llvm/unittests/Support/DataExtractorTest.cpp
@@ -214,7 +214,8 @@ TEST(DataExtractorTest, Cursor_chaining) {
   EXPECT_THAT_ERROR(C.takeError(), Succeeded());
 }
 
-#if defined(GTEST_HAS_DEATH_TEST) && defined(_DEBUG)
+#if defined(GTEST_HAS_DEATH_TEST) && defined(_DEBUG) &&
\
+LLVM_ENABLE_ABI_BREAKING_CHECKS
 TEST(DataExtractorDeathTest, Cursor) {
   DataExtractor DE(StringRef("AB"), false, 8);
 



___
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@lists.llvm.org

2021-01-07 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2021-01-07T14:20:16-08:00
New Revision: 973c35d3384ace023000eb2f86a2543ab9eb

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

LOG: [TableGen] Make CodeGenDAGPatterns::getSDNodeNamed take a StringRef 
instead of const std::string &.

All callers use a string literal and the getDef method the string
is passed to already takes a StringRef.

Added: 


Modified: 
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h

Removed: 




diff  --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp 
b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 6b6e1ec7b04d..2f8abe6dffed 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -3088,7 +3088,7 @@ CodeGenDAGPatterns::CodeGenDAGPatterns(RecordKeeper &R,
   VerifyInstructionFlags();
 }
 
-Record *CodeGenDAGPatterns::getSDNodeNamed(const std::string &Name) const {
+Record *CodeGenDAGPatterns::getSDNodeNamed(StringRef Name) const {
   Record *N = Records.getDef(Name);
   if (!N || !N->isSubClassOf("SDNode"))
 PrintFatalError("Error getting SDNode '" + Name + "'!");

diff  --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h 
b/llvm/utils/TableGen/CodeGenDAGPatterns.h
index c0c45a74de66..bc939fe9acc1 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h
@@ -1176,7 +1176,7 @@ class CodeGenDAGPatterns {
   const CodeGenTarget &getTargetInfo() const { return Target; }
   const TypeSetByHwMode &getLegalTypes() const { return LegalVTS; }
 
-  Record *getSDNodeNamed(const std::string &Name) const;
+  Record *getSDNodeNamed(StringRef Name) const;
 
   const SDNodeInfo &getSDNodeInfo(Record *R) const {
 auto F = SDNodes.find(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] [lld] eaadb41 - [LLD][COFF] When using PCH.OBJ, ensure func_id records indices are remapped under /DEBUG:GHASH

2021-01-07 Thread Alexandre Ganea via llvm-branch-commits

Author: Alexandre Ganea
Date: 2021-01-07T17:27:13-05:00
New Revision: eaadb41db6233cf1c9e882d74a31c1f9d6e211ff

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

LOG: [LLD][COFF] When using PCH.OBJ, ensure func_id records indices are 
remapped under /DEBUG:GHASH

Before this patch, when using LLD with /DEBUG:GHASH and MSVC precomp.OBJ files, 
we had a bunch of:

lld-link: warning: S_[GL]PROC32ID record in blabla.obj refers to PDB item index 
0x206ED1 which is not a LF[M]FUNC_ID record

This was caused by LF_FUNC_ID and LF_MFUNC_ID which didn't have correct mapping 
to the corresponding TPI records. The root issue was that the indexMapStorage 
was improperly re-assembled in UsePrecompSource::remapTpiWithGHashes.

After this patch, /DEBUG and /DEBUG:GHASH produce exactly the same debug infos 
in the PDB.

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

Added: 
lld/test/COFF/Inputs/precomp-ghash-obj1.obj
lld/test/COFF/Inputs/precomp-ghash-obj2.obj
lld/test/COFF/Inputs/precomp-ghash-precomp.obj
lld/test/COFF/precomp-ghash.test

Modified: 
lld/COFF/DebugTypes.cpp

Removed: 




diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 0c8bfd8ae5b8..d3996eabca7d 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -532,7 +532,7 @@ Error UsePrecompSource::mergeInPrecompHeaderObj() {
  TypeIndex::FirstNonSimpleIndex);
   assert(precompDependency.getTypesCount() <= precompSrc->tpiMap.size());
   // Use the previously remapped index map from the precompiled headers.
-  indexMapStorage.append(precompSrc->tpiMap.begin(),
+  indexMapStorage.insert(indexMapStorage.begin(), precompSrc->tpiMap.begin(),
  precompSrc->tpiMap.begin() +
  precompDependency.getTypesCount());
 
@@ -842,6 +842,7 @@ void UsePrecompSource::loadGHashes() {
 }
 
 void UsePrecompSource::remapTpiWithGHashes(GHashState *g) {
+  fillMapFromGHashes(g, indexMapStorage);
   // This object was compiled with /Yu, so process the corresponding
   // precompiled headers object (/Yc) first. Some type indices in the current
   // object are referencing data in the precompiled headers object, so we need
@@ -851,7 +852,6 @@ void UsePrecompSource::remapTpiWithGHashes(GHashState *g) {
 return;
   }
 
-  fillMapFromGHashes(g, indexMapStorage);
   tpiMap = indexMapStorage;
   ipiMap = indexMapStorage;
   mergeUniqueTypeRecords(file->debugTypes,

diff  --git a/lld/test/COFF/Inputs/precomp-ghash-obj1.obj 
b/lld/test/COFF/Inputs/precomp-ghash-obj1.obj
new file mode 100644
index ..078593e05f66
Binary files /dev/null and b/lld/test/COFF/Inputs/precomp-ghash-obj1.obj 
diff er

diff  --git a/lld/test/COFF/Inputs/precomp-ghash-obj2.obj 
b/lld/test/COFF/Inputs/precomp-ghash-obj2.obj
new file mode 100644
index ..f9cff3b9dfad
Binary files /dev/null and b/lld/test/COFF/Inputs/precomp-ghash-obj2.obj 
diff er

diff  --git a/lld/test/COFF/Inputs/precomp-ghash-precomp.obj 
b/lld/test/COFF/Inputs/precomp-ghash-precomp.obj
new file mode 100644
index ..b28ff77f19aa
Binary files /dev/null and b/lld/test/COFF/Inputs/precomp-ghash-precomp.obj 
diff er

diff  --git a/lld/test/COFF/precomp-ghash.test 
b/lld/test/COFF/precomp-ghash.test
new file mode 100644
index ..e9d1984ac40d
--- /dev/null
+++ b/lld/test/COFF/precomp-ghash.test
@@ -0,0 +1,53 @@
+
+# This test ensures that under /DEBUG:GHASH, IPI records LF_FUNC_ID/LF_MFUNC_ID
+# have properly remapped indices to corresponding TPI records.
+
+RUN: lld-link %p/Inputs/precomp-ghash-precomp.obj \
+RUN:%p/Inputs/precomp-ghash-obj1.obj\
+RUN:%p/Inputs/precomp-ghash-obj2.obj /debug:ghash /out:%t.exe /pdb:%t.pdb
+RUN: llvm-pdbutil dump -types -ids %t.pdb | FileCheck %s
+
+; These object files were generated via the following inputs and commands:
+; --
+; // precomp-ghash-obj.h
+; namespace NS {
+;   struct Foo {
+; explicit Foo(int x) : X(x) {}
+; int X;
+;   };
+;
+;   int func(const Foo &f);
+; }
+; --
+; // precomp-ghash-obj1.cpp
+; #include "precomp-ghash-obj.h"
+;
+; int main(int argc, char **argv) {
+;   NS::Foo f(argc);
+;   return NS::func(f);
+; }
+; --
+; // precomp-ghash-obj2.cpp
+; #include "precomp-ghash-obj.h"
+;
+; int NS::func(const Foo &f) {
+;   return 2 * f.X;
+; }
+; --
+; // precomp-ghash-precomp.cpp
+; #include "precomp-ghash-obj.h"
+; --
+; $ cl /c /Z7 /GS- precomp-ghash-precomp.cpp /Ycprecomp-ghash-obj.h
+; $ cl /c /Z7 /GS- precomp-ghash-obj1.cpp /Yuprecomp-ghash-obj.h
+; $ cl /c /Z7 /GS- precomp-ghash-obj2.c

[llvm-branch-commits] [lldb] 274afac - lldb: Add support for DW_AT_ranges on DW_TAG_subprograms

2021-01-07 Thread David Blaikie via llvm-branch-commits

Author: David Blaikie
Date: 2021-01-07T14:28:03-08:00
New Revision: 274afac9a17f43e5396a0d6c7a0741702596a7bd

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

LOG: lldb: Add support for DW_AT_ranges on DW_TAG_subprograms

gcc already produces debug info with this form
-freorder-block-and-partition
clang produces this sort of thing with -fbasic-block-sections and with a
coming-soon tweak to use ranges in DWARFv5 where they can allow greater
reuse of debug_addr than the low/high_pc forms.

This fixes the case of breaking on a function name, but leaves broken
printing a variable - a follow-up commit will add that and improve the
test case to match.

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

Added: 
lldb/test/Shell/SymbolFile/DWARF/Inputs/subprogram_ranges.s
lldb/test/Shell/SymbolFile/DWARF/subprogram_ranges.test

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 3eca911f4837..421298802645 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -687,13 +687,15 @@ const char *DWARFDebugInfoEntry::GetPubname(const 
DWARFUnit *cu) const {
 /// table, except that the actual DIE offset for the function is placed in the
 /// table instead of the compile unit offset.
 void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
-const DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
+DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
   if (m_tag) {
 if (m_tag == DW_TAG_subprogram) {
-  dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
-  dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
-  if (GetAttributeAddressRange(cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS)) {
-debug_aranges->AppendRange(GetOffset(), lo_pc, hi_pc);
+  DWARFRangeList ranges;
+  GetAttributeAddressRanges(cu, ranges,
+/*check_hi_lo_pc=*/true);
+  for (const auto &r : ranges) {
+debug_aranges->AppendRange(GetOffset(), r.GetRangeBase(),
+   r.GetRangeEnd());
   }
 }
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index 534d92e1feb9..0ba56a0a4161 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -42,7 +42,7 @@ class DWARFDebugInfoEntry {
   bool operator==(const DWARFDebugInfoEntry &rhs) const;
   bool operator!=(const DWARFDebugInfoEntry &rhs) const;
 
-  void BuildFunctionAddressRangeTable(const DWARFUnit *cu,
+  void BuildFunctionAddressRangeTable(DWARFUnit *cu,
   DWARFDebugAranges *debug_aranges) const;
 
   bool Extract(const lldb_private::DWARFDataExtractor &data,

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/Inputs/subprogram_ranges.s 
b/lldb/test/Shell/SymbolFile/DWARF/Inputs/subprogram_ranges.s
new file mode 100644
index ..1ff883c67f9e
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/Inputs/subprogram_ranges.s
@@ -0,0 +1,159 @@
+   .text
+   .file   "main.c"
+   .globl  main# -- Begin function main
+   .p2align4, 0x90
+   .type   main,@function
+main:   # @main
+.Lfunc_begin0:
+   .file   1 "/usr/local/google/home/blaikie/dev/scratch" "main.c"
+   .loc1 1 0   # main.c:1:0
+   .cfi_startproc
+# %bb.0:# %entry
+   pushq   %rbp
+   .cfi_def_cfa_offset 16
+   .cfi_offset %rbp, -16
+   movq%rsp, %rbp
+   .cfi_def_cfa_register %rbp
+   xorl%eax, %eax
+.Ltmp0:
+   .loc1 2 7 prologue_end  # main.c:2:7
+   movl$3, -4(%rbp)
+   .loc1 3 1   # main.c:3:1
+   popq%rbp
+   .cfi_def_cfa %rsp, 8
+   retq
+.Ltmp1:
+.Lfunc_end0:
+   .size   main, .Lfunc_end0-main
+   .cfi_endproc
+# -- End function
+   .section.debug_abbrev,"",@progbits
+   .byte   1   # Abbreviation Code
+   .byte   17  # DW_TAG_compile_unit
+   .byte   1   # DW_CHILDREN_yes
+   .byte   37  # DW_AT_producer
+   .byte   14  # DW_FORM_strp
+   .byte   19  # DW_AT_language

[llvm-branch-commits] [libcxx] c01202a - [libc++] Fix typo in run-buildbot

2021-01-07 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2021-01-07T17:37:09-05:00
New Revision: c01202a7efdd73fed280755184762b0ef8a5b78a

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

LOG: [libc++] Fix typo in run-buildbot

The installation directory was never meant to contain a brace.

Added: 


Modified: 
libcxx/utils/ci/run-buildbot

Removed: 




diff  --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 3a394de4f2d0..8b5dd46f697c 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -58,7 +58,7 @@ done
 
 MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
 BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
-INSTALL_DIR="${BUILD_DIR}/install}"
+INSTALL_DIR="${BUILD_DIR}/install"
 
 function clean() {
 rm -rf "${BUILD_DIR}"



___
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] 2cbbc6e - GlobalISel: Fail legalization on narrowing extload below memory size

2021-01-07 Thread Matt Arsenault via llvm-branch-commits

Author: Matt Arsenault
Date: 2021-01-07T17:40:34-05:00
New Revision: 2cbbc6e87c4b565a54c9bb85e34d464acb608f16

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

LOG: GlobalISel: Fail legalization on narrowing extload below memory size

Added: 


Modified: 
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-global.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-zextload-global.mir

Removed: 




diff  --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp 
b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index 7b346a1bbbec..61b2611866f2 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -962,10 +962,15 @@ LegalizerHelper::LegalizeResult 
LegalizerHelper::narrowScalar(MachineInstr &MI,
 
 Register TmpReg = MRI.createGenericVirtualRegister(NarrowTy);
 auto &MMO = **MI.memoperands_begin();
-if (MMO.getSizeInBits() == NarrowSize) {
+unsigned MemSize = MMO.getSizeInBits();
+
+if (MemSize == NarrowSize) {
   MIRBuilder.buildLoad(TmpReg, PtrReg, MMO);
-} else {
+} else if (MemSize < NarrowSize) {
   MIRBuilder.buildLoadInstr(MI.getOpcode(), TmpReg, PtrReg, MMO);
+} else if (MemSize > NarrowSize) {
+  // FIXME: Need to split the load.
+  return UnableToLegalize;
 }
 
 if (ZExt)

diff  --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-global.mir 
b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-global.mir
index b6633adbd79c..236dcf42f851 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-global.mir
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-global.mir
@@ -11,6 +11,7 @@
 # ERR-NEXT: remark: :0:0: unable to legalize instruction: %1:_(<2 x 
s32>) = G_SEXTLOAD %0:_(p1) :: (load 4, addrspace 1) (in function: 
test_sextload_global_v2i32_from_4)
 # ERR-NEXT: remark: :0:0: unable to legalize instruction: %1:_(<2 x 
s64>) = G_SEXTLOAD %0:_(p1) :: (load 4, addrspace 1) (in function: 
test_sextload_global_v2i64_from_4)
 # ERR-NEXT: remark: :0:0: unable to legalize instruction: %1:_(<2 x 
s64>) = G_SEXTLOAD %0:_(p1) :: (load 8, addrspace 1) (in function: 
test_sextload_global_v2i64_from_8)
+# ERR-NEXT: remark: :0:0: unable to legalize instruction: %1:_(s128) 
= G_SEXTLOAD %0:_(p1) :: (load 8, addrspace 1) (in function: 
test_sextload_global_s128_8)
 # ERR-NOT: remark
 
 ---
@@ -315,3 +316,22 @@ body: |
 %1:_(<2 x s64>) = G_SEXTLOAD %0 :: (load 8, addrspace 1)
 $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %1
 ...
+
+---
+name: test_sextload_global_s128_8
+body: |
+  bb.0:
+liveins: $vgpr0_vgpr1
+
+; GFX8-LABEL: name: test_sextload_global_s128_8
+; GFX8: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
+; GFX8: [[SEXTLOAD:%[0-9]+]]:_(s128) = G_SEXTLOAD [[COPY]](p1) :: (load 8, 
addrspace 1)
+; GFX8: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY [[SEXTLOAD]](s128)
+; GFX6-LABEL: name: test_sextload_global_s128_8
+; GFX6: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
+; GFX6: [[SEXTLOAD:%[0-9]+]]:_(s128) = G_SEXTLOAD [[COPY]](p1) :: (load 8, 
addrspace 1)
+; GFX6: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY [[SEXTLOAD]](s128)
+%0:_(p1) = COPY $vgpr0_vgpr1
+%1:_(s128) = G_SEXTLOAD %0 :: (load 8, addrspace 1)
+$vgpr0_vgpr1_vgpr2_vgpr3 = COPY %1
+...

diff  --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-zextload-global.mir 
b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-zextload-global.mir
index 80ea67233550..4177d2e2bba7 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-zextload-global.mir
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-zextload-global.mir
@@ -11,6 +11,7 @@
 # ERR-NEXT: remark: :0:0: unable to legalize instruction: %1:_(<2 x 
s32>) = G_ZEXTLOAD %0:_(p1) :: (load 4, addrspace 1) (in function: 
test_zextload_global_v2i32_from_4)
 # ERR-NEXT: remark: :0:0: unable to legalize instruction: %1:_(<2 x 
s64>) = G_ZEXTLOAD %0:_(p1) :: (load 4, addrspace 1) (in function: 
test_zextload_global_v2i64_from_4)
 # ERR-NEXT: remark: :0:0: unable to legalize instruction: %1:_(<2 x 
s64>) = G_ZEXTLOAD %0:_(p1) :: (load 8, addrspace 1) (in function: 
test_zextload_global_v2i64_from_8)
+# ERR-NEXT: remark: :0:0: unable to legalize instruction: %1:_(s128) 
= G_ZEXTLOAD %0:_(p1) :: (load 8, addrspace 1) (in function: 
test_zextload_global_s128_8)
 # ERR-NOT: remark
 
 ---
@@ -315,3 +316,22 @@ body: |
 %1:_(<2 x s64>) = G_ZEXTLOAD %0 :: (load 8, addrspace 1)
 $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %1
 ...
+
+---
+name: test_zextload_global_s128_8
+body: |
+  bb.0:
+liveins: $vgpr0_vgpr1
+
+; GFX8-LABEL: name: test_zextload_global_s128_8
+; GFX8: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
+; GFX8: [[ZEXTLOAD:%[0-9]+]]:_(s128) = G_ZEXTLOAD 

[llvm-branch-commits] [clang] f78d6af - [hip] Enable HIP compilation with ` on MSVC.

2021-01-07 Thread Michael Liao via llvm-branch-commits

Author: Michael Liao
Date: 2021-01-07T17:41:28-05:00
New Revision: f78d6af7319aa676a0f9f6cbb982f21c96e9aac5

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

LOG: [hip] Enable HIP compilation with ` on MSVC.

- MSVC has different `` implementation which calls into functions
  declared in ``. Provide their device-side implementation to enable
  `` compilation on HIP Windows.

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

Added: 


Modified: 
clang/lib/Headers/__clang_hip_cmath.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_cmath.h 
b/clang/lib/Headers/__clang_hip_cmath.h
index 3a702587ee17..128d64e271b8 100644
--- a/clang/lib/Headers/__clang_hip_cmath.h
+++ b/clang/lib/Headers/__clang_hip_cmath.h
@@ -624,6 +624,34 @@ _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif
 
+// Define device-side math functions from  on MSVC.
+#if defined(_MSC_VER)
+#if defined(__cplusplus)
+extern "C" {
+#endif // defined(__cplusplus)
+__DEVICE__ __attribute__((overloadable)) double _Cosh(double x, double y) {
+  return cosh(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) float _FCosh(float x, float y) {
+  return coshf(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) short _Dtest(double *p) {
+  return fpclassify(*p);
+}
+__DEVICE__ __attribute__((overloadable)) short _FDtest(float *p) {
+  return fpclassify(*p);
+}
+__DEVICE__ __attribute__((overloadable)) double _Sinh(double x, double y) {
+  return sinh(x) * y;
+}
+__DEVICE__ __attribute__((overloadable)) float _FSinh(float x, float y) {
+  return sinhf(x) * y;
+}
+#if defined(__cplusplus)
+}
+#endif // defined(__cplusplus)
+#endif // defined(_MSC_VER)
+
 #pragma pop_macro("__DEVICE__")
 
 #endif // __CLANG_HIP_CMATH_H__



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


[llvm-branch-commits] [openmp] 2ce1681 - [OpenMP] Always print error messages in libomptarget CUDA plugin

2021-01-07 Thread via llvm-branch-commits

Author: Joseph Huber
Date: 2021-01-07T17:47:32-05:00
New Revision: 2ce16810f28379b0a56f7036895a04e18d6b4506

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

LOG: [OpenMP] Always print error messages in libomptarget CUDA plugin

Summary:
Currently error messages from the CUDA plugins are only printed to the user if 
they have debugging enabled. Change this behaviour to always print the messages 
that result in offloading failure. This improves the error messages by 
indidcating what happened when the error occurs in the plugin library, such as 
a segmentation fault on the device.

Reviewed by: jdoerfert

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

Added: 


Modified: 
openmp/libomptarget/plugins/cuda/src/rtl.cpp

Removed: 




diff  --git a/openmp/libomptarget/plugins/cuda/src/rtl.cpp 
b/openmp/libomptarget/plugins/cuda/src/rtl.cpp
index 4fac6a76710e..a22195bae966 100644
--- a/openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -33,18 +33,29 @@
   const char *errStr = nullptr;
\
   CUresult errStr_status = cuGetErrorString(err, &errStr); 
\
   if (errStr_status == CUDA_ERROR_INVALID_VALUE)   
\
-DP("Unrecognized CUDA error code: %d\n", err); 
\
+REPORT("Unrecognized CUDA error code: %d\n", err); 
\
   else if (errStr_status == CUDA_SUCCESS)  
\
-DP("CUDA error is: %s\n", errStr); 
\
+REPORT("CUDA error is: %s\n", errStr); 
\
   else {   
\
-DP("Unresolved CUDA error code: %d\n", err);   
\
-DP("Unsuccessful cuGetErrorString return status: %d\n",
\
-   errStr_status); 
\
+REPORT("Unresolved CUDA error code: %d\n", err);   
\
+REPORT("Unsuccessful cuGetErrorString return status: %d\n",
\
+   errStr_status); 
\
   }
\
+} else {   
\
+  const char *errStr = nullptr;
\
+  CUresult errStr_status = cuGetErrorString(err, &errStr); 
\
+  if (errStr_status == CUDA_SUCCESS)   
\
+REPORT("%s \n", errStr);   
\
 }  
\
   } while (false)
 #else // OMPTARGET_DEBUG
-#define CUDA_ERR_STRING(err) {}
+#define CUDA_ERR_STRING(err)   
\
+  do { 
\
+const char *errStr = nullptr;  
\
+CUresult errStr_status = cuGetErrorString(err, &errStr);   
\
+if (errStr_status == CUDA_SUCCESS) 
\
+  REPORT("%s \n", errStr); 
\
+  } while (false)
 #endif // OMPTARGET_DEBUG
 
 #include "../../common/elf_common.c"
@@ -90,7 +101,7 @@ bool checkResult(CUresult Err, const char *ErrMsg) {
   if (Err == CUDA_SUCCESS)
 return true;
 
-  DP("%s", ErrMsg);
+  REPORT("%s", ErrMsg);
   CUDA_ERR_STRING(Err);
   return false;
 }
@@ -101,9 +112,9 @@ int memcpyDtoD(const void *SrcPtr, void *DstPtr, int64_t 
Size,
   cuMemcpyDtoDAsync((CUdeviceptr)DstPtr, (CUdeviceptr)SrcPtr, Size, 
Stream);
 
   if (Err != CUDA_SUCCESS) {
-DP("Error when copying data from device to device. Pointers: src "
-   "= " DPxMOD ", dst = " DPxMOD ", size = %" PRId64 "\n",
-   DPxPTR(SrcPtr), DPxPTR(DstPtr), Size);
+REPORT("Error when copying data from device to device. Pointers: src "
+   "= " DPxMOD ", dst = " DPxMOD ", size = %" PRId64 "\n",
+   DPxPTR(SrcPtr), DPxPTR(DstPtr), Size);
 CUDA_ERR_STRING(Err);
 return OFFLOAD_FAIL;
   }
@@ -501,12 +512,11 @@ class DeviceRTLTy {
   DeviceData[DeviceId].BlocksPerGrid = EnvTeamLimit;
 }
 
-if (getDebugLevel() || (getInfoLevel() & OMP_INFOTYPE_PLUGIN_KERNEL))
-  INFO(DeviceId,
-   "Device supports up to %d CUDA blocks and %d threads with a "
-   "warp size of %d\n",
-   DeviceData[DeviceId].BlocksPerGrid,
-   DeviceData[DeviceId].ThreadsPerBlock, 
De

[llvm-branch-commits] [llvm] 0992bf4 - [NewPM][Hexagon] Fix HexagonVectorLoopCarriedReusePass position in pipeline

2021-01-07 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2021-01-07T15:00:19-08:00
New Revision: 0992bf4e3f904e465fd8520b9852e305efd86809

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

LOG: [NewPM][Hexagon] Fix HexagonVectorLoopCarriedReusePass position in pipeline

In https://reviews.llvm.org/D88138 this was incorrectly added with
registerOptimizerLastEPCallback(), when it should be
registerLoopOptimizerEndEPCallback(), matching the legacy PM's
EP_LoopOptimizerEnd.

Reviewed By: rnk

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

Added: 


Modified: 
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp

Removed: 




diff  --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp 
b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
index 23c047e0c23b..ba0f45fe09f7 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
@@ -287,13 +287,9 @@ void 
HexagonTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB,
   [=](LoopPassManager &LPM, PassBuilder::OptimizationLevel Level) {
 LPM.addPass(HexagonLoopIdiomRecognitionPass());
   });
-  PB.registerOptimizerLastEPCallback(
-  [=](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
-LoopPassManager LPM(DebugPassManager);
-FunctionPassManager FPM(DebugPassManager);
+  PB.registerLoopOptimizerEndEPCallback(
+  [=](LoopPassManager &LPM, PassBuilder::OptimizationLevel Level) {
 LPM.addPass(HexagonVectorLoopCarriedReusePass());
-FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM)));
-MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   });
 }
 



___
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] 15f5971 - [LLDB][RISCV] Add RISC-V ArchSpec and rv32/rv64 variant detection

2021-01-07 Thread Luís Marques via llvm-branch-commits

Author: Luís Marques
Date: 2021-01-07T23:02:55Z
New Revision: 15f5971150684b656005cfd5b744c1a34477ff60

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

LOG: [LLDB][RISCV] Add RISC-V ArchSpec and rv32/rv64 variant detection

Adds the RISC-V ArchSpec bits contributed by @simoncook as part of D62732,
plus logic to distinguish between riscv32 and riscv64 based on ELF class.

The patch follows the implementation approach previously used for MIPS.
It defines RISC-V architecture subtypes and inspects the ELF header,
namely the ELF class, to detect the right subtype.

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

Added: 
lldb/test/Shell/ObjectFile/ELF/riscv-arch.yaml

Modified: 
lldb/include/lldb/Utility/ArchSpec.h
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Utility/ArchSpec.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/ArchSpec.h 
b/lldb/include/lldb/Utility/ArchSpec.h
index a727d5ca4f79..b35766d3d9cf 100644
--- a/lldb/include/lldb/Utility/ArchSpec.h
+++ b/lldb/include/lldb/Utility/ArchSpec.h
@@ -92,6 +92,12 @@ class ArchSpec {
 eARM_abi_hard_float = 0x0400
   };
 
+  enum RISCVSubType {
+eRISCVSubType_unknown,
+eRISCVSubType_riscv32,
+eRISCVSubType_riscv64,
+  };
+
   enum Core {
 eCore_arm_generic,
 eCore_arm_armv4,
@@ -184,6 +190,9 @@ class ArchSpec {
 eCore_hexagon_hexagonv4,
 eCore_hexagon_hexagonv5,
 
+eCore_riscv32,
+eCore_riscv64,
+
 eCore_uknownMach32,
 eCore_uknownMach64,
 

diff  --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 82a08a235084..cad9ce218b10 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -296,9 +296,23 @@ static uint32_t mipsVariantFromElfFlags (const 
elf::ELFHeader &header) {
   return arch_variant;
 }
 
+static uint32_t riscvVariantFromElfFlags(const elf::ELFHeader &header) {
+  uint32_t fileclass = header.e_ident[EI_CLASS];
+  switch (fileclass) {
+  case llvm::ELF::ELFCLASS32:
+return ArchSpec::eRISCVSubType_riscv32;
+  case llvm::ELF::ELFCLASS64:
+return ArchSpec::eRISCVSubType_riscv64;
+  default:
+return ArchSpec::eRISCVSubType_unknown;
+  }
+}
+
 static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
   if (header.e_machine == llvm::ELF::EM_MIPS)
 return mipsVariantFromElfFlags(header);
+  else if (header.e_machine == llvm::ELF::EM_RISCV)
+return riscvVariantFromElfFlags(header);
 
   return LLDB_INVALID_CPUTYPE;
 }

diff  --git a/lldb/source/Utility/ArchSpec.cpp 
b/lldb/source/Utility/ArchSpec.cpp
index b0cbb269b18b..8025f37c4b38 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -212,6 +212,11 @@ static const CoreDefinition g_core_definitions[] = {
 {eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon,
  ArchSpec::eCore_hexagon_hexagonv5, "hexagonv5"},
 
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::riscv32, ArchSpec::eCore_riscv32,
+ "riscv32"},
+{eByteOrderLittle, 8, 2, 4, llvm::Triple::riscv64, ArchSpec::eCore_riscv64,
+ "riscv64"},
+
 {eByteOrderLittle, 4, 4, 4, llvm::Triple::UnknownArch,
  ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
@@ -395,6 +400,10 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = {
  0xu, 0xu}, // ARC
 {ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE,
  0xu, 0xu}, // AVR
+{ArchSpec::eCore_riscv32, llvm::ELF::EM_RISCV,
+ ArchSpec::eRISCVSubType_riscv32, 0xu, 0xu}, // riscv32
+{ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV,
+ ArchSpec::eRISCVSubType_riscv64, 0xu, 0xu}, // riscv64
 };
 
 static const ArchDefinition g_elf_arch_def = {

diff  --git a/lldb/test/Shell/ObjectFile/ELF/riscv-arch.yaml 
b/lldb/test/Shell/ObjectFile/ELF/riscv-arch.yaml
new file mode 100644
index ..7fbf2059c74e
--- /dev/null
+++ b/lldb/test/Shell/ObjectFile/ELF/riscv-arch.yaml
@@ -0,0 +1,24 @@
+# RUN: yaml2obj --docnum=1 %s > %t32
+# RUN: yaml2obj --docnum=2 %s > %t64
+# RUN: lldb-test object-file %t32 | FileCheck --check-prefix=CHECK-RV32 %s
+# RUN: lldb-test object-file %t64 | FileCheck --check-prefix=CHECK-RV64 %s
+
+# CHECK-RV32: Architecture: riscv32--
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_RISCV
+...
+
+# CHECK-RV64: Architecture: riscv64--
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_RISCV
+...



___

[llvm-branch-commits] [llvm] b2dafd4 - [NewPM][Hexagon] Fix HexagonVectorLoopCarriedReusePass position in pipeline

2021-01-07 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2021-01-07T15:04:28-08:00
New Revision: b2dafd44ca7a975e3d58d68f3a24e36b2ceb2e1e

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

LOG: [NewPM][Hexagon] Fix HexagonVectorLoopCarriedReusePass position in pipeline

In https://reviews.llvm.org/D88138 this was incorrectly added with
registerOptimizerLastEPCallback(), when it should be
registerLoopOptimizerEndEPCallback(), matching the legacy PM's
EP_LoopOptimizerEnd.

Reviewed By: rnk

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

Added: 


Modified: 
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp

Removed: 




diff  --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp 
b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
index 23c047e0c23b..ba0f45fe09f7 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
@@ -287,13 +287,9 @@ void 
HexagonTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB,
   [=](LoopPassManager &LPM, PassBuilder::OptimizationLevel Level) {
 LPM.addPass(HexagonLoopIdiomRecognitionPass());
   });
-  PB.registerOptimizerLastEPCallback(
-  [=](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
-LoopPassManager LPM(DebugPassManager);
-FunctionPassManager FPM(DebugPassManager);
+  PB.registerLoopOptimizerEndEPCallback(
+  [=](LoopPassManager &LPM, PassBuilder::OptimizationLevel Level) {
 LPM.addPass(HexagonVectorLoopCarriedReusePass());
-FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM)));
-MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   });
 }
 



___
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] ff1b6f9 - [libc++] Alphabetize generate_feature_test_macro_components.py. NFCI.

2021-01-07 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-07T18:11:46-05:00
New Revision: ff1b6f9ff27cc4d5607ea2b5daa980a1c553236b

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

LOG: [libc++] Alphabetize generate_feature_test_macro_components.py. NFCI.

For ease of comparing our list with the official SD-6 list, which is 
alphabetized.
https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#library-feature-test-macros
This also alphabetizes the lists of headers in which the macros are
defined, which harmlessly alters many comments in .
Also drive-by-fix some trivial flake8 warnings.

Added: 


Modified: 
libcxx/include/version
libcxx/utils/generate_feature_test_macro_components.py

Removed: 




diff  --git a/libcxx/include/version b/libcxx/include/version
index dde6ca165b35..39e307e93bc2 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -15,13 +15,13 @@
 
 Macro name  Value   Headers
 __cpp_lib_addressof_constexpr   201603L 
-__cpp_lib_allocator_traits_is_always_equal  201411L  
 
- 
 
-  

-
 
+__cpp_lib_allocator_traits_is_always_equal  201411L  
 
+  

+  

+
 
 __cpp_lib_any   201606L 
 __cpp_lib_apply 201603L 
-__cpp_lib_array_constexpr   201811L  

+__cpp_lib_array_constexpr   201811L  

 201603L // C++17
 __cpp_lib_as_const  201510L 
 __cpp_lib_atomic_flag_test  201907L 
@@ -53,9 +53,9 @@ __cpp_lib_constexpr_utility 
201811L 
 __cpp_lib_destroying_delete 201806L 
 __cpp_lib_enable_shared_from_this   201603L 
 __cpp_lib_endian201907L 
-__cpp_lib_erase_if  202002L  
 
- 
 
- 
 
+__cpp_lib_erase_if  202002L  
 
+  

+
  
 __cpp_lib_exchange_function 201304L 
 __cpp_lib_execution 201603L 
 __cpp_lib_filesystem201703L 
@@ -89,8 +89,8 @@ __cpp_lib_math_special_functions
201603L 
 __cpp_lib_memory_resource   201603L 

 __cpp_lib_node_extract  201606L   

 
-__cpp_lib_nonmember_container_access201411L  
 
- 
 
+__cpp_lib_nonmember_container_access201411L  
 
+ 
 
   

 
  
 __cpp_lib_not_fn201603L 
@@ -119,7 +119,7 @@ __cpp_lib_transformation_trait_aliases  
201304L 
 __cpp_lib_transparent_operators 201510L 
 201210L // C++14
 __cpp_lib_tuple_element_t   201402L 
-__cpp_lib_tuples_by_type201304L  

+__cpp_lib_tuples_by_type201304L  

 __cpp_lib_type_trait_variable_templates 201510L 
 __cpp_lib_uncaught_exceptions   201411L 
 __cpp_lib_unordered_map_try_emplace 201411L 

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py 
b/libcxx/utils/generate_feature_test_macro_components.py
index 2302dc4ec505..37d8a95dd9ae 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -1,8 +1,7 @@
 #!/usr/bin/env python
 
 import os
-import tempfile
-from builtins import int, range
+from builtins import range

[llvm-branch-commits] [llvm] 9ccf13c - [NewPM][NVPTX] Port NVPTX opt passes

2021-01-07 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2021-01-07T15:12:35-08:00
New Revision: 9ccf13c36d1c450bc9a74bd04c9730df56f8bd73

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

LOG: [NewPM][NVPTX] Port NVPTX opt passes

There are only two used in the IR optimization pipeline.
Port these and add them to the default pipeline.

Similar to https://reviews.llvm.org/D93863.

I added -mtriple to some tests since under the new PM, the passes are
only available when the TargetMachine is specified.

Reviewed By: rnk

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

Added: 


Modified: 
llvm/lib/Target/NVPTX/NVPTX.h
llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
llvm/lib/Target/NVPTX/NVVMIntrRange.cpp
llvm/lib/Target/NVPTX/NVVMReflect.cpp
llvm/test/CodeGen/NVPTX/intrinsic-old.ll
llvm/test/CodeGen/NVPTX/nvvm-reflect-module-flag.ll
llvm/test/CodeGen/NVPTX/nvvm-reflect.ll
llvm/tools/opt/opt.cpp

Removed: 




diff  --git a/llvm/lib/Target/NVPTX/NVPTX.h b/llvm/lib/Target/NVPTX/NVPTX.h
index dfe0b9cb5ee6..c2fd090da084 100644
--- a/llvm/lib/Target/NVPTX/NVPTX.h
+++ b/llvm/lib/Target/NVPTX/NVPTX.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTX_H
 #define LLVM_LIB_TARGET_NVPTX_NVPTX_H
 
+#include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/CodeGen.h"
 
@@ -47,6 +48,24 @@ FunctionPass *createNVPTXLowerAllocaPass();
 MachineFunctionPass *createNVPTXPeephole();
 MachineFunctionPass *createNVPTXProxyRegErasurePass();
 
+struct NVVMIntrRangePass : PassInfoMixin {
+  NVVMIntrRangePass();
+  NVVMIntrRangePass(unsigned SmVersion) : SmVersion(SmVersion) {}
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+private:
+  unsigned SmVersion;
+};
+
+struct NVVMReflectPass : PassInfoMixin {
+  NVVMReflectPass();
+  NVVMReflectPass(unsigned SmVersion) : SmVersion(SmVersion) {}
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+private:
+  unsigned SmVersion;
+};
+
 namespace NVPTX {
 enum DrvInterface {
   NVCL,

diff  --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp 
b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
index 21da566b639f..f1a82f1cf607 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -24,6 +24,7 @@
 #include "llvm/CodeGen/TargetPassConfig.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/Pass.h"
+#include "llvm/Passes/PassBuilder.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Target/TargetMachine.h"
@@ -205,6 +206,32 @@ void 
NVPTXTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
 });
 }
 
+void NVPTXTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB,
+  bool DebugPassManager) {
+  PB.registerPipelineParsingCallback(
+  [](StringRef PassName, FunctionPassManager &PM,
+ ArrayRef) {
+if (PassName == "nvvm-reflect") {
+  PM.addPass(NVVMReflectPass());
+  return true;
+}
+if (PassName == "nvvm-intr-range") {
+  PM.addPass(NVVMIntrRangePass());
+  return true;
+}
+return false;
+  });
+
+  PB.registerPipelineStartEPCallback(
+  [this, DebugPassManager](ModulePassManager &PM,
+   PassBuilder::OptimizationLevel Level) {
+FunctionPassManager FPM(DebugPassManager);
+FPM.addPass(NVVMReflectPass(Subtarget.getSmVersion()));
+FPM.addPass(NVVMIntrRangePass(Subtarget.getSmVersion()));
+PM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+  });
+}
+
 TargetTransformInfo
 NVPTXTargetMachine::getTargetTransformInfo(const Function &F) {
   return TargetTransformInfo(NVPTXTTIImpl(this, F));

diff  --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h 
b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
index 5b1e77958eb1..bef541c2b28d 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
@@ -62,6 +62,8 @@ class NVPTXTargetMachine : public LLVMTargetMachine {
   }
 
   void adjustPassManager(PassManagerBuilder &) override;
+  void registerPassBuilderCallbacks(PassBuilder &PB,
+bool DebugPassManager) override;
 
   TargetTransformInfo getTargetTransformInfo(const Function &F) override;
 

diff  --git a/llvm/lib/Target/NVPTX/NVVMIntrRange.cpp 
b/llvm/lib/Target/NVPTX/NVVMIntrRange.cpp
index baaedc7ac87c..5381646434eb 100644
--- a/llvm/lib/Target/NVPTX/NVVMIntrRange.cpp
+++ b/llvm/lib/Target/NVPTX/NVVMIntrRange.cpp
@@ -17,6 +17,7 @@
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
+#includ

[llvm-branch-commits] [llvm] 087be53 - [NFC][SimplifyCFG] Add a test with cond br on constant w/ identical destinations

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-08T02:15:24+03:00
New Revision: 087be536feab0aacc043aed52bee2e48e90e538c

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

LOG: [NFC][SimplifyCFG] Add a test with cond br on constant w/ identical 
destinations

Added: 


Modified: 
llvm/test/Transforms/SimplifyCFG/branch-fold.ll

Removed: 




diff  --git a/llvm/test/Transforms/SimplifyCFG/branch-fold.ll 
b/llvm/test/Transforms/SimplifyCFG/branch-fold.ll
index a4ac23bada70..5b9f20b97d4e 100644
--- a/llvm/test/Transforms/SimplifyCFG/branch-fold.ll
+++ b/llvm/test/Transforms/SimplifyCFG/branch-fold.ll
@@ -1,35 +1,59 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | 
FileCheck %s
 
 define void @test(i32* %P, i32* %Q, i1 %A, i1 %B) {
-; CHECK: test
-; CHECK: br i1
-; CHECK-NOT: br i1
-; CHECK: ret
-; CHECK: ret
+; CHECK-LABEL: @test(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_NOT:%.*]] = xor i1 [[A:%.*]], true
+; CHECK-NEXT:[[BRMERGE:%.*]] = or i1 [[A_NOT]], [[B:%.*]]
+; CHECK-NEXT:br i1 [[BRMERGE]], label [[B:%.*]], label [[C:%.*]]
+; CHECK:   b:
+; CHECK-NEXT:store i32 123, i32* [[P:%.*]], align 4
+; CHECK-NEXT:ret void
+; CHECK:   c:
+; CHECK-NEXT:ret void
+;
 
 entry:
-br i1 %A, label %a, label %b
+  br i1 %A, label %a, label %b
 a:
-br i1 %B, label %b, label %c
+  br i1 %B, label %b, label %c
 b:
-store i32 123, i32* %P
-ret void
+  store i32 123, i32* %P
+  ret void
 c:
-ret void
+  ret void
 }
 
 ; rdar://10554090
 define zeroext i1 @test2(i64 %i0, i64 %i1) nounwind uwtable readonly ssp {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[AND_I_I:%.*]] = and i64 [[I0:%.*]], 281474976710655
+; CHECK-NEXT:[[AND_I11_I:%.*]] = and i64 [[I1:%.*]], 281474976710655
+; CHECK-NEXT:[[OR_COND:%.*]] = icmp eq i64 [[AND_I_I]], [[AND_I11_I]]
+; CHECK-NEXT:br i1 [[OR_COND]], label [[C:%.*]], label [[A:%.*]]
+; CHECK:   a:
+; CHECK-NEXT:[[SHR_I4_I:%.*]] = lshr i64 [[I0]], 48
+; CHECK-NEXT:[[AND_I5_I:%.*]] = and i64 [[SHR_I4_I]], 32767
+; CHECK-NEXT:[[SHR_I_I:%.*]] = lshr i64 [[I1]], 48
+; CHECK-NEXT:[[AND_I2_I:%.*]] = and i64 [[SHR_I_I]], 32767
+; CHECK-NEXT:[[CMP9_I:%.*]] = icmp ult i64 [[AND_I5_I]], [[AND_I2_I]]
+; CHECK-NEXT:[[PHITMP:%.*]] = icmp uge i64 [[AND_I2_I]], [[AND_I5_I]]
+; CHECK-NEXT:[[NOT_COND:%.*]] = xor i1 [[CMP9_I]], true
+; CHECK-NEXT:[[AND_COND:%.*]] = and i1 [[NOT_COND]], [[PHITMP]]
+; CHECK-NEXT:br label [[C]]
+; CHECK:   c:
+; CHECK-NEXT:[[O2:%.*]] = phi i1 [ [[AND_COND]], [[A]] ], [ false, 
[[ENTRY:%.*]] ]
+; CHECK-NEXT:ret i1 [[O2]]
+;
 entry:
-; CHECK: test2
-; CHECK: br i1
   %and.i.i = and i64 %i0, 281474976710655
   %and.i11.i = and i64 %i1, 281474976710655
   %or.cond = icmp eq i64 %and.i.i, %and.i11.i
   br i1 %or.cond, label %c, label %a
 
 a:
-; CHECK: br
   %shr.i4.i = lshr i64 %i0, 48
   %and.i5.i = and i64 %shr.i4.i, 32767
   %shr.i.i = lshr i64 %i1, 48
@@ -38,7 +62,6 @@ a:
   br i1 %cmp9.i, label %c, label %b
 
 b:
-; CHECK-NOT: br
   %shr.i13.i9 = lshr i64 %i1, 48
   %and.i14.i10 = and i64 %shr.i13.i9, 32767
   %shr.i.i11 = lshr i64 %i0, 48
@@ -53,6 +76,10 @@ c:
 
 ; PR13180
 define void @pr13180(i8 %p) {
+; CHECK-LABEL: @pr13180(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:unreachable
+;
 entry:
   %tobool = icmp eq i8 %p, 0
   br i1 %tobool, label %cond.false, label %cond.true
@@ -68,3 +95,18 @@ cond.end: ; preds = 
%cond.false, %cond.t
   %cond = phi i1 [ undef, %cond.true ], [ %phitmp, %cond.false ]
   unreachable
 }
+
+declare void @foo()
+define void @test3() {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:call void @foo()
+; CHECK-NEXT:ret void
+;
+entry:
+  br i1 0, label %bb0, label %bb0
+
+bb0:
+  call void @foo()
+  ret void
+}



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


[llvm-branch-commits] [llvm] 16ab8e5 - [SimplifyCFG] ConstantFoldTerminator(): handle matching destinations of condbr earlier

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-08T02:15:24+03:00
New Revision: 16ab8e5f6dbbeb5b8e900677f4a64c9924ecd7ba

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

LOG: [SimplifyCFG] ConstantFoldTerminator(): handle matching destinations of 
condbr earlier

We need to handle this case before dealing with the case of constant
branch condition, because if the destinations match, latter fold
would try to remove the DomTree edge that would still be present.

This allows to make that particular DomTree update non-permissive

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/Local.cpp 
b/llvm/lib/Transforms/Utils/Local.cpp
index e3bdfbae9287..107929e801d9 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -134,27 +134,10 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool 
DeleteDeadConditions,
   // Branch - See if we are conditional jumping on constant
   if (auto *BI = dyn_cast(T)) {
 if (BI->isUnconditional()) return false;  // Can't optimize uncond branch
+
 BasicBlock *Dest1 = BI->getSuccessor(0);
 BasicBlock *Dest2 = BI->getSuccessor(1);
 
-if (auto *Cond = dyn_cast(BI->getCondition())) {
-  // Are we branching on constant?
-  // YES.  Change to unconditional branch...
-  BasicBlock *Destination = Cond->getZExtValue() ? Dest1 : Dest2;
-  BasicBlock *OldDest = Cond->getZExtValue() ? Dest2 : Dest1;
-
-  // Let the basic block know that we are letting go of it.  Based on this,
-  // it will adjust it's PHI nodes.
-  OldDest->removePredecessor(BB);
-
-  // Replace the conditional branch with an unconditional one.
-  Builder.CreateBr(Destination);
-  BI->eraseFromParent();
-  if (DTU)
-DTU->applyUpdatesPermissive({{DominatorTree::Delete, BB, OldDest}});
-  return true;
-}
-
 if (Dest2 == Dest1) {   // Conditional branch to same location?
   // This branch matches something like this:
   // br bool %cond, label %Dest, label %Dest
@@ -172,6 +155,25 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool 
DeleteDeadConditions,
 RecursivelyDeleteTriviallyDeadInstructions(Cond, TLI);
   return true;
 }
+
+if (auto *Cond = dyn_cast(BI->getCondition())) {
+  // Are we branching on constant?
+  // YES.  Change to unconditional branch...
+  BasicBlock *Destination = Cond->getZExtValue() ? Dest1 : Dest2;
+  BasicBlock *OldDest = Cond->getZExtValue() ? Dest2 : Dest1;
+
+  // Let the basic block know that we are letting go of it.  Based on this,
+  // it will adjust it's PHI nodes.
+  OldDest->removePredecessor(BB);
+
+  // Replace the conditional branch with an unconditional one.
+  Builder.CreateBr(Destination);
+  BI->eraseFromParent();
+  if (DTU)
+DTU->applyUpdates({{DominatorTree::Delete, BB, OldDest}});
+  return true;
+}
+
 return false;
   }
 



___
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] 36593a3 - [SimplifyCFG] ConstantFoldTerminator(): switch to non-permissive DomTree updates in `SwitchInst` handling

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-08T02:15:24+03:00
New Revision: 36593a30a40b52e8040d821bbd294ef6758cf9cf

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

LOG: [SimplifyCFG] ConstantFoldTerminator(): switch to non-permissive DomTree 
updates in `SwitchInst` handling

... which requires not deleting edges that will still be present.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/Local.cpp 
b/llvm/lib/Transforms/Utils/Local.cpp
index 107929e801d9..5ce0e29cadab 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -231,9 +231,6 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool 
DeleteDeadConditions,
 i = SI->removeCase(i);
 e = SI->case_end();
 Changed = true;
-if (DTU)
-  DTU->applyUpdatesPermissive(
-  {{DominatorTree::Delete, ParentBB, DefaultDest}});
 continue;
   }
 
@@ -259,19 +256,19 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool 
DeleteDeadConditions,
   // Insert the new branch.
   Builder.CreateBr(TheOnlyDest);
   BasicBlock *BB = SI->getParent();
-  std::vector  Updates;
-  if (DTU)
-Updates.reserve(SI->getNumSuccessors() - 1);
+
+  SmallSetVector RemovedSuccessors;
 
   // Remove entries from PHI nodes which we no longer branch to...
+  BasicBlock *SuccToKeep = TheOnlyDest;
   for (BasicBlock *Succ : successors(SI)) {
+if (DTU && Succ != TheOnlyDest)
+  RemovedSuccessors.insert(Succ);
 // Found case matching a constant operand?
-if (Succ == TheOnlyDest) {
-  TheOnlyDest = nullptr; // Don't modify the first branch to 
TheOnlyDest
+if (Succ == SuccToKeep) {
+  SuccToKeep = nullptr; // Don't modify the first branch to TheOnlyDest
 } else {
   Succ->removePredecessor(BB);
-  if (DTU)
-Updates.push_back({DominatorTree::Delete, BB, Succ});
 }
   }
 
@@ -280,8 +277,13 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool 
DeleteDeadConditions,
   SI->eraseFromParent();
   if (DeleteDeadConditions)
 RecursivelyDeleteTriviallyDeadInstructions(Cond, TLI);
-  if (DTU)
-DTU->applyUpdatesPermissive(Updates);
+  if (DTU) {
+std::vector Updates;
+Updates.reserve(RemovedSuccessors.size());
+for (auto *RemovedSuccessor : RemovedSuccessors)
+  Updates.push_back({DominatorTree::Delete, BB, RemovedSuccessor});
+DTU->applyUpdates(Updates);
+  }
   return true;
 }
 



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


[llvm-branch-commits] [llvm] 8b9a0e6 - [NFC][SimlifyCFG] Add some indirectbr-of-blockaddress tests

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-08T02:15:25+03:00
New Revision: 8b9a0e6f7ed2fa3293ba5cd2c2fb1acd21db6e2d

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

LOG: [NFC][SimlifyCFG] Add some indirectbr-of-blockaddress tests

Added: 


Modified: 
llvm/test/Transforms/SimplifyCFG/indirectbr.ll

Removed: 




diff  --git a/llvm/test/Transforms/SimplifyCFG/indirectbr.ll 
b/llvm/test/Transforms/SimplifyCFG/indirectbr.ll
index 52ef6b77166c..3c82f5a64ee3 100644
--- a/llvm/test/Transforms/SimplifyCFG/indirectbr.ll
+++ b/llvm/test/Transforms/SimplifyCFG/indirectbr.ll
@@ -1,17 +1,33 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | 
FileCheck %s
 
 ; SimplifyCFG should eliminate redundant indirectbr edges.
 
-; CHECK: indbrtest0
-; CHECK: indirectbr i8* %t, [label %BB0, label %BB1, label %BB2]
-; CHECK: %x = phi i32 [ 0, %BB0 ], [ 1, %entry ]
-
 declare void @foo()
 declare void @A()
 declare void @B(i32)
 declare void @C()
 
 define void @indbrtest0(i8** %P, i8** %Q) {
+; CHECK-LABEL: @indbrtest0(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:store i8* blockaddress(@indbrtest0, [[BB0:%.*]]), i8** 
[[P:%.*]], align 8
+; CHECK-NEXT:store i8* blockaddress(@indbrtest0, [[BB1:%.*]]), i8** [[P]], 
align 8
+; CHECK-NEXT:store i8* blockaddress(@indbrtest0, [[BB2:%.*]]), i8** [[P]], 
align 8
+; CHECK-NEXT:call void @foo()
+; CHECK-NEXT:[[T:%.*]] = load i8*, i8** [[Q:%.*]], align 8
+; CHECK-NEXT:indirectbr i8* [[T]], [label [[BB0]], label [[BB1]], label 
%BB2]
+; CHECK:   BB0:
+; CHECK-NEXT:call void @A()
+; CHECK-NEXT:br label [[BB1]]
+; CHECK:   BB1:
+; CHECK-NEXT:[[X:%.*]] = phi i32 [ 0, [[BB0]] ], [ 1, [[ENTRY:%.*]] ]
+; CHECK-NEXT:call void @B(i32 [[X]])
+; CHECK-NEXT:ret void
+; CHECK:   BB2:
+; CHECK-NEXT:call void @C()
+; CHECK-NEXT:ret void
+;
 entry:
   store i8* blockaddress(@indbrtest0, %BB0), i8** %P
   store i8* blockaddress(@indbrtest0, %BB1), i8** %P
@@ -35,10 +51,17 @@ BB2:
 ; better if it removed the branch altogether, but simplifycfdg currently misses
 ; that because the predecessor is the entry block.
 
-; CHECK: indbrtest1
-; CHECK: br label %BB0
 
 define void @indbrtest1(i8** %P, i8** %Q) {
+; CHECK-LABEL: @indbrtest1(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:store i8* blockaddress(@indbrtest1, [[BB0:%.*]]), i8** 
[[P:%.*]], align 8
+; CHECK-NEXT:call void @foo()
+; CHECK-NEXT:br label [[BB0]]
+; CHECK:   BB0:
+; CHECK-NEXT:call void @A()
+; CHECK-NEXT:ret void
+;
 entry:
   store i8* blockaddress(@indbrtest1, %BB0), i8** %P
   call void @foo()
@@ -52,11 +75,12 @@ BB0:
 ; SimplifyCFG should notice that BB0 does not have its address taken and
 ; remove it from entry's successor list.
 
-; CHECK: indbrtest2
-; CHECK: entry:
-; CHECK-NEXT: unreachable
 
 define void @indbrtest2(i8* %t) {
+; CHECK-LABEL: @indbrtest2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:unreachable
+;
 entry:
   indirectbr i8* %t, [label %BB0, label %BB0]
 BB0:
@@ -77,13 +101,17 @@ BB0:
 ; SimplifyCFG should turn the indirectbr into a conditional branch on the
 ; condition of the select.
 
-; CHECK-LABEL: @indbrtest3(
-; CHECK-NEXT: entry:
-; CHECK-NEXT: br i1 %cond, label %L1, label %L2
-; CHECK-NOT: indirectbr
-; CHECK-NOT: br
-; CHECK-NOT: L3:
 define void @indbrtest3(i1 %cond, i8* %address) nounwind {
+; CHECK-LABEL: @indbrtest3(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br i1 [[COND:%.*]], label [[L1:%.*]], label [[L2:%.*]]
+; CHECK:   L1:
+; CHECK-NEXT:call void @A()
+; CHECK-NEXT:ret void
+; CHECK:   L2:
+; CHECK-NEXT:call void @C()
+; CHECK-NEXT:ret void
+;
 entry:
   %indirect.goto.dest = select i1 %cond, i8* blockaddress(@indbrtest3, %L1), 
i8* blockaddress(@indbrtest3, %L2)
   indirectbr i8* %indirect.goto.dest, [label %L1, label %L2, label %L3]
@@ -104,10 +132,14 @@ L3:
 ; As in @indbrtest1, it should really remove the branch entirely, but it 
doesn't
 ; because it's in the entry block.
 
-; CHECK-LABEL: @indbrtest4(
-; CHECK-NEXT: entry:
-; CHECK-NEXT: br label %L1
 define void @indbrtest4(i1 %cond) nounwind {
+; CHECK-LABEL: @indbrtest4(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[L1:%.*]]
+; CHECK:   L1:
+; CHECK-NEXT:call void @A()
+; CHECK-NEXT:ret void
+;
 entry:
   %indirect.goto.dest = select i1 %cond, i8* blockaddress(@indbrtest4, %L1), 
i8* blockaddress(@indbrtest4, %L1)
   indirectbr i8* %indirect.goto.dest, [label %L1, label %L2, label %L3]
@@ -126,11 +158,11 @@ L3:
 ; SimplifyCFG should turn the indirectbr into an unreachable because neither
 ; destination is listed as a successor.
 
-; CHECK-LABEL: @indbrtest5(
-; CHECK-NEXT: entry:
-; CHECK-NEXT: unreachable
-

[llvm-branch-commits] [llvm] b382272 - [SimplifyCFG] ConstantFoldTerminator(): switch to non-permissive DomTree updates in `indirectbr` handling

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-08T02:15:25+03:00
New Revision: b3822728fae2e3755d6daff7fc31fbac16e61fe4

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

LOG: [SimplifyCFG] ConstantFoldTerminator(): switch to non-permissive DomTree 
updates in `indirectbr` handling

... which requires not deleting edges that were just deleted already.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/Local.cpp 
b/llvm/lib/Transforms/Utils/Local.cpp
index 5ce0e29cadab..38cfee31c35d 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -329,22 +329,20 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool 
DeleteDeadConditions,
 if (auto *BA =
   dyn_cast(IBI->getAddress()->stripPointerCasts())) {
   BasicBlock *TheOnlyDest = BA->getBasicBlock();
-  std::vector  Updates;
-  if (DTU)
-Updates.reserve(IBI->getNumDestinations() - 1);
+  SmallSetVector RemovedSuccessors;
 
   // Insert the new branch.
   Builder.CreateBr(TheOnlyDest);
 
+  BasicBlock *SuccToKeep = TheOnlyDest;
   for (unsigned i = 0, e = IBI->getNumDestinations(); i != e; ++i) {
-if (IBI->getDestination(i) == TheOnlyDest) {
-  TheOnlyDest = nullptr;
+BasicBlock *DestBB = IBI->getDestination(i);
+if (DTU && DestBB != TheOnlyDest)
+  RemovedSuccessors.insert(DestBB);
+if (IBI->getDestination(i) == SuccToKeep) {
+  SuccToKeep = nullptr;
 } else {
-  BasicBlock *ParentBB = IBI->getParent();
-  BasicBlock *DestBB = IBI->getDestination(i);
-  DestBB->removePredecessor(ParentBB);
-  if (DTU)
-Updates.push_back({DominatorTree::Delete, ParentBB, DestBB});
+  DestBB->removePredecessor(BB);
 }
   }
   Value *Address = IBI->getAddress();
@@ -361,13 +359,18 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool 
DeleteDeadConditions,
   // If we didn't find our destination in the IBI successor list, then we
   // have undefined behavior.  Replace the unconditional branch with an
   // 'unreachable' instruction.
-  if (TheOnlyDest) {
+  if (SuccToKeep) {
 BB->getTerminator()->eraseFromParent();
 new UnreachableInst(BB->getContext(), BB);
   }
 
-  if (DTU)
-DTU->applyUpdatesPermissive(Updates);
+  if (DTU) {
+std::vector Updates;
+Updates.reserve(RemovedSuccessors.size());
+for (auto *RemovedSuccessor : RemovedSuccessors)
+  Updates.push_back({DominatorTree::Delete, BB, RemovedSuccessor});
+DTU->applyUpdates(Updates);
+  }
   return true;
 }
   }



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


[llvm-branch-commits] [llvm] 1f9b591 - [SimplifyCFG] TryToSimplifyUncondBranchFromEmptyBlock(): switch to non-permissive DomTree updates

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-08T02:15:25+03:00
New Revision: 1f9b591ee66fe5abd6f63990b085e1f1f559d8d9

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

LOG: [SimplifyCFG] TryToSimplifyUncondBranchFromEmptyBlock(): switch to 
non-permissive DomTree updates

... which requires not deleting edges that were just deleted already,
by not processing the same predecessor more than once.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/Local.cpp 
b/llvm/lib/Transforms/Utils/Local.cpp
index 38cfee31c35d..7c962edba3ca 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1048,11 +1048,13 @@ bool 
llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
   if (DTU) {
 Updates.push_back({DominatorTree::Delete, BB, Succ});
 // All predecessors of BB will be moved to Succ.
-for (auto I = pred_begin(BB), E = pred_end(BB); I != E; ++I) {
-  Updates.push_back({DominatorTree::Delete, *I, BB});
+SmallSetVector Predecessors(pred_begin(BB), pred_end(BB));
+Updates.reserve(Updates.size() + 2 * Predecessors.size());
+for (auto *Predecessor : Predecessors) {
+  Updates.push_back({DominatorTree::Delete, Predecessor, BB});
   // This predecessor of BB may already have Succ as a successor.
-  if (!llvm::is_contained(successors(*I), Succ))
-Updates.push_back({DominatorTree::Insert, *I, Succ});
+  if (!llvm::is_contained(successors(Predecessor), Succ))
+Updates.push_back({DominatorTree::Insert, Predecessor, Succ});
 }
   }
 
@@ -1109,7 +,7 @@ bool 
llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
"applying corresponding DTU updates.");
 
   if (DTU) {
-DTU->applyUpdatesPermissive(Updates);
+DTU->applyUpdates(Updates);
 DTU->deleteBB(BB);
   } else {
 BB->eraseFromParent(); // Delete the old basic block.



___
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] f8875c3 - [NFC][SimplifyCFG] Add test with an unreachable block with two identical successors

2021-01-07 Thread Roman Lebedev via llvm-branch-commits

Author: Roman Lebedev
Date: 2021-01-08T02:15:25+03:00
New Revision: f8875c313c381764a9734dbd6e94539e8837d9f7

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

LOG: [NFC][SimplifyCFG] Add test with an unreachable block with two identical 
successors

Added: 
llvm/test/Transforms/SimplifyCFG/unreachable-matching-successor.ll

Modified: 


Removed: 




diff  --git 
a/llvm/test/Transforms/SimplifyCFG/unreachable-matching-successor.ll 
b/llvm/test/Transforms/SimplifyCFG/unreachable-matching-successor.ll
new file mode 100644
index ..25a4ab7203f5
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/unreachable-matching-successor.ll
@@ -0,0 +1,16 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S < %s | 
FileCheck %s
+
+define void @fn(i1 %c) {
+; CHECK-LABEL: @fn(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:ret void
+;
+entry:
+  ret void
+
+unreachable_bb0:
+  br i1 %c, label %unreachable_bb1, label %unreachable_bb1
+unreachable_bb1:
+  br label %unreachable_bb0
+}



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


  1   2   >