[llvm-branch-commits] [mlir] 4086072 - Reland "[mlir][linalg] Support parsing attributes in named op spec"

2021-01-12 Thread Lei Zhang via llvm-branch-commits

Author: Lei Zhang
Date: 2021-01-12T10:57:46-05:00
New Revision: 4086072f8a9200216088c435c9aa90a2d8ed74a5

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

LOG: Reland "[mlir][linalg] Support parsing attributes in named op spec"

With this, now we can specify a list of attributes on named ops
generated from the spec. The format is defined as

```
attr-id ::= bare-id (`?`)?
attr-typedef ::= type (`[` `]`)?
attr-def ::= attr-id `:` attr-typedef

tc-attr-def ::= `attr` `(` attr-def-list `)`
tc-def ::= `def` bare-id
  `(`tensor-def-list`)` `->` `(` tensor-def-list`)`
  (tc-attr-def)?
```

For example,

```
ods_def
def some_op(...) -> (...)
attr(
  f32_attr: f32,
  i32_attr: i32,
  array_attr : f32[],
  optional_attr? : f32
)
```

where `?` means optional attribute and `[]` means array type.

Reviewed By: hanchung, nicolasvasilache

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

Added: 


Modified: 
mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp

Removed: 




diff  --git a/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc 
b/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
index f81380f02bb3..1ef128760637 100644
--- a/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
+++ b/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-gen.tc
@@ -72,3 +72,25 @@ ods_def :
 def test3(A: f32(Batch, M, K), B: f32(K, N)) -> (C: f32(Batch, M, N)) {
   C(b, m, n) = std_addf(std_mulf(A(b, m, k), B(k, n)));
 }
+
+// Test attribute definitions
+// ODS-LABEL: def Test4Op
+// ODS: F32ArrayAttr:$array_attr,
+// ODS: F32:$f32_attr,
+// ODS: RankedF32ElementsAttr<[4]>:$fvec_attr,
+// ODS: I32:$i32_attr,
+// ODS: RankedI32ElementsAttr<[5, 6]>:$ivec_attr,
+// ODS: OptionalAttr:$optional_attr
+//
+ods_def :
+def test4(A: f32(Batch, M, K), B: f32(K, N)) -> (C: f32(Batch, M, N))
+attr(
+  f32_attr: f32,
+  i32_attr: i32,
+  fvec_attr: 4xf32,
+  ivec_attr: 5x6xi32,
+  array_attr : f32[],
+  optional_attr? : f32
+) {
+  C(b, m, n) = std_addf(std_mulf(A(b, m, k), B(k, n)));
+}

diff  --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp 
b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
index 592e6cb774fb..138c5a4e904e 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
@@ -20,11 +20,17 @@
 #include "mlir/Support/LLVM.h"
 #include "mlir/Support/LogicalResult.h"
 #include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/ToolOutputFile.h"
 
+#include 
+
 #define DEBUG_TYPE "linalg-ods-gen"
 
 static llvm::cl::OptionCategory ODSGenCat("Linalg ODS Gen");
@@ -79,11 +85,14 @@ class Token {
 gt,
 l_brace,
 l_paren,
+l_square,
 lt,
 minus,
 plus,
+question,
 r_brace,
 r_paren,
+r_square,
 semicolon,
 star,
 
@@ -91,6 +100,7 @@ class Token {
 kw_def,
 FIRST_KEYWORD = kw_def,
 kw_ods_def,
+kw_attr_def,
 kw_floordiv,
 kw_ceildiv,
 kw_mod,
@@ -151,6 +161,10 @@ class Lexer {
   Token emitError(llvm::SMLoc loc, const Twine &msg);
   Token emitError(const char *loc, const Twine &msg);
 
+  /// Change the position of the lexer cursor. The next token we lex will start
+  /// at the designated point in the input.
+  void resetPointer(const char *newPtr) { curPtr = newPtr; }
+
 private:
   Token formToken(Token::Kind kind, const char *tokStart) {
 return Token(kind, StringRef(tokStart, curPtr - tokStart));
@@ -247,10 +261,14 @@ Token Lexer::lexToken() {
   return formToken(Token::Kind::l_brace, tokStart);
 case '(':
   return formToken(Token::Kind::l_paren, tokStart);
+case '[':
+  return formToken(Token::Kind::l_square, tokStart);
 case '}':
   return formToken(Token::Kind::r_brace, tokStart);
 case ')':
   return formToken(Token::Kind::r_paren, tokStart);
+case ']':
+  return formToken(Token::Kind::r_square, tokStart);
 case '<':
   return formToken(Token::Kind::lt, tokStart);
 case '>':
@@ -263,6 +281,8 @@ Token Lexer::lexToken() {
   return formToken(Token::Kind::semicolon, tokStart);
 case '*':
   return formToken(Token::Kind::star, tokStart);
+case '?':
+  return formToken(Token::Kind::question, tokStart);
 case '/':
   if (*curPtr == '/') {
 skipComment();
@@ -289,6 +309,7 @@ Token Lexer::lexIdentifier(const char *tokStart) {
   // Check to see if this identifier is a keyword.
   StringRef str(tokStart, curPtr - tokStart);
   Token::Kind kind = S

[llvm-branch-commits] [mlir] 4fa01f7 - [mlir][CAPI] Fix inline function declaration

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

Author: Vladislav Vinogradov
Date: 2021-01-12T17:05:02+01:00
New Revision: 4fa01f72de6cc48a44afe057c04803711160c92d

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

LOG: [mlir][CAPI] Fix inline function declaration

Add `static` keyword, otherwise build fail with linker error for some cases.

Reviewed By: ftynse

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

Added: 


Modified: 
mlir/include/mlir-c/AffineExpr.h

Removed: 




diff  --git a/mlir/include/mlir-c/AffineExpr.h 
b/mlir/include/mlir-c/AffineExpr.h
index ec445682c011..d5c6e7b9f29e 100644
--- a/mlir/include/mlir-c/AffineExpr.h
+++ b/mlir/include/mlir-c/AffineExpr.h
@@ -50,7 +50,7 @@ MLIR_CAPI_EXPORTED bool mlirAffineExprEqual(MlirAffineExpr 
lhs,
 
 /// Returns `true` if the given affine expression is a null expression. Note
 /// constant zero is not a null expression.
-inline bool mlirAffineExprIsNull(MlirAffineExpr affineExpr) {
+inline static bool mlirAffineExprIsNull(MlirAffineExpr affineExpr) {
   return affineExpr.ptr == NULL;
 }
 



___
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] 9667d15 - [mlir] Fix for LIT tests

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

Author: Vladislav Vinogradov
Date: 2021-01-12T17:07:23+01:00
New Revision: 9667d15e7496e6d8c313251f22ac157dbbd0c1c2

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

LOG: [mlir] Fix for LIT tests

Add `MLIR_SPIRV_CPU_RUNNER_ENABLED` to `llvm_canonicalize_cmake_booleans`.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/test/CMakeLists.txt

Removed: 




diff  --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt
index f6d5af141630..293d93268a11 100644
--- a/mlir/test/CMakeLists.txt
+++ b/mlir/test/CMakeLists.txt
@@ -12,6 +12,7 @@ llvm_canonicalize_cmake_booleans(
   MLIR_CUDA_RUNNER_ENABLED
   MLIR_ROCM_CONVERSIONS_ENABLED
   MLIR_ROCM_RUNNER_ENABLED
+  MLIR_SPIRV_CPU_RUNNER_ENABLED
   MLIR_VULKAN_RUNNER_ENABLED
   )
 



___
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] 1f12501 - [libc++] [C++2b] [P1048] Add is_scoped_enum and is_scoped_enum_v.

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

Author: Marek Kurdej
Date: 2021-01-12T17:08:20+01:00
New Revision: 1f1250151f222ba391d05dcc173f4b6c65d05ca2

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

LOG: [libc++] [C++2b] [P1048] Add is_scoped_enum and is_scoped_enum_v.

* https://wg21.link/p1048

Reviewed By: ldionne, #libc

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

Added: 

libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_scoped_enum.pass.cpp

Modified: 
libcxx/docs/Cxx2bStatusPaperStatus.csv
libcxx/docs/FeatureTestMacroTable.rst
libcxx/include/type_traits
libcxx/include/version

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

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py

Removed: 




diff  --git a/libcxx/docs/Cxx2bStatusPaperStatus.csv 
b/libcxx/docs/Cxx2bStatusPaperStatus.csv
index c79509528add..f5c893fdbd48 100644
--- a/libcxx/docs/Cxx2bStatusPaperStatus.csv
+++ b/libcxx/docs/Cxx2bStatusPaperStatus.csv
@@ -1,6 +1,6 @@
 "Paper #","Group","Paper Name","Meeting","Status","First released version"
 "`P0881R7 `__","LWG","A Proposal to add stacktrace 
library","Autumn 2020","",""
 "`P0943R6 `__","LWG","Support C atomics in 
C++","Autumn 2020","",""
-"`P1048R1 `__","LWG","A proposal for a type trait 
to detect scoped enumerations","Autumn 2020","",""
+"`P1048R1 `__","LWG","A proposal for a type trait 
to detect scoped enumerations","Autumn 2020","|Complete|","12.0"
 "`P1679R3 `__","LWG","string contains 
function","Autumn 2020","",""
 "","","","","",""

diff  --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index 99fb4e790c7d..8221bbe2a4af 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -292,7 +292,7 @@ Status
 - -
 **C++ 2b**
 ---
-``__cpp_lib_is_scoped_enum``  *unimplemented*
+``__cpp_lib_is_scoped_enum``  ``202011L``
 - -
 ``__cpp_lib_stacktrace``  *unimplemented*
 - -

diff  --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 99b2a8f9f025..48884eab8e86 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -51,6 +51,7 @@ namespace std
 template  struct is_arithmetic;
 template  struct is_fundamental;
 template  struct is_member_pointer;
+template  struct is_scoped_enum; // C++2b
 template  struct is_scalar;
 template  struct is_object;
 template  struct is_compound;
@@ -284,6 +285,8 @@ namespace std
 = is_compound::value; // 
C++17
   template  inline constexpr bool is_member_pointer_v
 = is_member_pointer::value;   // 
C++17
+  template  inline constexpr bool is_scoped_enum_v
+= is_scoped_enum::value;  // 
C++2b
 
   // See C++14 20.10.4.3, type properties
   template  inline constexpr bool is_const_v
@@ -4177,6 +4180,25 @@ struct __has_operator_addressof
 
 #endif  // _LIBCPP_CXX03_LANG
 
+// is_scoped_enum [meta.unary.prop]
+
+#if _LIBCPP_STD_VER > 20
+template  >
+struct __is_scoped_enum_helper : false_type {};
+
+template 
+struct __is_scoped_enum_helper<_Tp, true>
+: public bool_constant > > 
{};
+
+template 
+struct _LIBCPP_TEMPLATE_VIS is_scoped_enum
+: public __is_scoped_enum_helper<_Tp> {};
+
+template 
+_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scoped_enum_v =
+is_scoped_enum<_Tp>::value;
+#endif
+
 #if _LIBCPP_STD_VER > 14
 
 template 

diff  --git a/libcxx/include/version b/libcxx/include/version
index 3920b69a601c..9e5fc81da44e 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -355,7 +355,7 @@ __cpp_lib_void_t
201411L 
 #endif
 
 #if _LIBCPP_STD_VER > 20
-// # define __cpp_lib_is_scoped_enum   202011L
+# define __cpp_lib_is_scoped_enum   202011L
 // # define __cpp_lib_stacktrace   202011L
 // # define __cpp_lib_stdatomic_h  202011L
 // # define __cpp_lib_string_contains  202011L

diff  --git 
a/libcxx/test/std/language.support/support.limits/supp

[llvm-branch-commits] [llvm] 93b54b7 - [PowerPC][NFCI] PassSubtarget to ASMWriter

2021-01-12 Thread Jinsong Ji via llvm-branch-commits

Author: Jinsong Ji
Date: 2021-01-12T16:25:35Z
New Revision: 93b54b7c6733fcb11fd6536499e73872d7452ffb

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

LOG: [PowerPC][NFCI] PassSubtarget to ASMWriter

Subtarget feature bits are needed to change instprinter's behavior based
on feature bits.

Most of the other popular targets were updated back in 2015,
in https://reviews.llvm.org/rGb46d0234a6969
we should update it too.

Reviewed By: sfertile

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h
llvm/lib/Target/PowerPC/PPC.td

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp 
b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
index 2eff1d94ce20..a291a34d4c52 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
@@ -71,11 +71,11 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t 
Address,
"reference expression if it is an expression at all.");
 
 O << "\taddis ";
-printOperand(MI, 0, O);
+printOperand(MI, 0, STI, O);
 O << ", ";
-printOperand(MI, 2, O);
+printOperand(MI, 2, STI, O);
 O << "(";
-printOperand(MI, 1, O);
+printOperand(MI, 1, STI, O);
 O << ")";
 return;
   }
@@ -94,7 +94,7 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t 
Address,
   if (SymExpr && SymExpr->getKind() == MCSymbolRefExpr::VK_PPC_PCREL_OPT) {
 const MCSymbol &Symbol = SymExpr->getSymbol();
 if (MI->getOpcode() == PPC::PLDpc) {
-  printInstruction(MI, Address, O);
+  printInstruction(MI, Address, STI, O);
   O << "\n";
   Symbol.print(O, &MAI);
   O << ":";
@@ -124,9 +124,9 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t 
Address,
   SH = 32-SH;
 }
 if (useSubstituteMnemonic) {
-  printOperand(MI, 0, O);
+  printOperand(MI, 0, STI, O);
   O << ", ";
-  printOperand(MI, 1, O);
+  printOperand(MI, 1, STI, O);
   O << ", " << (unsigned int)SH;
 
   printAnnotation(O, Annot);
@@ -141,9 +141,9 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t 
Address,
 // rldicr RA, RS, SH, 63-SH == sldi RA, RS, SH
 if (63-SH == ME) {
   O << "\tsldi ";
-  printOperand(MI, 0, O);
+  printOperand(MI, 0, STI, O);
   O << ", ";
-  printOperand(MI, 1, O);
+  printOperand(MI, 1, STI, O);
   O << ", " << (unsigned int)SH;
   printAnnotation(O, Annot);
   return;
@@ -171,9 +171,9 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t 
Address,
 if (IsBookE && TH != 0 && TH != 16)
   O << (unsigned int) TH << ", ";
 
-printOperand(MI, 1, O);
+printOperand(MI, 1, STI, O);
 O << ", ";
-printOperand(MI, 2, O);
+printOperand(MI, 2, STI, O);
 
 if (!IsBookE && TH != 0 && TH != 16)
   O << ", " << (unsigned int) TH;
@@ -198,21 +198,22 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t 
Address,
 O << "stps";
   O << " ";
 
-  printOperand(MI, 1, O);
+  printOperand(MI, 1, STI, O);
   O << ", ";
-  printOperand(MI, 2, O);
+  printOperand(MI, 2, STI, O);
 
   printAnnotation(O, Annot);
   return;
 }
   }
 
-  if (!printAliasInstr(MI, Address, O))
-printInstruction(MI, Address, O);
+  if (!printAliasInstr(MI, Address, STI, O))
+printInstruction(MI, Address, STI, O);
   printAnnotation(O, Annot);
 }
 
 void PPCInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNo,
+   const MCSubtargetInfo &STI,
raw_ostream &O,
const char *Modifier) {
   unsigned Code = MI->getOperand(OpNo).getImm();
@@ -306,10 +307,11 @@ void PPCInstPrinter::printPredicateOperand(const MCInst 
*MI, unsigned OpNo,
 
   assert(StringRef(Modifier) == "reg" &&
  "Need to specify 'cc', 'pm' or 'reg' as predicate op modifier!");
-  printOperand(MI, OpNo+1, O);
+  printOperand(MI, OpNo + 1, STI, O);
 }
 
 void PPCInstPrinter::printATBitsAsHint(const MCInst *MI, unsigned OpNo,
+   const MCSubtargetInfo &STI,
raw_ostream &O) {
   unsigned Code = MI->getOperand(OpNo).getImm();
   if (Code == 2)
@@ -319,6 +321,7 @@ void PPCInstPrinter::printATBitsAsHint(const MCInst *MI, 
unsigned OpNo,
 }
 
 void PPCInstPrinter::printU1ImmOperand(const MCInst *MI, unsigned OpNo,
+   const MCSubtargetInfo &STI,
 

[llvm-branch-commits] [mlir] 67a339e - [MLIR] Disallow `sym_visibility`, `sym_name` and `type` attributes in the parsed attribute dictionary.

2021-01-12 Thread Rahul Joshi via llvm-branch-commits

Author: Rahul Joshi
Date: 2021-01-12T09:11:02-08:00
New Revision: 67a339e96839cdecb5efad0e2731ab20a4ee458e

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

LOG: [MLIR] Disallow `sym_visibility`, `sym_name` and `type` attributes in the 
parsed attribute dictionary.

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

Added: 


Modified: 
mlir/lib/IR/FunctionImplementation.cpp
mlir/test/Dialect/Tosa/inlining.mlir
mlir/test/IR/core-ops.mlir
mlir/test/IR/invalid-func-op.mlir

Removed: 




diff  --git a/mlir/lib/IR/FunctionImplementation.cpp 
b/mlir/lib/IR/FunctionImplementation.cpp
index 90ea91d49fb6..4bec1684b5ee 100644
--- a/mlir/lib/IR/FunctionImplementation.cpp
+++ b/mlir/lib/IR/FunctionImplementation.cpp
@@ -180,7 +180,7 @@ mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, 
OperationState &result,
 return failure();
 
   // Parse the function signature.
-  auto signatureLocation = parser.getCurrentLocation();
+  llvm::SMLoc signatureLocation = parser.getCurrentLocation();
   bool isVariadic = false;
   if (parseFunctionSignature(parser, allowVariadic, entryArgs, argTypes,
  argAttrs, isVariadic, resultTypes, resultAttrs))
@@ -196,9 +196,24 @@ mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, 
OperationState &result,
<< (errorMessage.empty() ? "" : ": ") << errorMessage;
 
   // If function attributes are present, parse them.
-  if (parser.parseOptionalAttrDictWithKeyword(result.attributes))
+  NamedAttrList parsedAttributes;
+  llvm::SMLoc attributeDictLocation = parser.getCurrentLocation();
+  if (parser.parseOptionalAttrDictWithKeyword(parsedAttributes))
 return failure();
 
+  // Disallow attributes that are inferred from elsewhere in the attribute
+  // dictionary.
+  for (StringRef disallowed :
+   {SymbolTable::getVisibilityAttrName(), SymbolTable::getSymbolAttrName(),
+getTypeAttrName()}) {
+if (parsedAttributes.get(disallowed))
+  return parser.emitError(attributeDictLocation, "'")
+ << disallowed
+ << "' is an inferred attribute and should not be specified in the 
"
+"explicit attribute dictionary";
+  }
+  result.attributes.append(parsedAttributes);
+
   // Add the attributes to the function arguments.
   assert(argAttrs.size() == argTypes.size());
   assert(resultAttrs.size() == resultTypes.size());

diff  --git a/mlir/test/Dialect/Tosa/inlining.mlir 
b/mlir/test/Dialect/Tosa/inlining.mlir
index 363358b0781b..f6789fafe3ed 100644
--- a/mlir/test/Dialect/Tosa/inlining.mlir
+++ b/mlir/test/Dialect/Tosa/inlining.mlir
@@ -19,11 +19,11 @@ func @inlined_if_fn(%arg0: tensor, %arg1: tensor, 
%arg2: tensor) -
   }) : (tensor, tensor, tensor) -> tensor
   return %0 : tensor
 }
-func @add(%arg0: tensor, %arg1: tensor) -> tensor attributes 
{sym_visibility = "private"} {
+func private @add(%arg0: tensor, %arg1: tensor) -> tensor {
   %0 = "tosa.add"(%arg0, %arg1) : (tensor, tensor) -> tensor
   return %0 : tensor
 }
-func @sub(%arg0: tensor, %arg1: tensor) -> tensor attributes 
{sym_visibility = "private"} {
+func private @sub(%arg0: tensor, %arg1: tensor) -> tensor {
   %0 = "tosa.sub"(%arg0, %arg1) : (tensor, tensor) -> tensor
   return %0 : tensor
 }
@@ -45,12 +45,12 @@ func @inlined_while_fn(%arg0: tensor, %arg1: 
tensor, %arg2: tensor, tensor, tensor, tensor<10xi32>) -> 
(tensor, tensor, tensor, tensor<10xi32>)
   return %1#3 : tensor<10xi32>
 }
-func @while_body_50(%arg0: tensor, %arg1: tensor, %arg2: 
tensor, %arg3: tensor<10xi32>) -> (tensor, tensor, tensor, 
tensor<10xi32>) attributes {sym_visibility = "private"} {
+func private @while_body_50(%arg0: tensor, %arg1: tensor, %arg2: 
tensor, %arg3: tensor<10xi32>) -> (tensor, tensor, tensor, 
tensor<10xi32>) {
   %1 = "tosa.add"(%arg0, %arg1) : (tensor, tensor) -> tensor
   %2 = "tosa.add"(%arg3, %1) : (tensor<10xi32>, tensor) -> tensor<10xi32>
   return %1, %arg1, %arg2, %2: tensor, tensor, tensor, 
tensor<10xi32>
 }
-func @while_cond_40(%arg0: tensor, %arg1: tensor, %arg2: 
tensor, %arg3: tensor<10xi32>) -> tensor attributes {sym_visibility = 
"private"} {
+func private @while_cond_40(%arg0: tensor, %arg1: tensor, %arg2: 
tensor, %arg3: tensor<10xi32>) -> tensor {
   %0 = "tosa.greater_equal"(%arg0, %arg1) : (tensor, tensor) -> 
tensor
   %1 = "tosa.logical_not"(%0) : (tensor) -> tensor
   return %1 : tensor

diff  --git a/mlir/test/IR/core-ops.mlir b/mlir/test/IR/core-ops.mlir
index fc712d4939ba..396211c10430 100644
--- a/mlir/test/IR/core-ops.mlir
+++ b/mlir/test/IR/core-ops.mlir
@@ -942,6 +942,3 @@ func @subtensor_insert(%t: tensor<8x16x4xf32>, %t2: 
tensor<16x32x8xf32>, %idx :
 
   return
 }
-
-// CHECK-LABEL: func private @legacy_visibility_syntax
-func @legacy_visibility_syntax() attri

[llvm-branch-commits] [llvm] 85aaa3e - [X86] Regenerate sdiv_fix_sat.ll + udiv_fix_sat.ll tests

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

Author: Simon Pilgrim
Date: 2021-01-12T17:25:30Z
New Revision: 85aaa3e310c23ec8a375b7a2e2fceee5a72441ef

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

LOG: [X86] Regenerate sdiv_fix_sat.ll + udiv_fix_sat.ll tests

Adding missing libcall PLT qualifiers

Added: 


Modified: 
llvm/test/CodeGen/X86/sdiv_fix_sat.ll
llvm/test/CodeGen/X86/udiv_fix_sat.ll

Removed: 




diff  --git a/llvm/test/CodeGen/X86/sdiv_fix_sat.ll 
b/llvm/test/CodeGen/X86/sdiv_fix_sat.ll
index 512488e8f872..617d5d7876bd 100644
--- a/llvm/test/CodeGen/X86/sdiv_fix_sat.ll
+++ b/llvm/test/CodeGen/X86/sdiv_fix_sat.ll
@@ -322,7 +322,7 @@ define i64 @func5(i64 %x, i64 %y) nounwind {
 ; X64-NEXT:movq %r15, %rdi
 ; X64-NEXT:movq %r12, %rsi
 ; X64-NEXT:movq %r13, %rcx
-; X64-NEXT:callq __divti3
+; X64-NEXT:callq __divti3@PLT
 ; X64-NEXT:movq %rax, %rbx
 ; X64-NEXT:movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
 ; X64-NEXT:movq %rdx, %rbp
@@ -338,7 +338,7 @@ define i64 @func5(i64 %x, i64 %y) nounwind {
 ; X64-NEXT:movq %r12, %rsi
 ; X64-NEXT:movq (%rsp), %rdx # 8-byte Reload
 ; X64-NEXT:movq %r13, %rcx
-; X64-NEXT:callq __modti3
+; X64-NEXT:callq __modti3@PLT
 ; X64-NEXT:orq %rax, %rdx
 ; X64-NEXT:setne %al
 ; X64-NEXT:testb %r14b, %al
@@ -613,7 +613,7 @@ define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
 ; X64-NEXT:movq %r12, %rdi
 ; X64-NEXT:movq %rbp, %rsi
 ; X64-NEXT:movq %r15, %rcx
-; X64-NEXT:callq __divti3
+; X64-NEXT:callq __divti3@PLT
 ; X64-NEXT:movq %rax, %r13
 ; X64-NEXT:movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
 ; X64-NEXT:movq %rdx, %r14
@@ -626,7 +626,7 @@ define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
 ; X64-NEXT:movq %rbp, %rsi
 ; X64-NEXT:movq {{[-0-9]+}}(%r{{[sb]}}p), %rdx # 8-byte Reload
 ; X64-NEXT:movq %r15, %rcx
-; X64-NEXT:callq __modti3
+; X64-NEXT:callq __modti3@PLT
 ; X64-NEXT:orq %rax, %rdx
 ; X64-NEXT:setne %al
 ; X64-NEXT:testb %bl, %al
@@ -668,7 +668,7 @@ define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
 ; X64-NEXT:movq %r15, %rdi
 ; X64-NEXT:movq %r13, %rsi
 ; X64-NEXT:movq %rbp, %rcx
-; X64-NEXT:callq __divti3
+; X64-NEXT:callq __divti3@PLT
 ; X64-NEXT:movq %rax, %r12
 ; X64-NEXT:movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
 ; X64-NEXT:movq %rdx, %r14
@@ -681,7 +681,7 @@ define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
 ; X64-NEXT:movq %r13, %rsi
 ; X64-NEXT:movq {{[-0-9]+}}(%r{{[sb]}}p), %rdx # 8-byte Reload
 ; X64-NEXT:movq %rbp, %rcx
-; X64-NEXT:callq __modti3
+; X64-NEXT:callq __modti3@PLT
 ; X64-NEXT:orq %rax, %rdx
 ; X64-NEXT:setne %al
 ; X64-NEXT:testb %bl, %al
@@ -735,7 +735,7 @@ define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
 ; X64-NEXT:movq %r15, %rdi
 ; X64-NEXT:movq %r12, %rsi
 ; X64-NEXT:movq %rbp, %rcx
-; X64-NEXT:callq __divti3
+; X64-NEXT:callq __divti3@PLT
 ; X64-NEXT:movq %rax, %r13
 ; X64-NEXT:movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
 ; X64-NEXT:movq %rdx, %r14
@@ -748,7 +748,7 @@ define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
 ; X64-NEXT:movq %r12, %rsi
 ; X64-NEXT:movq {{[-0-9]+}}(%r{{[sb]}}p), %rdx # 8-byte Reload
 ; X64-NEXT:movq %rbp, %rcx
-; X64-NEXT:callq __modti3
+; X64-NEXT:callq __modti3@PLT
 ; X64-NEXT:orq %rax, %rdx
 ; X64-NEXT:setne %al
 ; X64-NEXT:testb %bl, %al
@@ -790,7 +790,7 @@ define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
 ; X64-NEXT:movq %r15, %rdi
 ; X64-NEXT:movq %r13, %rsi
 ; X64-NEXT:movq %rbp, %rcx
-; X64-NEXT:callq __divti3
+; X64-NEXT:callq __divti3@PLT
 ; X64-NEXT:movq %rax, %r12
 ; X64-NEXT:movq %rax, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
 ; X64-NEXT:movq %rdx, %r14
@@ -803,7 +803,7 @@ define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
 ; X64-NEXT:movq %r13, %rsi
 ; X64-NEXT:movq {{[-0-9]+}}(%r{{[sb]}}p), %rdx # 8-byte Reload
 ; X64-NEXT:movq %rbp, %rcx
-; X64-NEXT:callq __modti3
+; X64-NEXT:callq __modti3@PLT
 ; X64-NEXT:orq %rax, %rdx
 ; X64-NEXT:setne %al
 ; X64-NEXT:testb %bl, %al

diff  --git a/llvm/test/CodeGen/X86/udiv_fix_sat.ll 
b/llvm/test/CodeGen/X86/udiv_fix_sat.ll
index d2e3b80c2145..2be51c3ccbba 100644
--- a/llvm/test/CodeGen/X86/udiv_fix_sat.ll
+++ b/llvm/test/CodeGen/X86/udiv_fix_sat.ll
@@ -179,7 +179,7 @@ define i64 @func5(i64 %x, i64 %y) nounwind {
 ; X64-NEXT:shlq $32, %rdi
 ; X64-NEXT:xorl %ebx, %ebx
 ; X64-NEXT:xorl %ecx, %ecx
-; X64-NEXT:callq __udivti3
+; X64-NEXT:callq __udivti3@PLT
 ; X64-NEXT:cmpq $-1, %rax
 ; X64-NEXT:movq $-1, %rcx
 ; X

[llvm-branch-commits] [clang] dd95577 - Fix typo in diagnostic message

2021-01-12 Thread Akira Hatanaka via llvm-branch-commits

Author: Akira Hatanaka
Date: 2021-01-12T09:58:11-08:00
New Revision: dd955771240289fbcba5fa1312cb8c78f20cd78f

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

LOG: Fix typo in diagnostic message

rdar://66684531

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 19b003398b02..717bf6e12ccd 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3263,7 +3263,7 @@ def warn_attribute_dllexport_explicit_instantiation_def : 
Warning<
   "'dllexport' attribute ignored on explicit instantiation definition">,
   InGroup;
 def warn_invalid_initializer_from_system_header : Warning<
-  "invalid constructor form class in system header, should not be explicit">,
+  "invalid constructor from class in system header, should not be explicit">,
   InGroup>;
 def note_used_in_initialization_here : Note<"used in initialization here">;
 def err_attribute_dll_member_of_dll_class : Error<



___
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] a4931d4 - [AMDGPU] Regenerate umax crash test

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

Author: Simon Pilgrim
Date: 2021-01-12T18:02:15Z
New Revision: a4931d4fe38d6feef53f97f3dcc7792bfcb06c84

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

LOG: [AMDGPU] Regenerate umax crash test

Added: 


Modified: 
llvm/test/CodeGen/AMDGPU/r600-legalize-umax-bug.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AMDGPU/r600-legalize-umax-bug.ll 
b/llvm/test/CodeGen/AMDGPU/r600-legalize-umax-bug.ll
index b7ed34bbf09b..b4cd36daad65 100644
--- a/llvm/test/CodeGen/AMDGPU/r600-legalize-umax-bug.ll
+++ b/llvm/test/CodeGen/AMDGPU/r600-legalize-umax-bug.ll
@@ -1,8 +1,27 @@
-; RUN: llc -march=r600 -mcpu=cypress -start-after safe-stack %s -o - | 
FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -march=r600 -mcpu=cypress -start-after safe-stack | FileCheck 
%s
 ; Don't crash
 
-; CHECK: MAX_UINT
 define amdgpu_kernel void @test(i64 addrspace(1)* %out) {
+; CHECK-LABEL: test:
+; CHECK:   ; %bb.0: ; %bb
+; CHECK-NEXT:ALU 4, @6, KC0[CB0:0-32], KC1[]
+; CHECK-NEXT:MEM_RAT_CACHELESS STORE_RAW T0.XY, T1.X, 0
+; CHECK-NEXT:ALU 3, @11, KC0[], KC1[]
+; CHECK-NEXT:MEM_RAT_CACHELESS STORE_RAW T0.XY, T1.X, 1
+; CHECK-NEXT:CF_END
+; CHECK-NEXT:PAD
+; CHECK-NEXT:ALU clause starting at 6:
+; CHECK-NEXT: MOV T0.X, literal.x,
+; CHECK-NEXT: MOV T0.Y, 0.0,
+; CHECK-NEXT: LSHR * T1.X, KC0[2].Y, literal.x,
+; CHECK-NEXT:2(2.802597e-45), 0(0.00e+00)
+; CHECK-NEXT: MOV * T0.W, KC0[2].Y,
+; CHECK-NEXT:ALU clause starting at 11:
+; CHECK-NEXT: MAX_UINT T0.X, T0.X, literal.x,
+; CHECK-NEXT: MOV T0.Y, 0.0,
+; CHECK-NEXT: LSHR * T1.X, T0.W, literal.y,
+; CHECK-NEXT:4(5.605194e-45), 2(2.802597e-45)
 bb:
   store i64 2, i64 addrspace(1)* %out
   %tmp = load i64, i64 addrspace(1)* %out



___
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] 3d9c51d - [SVE][NFC] Regenerate a few CodeGen tests

2021-01-12 Thread Cullen Rhodes via llvm-branch-commits

Author: Cullen Rhodes
Date: 2021-01-12T18:10:36Z
New Revision: 3d9c51d111d0c8480d10fc48fb621bac1d080449

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

LOG: [SVE][NFC] Regenerate a few CodeGen tests

Regenerated using llvm/utils/update_llc_test_checks.py as part of
D94504, committing separately to reduce the diff for D94504.

Added: 


Modified: 
llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll

llvm/test/CodeGen/AArch64/sve-pred-contiguous-ldst-addressing-mode-reg-imm.ll

llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll

Removed: 




diff  --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll 
b/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
index be1c03a754fe..44d4b1d27560 100644
--- a/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
+++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
 ; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
 
@@ -10,18 +11,20 @@
 
 define  @ldnf1b( %pg, i8* %a) {
 ; CHECK-LABEL: ldnf1b:
-; CHECK: ldnf1b { z0.b }, p0/z, [x0]
-; CHECK-NEXT: ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ldnf1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT:ret
   %load = call  @llvm.aarch64.sve.ldnf1.nxv16i8( %pg, i8* %a)
   ret  %load
 }
 
 define  @ldnf1b_out_of_lower_bound( %pg, 
i8* %a) {
 ; CHECK-LABEL: ldnf1b_out_of_lower_bound:
-; CHECK:   rdvlx[[OFFSET:[0-9]+]], #-9
-; CHECK-NEXT:  add x[[BASE:[0-9]+]], x0, x[[OFFSET]]
-; CHECK-NEXT:  ldnf1b { z0.b }, p0/z, [x[[BASE]]]
-; CHECK-NEXT:  ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rdvl x8, #-9
+; CHECK-NEXT:add x8, x0, x8
+; CHECK-NEXT:ldnf1b { z0.b }, p0/z, [x8]
+; CHECK-NEXT:ret
   %base_scalable = bitcast i8* %a to *
   %base = getelementptr , * 
%base_scalable, i64 -9
   %base_scalar = bitcast * %base to i8*
@@ -31,8 +34,9 @@ define  @ldnf1b_out_of_lower_bound( %pg, i8*
 
 define  @ldnf1b_lower_bound( %pg, i8* %a) {
 ; CHECK-LABEL: ldnf1b_lower_bound:
-; CHECK: ldnf1b { z0.b }, p0/z, [x0, #-8, mul vl]
-; CHECK-NEXT: ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ldnf1b { z0.b }, p0/z, [x0, #-8, mul vl]
+; CHECK-NEXT:ret
   %base_scalable = bitcast i8* %a to *
   %base = getelementptr , * 
%base_scalable, i64 -8
   %base_scalar = bitcast * %base to i8*
@@ -42,8 +46,9 @@ define  @ldnf1b_lower_bound( %pg, i8* %a) {
 
 define  @ldnf1b_inbound( %pg, i8* %a) {
 ; CHECK-LABEL: ldnf1b_inbound:
-; CHECK: ldnf1b { z0.b }, p0/z, [x0, #1, mul vl]
-; CHECK-NEXT: ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ldnf1b { z0.b }, p0/z, [x0, #1, mul vl]
+; CHECK-NEXT:ret
   %base_scalable = bitcast i8* %a to *
   %base = getelementptr , * 
%base_scalable, i64 1
   %base_scalar = bitcast * %base to i8*
@@ -53,8 +58,9 @@ define  @ldnf1b_inbound( 
%pg, i8* %a) {
 
 define  @ldnf1b_upper_bound( %pg, i8* %a) {
 ; CHECK-LABEL: ldnf1b_upper_bound:
-; CHECK: ldnf1b { z0.b }, p0/z, [x0, #7, mul vl]
-; CHECK-NEXT: ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ldnf1b { z0.b }, p0/z, [x0, #7, mul vl]
+; CHECK-NEXT:ret
   %base_scalable = bitcast i8* %a to *
   %base = getelementptr , * 
%base_scalable, i64 7
   %base_scalar = bitcast * %base to i8*
@@ -64,10 +70,11 @@ define  @ldnf1b_upper_bound( %pg, i8* %a) {
 
 define  @ldnf1b_out_of_upper_bound( %pg, 
i8* %a) {
 ; CHECK-LABEL: ldnf1b_out_of_upper_bound:
-; CHECK:   rdvlx[[OFFSET:[0-9]+]], #8
-; CHECK-NEXT:  add x[[BASE:[0-9]+]], x0, x[[OFFSET]]
-; CHECK-NEXT:  ldnf1b { z0.b }, p0/z, [x[[BASE]]]
-; CHECK-NEXT:  ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rdvl x8, #8
+; CHECK-NEXT:add x8, x0, x8
+; CHECK-NEXT:ldnf1b { z0.b }, p0/z, [x8]
+; CHECK-NEXT:ret
   %base_scalable = bitcast i8* %a to *
   %base = getelementptr , * 
%base_scalable, i64 8
   %base_scalar = bitcast * %base to i8*
@@ -77,8 +84,9 @@ define  @ldnf1b_out_of_upper_bound( %pg, i8*
 
 define  @ldnf1b_h( %pg, i8* %a) {
 ; CHECK-LABEL: ldnf1b_h:
-; CHECK: ldnf1b { z0.h }, p0/z, [x0]
-; CHECK-NEXT: ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ldnf1b { z0.h }, p0/z, [x0]
+; CHECK-NEXT:ret
   %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
   %res = zext  %load to 
   ret  %res
@@ -86,8 +94,9 @@ define  @ldnf1b_h( %pg, 
i8* %a) {
 
 define  @ldnf1b_h_inbound( %pg, i8* %a) {
 ; CHECK-LABEL: ldnf1b_h_inbound:
-; CHECK: ldnf1b { z0.h }, p0/z, [x0, #7, mul vl]
-; CHECK-NEXT: ret
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ldnf1b { z0.h }, p0/z, [x0, #7, mul vl]
+; CHECK-NEXT:ret
   %base_scalable = bitcast i8* %a to *
   %base = getelementptr , * %base_scalable, 
i64 7
   %base_scalar = bitcast * %bas

[llvm-branch-commits] [clang] 3484715 - Add -ansi option to CompileOnly group

2021-01-12 Thread Aaron Ballman via llvm-branch-commits

Author: Timm Bäder
Date: 2021-01-12T13:16:49-05:00
New Revision: 348471575d9c24bbfb124ca5eac1589de075da88

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

LOG: Add -ansi option to CompileOnly group

-ansi is documented as being the "same as -std=c89", but there are
differences when passing it to a link.

Adding -ansi to said group makes sense since it's supposed to be an
alias for -std=c89 and resolves this inconsistency.

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d9586e086a9c..b441c1b4c169 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -800,7 +800,7 @@ def Z_Flag : Flag<["-"], "Z">, Group;
 def Z_Joined : Joined<["-"], "Z">;
 def all__load : Flag<["-"], "all_load">;
 def allowable__client : Separate<["-"], "allowable_client">;
-def ansi : Flag<["-", "--"], "ansi">;
+def ansi : Flag<["-", "--"], "ansi">, Group;
 def arch__errors__fatal : Flag<["-"], "arch_errors_fatal">;
 def arch : Separate<["-"], "arch">, Flags<[NoXarchOption]>;
 def arch__only : Separate<["-"], "arch_only">;



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


[llvm-branch-commits] [lld] b117d17 - [doc] Place sha256 in lld/README.md into backticks

2021-01-12 Thread Shoaib Meenai via llvm-branch-commits

Author: Emil Engler
Date: 2021-01-12T10:19:40-08:00
New Revision: b117d17d264f448e0b037a62f5a48ec9aedd886c

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

LOG: [doc] Place sha256 in lld/README.md into backticks

Reviewed By: smeenai

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

Added: 


Modified: 
lld/README.md

Removed: 




diff  --git a/lld/README.md b/lld/README.md
index 3b8cd7a14948..3b693c9957ee 100644
--- a/lld/README.md
+++ b/lld/README.md
@@ -16,4 +16,4 @@ same tests, we create a collection of self contained programs.
 
 It is hosted at 
https://s3-us-west-2.amazonaws.com/linker-tests/lld-speed-test.tar.xz
 
-The current sha256 is 
10eec685463d5a8bbf08d77f4ca96282161d396c65bd97dc99dbde644a31610f.
+The current sha256 is 
`10eec685463d5a8bbf08d77f4ca96282161d396c65bd97dc99dbde644a31610f`.



___
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] ef3800e - Return false from __has_declspec_attribute() if not explicitly enabled

2021-01-12 Thread Aaron Ballman via llvm-branch-commits

Author: Timm Bäder
Date: 2021-01-12T13:20:08-05:00
New Revision: ef3800e82169c674219501d9ac09ef12b28e6359

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

LOG: Return false from __has_declspec_attribute() if not explicitly enabled

Currently, projects can check for __has_declspec_attribute() and use
it accordingly, but the check for __has_declspec_attribute will return
true even if declspec attributes are not enabled for the target.

This changes Clang to instead return false when declspec attributes are
not supported for the target.

Added: 


Modified: 
clang/lib/Lex/PPMacroExpansion.cpp

Removed: 




diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 3969630f2002..43d31d6c5732 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1693,8 +1693,14 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
   [this](Token &Tok, bool &HasLexedNextToken) -> int {
 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
diag::err_feature_check_malformed);
-return II ? hasAttribute(AttrSyntax::Declspec, nullptr, II,
- getTargetInfo(), getLangOpts()) : 0;
+if (II) {
+  const LangOptions &LangOpts = getLangOpts();
+  return LangOpts.DeclSpecKeyword &&
+ hasAttribute(AttrSyntax::Declspec, nullptr, II,
+  getTargetInfo(), LangOpts);
+}
+
+return false;
   });
   } else if (II == Ident__has_cpp_attribute ||
  II == Ident__has_c_attribute) {



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


[llvm-branch-commits] [llvm] 5aefc8d - [llvm] [cmake] Remove obsolete /usr/local hack for *BSD

2021-01-12 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2021-01-12T19:26:04+01:00
New Revision: 5aefc8dc4d14ad04259ab8ae0b2e0da2596d66f7

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

LOG: [llvm] [cmake] Remove obsolete /usr/local hack for *BSD

Remove the hack adding /usr/local paths on FreeBSD and DragonFlyBSD.
It does not seem to be necessary today, and it breaks cross builds.

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

Added: 


Modified: 
llvm/CMakeLists.txt

Removed: 




diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index ee1b646ab651..26a7029afefd 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -911,13 +911,6 @@ if(LLVM_TARGET_IS_CROSSCOMPILE_HOST)
 # (this is a variable that CrossCompile sets on recursive invocations)
 endif()
 
-if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
-  # On FreeBSD, /usr/local/* is not used by default. In order to build LLVM
-  # with libxml2, iconv.h, etc., we must add /usr/local paths.
-  include_directories(SYSTEM "/usr/local/include")
-  link_directories("/usr/local/lib")
-endif(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
-
 if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
# special hack for Solaris to handle crazy system sys/regset.h
include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")



___
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] bb9ebf6 - [Tests] Add tests for new InstCombine OR transformation, NFC

2021-01-12 Thread Dávid Bolvanský via llvm-branch-commits

Author: Dávid Bolvanský
Date: 2021-01-12T19:29:17+01:00
New Revision: bb9ebf6baf7057d7f2aed90fccbac2414cf9a134

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

LOG: [Tests] Add tests for new InstCombine OR transformation, NFC

Added: 


Modified: 
llvm/test/Transforms/InstCombine/or.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/or.ll 
b/llvm/test/Transforms/InstCombine/or.ll
index b5e3af2c7652..d41b8d53dd40 100644
--- a/llvm/test/Transforms/InstCombine/or.ll
+++ b/llvm/test/Transforms/InstCombine/or.ll
@@ -2,6 +2,7 @@
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 
 target datalayout = 
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n32:64"
+declare void @use(i32)
 
 define i32 @test12(i32 %A) {
 ; Should be eliminated
@@ -1000,3 +1001,116 @@ end:
   %conv8 = zext i1 %t5 to i32
   ret i32 %conv8
 }
+
+define i32 @test1(i32 %x, i32 %y) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y]], [[X]]
+; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
+; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:ret i32 [[OR1]]
+;
+  %xor = xor i32 %y, %x
+  %or = or i32 %y, %x
+  %neg = xor i32 %or, -1
+  %or1 = or i32 %xor, %neg
+  ret i32 %or1
+}
+
+define i32 @test2(i32 %x, i32 %y) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
+; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y]], [[X]]
+; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:ret i32 [[OR1]]
+;
+  %or = or i32 %y, %x
+  %neg = xor i32 %or, -1
+  %xor = xor i32 %y, %x
+  %or1 = or i32 %xor, %neg
+  ret i32 %or1
+}
+
+define i32 @test3(i32 %x, i32 %y) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
+; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y]], [[X]]
+; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:ret i32 [[OR1]]
+;
+  %or = or i32 %y, %x
+  %neg = xor i32 %or, -1
+  %xor = xor i32 %y, %x
+  %or1 = or i32 %xor, %neg
+  ret i32 %or1
+}
+
+define <2 x i32> @test4_vec(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @test4_vec(
+; CHECK-NEXT:[[OR:%.*]] = or <2 x i32> [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[NEG:%.*]] = xor <2 x i32> [[OR]], 
+; CHECK-NEXT:[[XOR:%.*]] = xor <2 x i32> [[Y]], [[X]]
+; CHECK-NEXT:[[OR1:%.*]] = or <2 x i32> [[XOR]], [[NEG]]
+; CHECK-NEXT:ret <2 x i32> [[OR1]]
+;
+  %or = or <2 x i32> %y, %x
+  %neg = xor <2 x i32> %or, 
+  %xor = xor <2 x i32> %y, %x
+  %or1 = or <2 x i32> %xor, %neg
+  ret <2 x i32> %or1
+}
+
+define i32 @test5_use(i32 %x, i32 %y) {
+; CHECK-LABEL: @test5_use(
+; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
+; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y]], [[X]]
+; CHECK-NEXT:call void @use(i32 [[NEG]])
+; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:ret i32 [[OR1]]
+;
+  %or = or i32 %y, %x
+  %neg = xor i32 %or, -1
+  %xor = xor i32 %y, %x
+  call void @use(i32 %neg)
+  %or1 = or i32 %xor, %neg
+  ret i32 %or1
+}
+
+define i32 @test5_use2(i32 %x, i32 %y) {
+; CHECK-LABEL: @test5_use2(
+; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
+; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y]], [[X]]
+; CHECK-NEXT:call void @use(i32 [[XOR]])
+; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:ret i32 [[OR1]]
+;
+  %or = or i32 %y, %x
+  %neg = xor i32 %or, -1
+  %xor = xor i32 %y, %x
+  call void @use(i32 %xor)
+  %or1 = or i32 %xor, %neg
+  ret i32 %or1
+}
+define i32 @test5_use3(i32 %x, i32 %y) {
+; CHECK-LABEL: @test5_use3(
+; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
+; CHECK-NEXT:call void @use(i32 [[NEG]])
+; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y]], [[X]]
+; CHECK-NEXT:call void @use(i32 [[XOR]])
+; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:ret i32 [[OR1]]
+;
+  %or = or i32 %y, %x
+  %neg = xor i32 %or, -1
+  call void @use(i32 %neg)
+  %xor = xor i32 %y, %x
+  call void @use(i32 %xor)
+  %or1 = or i32 %xor, %neg
+  ret i32 %or1
+}
+



___
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] 0529946 - [instCombine] Add (A ^ B) | ~(A | B) -> ~(A & B)

2021-01-12 Thread Dávid Bolvanský via llvm-branch-commits

Author: Dávid Bolvanský
Date: 2021-01-12T19:29:17+01:00
New Revision: 0529946b5bafafd10d77b946ee9fa96f388860ef

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

LOG: [instCombine] Add (A ^ B) | ~(A | B) -> ~(A & B)

define i32 @src(i32 %x, i32 %y) {
%0:
  %xor = xor i32 %y, %x
  %or = or i32 %y, %x
  %neg = xor i32 %or, 4294967295
  %or1 = or i32 %xor, %neg
  ret i32 %or1
}
=>
define i32 @tgt(i32 %x, i32 %y) {
%0:
  %and = and i32 %x, %y
  %neg = xor i32 %and, 4294967295
  ret i32 %neg
}
Transformation seems to be correct!

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

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/or.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 15dcf2d19c15..352126fa07ca 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1627,6 +1627,14 @@ static Instruction *foldOrToXor(BinaryOperator &I,
 match(Op1, m_Not(m_c_Or(m_Specific(A), m_Specific(B)
   return BinaryOperator::CreateNot(Builder.CreateXor(A, B));
 
+  // Operand complexity canonicalization guarantees that the 'xor' is Op0.
+  // (A ^ B) | ~(A | B) --> ~(A & B)
+  // (A ^ B) | ~(B | A) --> ~(A & B)
+  if (Op0->hasOneUse() || Op1->hasOneUse())
+if (match(Op0, m_Xor(m_Value(A), m_Value(B))) &&
+match(Op1, m_Not(m_c_Or(m_Specific(A), m_Specific(B)
+  return BinaryOperator::CreateNot(Builder.CreateAnd(A, B));
+
   // (A & ~B) | (~A & B) --> A ^ B
   // (A & ~B) | (B & ~A) --> A ^ B
   // (~B & A) | (~A & B) --> A ^ B

diff  --git a/llvm/test/Transforms/InstCombine/or.ll 
b/llvm/test/Transforms/InstCombine/or.ll
index d41b8d53dd40..b5da1734c102 100644
--- a/llvm/test/Transforms/InstCombine/or.ll
+++ b/llvm/test/Transforms/InstCombine/or.ll
@@ -1004,10 +1004,8 @@ end:
 
 define i32 @test1(i32 %x, i32 %y) {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y:%.*]], [[X:%.*]]
-; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y]], [[X]]
-; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
-; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:[[TMP1:%.*]] = and i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[OR1:%.*]] = xor i32 [[TMP1]], -1
 ; CHECK-NEXT:ret i32 [[OR1]]
 ;
   %xor = xor i32 %y, %x
@@ -1019,13 +1017,11 @@ define i32 @test1(i32 %x, i32 %y) {
 
 define i32 @test2(i32 %x, i32 %y) {
 ; CHECK-LABEL: @test2(
-; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y:%.*]], [[X:%.*]]
-; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
-; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y]], [[X]]
-; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:[[TMP1:%.*]] = and i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[OR1:%.*]] = xor i32 [[TMP1]], -1
 ; CHECK-NEXT:ret i32 [[OR1]]
 ;
-  %or = or i32 %y, %x
+  %or = or i32 %x, %y
   %neg = xor i32 %or, -1
   %xor = xor i32 %y, %x
   %or1 = or i32 %xor, %neg
@@ -1034,25 +1030,21 @@ define i32 @test2(i32 %x, i32 %y) {
 
 define i32 @test3(i32 %x, i32 %y) {
 ; CHECK-LABEL: @test3(
-; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y:%.*]], [[X:%.*]]
-; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
-; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y]], [[X]]
-; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:[[TMP1:%.*]] = and i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:[[OR1:%.*]] = xor i32 [[TMP1]], -1
 ; CHECK-NEXT:ret i32 [[OR1]]
 ;
   %or = or i32 %y, %x
   %neg = xor i32 %or, -1
-  %xor = xor i32 %y, %x
+  %xor = xor i32 %x, %y
   %or1 = or i32 %xor, %neg
   ret i32 %or1
 }
 
 define <2 x i32> @test4_vec(<2 x i32> %x, <2 x i32> %y) {
 ; CHECK-LABEL: @test4_vec(
-; CHECK-NEXT:[[OR:%.*]] = or <2 x i32> [[Y:%.*]], [[X:%.*]]
-; CHECK-NEXT:[[NEG:%.*]] = xor <2 x i32> [[OR]], 
-; CHECK-NEXT:[[XOR:%.*]] = xor <2 x i32> [[Y]], [[X]]
-; CHECK-NEXT:[[OR1:%.*]] = or <2 x i32> [[XOR]], [[NEG]]
+; CHECK-NEXT:[[TMP1:%.*]] = and <2 x i32> [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[OR1:%.*]] = xor <2 x i32> [[TMP1]], 
 ; CHECK-NEXT:ret <2 x i32> [[OR1]]
 ;
   %or = or <2 x i32> %y, %x
@@ -1066,9 +1058,9 @@ define i32 @test5_use(i32 %x, i32 %y) {
 ; CHECK-LABEL: @test5_use(
 ; CHECK-NEXT:[[OR:%.*]] = or i32 [[Y:%.*]], [[X:%.*]]
 ; CHECK-NEXT:[[NEG:%.*]] = xor i32 [[OR]], -1
-; CHECK-NEXT:[[XOR:%.*]] = xor i32 [[Y]], [[X]]
 ; CHECK-NEXT:call void @use(i32 [[NEG]])
-; CHECK-NEXT:[[OR1:%.*]] = or i32 [[XOR]], [[NEG]]
+; CHECK-NEXT:[[TMP1:%.*]] = and i32 [[Y]], [[X]]
+; CHECK-NEXT:[[OR1:%.*]] = xor i32 [[TMP1]], -1
 ; CHECK-NEXT:ret i32 [[OR1]]
 ;
   %or = or i32 %y, %x
@@ -1081,11 +1073,10 @@ define i32 @test5_use(i32

[llvm-branch-commits] [libunwind] b6164d9 - Bump version to 11.1.0

2021-01-12 Thread Tom Stellard via llvm-branch-commits

Author: Tom Stellard
Date: 2021-01-12T10:34:51-08:00
New Revision: b6164d967e010ed54ed8ce0d4a3ea19f54e90108

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

LOG: Bump version to 11.1.0

Added: 


Modified: 
libcxx/CMakeLists.txt
libcxxabi/CMakeLists.txt
libunwind/CMakeLists.txt
llvm/CMakeLists.txt
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/release/build_llvm_package.bat

Removed: 




diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index f145831c75d8..910d04b54b6d 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -32,7 +32,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR 
LIBCXX_STANDALONE_BUIL
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION 11.0.1)
+  set(PACKAGE_VERSION 11.1.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

diff  --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index deff3d5e4ad1..36c6b2249e2b 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -25,7 +25,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR 
LIBCXXABI_STANDALONE_B
   project(libcxxabi CXX C)
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 11.0.1)
+  set(PACKAGE_VERSION 11.1.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index cdac67e93df1..e44a103648f9 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -83,7 +83,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR 
LIBUNWIND_STANDALONE_B
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 11.0.1)
+  set(PACKAGE_VERSION 11.1.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index b8dabbbca05a..247ad36d3845 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -27,10 +27,10 @@ if(NOT DEFINED LLVM_VERSION_MAJOR)
   set(LLVM_VERSION_MAJOR 11)
 endif()
 if(NOT DEFINED LLVM_VERSION_MINOR)
-  set(LLVM_VERSION_MINOR 0)
+  set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 1)
+  set(LLVM_VERSION_PATCH 0)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX "")

diff  --git a/llvm/utils/gn/secondary/llvm/version.gni 
b/llvm/utils/gn/secondary/llvm/version.gni
index e2b6390b66cc..ebc66a5138e7 100644
--- a/llvm/utils/gn/secondary/llvm/version.gni
+++ b/llvm/utils/gn/secondary/llvm/version.gni
@@ -1,4 +1,4 @@
 llvm_version_major = 11
-llvm_version_minor = 0
-llvm_version_patch = 1
+llvm_version_minor = 1
+llvm_version_patch = 0
 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch"

diff  --git a/llvm/utils/release/build_llvm_package.bat 
b/llvm/utils/release/build_llvm_package.bat
index 31e237c63565..73362920773b 100755
--- a/llvm/utils/release/build_llvm_package.bat
+++ b/llvm/utils/release/build_llvm_package.bat
@@ -27,8 +27,8 @@ set 
python64_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36
 for /f "usebackq" %%i in (`PowerShell ^(Get-Date^).ToString^('MMdd'^)`) do 
set datestamp=%%i
 
 set revision=%1
-set package_version=11.0.1-%revision:~0,8%
-set clang_format_vs_version=11.0.1.%datestamp%
+set package_version=11.1.0-%revision:~0,8%
+set clang_format_vs_version=11.1.0.%datestamp%
 set build_dir=llvm_package_%revision:~0,8%
 
 echo Revision: %revision%



___
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] 9bbcb55 - Address ABI issues introduced with CXCursor_CXXAddrspaceCastExpr

2021-01-12 Thread Tom Stellard via llvm-branch-commits

Author: Marco Antognini
Date: 2021-01-12T10:34:52-08:00
New Revision: 9bbcb554cdbf1a7b85e9a72169e4037cf4736a10

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

LOG: Address ABI issues introduced with CXCursor_CXXAddrspaceCastExpr

Revert values in CXCursorKind as they were before
CXCursor_CXXAddrspaceCastExpr was introduced in a6a237f2046a ([OpenCL]
Added addrspace_cast operator in C++ mode., 2020-05-18).

Insert CXCursor_CXXAddrspaceCastExpr after the last expression in
CXCursorKind using the next available value.

Reviewed By: akyrtzi, svenvh

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

(cherry picked from commit bbdbd020d2c2f315ed1545b23c23ec6ff1abc022)

Added: 


Modified: 
clang/include/clang-c/Index.h

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 5fa728d6d66c..9f5a727c84bb 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -33,7 +33,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 60
+#define CINDEX_VERSION_MINOR 61
 
 #define CINDEX_VERSION_ENCODE(major, minor) (((major)*1) + ((minor)*1))
 
@@ -2052,62 +2052,58 @@ enum CXCursorKind {
*/
   CXCursor_CXXFunctionalCastExpr = 128,
 
-  /** OpenCL's addrspace_cast<> expression.
-   */
-  CXCursor_CXXAddrspaceCastExpr = 129,
-
   /** A C++ typeid expression (C++ [expr.typeid]).
*/
-  CXCursor_CXXTypeidExpr = 130,
+  CXCursor_CXXTypeidExpr = 129,
 
   /** [C++ 2.13.5] C++ Boolean Literal.
*/
-  CXCursor_CXXBoolLiteralExpr = 131,
+  CXCursor_CXXBoolLiteralExpr = 130,
 
   /** [C++0x 2.14.7] C++ Pointer Literal.
*/
-  CXCursor_CXXNullPtrLiteralExpr = 132,
+  CXCursor_CXXNullPtrLiteralExpr = 131,
 
   /** Represents the "this" expression in C++
*/
-  CXCursor_CXXThisExpr = 133,
+  CXCursor_CXXThisExpr = 132,
 
   /** [C++ 15] C++ Throw Expression.
*
* This handles 'throw' and 'throw' assignment-expression. When
* assignment-expression isn't present, Op will be null.
*/
-  CXCursor_CXXThrowExpr = 134,
+  CXCursor_CXXThrowExpr = 133,
 
   /** A new expression for memory allocation and constructor calls, e.g:
* "new CXXNewExpr(foo)".
*/
-  CXCursor_CXXNewExpr = 135,
+  CXCursor_CXXNewExpr = 134,
 
   /** A delete expression for memory deallocation and destructor calls,
* e.g. "delete[] pArray".
*/
-  CXCursor_CXXDeleteExpr = 136,
+  CXCursor_CXXDeleteExpr = 135,
 
   /** A unary expression. (noexcept, sizeof, or other traits)
*/
-  CXCursor_UnaryExpr = 137,
+  CXCursor_UnaryExpr = 136,
 
   /** An Objective-C string literal i.e. @"foo".
*/
-  CXCursor_ObjCStringLiteral = 138,
+  CXCursor_ObjCStringLiteral = 137,
 
   /** An Objective-C \@encode expression.
*/
-  CXCursor_ObjCEncodeExpr = 139,
+  CXCursor_ObjCEncodeExpr = 138,
 
   /** An Objective-C \@selector expression.
*/
-  CXCursor_ObjCSelectorExpr = 140,
+  CXCursor_ObjCSelectorExpr = 139,
 
   /** An Objective-C \@protocol expression.
*/
-  CXCursor_ObjCProtocolExpr = 141,
+  CXCursor_ObjCProtocolExpr = 140,
 
   /** An Objective-C "bridged" cast expression, which casts between
* Objective-C pointers and C pointers, transferring ownership in the 
process.
@@ -2116,7 +2112,7 @@ enum CXCursorKind {
*   NSString *str = (__bridge_transfer NSString *)CFCreateString();
* \endcode
*/
-  CXCursor_ObjCBridgedCastExpr = 142,
+  CXCursor_ObjCBridgedCastExpr = 141,
 
   /** Represents a C++0x pack expansion that produces a sequence of
* expressions.
@@ -2131,7 +2127,7 @@ enum CXCursorKind {
* }
* \endcode
*/
-  CXCursor_PackExpansionExpr = 143,
+  CXCursor_PackExpansionExpr = 142,
 
   /** Represents an expression that computes the length of a parameter
* pack.
@@ -2143,7 +2139,7 @@ enum CXCursorKind {
* };
* \endcode
*/
-  CXCursor_SizeOfPackExpr = 144,
+  CXCursor_SizeOfPackExpr = 143,
 
   /* Represents a C++ lambda expression that produces a local function
* object.
@@ -2157,39 +2153,43 @@ enum CXCursorKind {
* }
* \endcode
*/
-  CXCursor_LambdaExpr = 145,
+  CXCursor_LambdaExpr = 144,
 
   /** Objective-c Boolean Literal.
*/
-  CXCursor_ObjCBoolLiteralExpr = 146,
+  CXCursor_ObjCBoolLiteralExpr = 145,
 
   /** Represents the "self" expression in an Objective-C method.
*/
-  CXCursor_ObjCSelfExpr = 147,
+  CXCursor_ObjCSelfExpr = 146,
 
   /** OpenMP 5.0 [2.1.5, Array Section].
*/
-  CXCursor_OMPArraySectionExpr = 148,
+  CXCursor_OMPArraySectionExpr = 147,
 
   /** Represents an @available(...) check.
*/
-  CXCursor_ObjCAvailabilityCheckExpr = 149,
+  CXCursor_ObjCAvailabilityCheckExpr = 148,
 
   /**
* Fixed point literal
*/
-  CXCurso

[llvm-branch-commits] [flang] 6f4d460 - [Flang][openmp][openacc] Extend CheckNoBranching to handle branching provided by LabelEnforce.

2021-01-12 Thread Sameeran joshi via llvm-branch-commits

Author: sameeran joshi
Date: 2021-01-13T00:04:45+05:30
New Revision: 6f4d460762006af17826693abc1e7139a76aa1f2

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

LOG: [Flang][openmp][openacc] Extend CheckNoBranching to handle branching 
provided by LabelEnforce.

`CheckNoBranching` is currently handling only illegal branching out for 
constructs
with `Parser::Name` in them.
Extend the same for handling illegal branching out caused by `Parser::Label` 
based statements.
This patch could possibly solve one of the issues(typically branching out) 
mentioned in D92735.

Reviewed By: kiranchandramohan

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

Added: 


Modified: 
flang/lib/Semantics/check-directive-structure.h
flang/lib/Semantics/check-omp-structure.cpp
flang/test/Semantics/omp-parallell01.f90

Removed: 




diff  --git a/flang/lib/Semantics/check-directive-structure.h 
b/flang/lib/Semantics/check-directive-structure.h
index 062f85b63b85..1075087feb4f 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -15,7 +15,6 @@
 #include "flang/Common/enum-set.h"
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/tools.h"
-
 #include 
 
 namespace Fortran::semantics {
@@ -43,6 +42,9 @@ template  class NoBranchingEnforce {
 
   template  bool Pre(const parser::Statement &statement) {
 currentStatementSourcePosition_ = statement.source;
+if (statement.label.has_value()) {
+  labels_.insert(*statement.label);
+}
 return true;
   }
 
@@ -54,6 +56,8 @@ template  class NoBranchingEnforce {
   }
   void Post(const parser::StopStmt &) { EmitBranchOutError("STOP"); }
 
+  std::set labels() { return labels_; }
+
 private:
   parser::MessageFormattedText GetEnclosingMsg() const {
 return {"Enclosing %s construct"_en_US, upperCaseDirName_};
@@ -103,6 +107,7 @@ template  class NoBranchingEnforce {
   parser::CharBlock sourcePosition_;
   std::string upperCaseDirName_;
   D currentDirective_;
+  std::set labels_;
 };
 
 // Generic structure checker for directives/clauses language such as OpenMP
@@ -226,6 +231,9 @@ class DirectiveStructureChecker : public virtual 
BaseChecker {
   SayNotMatching(beginDir.source, endDir.source);
 }
   }
+  // Check illegal branching out of `Parser::Block` for `Parser::Name` based
+  // nodes (examples `Parser::ExitStmt`) along with `Parser::Label`
+  // based nodes (example `Parser::GotoStmt`).
   void CheckNoBranching(const parser::Block &block, D directive,
   const parser::CharBlock &directiveSource);
 
@@ -271,6 +279,11 @@ void DirectiveStructureChecker::CheckNoBranching(
   NoBranchingEnforce noBranchingEnforce{
   context_, directiveSource, directive, ContextDirectiveAsFortran()};
   parser::Walk(block, noBranchingEnforce);
+
+  LabelEnforce directiveLabelEnforce{context_, noBranchingEnforce.labels(),
+  directiveSource,
+  parser::ToUpperCaseLetters(getDirectiveName(directive).str()).c_str()};
+  parser::Walk(block, directiveLabelEnforce);
 }
 
 // Check that only clauses included in the given set are present after the 
given

diff  --git a/flang/lib/Semantics/check-omp-structure.cpp 
b/flang/lib/Semantics/check-omp-structure.cpp
index 4d1c96f66905..773f5b2aeb21 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -125,14 +125,7 @@ void OmpStructureChecker::Enter(const 
parser::OpenMPBlockConstruct &x) {
   CheckMatching(beginDir, endDir);
 
   PushContextAndClauseSets(beginDir.source, beginDir.v);
-
-  switch (beginDir.v) {
-  case llvm::omp::OMPD_parallel:
-CheckNoBranching(block, llvm::omp::OMPD_parallel, beginDir.source);
-break;
-  default:
-break;
-  }
+  CheckNoBranching(block, beginDir.v, beginDir.source);
 }
 
 void OmpStructureChecker::Leave(const parser::OpenMPBlockConstruct &) {

diff  --git a/flang/test/Semantics/omp-parallell01.f90 
b/flang/test/Semantics/omp-parallell01.f90
index e3490563f332..1a2cae1830bc 100644
--- a/flang/test/Semantics/omp-parallell01.f90
+++ b/flang/test/Semantics/omp-parallell01.f90
@@ -1,5 +1,4 @@
 ! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
-! XFAIL: *
 
 ! OpenMP Version 4.5
 ! 2.5 parallel construct.
@@ -13,7 +12,7 @@ program omp_parallel
   do i = 1, 10
 do j = 1, 10
   print *, "Hello"
-  !ERROR: invalid branch to/from OpenMP structured block
+  !ERROR: Control flow escapes from PARALLEL
   goto 10
 end do
   end do



___
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] 03c8d6a - [LegalizeDAG][RISCV][PowerPC][AMDGPU][WebAssembly] Improve expansion of SETONE/SETUEQ on targets without SETO/SETUO.

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

Author: Craig Topper
Date: 2021-01-12T10:45:03-08:00
New Revision: 03c8d6a0c4bd0016bdfd1e53e6878696fe6412ed

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

LOG: [LegalizeDAG][RISCV][PowerPC][AMDGPU][WebAssembly] Improve expansion of 
SETONE/SETUEQ on targets without SETO/SETUO.

If SETO/SETUO aren't legal, they'll be expanded and we'll end up
with 3 comparisons.

SETONE is equivalent to (SETOGT || SETOLT)
so if one of those operations is supported use that expansion. We
don't need both since we can commute the operands to make the other.

SETUEQ can be implemented with !(SETOGT || SETOLT) or (SETULE && SETUGE).
I've only implemented the first because it didn't look like most of the
affected targets had legal SETULE/SETUGE.

Reviewed By: frasercrmck, tlively, nemanjai

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/test/CodeGen/AMDGPU/setcc.ll
llvm/test/CodeGen/PowerPC/spe.ll
llvm/test/CodeGen/PowerPC/vsx.ll
llvm/test/CodeGen/RISCV/double-br-fcmp.ll
llvm/test/CodeGen/RISCV/double-fcmp.ll
llvm/test/CodeGen/RISCV/double-select-fcmp.ll
llvm/test/CodeGen/RISCV/float-br-fcmp.ll
llvm/test/CodeGen/RISCV/float-fcmp.ll
llvm/test/CodeGen/RISCV/float-select-fcmp.ll
llvm/test/CodeGen/RISCV/half-br-fcmp.ll
llvm/test/CodeGen/RISCV/half-fcmp.ll
llvm/test/CodeGen/RISCV/half-select-fcmp.ll
llvm/test/CodeGen/RISCV/rvv/setcc-fp-rv32.ll
llvm/test/CodeGen/RISCV/rvv/setcc-fp-rv64.ll
llvm/test/CodeGen/WebAssembly/comparisons-f32.ll
llvm/test/CodeGen/WebAssembly/comparisons-f64.ll
llvm/test/CodeGen/WebAssembly/simd-comparisons.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 9e1ea7c81a35..523895200f6a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -1741,13 +1741,28 @@ bool SelectionDAGLegalize::LegalizeSetCCCondCode(
 assert(TLI.isCondCodeLegal(ISD::SETOEQ, OpVT)
 && "If SETO is expanded, SETOEQ must be legal!");
 CC1 = ISD::SETOEQ; CC2 = ISD::SETOEQ; Opc = ISD::AND; break;
+case ISD::SETONE:
+case ISD::SETUEQ:
+// If the SETUO or SETO CC isn't legal, we might be able to use
+// SETOGT || SETOLT, inverting the result for SETUEQ. We only need one
+// of SETOGT/SETOLT to be legal, the other can be emulated by swapping
+// the operands.
+CC2 = ((unsigned)CCCode & 0x8U) ? ISD::SETUO : ISD::SETO;
+if (!TLI.isCondCodeLegal(CC2, OpVT) &&
+(TLI.isCondCodeLegal(ISD::SETOGT, OpVT) ||
+ TLI.isCondCodeLegal(ISD::SETOLT, OpVT))) {
+  CC1 = ISD::SETOGT;
+  CC2 = ISD::SETOLT;
+  Opc = ISD::OR;
+  NeedInvert = ((unsigned)CCCode & 0x8U);
+  break;
+}
+LLVM_FALLTHROUGH;
 case ISD::SETOEQ:
 case ISD::SETOGT:
 case ISD::SETOGE:
 case ISD::SETOLT:
 case ISD::SETOLE:
-case ISD::SETONE:
-case ISD::SETUEQ:
 case ISD::SETUNE:
 case ISD::SETUGT:
 case ISD::SETUGE:

diff  --git a/llvm/test/CodeGen/AMDGPU/setcc.ll 
b/llvm/test/CodeGen/AMDGPU/setcc.ll
index a259784bc278..e888ceb94cfa 100644
--- a/llvm/test/CodeGen/AMDGPU/setcc.ll
+++ b/llvm/test/CodeGen/AMDGPU/setcc.ll
@@ -96,11 +96,9 @@ entry:
 }
 
 ; FUNC-LABEL: {{^}}f32_one:
-; R600-DAG: SETE_DX10
-; R600-DAG: SETE_DX10
-; R600-DAG: AND_INT
-; R600-DAG: SETNE_DX10
-; R600-DAG: AND_INT
+; R600-DAG: SETGT_DX10
+; R600-DAG: SETGT_DX10
+; R600-DAG: OR_INT
 ; R600-DAG: SETNE_INT
 
 ; GCN: v_cmp_lg_f32_e32 vcc
@@ -128,12 +126,10 @@ entry:
 }
 
 ; FUNC-LABEL: {{^}}f32_ueq:
-; R600-DAG: SETNE_DX10
-; R600-DAG: SETNE_DX10
-; R600-DAG: OR_INT
-; R600-DAG: SETE_DX10
+; R600-DAG: SETGT_DX10
+; R600-DAG: SETGT_DX10
 ; R600-DAG: OR_INT
-; R600-DAG: SETNE_INT
+; R600-DAG: SETE_INT
 
 ; GCN: v_cmp_nlg_f32_e32 vcc
 ; GCN-NEXT: v_cndmask_b32_e64 {{v[0-9]+}}, 0, -1, vcc

diff  --git a/llvm/test/CodeGen/PowerPC/spe.ll 
b/llvm/test/CodeGen/PowerPC/spe.ll
index 59bc6abc4f75..6ab05554aa81 100644
--- a/llvm/test/CodeGen/PowerPC/spe.ll
+++ b/llvm/test/CodeGen/PowerPC/spe.ll
@@ -297,12 +297,10 @@ define i1 @test_fcmpord(float %a, float %b) #0 {
 define i1 @test_fcmpueq(float %a, float %b) #0 {
 ; CHECK-LABEL: test_fcmpueq:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:efscmpeq 0, 3, 3
-; CHECK-NEXT:efscmpeq 1, 4, 4
-; CHECK-NEXT:crnand 20, 5, 1
-; CHECK-NEXT:efscmpeq 0, 3, 4
+; CHECK-NEXT:efscmpgt 0, 3, 4
+; CHECK-NEXT:efscmplt 1, 3, 4
 ; CHECK-NEXT:li 5, 1
-; CHECK-NEXT:crnor 20, 1, 20
+; CHECK-NEXT:cror 20, 5, 1
 ; CHECK-NEXT:bc 12, 20, .LBB14_2
 ; CHECK-NEXT:  # 

[llvm-branch-commits] [clang-tools-extra] 4718ec0 - [clangd] Avoid recursion in TargetFinder::add()

2021-01-12 Thread Nathan Ridge via llvm-branch-commits

Author: Nathan Ridge
Date: 2021-01-12T13:57:54-05:00
New Revision: 4718ec01669b01373180f4cd1256c6e2dd6f3999

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

LOG: [clangd] Avoid recursion in TargetFinder::add()

Fixes https://github.com/clangd/clangd/issues/633

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/FindTarget.h
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 9a502a84e36f..84316659daad 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -330,6 +330,7 @@ struct TargetFinder {
   llvm::SmallDenseMap>
   Decls;
+  llvm::SmallDenseMap Seen;
   RelSet Flags;
 
   template  void debug(T &Node, RelSet Flags) {
@@ -359,6 +360,15 @@ struct TargetFinder {
 if (!D)
   return;
 debug(*D, Flags);
+
+// Avoid recursion (which can arise in the presence of heuristic
+// resolution of dependent names) by exiting early if we have
+// already seen this decl with all flags in Flags.
+auto Res = Seen.try_emplace(D);
+if (!Res.second && Res.first->second.contains(Flags))
+  return;
+Res.first->second |= Flags;
+
 if (const UsingDirectiveDecl *UDD = llvm::dyn_cast(D))
   D = UDD->getNominatedNamespaceAsWritten();
 

diff  --git a/clang-tools-extra/clangd/FindTarget.h 
b/clang-tools-extra/clangd/FindTarget.h
index 435e4f4ac038..92e4354d1eaa 100644
--- a/clang-tools-extra/clangd/FindTarget.h
+++ b/clang-tools-extra/clangd/FindTarget.h
@@ -194,6 +194,9 @@ class DeclRelationSet {
 S &= Other.S;
 return *this;
   }
+  bool contains(DeclRelationSet Other) const {
+return (S & Other.S) == Other.S;
+  }
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &, DeclRelationSet);
 };
 // The above operators can't be looked up if both sides are enums.

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index dd7e9878a6d5..46e17dc053c0 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -787,6 +787,47 @@ TEST_F(TargetDeclTest, DependentTypes) {
"template  struct B");
 }
 
+TEST_F(TargetDeclTest, TypedefCascade) {
+  Code = R"cpp(
+struct C {
+  using type = int;
+};
+struct B {
+  using type = C::type;
+};
+struct A {
+  using type = B::type;
+};
+A::[[type]] waldo;
+  )cpp";
+  EXPECT_DECLS("TypedefTypeLoc",
+   {"using type = int", Rel::Alias | Rel::Underlying},
+   {"using type = C::type", Rel::Alias | Rel::Underlying},
+   {"using type = B::type", Rel::Alias});
+}
+
+TEST_F(TargetDeclTest, RecursiveTemplate) {
+  Flags.push_back("-std=c++20"); // the test case uses concepts
+
+  Code = R"cpp(
+template 
+concept Leaf = false;
+
+template 
+struct descend_left {
+  using type = typename descend_left::[[type]];
+};
+
+template 
+struct descend_left {
+  using type = typename Tree::value;
+};
+  )cpp";
+  EXPECT_DECLS("DependentNameTypeLoc",
+   {"using type = typename descend_left::type",
+Rel::Alias | Rel::Underlying});
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(



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


[llvm-branch-commits] [llvm] f748e92 - [NewPM] Run non-trivial loop unswitching under -O2/3/s/z

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

Author: Arthur Eubanks
Date: 2021-01-12T11:04:40-08:00
New Revision: f748e92295515ea7b39cd687a718915b559de6ec

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

LOG: [NewPM] Run non-trivial loop unswitching under -O2/3/s/z

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

Reviewed By: asbirlea

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

Added: 
llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll

Modified: 
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Transforms/LoopUnroll/opt-levels.ll

Removed: 




diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 527d19d63589..0d7f442f9ff4 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -724,7 +724,7 @@ 
PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
   LPM1.addPass(LoopRotatePass(Level != OptimizationLevel::Oz));
   // TODO: Investigate promotion cap for O1.
   LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
-  LPM1.addPass(SimpleLoopUnswitchPass());
+  LPM1.addPass(SimpleLoopUnswitchPass(/* NonTrivial */ true));
   LPM2.addPass(LoopIdiomRecognizePass());
   LPM2.addPass(IndVarSimplifyPass());
 

diff  --git a/llvm/test/Transforms/LoopUnroll/opt-levels.ll 
b/llvm/test/Transforms/LoopUnroll/opt-levels.ll
index ed0abc7672e0..f268d9bd5506 100644
--- a/llvm/test/Transforms/LoopUnroll/opt-levels.ll
+++ b/llvm/test/Transforms/LoopUnroll/opt-levels.ll
@@ -7,10 +7,10 @@
 ; the behavior, we artificially disable unrolling for anything but O3 by 
setting
 ; the default threshold to 0.
 
-; O3: loop2.preheader
-; O2-NOT: loop2.preheader
-; Os-NOT: loop2.preheader
-; Oz-NOT: loop2.preheader
+; O3: loop1.preheader
+; O2-NOT: loop1.preheader
+; Os-NOT: loop1.preheader
+; Oz-NOT: loop1.preheader
 
 define void @unroll(i32 %iter, i32* %addr1, i32* %addr2) nounwind {
 entry:

diff  --git a/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll 
b/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll
new file mode 100644
index ..953b407cccd9
--- /dev/null
+++ b/llvm/test/Transforms/SimpleLoopUnswitch/pipeline.ll
@@ -0,0 +1,39 @@
+; RUN: opt < %s -S -passes="default" | FileCheck %s -check-prefix=O1
+; RUN: opt < %s -S -passes="default" | FileCheck %s -check-prefix=O2
+
+declare i32 @a()
+declare i32 @b()
+declare i32 @c()
+
+; O1-NOT: loop_begin.us:
+; O2: loop_begin.us:
+
+define i32 @test1(i1* %ptr, i1 %cond1, i1 %cond2) {
+entry:
+  br label %loop_begin
+
+loop_begin:
+  br i1 %cond1, label %loop_a, label %loop_b
+
+loop_a:
+  call i32 @a()
+  br label %latch
+
+loop_b:
+  br i1 %cond2, label %loop_b_a, label %loop_b_b
+
+loop_b_a:
+  call i32 @b()
+  br label %latch
+
+loop_b_b:
+  call i32 @c()
+  br label %latch
+
+latch:
+  %v = load i1, i1* %ptr
+  br i1 %v, label %loop_begin, label %loop_exit
+
+loop_exit:
+  ret i32 0
+}



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


[llvm-branch-commits] [llvm] a14040b - [RISCV] Use vmerge.vim for llvm.riscv.vfmerge with a 0.0 scalar operand.

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

Author: Craig Topper
Date: 2021-01-12T11:08:26-08:00
New Revision: a14040bd4d902419b53cf0ad576caa0f01eccf5c

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

LOG: [RISCV] Use vmerge.vim for llvm.riscv.vfmerge with a 0.0 scalar operand.

We can use a 0 immediate to avoid needing to materialize 0 into
an FPR first.

Reviewed By: frasercrmck

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vfmerge-rv64.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index bf5ee06bce35..3604a25b0d6a 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -3367,6 +3367,14 @@ defm "" : VPatBinaryV_VM<"int_riscv_vfmerge", 
"PseudoVMERGE",
 defm "" : VPatBinaryV_XM<"int_riscv_vfmerge", "PseudoVFMERGE",
  /*CarryOut = */0, /*vtilist=*/AllFloatVectors>;
 
+foreach fvti = AllFloatVectors in {
+  defvar instr = !cast("PseudoVMERGE_VIM_"#fvti.LMul.MX);
+  def : Pat<(fvti.Vector (int_riscv_vfmerge (fvti.Vector fvti.RegClass:$rs2),
+(fvti.Scalar (fpimm0)),
+(fvti.Mask V0), (XLenVT GPR:$vl))),
+(instr fvti.RegClass:$rs2, 0, (fvti.Mask V0), (NoX0 GPR:$vl), 
fvti.SEW)>;
+}
+
 
//===--===//
 // 14.16. Vector Floating-Point Move Instruction
 
//===--===//

diff  --git a/llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll 
b/llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll
index a6b09704c8a6..5a7262c348c5 100644
--- a/llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll
@@ -439,3 +439,157 @@ entry:
 
   ret  %a
 }
+
+define  @intrinsic_vfmerge_vzm_nxv1f16_nxv1f16_f16( %0,  %1, i32 %2) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vzm_nxv1f16_nxv1f16_f16
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e16,mf4,ta,mu
+; CHECK:   vmerge.vim {{v[0-9]+}}, {{v[0-9]+}}, 0, v0
+  %a = call  @llvm.riscv.vfmerge.nxv1f16.f16(
+ %0,
+half zeroinitializer,
+ %1,
+i32 %2)
+
+  ret  %a
+}
+
+define  @intrinsic_vfmerge_vzm_nxv2f16_nxv2f16_f16( %0,  %1, i32 %2) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vzm_nxv2f16_nxv2f16_f16
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e16,mf2,ta,mu
+; CHECK:   vmerge.vim {{v[0-9]+}}, {{v[0-9]+}}, 0, v0
+  %a = call  @llvm.riscv.vfmerge.nxv2f16.f16(
+ %0,
+half zeroinitializer,
+ %1,
+i32 %2)
+
+  ret  %a
+}
+
+define  @intrinsic_vfmerge_vzm_nxv4f16_nxv4f16_f16( %0,  %1, i32 %2) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vzm_nxv4f16_nxv4f16_f16
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e16,m1,ta,mu
+; CHECK:   vmerge.vim {{v[0-9]+}}, {{v[0-9]+}}, 0, v0
+  %a = call  @llvm.riscv.vfmerge.nxv4f16.f16(
+ %0,
+half zeroinitializer,
+ %1,
+i32 %2)
+
+  ret  %a
+}
+
+define  @intrinsic_vfmerge_vzm_nxv8f16_nxv8f16_f16( %0,  %1, i32 %2) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vzm_nxv8f16_nxv8f16_f16
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e16,m2,ta,mu
+; CHECK:   vmerge.vim {{v[0-9]+}}, {{v[0-9]+}}, 0, v0
+  %a = call  @llvm.riscv.vfmerge.nxv8f16.f16(
+ %0,
+half zeroinitializer,
+ %1,
+i32 %2)
+
+  ret  %a
+}
+
+define  
@intrinsic_vfmerge_vzm_nxv16f16_nxv16f16_f16( %0,  %1, i32 %2) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vzm_nxv16f16_nxv16f16_f16
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e16,m4,ta,mu
+; CHECK:   vmerge.vim {{v[0-9]+}}, {{v[0-9]+}}, 0, v0
+  %a = call  @llvm.riscv.vfmerge.nxv16f16.f16(
+ %0,
+half zeroinitializer,
+ %1,
+i32 %2)
+
+  ret  %a
+}
+
+define  
@intrinsic_vfmerge_vzm_nxv32f16_nxv32f16_f16( %0,  %1, i32 %2) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vzm_nxv32f16_nxv32f16_f16
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e16,m8,ta,mu
+; CHECK:   vmerge.vim {{v[0-9]+}}, {{v[0-9]+}}, 0, v0
+  %a = call  @llvm.riscv.vfmerge.nxv32f16.f16(
+ %0,
+half zeroinitializer,
+ %1,
+i32 %2)
+
+  ret  %a
+}
+
+define  @intrinsic_vfmerge_vzm_nxv1f32_nxv1f32_f32( %0,  %1, i32 %2) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vzm_nxv1f32_nxv1f32_f32
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e32,mf2,ta,mu
+; CHECK:   vmerge.vim {{v[0-9]+}}, {{v[0-9]+}}, 0, v0
+  %a = call  @llvm.riscv.vfmerge.nxv1f32.f32(
+ %0,
+float zeroinitializer,
+ %1,
+i32 %2)
+
+  ret  %a
+}
+
+define  @intrinsic_vfmerge_vzm_nxv

[llvm-branch-commits] [libcxx] eef4bdb - [libc++] Add a missing `<_Compare>` template argument.

2021-01-12 Thread Arthur O'Dwyer via llvm-branch-commits

Author: Arthur O'Dwyer
Date: 2021-01-12T14:18:24-05:00
New Revision: eef4bdbb34de2dda657668c2ab39397e61e36a0a

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

LOG: [libc++] Add a missing `<_Compare>` template argument.

Sometimes `_Compare` is an lvalue reference type, so letting it be
deduced is pretty much always wrong. (Well, less efficient than
it could be, anyway.)

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

Added: 


Modified: 
libcxx/include/algorithm

Removed: 




diff  --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 7a4cc39dbeab..fe9caf475f5a 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -4483,7 +4483,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, 
_BidirectionalIterator
 value_type* __p = __buff;
 for (_BidirectionalIterator __i = __first; __i != __middle; 
__d.template __incr(), (void) ++__i, (void) ++__p)
 ::new ((void*)__p) value_type(_VSTD::move(*__i));
-_VSTD::__half_inplace_merge(__buff, __p, __middle, __last, __first, 
__comp);
+_VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, 
__first, __comp);
 }
 else
 {
@@ -4492,9 +4492,10 @@ __buffered_inplace_merge(_BidirectionalIterator __first, 
_BidirectionalIterator
 ::new ((void*)__p) value_type(_VSTD::move(*__i));
 typedef reverse_iterator<_BidirectionalIterator> _RBi;
 typedef reverse_iterator _Rv;
-_VSTD::__half_inplace_merge(_Rv(__p), _Rv(__buff),
+typedef __invert<_Compare> _Inverted;
+_VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff),
 _RBi(__middle), _RBi(__first),
-_RBi(__last), 
_VSTD::__invert<_Compare>(__comp));
+_RBi(__last), _Inverted(__comp));
 }
 }
 



___
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] 08d4a50 - [FunctionAttrs] Precommit tests for willreturn inference.

2021-01-12 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2021-01-12T19:16:50Z
New Revision: 08d4a50467ecef1337f8d7d9763c7738861bd6f6

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

LOG: [FunctionAttrs] Precommit tests for willreturn inference.

Tests for D94502.

Added: 
llvm/test/Transforms/FunctionAttrs/willreturn.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/FunctionAttrs/willreturn.ll 
b/llvm/test/Transforms/FunctionAttrs/willreturn.ll
new file mode 100644
index ..56ca12638e9c
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/willreturn.ll
@@ -0,0 +1,72 @@
+; RUN: opt -function-attrs -S %s | FileCheck %s
+
+; TODO
+define void @mustprogress_readnone() mustprogress {
+; CHECK-NOT: Function Attrs: {{.*}} willreturn
+; CHECK: define void @mustprogress_readnone()
+;
+entry:
+  br label %while.body
+
+while.body:
+  br label %while.body
+}
+
+; TODO
+define i32 @mustprogress_load(i32* %ptr) mustprogress {
+; CHECK-NOT: Function Attrs: {{.*}} willreturn
+; CHECK: define i32 @mustprogress_load(
+;
+entry:
+  %r = load i32, i32* %ptr
+  ret i32 %r
+}
+
+define void @mustprogress_store(i32* %ptr) mustprogress {
+; CHECK-NOT: Function Attrs: {{.*}} willreturn
+; CHECK: define void @mustprogress_store(
+;
+entry:
+  store i32 0, i32* %ptr
+  ret void
+}
+
+declare void @unknown_fn()
+
+define void @mustprogress_call_unknown_fn() mustprogress {
+; CHECK-NOT: Function Attrs: {{.*}} willreturn
+; CHECK: define void @mustprogress_call_unknown_fn(
+;
+  call void @unknown_fn()
+  ret void
+}
+
+; TODO
+define i32 @mustprogress_call_known_functions(i32* %ptr) mustprogress {
+; CHECK-NOT: Function Attrs: {{.*}} willreturn
+; CHECK: define i32 @mustprogress_call_known_functions(
+;
+  call void @mustprogress_readnone()
+  %r = call i32 @mustprogress_load(i32* %ptr)
+  ret i32 %r
+}
+
+declare i32 @__gxx_personality_v0(...)
+
+; TODO
+define i64 @mustprogress_mayunwind() mustprogress personality i8* bitcast (i32 
(...)* @__gxx_personality_v0 to i8*) {
+; CHECK-NOT: Function Attrs: {{.*}} willreturn
+; CHECK: define i64 @mustprogress_mayunwind(
+;
+  %a = invoke i64 @fn_noread()
+  to label %A unwind label %B
+A:
+  ret i64 10
+
+B:
+  %val = landingpad { i8*, i32 }
+   catch i8* null
+  ret i64 0
+}
+
+declare i64 @fn_noread() readnone



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


[llvm-branch-commits] [libcxx] 79f99ba - [libcxx] Port to OpenBSD

2021-01-12 Thread Brad Smith via llvm-branch-commits

Author: Brad Smith
Date: 2021-01-12T14:21:11-05:00
New Revision: 79f99ba65d96a35a79911daf1b67559dd52a684d

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

LOG: [libcxx] Port to OpenBSD

Add initial OpenBSD support.

Reviewed By: ldionne

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

Added: 
libcxx/include/support/openbsd/xlocale.h

Modified: 
libcxx/include/CMakeLists.txt
libcxx/include/__config
libcxx/include/__locale

Removed: 




diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index cd12f60a049c..2ffdf07efcd4 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -159,6 +159,7 @@ set(files
   support/musl/xlocale.h
   support/newlib/xlocale.h
   support/nuttx/xlocale.h
+  support/openbsd/xlocale.h
   support/solaris/floatingpoint.h
   support/solaris/wchar.h
   support/solaris/xlocale.h

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 4537d249cf4f..f1606c6d3b1c 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -264,14 +264,14 @@
 #  endif  // __LONG_LONG_SUPPORTED
 #endif  // __FreeBSD__
 
-#ifdef __NetBSD__
+#if defined(__NetBSD__) || defined(__OpenBSD__)
 #  include 
 #  if _BYTE_ORDER == _LITTLE_ENDIAN
 #define _LIBCPP_LITTLE_ENDIAN
 #  else  // _BYTE_ORDER == _LITTLE_ENDIAN
 #define _LIBCPP_BIG_ENDIAN
 #  endif  // _BYTE_ORDER == _LITTLE_ENDIAN
-#endif  // __NetBSD__
+#endif  // defined(__NetBSD__) || defined(__OpenBSD__)
 
 #if defined(_WIN32)
 #  define _LIBCPP_WIN32API
@@ -312,7 +312,7 @@
 #  endif
 #endif // __sun__
 
-#if defined(__CloudABI__)
+#if defined(__OpenBSD__) || defined(__CloudABI__)
// Certain architectures provide arc4random(). Prefer using
// arc4random() over /dev/{u,}random to make it possible to obtain
// random data even when using sandboxing mechanisms such as chroots,
@@ -370,6 +370,9 @@
 #define _LIBCPP_HAS_ALIGNED_ALLOC
 #define _LIBCPP_HAS_QUICK_EXIT
 #define _LIBCPP_HAS_TIMESPEC_GET
+#  elif defined(__OpenBSD__)
+#define _LIBCPP_HAS_ALIGNED_ALLOC
+#define _LIBCPP_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
 #  if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
@@ -1109,6 +1112,7 @@ extern "C" _LIBCPP_FUNC_VIS void 
__sanitizer_annotate_contiguous_container(
 #  if defined(__FreeBSD__) || \
   defined(__wasi__) || \
   defined(__NetBSD__) || \
+  defined(__OpenBSD__) || \
   defined(__NuttX__) || \
   defined(__linux__) || \
   defined(__GNU__) || \
@@ -1204,14 +1208,15 @@ extern "C" _LIBCPP_FUNC_VIS void 
__sanitizer_annotate_contiguous_container(
 // Some systems do not provide gets() in their C library, for security reasons.
 #ifndef _LIBCPP_C_HAS_NO_GETS
 #  if defined(_LIBCPP_MSVCRT) || \
-  (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043)
+  (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
+  defined(__OpenBSD__)
 #define _LIBCPP_C_HAS_NO_GETS
 #  endif
 #endif
 
 #if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) ||  
\
 defined(__Fuchsia__) || defined(__wasi__) || 
defined(_LIBCPP_HAS_MUSL_LIBC) || \
-defined(__MVS__)
+defined(__MVS__) || defined(__OpenBSD__)
 #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
 #endif
 

diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index f32bd59ae585..4e9e0c08acf0 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -33,6 +33,8 @@
 # include 
 #elif defined(_NEWLIB_VERSION)
 # include 
+#elif defined(__OpenBSD__)
+# include 
 #elif (defined(__APPLE__)  || defined(__FreeBSD__) \
 || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
 # include 

diff  --git a/libcxx/include/support/openbsd/xlocale.h 
b/libcxx/include/support/openbsd/xlocale.h
new file mode 100644
index ..fbfaedd127c6
--- /dev/null
+++ b/libcxx/include/support/openbsd/xlocale.h
@@ -0,0 +1,19 @@
+// -*- C++ -*-
+//=== support/openbsd/xlocale.h 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H
+#define _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#endif



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


[llvm-branch-commits] [llvm] 7ecad2e - [InstSimplify] Don't fold gep p, -p to null

2021-01-12 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2021-01-12T20:24:23+01:00
New Revision: 7ecad2e4ced180b4fdebc6b7bf6d26d83b454318

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

LOG: [InstSimplify] Don't fold gep p, -p to null

This is a partial fix for https://bugs.llvm.org/show_bug.cgi?id=44403.
Folding gep p, q-p to q is only legal if p and q have the same
provenance. This fold should probably be guarded by something like
getUnderlyingObject(p) == getUnderlyingObject(q).

This patch is a partial fix that removes the special handling for
gep p, 0-p, which will fold to a null pointer, which would certainly
not pass an underlying object check (unless p is also null, in which
case this would fold trivially anyway). Folding to a null pointer
is particularly problematic due to the special handling it receives
in many places, making end-to-end miscompiles more likely.

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

Added: 


Modified: 
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/gep.ll

Removed: 




diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp 
b/llvm/lib/Analysis/InstructionSimplify.cpp
index 96a3ada89db4..2ae4228495e3 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4270,9 +4270,7 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef Ops,
   // doesn't truncate the pointers.
   if (Ops[1]->getType()->getScalarSizeInBits() ==
   Q.DL.getPointerSizeInBits(AS)) {
-auto PtrToIntOrZero = [GEPTy](Value *P) -> Value * {
-  if (match(P, m_Zero()))
-return Constant::getNullValue(GEPTy);
+auto PtrToInt = [GEPTy](Value *P) -> Value * {
   Value *Temp;
   if (match(P, m_PtrToInt(m_Value(Temp
 if (Temp->getType() == GEPTy)
@@ -4280,10 +4278,14 @@ static Value *SimplifyGEPInst(Type *SrcTy, 
ArrayRef Ops,
   return nullptr;
 };
 
+// FIXME: The following transforms are only legal if P and V have the
+// same provenance (PR44403). Check whether getUnderlyingObject() is
+// the same?
+
 // getelementptr V, (sub P, V) -> P if P points to a type of size 1.
 if (TyAllocSize == 1 &&
 match(Ops[1], m_Sub(m_Value(P), m_PtrToInt(m_Specific(Ops[0])
-  if (Value *R = PtrToIntOrZero(P))
+  if (Value *R = PtrToInt(P))
 return R;
 
 // getelementptr V, (ashr (sub P, V), C) -> Q
@@ -4292,7 +4294,7 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef Ops,
   m_AShr(m_Sub(m_Value(P), m_PtrToInt(m_Specific(Ops[0]))),
  m_ConstantInt(C))) &&
 TyAllocSize == 1ULL << C)
-  if (Value *R = PtrToIntOrZero(P))
+  if (Value *R = PtrToInt(P))
 return R;
 
 // getelementptr V, (sdiv (sub P, V), C) -> Q
@@ -4300,7 +4302,7 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef Ops,
 if (match(Ops[1],
   m_SDiv(m_Sub(m_Value(P), m_PtrToInt(m_Specific(Ops[0]))),
  m_SpecificInt(TyAllocSize
-  if (Value *R = PtrToIntOrZero(P))
+  if (Value *R = PtrToInt(P))
 return R;
   }
 }
@@ -4317,15 +4319,21 @@ static Value *SimplifyGEPInst(Type *SrcTy, 
ArrayRef Ops,
   Ops[0]->stripAndAccumulateInBoundsConstantOffsets(Q.DL,
 BasePtrOffset);
 
+  // Avoid creating inttoptr of zero here: While LLVMs treatment of
+  // inttoptr is generally conservative, this particular case is folded to
+  // a null pointer, which will have incorrect provenance.
+
   // gep (gep V, C), (sub 0, V) -> C
   if (match(Ops.back(),
-m_Sub(m_Zero(), m_PtrToInt(m_Specific(StrippedBasePtr) {
+m_Sub(m_Zero(), m_PtrToInt(m_Specific(StrippedBasePtr &&
+  !BasePtrOffset.isNullValue()) {
 auto *CI = ConstantInt::get(GEPTy->getContext(), BasePtrOffset);
 return ConstantExpr::getIntToPtr(CI, GEPTy);
   }
   // gep (gep V, C), (xor V, -1) -> C-1
   if (match(Ops.back(),
-m_Xor(m_PtrToInt(m_Specific(StrippedBasePtr)), m_AllOnes( {
+m_Xor(m_PtrToInt(m_Specific(StrippedBasePtr)), m_AllOnes())) &&
+  !BasePtrOffset.isOneValue()) {
 auto *CI = ConstantInt::get(GEPTy->getContext(), BasePtrOffset - 1);
 return ConstantExpr::getIntToPtr(CI, GEPTy);
   }

diff  --git a/llvm/test/Transforms/InstSimplify/gep.ll 
b/llvm/test/Transforms/InstSimplify/gep.ll
index e6670e4a9345..8fff9e99d34b 100644
--- a/llvm/test/Transforms/InstSimplify/gep.ll
+++ b/llvm/test/Transforms/InstSimplify/gep.ll
@@ -40,9 +40,16 

[llvm-branch-commits] [openmp] bdd1ad5 - [OpenMP] Fixed include directories for OpenMP when building OpenMP with LLVM_ENABLE_RUNTIMES

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

Author: Shilei Tian
Date: 2021-01-12T14:32:38-05:00
New Revision: bdd1ad5e5c57ae0f0bf899517c540ad8a679f01a

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

LOG: [OpenMP] Fixed include directories for OpenMP when building OpenMP with 
LLVM_ENABLE_RUNTIMES

Some LLVM headers are generated by CMake. Before the installation,
LLVM's headers are distributed everywhere, some of which are in
`${LLVM_SRC_ROOT}/llvm/include/llvm`, and some are in
`${LLVM_BINARY_ROOT}/include/llvm`. After intallation, they're all in
`${LLVM_INSTALLATION_ROOT}/include/llvm`.

OpenMP now depends on LLVM headers. Some headers depend on headers generated
by CMake. When building OpenMP along with LLVM, a.k.a via 
`LLVM_ENABLE_RUNTIMES`,
we need to tell OpenMP where it can find those headers, especially those still
have not been copied/installed.

Reviewed By: jdoerfert, jhuber6

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

Added: 


Modified: 
openmp/CMakeLists.txt
openmp/libomptarget/CMakeLists.txt
openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
openmp/libomptarget/src/CMakeLists.txt

Removed: 




diff  --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index dc0d3a6e718a..12e8d542f9f6 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -39,6 +39,8 @@ else()
 set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
 set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
   endif()
+
+  list(APPEND LIBOMPTARGET_LLVM_INCLUDE_DIRS ${LLVM_MAIN_INCLUDE_DIR} 
${LLVM_BINARY_DIR}/include)
 endif()
 
 # Check and set up common compiler flags.
@@ -67,16 +69,16 @@ if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP14_FLAG)
 endif()
 
 # Attempt to locate LLVM source, required by libomptarget
-if (NOT LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR)
+if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS)
   if (LLVM_MAIN_INCLUDE_DIR)
-set(LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR})
+list(APPEND LIBOMPTARGET_LLVM_INCLUDE_DIRS ${LLVM_MAIN_INCLUDE_DIR})
   elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../llvm/include)
-set(LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR 
${CMAKE_CURRENT_SOURCE_DIR}/../llvm/include)
+list(APPENDset LIBOMPTARGET_LLVM_INCLUDE_DIRS 
${CMAKE_CURRENT_SOURCE_DIR}/../llvm/include)
   endif()
 endif()
 
-if (NOT LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR)
-  message(STATUS "Missing definition for LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR, 
disabling libomptarget")
+if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS)
+  message(STATUS "Missing definition for LIBOMPTARGET_LLVM_INCLUDE_DIRS, 
disabling libomptarget")
   set(ENABLE_LIBOMPTARGET OFF)
 endif()
 

diff  --git a/openmp/libomptarget/CMakeLists.txt 
b/openmp/libomptarget/CMakeLists.txt
index 06db7b4c35e2..6c90ced107eb 100644
--- a/openmp/libomptarget/CMakeLists.txt
+++ b/openmp/libomptarget/CMakeLists.txt
@@ -31,8 +31,8 @@ include(LibomptargetUtils)
 include(LibomptargetGetDependencies)
 
 # LLVM source tree is required at build time for libomptarget
-if (NOT LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR)
-  message(FATAL_ERROR "Missing definition for 
LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR")
+if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS)
+  message(FATAL_ERROR "Missing definition for LIBOMPTARGET_LLVM_INCLUDE_DIRS")
 endif()
 
 # This is a list of all the targets that are supported/tested right now.

diff  --git a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt 
b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
index 2d58388c80bb..43934b52e42b 100644
--- a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
@@ -30,8 +30,8 @@ if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES 
"(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_
   return()
 endif()
 
-if (NOT LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR)
-  libomptarget_say("Not building AMDGPU plugin: Missing definition for 
LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR")
+if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS)
+  libomptarget_say("Not building AMDGPU plugin: Missing definition for 
LIBOMPTARGET_LLVM_INCLUDE_DIRS")
   return()
 endif()
 
@@ -50,7 +50,7 @@ endif()
 
 include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}/impl
-  ${LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR}
+  ${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
 )
 
 add_library(omptarget.rtl.amdgpu SHARED

diff  --git a/openmp/libomptarget/src/CMakeLists.txt 
b/openmp/libomptarget/src/CMakeLists.txt
index 4088f59042fc..38eaf455f95b 100644
--- a/openmp/libomptarget/src/CMakeLists.txt
+++ b/openmp/libomptarget/src/CMakeLists.txt
@@ -20,7 +20,7 @@ set(LIBOMPTARGET_SRC_FILES
   ${CMAKE_CURRENT_SOURCE_DIR}/omptarget.cpp
 )
 
-include_directories(${LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR})
+include_directories(${LIBOMPTARGET_LLVM_INCLUDE_DIRS})
 
 # Build libomptarget library with libdl dependency. Add LLVMSupport
 # dependency if bu

[llvm-branch-commits] [openmp] 33e2494 - [libomptarget][amdgpu][nfc] Fix build on centos

2021-01-12 Thread Jon Chesterfield via llvm-branch-commits

Author: Jon Chesterfield
Date: 2021-01-12T19:40:03Z
New Revision: 33e2494bea653a845cb0502cc6d3cecdf2b47750

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

LOG: [libomptarget][amdgpu][nfc] Fix build on centos

[libomptarget][amdgpu][nfc] Fix build on centos

rtl.cpp replaced 224 with a #define from elf.h, but that
doesn't work on a centos 7 build machine with an old elf.h

Reviewed By: ronlieb

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

Added: 


Modified: 
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Removed: 




diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp 
b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index 437846f8b15b8..bd450f9898faf 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -638,7 +638,7 @@ void finiAsyncInfoPtr(__tgt_async_info *async_info_ptr) {
 }
 
 bool elf_machine_id_is_amdgcn(__tgt_device_image *image) {
-  const uint16_t amdgcnMachineID = EM_AMDGPU;
+  const uint16_t amdgcnMachineID = 224; // EM_AMDGPU may not be in system elf.h
   int32_t r = elf_check_machine(image, amdgcnMachineID);
   if (!r) {
 DP("Supported machine ID not found\n");



___
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] e5f51fd - [clang][aarch64] Precondition isHomogeneousAggregate on isCXX14Aggregate

2021-01-12 Thread David Truby via llvm-branch-commits

Author: David Truby
Date: 2021-01-12T19:44:01Z
New Revision: e5f51fdd650c6d20c81fedb8e856e9858aa10991

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

LOG: [clang][aarch64] Precondition isHomogeneousAggregate on isCXX14Aggregate

MSVC on WoA64 includes isCXX14Aggregate in its definition. This is de-facto
specification on that platform, so match msvc's behaviour.

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

Co-authored-by: Peter Waller 

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

Added: 


Modified: 
clang/lib/CodeGen/CGCXXABI.h
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGenCXX/homogeneous-aggregates.cpp
llvm/test/CodeGen/AArch64/arm64-windows-calls.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 171428a3525d..ea839db7528e 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -146,6 +146,13 @@ class CGCXXABI {
   /// 'this' parameter of C++ instance methods.
   virtual bool isSRetParameterAfterThis() const { return false; }
 
+  /// Returns true if the ABI permits the argument to be a homogeneous
+  /// aggregate.
+  virtual bool
+  isPermittedToBeHomogeneousAggregate(const CXXRecordDecl *RD) const {
+return true;
+  };
+
   /// Find the LLVM type used to represent the given member pointer
   /// type.
   virtual llvm::Type *

diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index c16c72dc93d5..cb0dc1d5d717 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -771,6 +771,9 @@ class MicrosoftCXXABI : public CGCXXABI {
   LoadVTablePtr(CodeGenFunction &CGF, Address This,
 const CXXRecordDecl *RD) override;
 
+  virtual bool
+  isPermittedToBeHomogeneousAggregate(const CXXRecordDecl *RD) const override;
+
 private:
   typedef std::pair VFTableIdTy;
   typedef llvm::DenseMap VTablesMapTy;
@@ -1070,7 +1073,7 @@ bool MicrosoftCXXABI::hasMostDerivedReturn(GlobalDecl GD) 
const {
   return isDeletingDtor(GD);
 }
 
-static bool isCXX14Aggregate(const CXXRecordDecl *RD) {
+static bool isTrivialForAArch64MSVC(const CXXRecordDecl *RD) {
   // For AArch64, we use the C++14 definition of an aggregate, so we also
   // check for:
   //   No private or protected non static data members.
@@ -1107,7 +1110,7 @@ bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo 
&FI) const {
   bool isTrivialForABI = RD->isPOD();
   bool isAArch64 = CGM.getTarget().getTriple().isAArch64();
   if (isAArch64)
-isTrivialForABI = RD->canPassInRegisters() && isCXX14Aggregate(RD);
+isTrivialForABI = RD->canPassInRegisters() && isTrivialForAArch64MSVC(RD);
 
   // MSVC always returns structs indirectly from C++ instance methods.
   bool isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod();
@@ -4358,3 +4361,12 @@ MicrosoftCXXABI::LoadVTablePtr(CodeGenFunction &CGF, 
Address This,
   performBaseAdjustment(CGF, This, QualType(RD->getTypeForDecl(), 0));
   return {CGF.GetVTablePtr(This, CGM.Int8PtrTy, RD), RD};
 }
+
+bool MicrosoftCXXABI::isPermittedToBeHomogeneousAggregate(
+const CXXRecordDecl *CXXRD) const {
+  // MSVC Windows on Arm64 considers a type not HFA if it is not an
+  // aggregate according to the C++14 spec. This is not consistent with the
+  // AAPCS64, but is defacto spec on that platform.
+  return !CGM.getTarget().getTriple().isAArch64() ||
+ isTrivialForAArch64MSVC(CXXRD);
+}

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index d36c7344e284..9a11a0720f3c 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -5065,8 +5065,12 @@ bool ABIInfo::isHomogeneousAggregate(QualType Ty, const 
Type *&Base,
 
 Members = 0;
 
-// If this is a C++ record, check the bases first.
+// If this is a C++ record, check the properties of the record such as
+// bases and ABI specific restrictions
 if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) {
+  if (!getCXXABI().isPermittedToBeHomogeneousAggregate(CXXRD))
+return false;
+
   for (const auto &I : CXXRD->bases()) {
 // Ignore empty records.
 if (isEmptyRecord(getContext(), I.getType(), true))

diff  --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp 
b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp
index 2b3af4226407..0fa30b2663bf 100644
--- a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp
+++ b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -mfloat-abi hard -triple armv7-unknown-linux-gnueabi 
-emit-llvm -o - %s | FileCheck %s --check-prefix=ARM32
 // RUN: %clang_cc1 -mfloat-abi hard -triple aarch64-unknown-lin

[llvm-branch-commits] [llvm] 6cd44b2 - [FunctionAttrs] Derive willreturn for fns with readonly` & `mustprogress`.

2021-01-12 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2021-01-12T20:02:34Z
New Revision: 6cd44b204c6c6f2e915270af6792f247c4c23abc

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

LOG: [FunctionAttrs] Derive willreturn for fns with readonly` & `mustprogress`.

Similar to D94125, derive `willreturn` for functions that are `readonly` and
`mustprogress` in FunctionAttrs.

To quote the reasoning from D94125:

Since D86233 we have `mustprogress` which, in combination with
`readonly`, implies `willreturn`. The idea is that every side-effect
has to be modeled as a "write". Consequently, `readonly` means there
is no side-effect, and `mustprogress` guarantees that we cannot "loop"
forever without side-effect.

Reviewed By: jdoerfert, nikic

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

Added: 


Modified: 
llvm/include/llvm/IR/Function.h
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/test/Transforms/FunctionAttrs/willreturn.ll

Removed: 




diff  --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index 019e3a98a1af..7e209bb3769b 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -640,6 +640,10 @@ class Function : public GlobalObject, public 
ilist_node {
   }
   void setMustProgress() { addFnAttr(Attribute::MustProgress); }
 
+  /// Determine if the function will return.
+  bool willReturn() const { return hasFnAttribute(Attribute::WillReturn); }
+  void setWillReturn() { addFnAttr(Attribute::WillReturn); }
+
   /// True if the ABI mandates (or the user requested) that this
   /// function be in a unwind table.
   bool hasUWTable() const {

diff  --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp 
b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 5cf5e9463b45..2e24cad1393b 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -77,6 +77,7 @@ STATISTIC(NumNonNullReturn, "Number of function returns 
marked nonnull");
 STATISTIC(NumNoRecurse, "Number of functions marked as norecurse");
 STATISTIC(NumNoUnwind, "Number of functions marked as nounwind");
 STATISTIC(NumNoFree, "Number of functions marked as nofree");
+STATISTIC(NumWillReturn, "Number of functions marked as willreturn");
 
 static cl::opt EnableNonnullArgPropagation(
 "enable-nonnull-arg-prop", cl::init(true), cl::Hidden,
@@ -1424,6 +1425,22 @@ static bool addNoReturnAttrs(const SCCNodeSet &SCCNodes) 
{
   return Changed;
 }
 
+// Set the willreturn function attribute if possible.
+static bool addWillReturn(const SCCNodeSet &SCCNodes) {
+  bool Changed = false;
+
+  for (Function *F : SCCNodes) {
+if (!F || !F->onlyReadsMemory() || !F->mustProgress() || F->willReturn())
+  continue;
+
+F->setWillReturn();
+NumWillReturn++;
+Changed = true;
+  }
+
+  return Changed;
+}
+
 static SCCNodesResult createSCCNodeSet(ArrayRef Functions) {
   SCCNodesResult Res;
   Res.HasUnknownCall = false;
@@ -1468,6 +1485,7 @@ static bool deriveAttrsInPostOrder(ArrayRef 
Functions,
   Changed |= addArgumentAttrs(Nodes.SCCNodes);
   Changed |= inferConvergent(Nodes.SCCNodes);
   Changed |= addNoReturnAttrs(Nodes.SCCNodes);
+  Changed |= addWillReturn(Nodes.SCCNodes);
 
   // If we have no external nodes participating in the SCC, we can deduce some
   // more precise attributes as well.

diff  --git a/llvm/test/Transforms/FunctionAttrs/willreturn.ll 
b/llvm/test/Transforms/FunctionAttrs/willreturn.ll
index 56ca12638e9c..d92151c299fe 100644
--- a/llvm/test/Transforms/FunctionAttrs/willreturn.ll
+++ b/llvm/test/Transforms/FunctionAttrs/willreturn.ll
@@ -1,9 +1,8 @@
 ; RUN: opt -function-attrs -S %s | FileCheck %s
 
-; TODO
 define void @mustprogress_readnone() mustprogress {
-; CHECK-NOT: Function Attrs: {{.*}} willreturn
-; CHECK: define void @mustprogress_readnone()
+; CHECK:  Function Attrs: {{.*}} noreturn {{.*}} readnone willreturn
+; CHECK-NEXT: define void @mustprogress_readnone()
 ;
 entry:
   br label %while.body
@@ -12,10 +11,9 @@ while.body:
   br label %while.body
 }
 
-; TODO
 define i32 @mustprogress_load(i32* %ptr) mustprogress {
-; CHECK-NOT: Function Attrs: {{.*}} willreturn
-; CHECK: define i32 @mustprogress_load(
+; CHECK:  Function Attrs: {{.*}} readonly willreturn
+; CHECK-NEXT: define i32 @mustprogress_load(
 ;
 entry:
   %r = load i32, i32* %ptr
@@ -35,16 +33,15 @@ declare void @unknown_fn()
 
 define void @mustprogress_call_unknown_fn() mustprogress {
 ; CHECK-NOT: Function Attrs: {{.*}} willreturn
-; CHECK: define void @mustprogress_call_unknown_fn(
+; CHECK: define void @mustprogress_call_unknown_fn(
 ;
   call void @unknown_fn()
   ret void
 }
 
-; TODO
 define i32 @mustprogress_call_known_functions(i32* %ptr) mustprogress {
-; CHECK-NOT: Function Attrs: {{.*}} will

[llvm-branch-commits] [clang] e53bbd9 - [IR] move nomerge attribute from function declaration/definition to callsites

2021-01-12 Thread Zequan Wu via llvm-branch-commits

Author: Zequan Wu
Date: 2021-01-12T12:10:46-08:00
New Revision: e53bbd99516fc7b612df1ae08d48288d0b8784ea

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

LOG: [IR] move nomerge attribute from function declaration/definition to 
callsites

Move nomerge attribute from function declaration/definition to callsites to
allow virtual function calls attach the attribute.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-nomerge.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 2cc7203d1194..42801372189b 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1985,7 +1985,9 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
 NBA = Fn->getAttr();
   }
-  if (!AttrOnCallSite && TargetDecl->hasAttr())
+  // Only place nomerge attribute on call sites, never functions. This
+  // allows it to work on indirect virtual function calls.
+  if (AttrOnCallSite && TargetDecl->hasAttr())
 FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
 }
 
@@ -5018,13 +5020,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 Attrs.addAttribute(getLLVMContext(), 
llvm::AttributeList::FunctionIndex,
llvm::Attribute::StrictFP);
 
-  // Add nomerge attribute to the call-site if the callee function doesn't have
-  // the attribute.
-  if (const FunctionDecl *FD = dyn_cast_or_null(TargetDecl))
-if (!FD->hasAttr() && InNoMergeAttributedStmt)
-  Attrs = Attrs.addAttribute(getLLVMContext(),
- llvm::AttributeList::FunctionIndex,
- llvm::Attribute::NoMerge);
+  // Add call-site nomerge attribute if exists.
+  if (InNoMergeAttributedStmt)
+Attrs =
+Attrs.addAttribute(getLLVMContext(), 
llvm::AttributeList::FunctionIndex,
+   llvm::Attribute::NoMerge);
 
   // Apply some call-site-specific attributes.
   // TODO: work this into building the attribute set.

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index da5b03b138bf..bee51715bdc6 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1772,9 +1772,6 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   B.addAttribute(llvm::Attribute::MinSize);
   }
 
-  if (D->hasAttr())
-B.addAttribute(llvm::Attribute::NoMerge);
-
   F->addAttributes(llvm::AttributeList::FunctionIndex, B);
 
   unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();

diff  --git a/clang/test/CodeGen/attr-nomerge.cpp 
b/clang/test/CodeGen/attr-nomerge.cpp
index d93f4a7c96d6..fc26af379fdb 100644
--- a/clang/test/CodeGen/attr-nomerge.cpp
+++ b/clang/test/CodeGen/attr-nomerge.cpp
@@ -3,7 +3,7 @@
 class A {
 public:
   [[clang::nomerge]] A();
-  [[clang::nomerge]] ~A();
+  [[clang::nomerge]] virtual ~A();
   [[clang::nomerge]] void f();
   [[clang::nomerge]] virtual void g();
   [[clang::nomerge]] static void f1();
@@ -14,14 +14,14 @@ class B : public A {
   void g() override;
 };
 
-[[clang::nomerge]] bool bar();
+bool bar();
 [[clang::nomerge]] void f(bool, bool);
 
 void foo(int i, A *ap, B *bp) {
   [[clang::nomerge]] bar();
   [[clang::nomerge]] (i = 4, bar());
   [[clang::nomerge]] (void)(bar());
-  [[clang::nomerge]] f(bar(), bar());
+  f(bar(), bar());
   [[clang::nomerge]] [] { bar(); bar(); }(); // nomerge only applies to the 
anonymous function call
   [[clang::nomerge]] for (bar(); bar(); bar()) {}
   [[clang::nomerge]] { asm("nop"); }
@@ -37,6 +37,9 @@ void foo(int i, A *ap, B *bp) {
 
   B b;
   b.g();
+
+  A *newA = new B();
+  delete newA;
 }
 
 int g(int i);
@@ -57,37 +60,34 @@ void something_else_again() {
   g(1);
 }
 
+// CHECK: call zeroext i1 @_Z3barv() #[[ATTR0:[0-9]+]]
+// CHECK: call zeroext i1 @_Z3barv() #[[ATTR0]]
+// CHECK: call zeroext i1 @_Z3barv() #[[ATTR0]]
 // CHECK: call zeroext i1 @_Z3barv(){{$}}
 // CHECK: call zeroext i1 @_Z3barv(){{$}}
-// CHECK: call zeroext i1 @_Z3barv(){{$}}
-// CHECK: call zeroext i1 @_Z3barv(){{$}}
-// CHECK: call zeroext i1 @_Z3barv(){{$}}
-// CHECK: call void @_Z1fbb({{.*}}){{$}}
-// CHECK: call void @"_ZZ3fooiP1AP1BENK3$_0clEv"{{.*}} #[[ATTR0:[0-9]+]]
-// CHECK: call zeroext i1 @_Z3barv(){{$}}
-// CHECK: call zeroext i1 @_Z3barv(){{$}}
-// CHECK: call zeroext i1 @_Z3barv(){{$}}
+// CHECK: call void @_Z1fbb({{.*}}) #[[ATTR0]]
+// CHECK: call void @"_ZZ3fooiP1AP1BENK3$_0clEv"{{.*}} #[[ATTR0]]
+// CHECK: call zeroext i1 @_Z3barv() #[[ATTR0]]
+// CHECK-LABEL: for.cond:
+

[llvm-branch-commits] [clang-tools-extra] 922a5b8 - [clang-tidy] Add test for Transformer-based checks with diagnostics.

2021-01-12 Thread Yitzhak Mandelbaum via llvm-branch-commits

Author: Yitzhak Mandelbaum
Date: 2021-01-12T20:15:22Z
New Revision: 922a5b894114defb5302e514973de8c9cd23af6a

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

LOG: [clang-tidy] Add test for Transformer-based checks with diagnostics.

Adds a test that checks the diagnostic output of the tidy.

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

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
index e8df4bb60071..24b6bea98787 100644
--- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -10,8 +10,10 @@
 #include "ClangTidyTest.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Transformer/RangeSelector.h"
+#include "clang/Tooling/Transformer/RewriteRule.h"
 #include "clang/Tooling/Transformer/Stencil.h"
 #include "clang/Tooling/Transformer/Transformer.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -25,20 +27,21 @@ using transformer::change;
 using transformer::IncludeFormat;
 using transformer::makeRule;
 using transformer::node;
+using transformer::noopEdit;
 using transformer::RewriteRule;
+using transformer::RootID;
 using transformer::statement;
 
 // Invert the code of an if-statement, while maintaining its semantics.
 RewriteRule invertIf() {
   StringRef C = "C", T = "T", E = "E";
-  RewriteRule Rule =
-  makeRule(ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
-  hasElse(stmt().bind(E))),
-   change(statement(std::string(RewriteRule::RootID)),
-  cat("if(!(", node(std::string(C)), ")) ",
-  statement(std::string(E)), " else ",
-  statement(std::string(T,
-   cat("negate condition and reverse `then` and `else` branches"));
+  RewriteRule Rule = makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  change(statement(RootID), cat("if(!(", node(std::string(C)), ")) ",
+statement(std::string(E)), " else ",
+statement(std::string(T,
+  cat("negate condition and reverse `then` and `else` branches"));
   return Rule;
 }
 
@@ -68,6 +71,25 @@ TEST(TransformerClangTidyCheckTest, Basic) {
   EXPECT_EQ(Expected, test::runCheckOnCode(Input));
 }
 
+TEST(TransformerClangTidyCheckTest, DiagnosticsCorrectlyGenerated) {
+  class DiagOnlyCheck : public TransformerClangTidyCheck {
+  public:
+DiagOnlyCheck(StringRef Name, ClangTidyContext *Context)
+: TransformerClangTidyCheck(
+  makeRule(returnStmt(), noopEdit(node(RootID)), cat("message")),
+  Name, Context) {}
+  };
+  std::string Input = "int h() { return 5; }";
+  std::vector Errors;
+  EXPECT_EQ(Input, test::runCheckOnCode(Input, &Errors));
+  EXPECT_EQ(Errors.size(), 1U);
+  EXPECT_EQ(Errors[0].Message.Message, "message");
+  EXPECT_THAT(Errors[0].Ranges, testing::IsEmpty());
+
+  // The diagnostic is anchored to the match, "return 5".
+  EXPECT_EQ(Errors[0].Message.FileOffset, 10U);
+}
+
 class IntLitCheck : public TransformerClangTidyCheck {
 public:
   IntLitCheck(StringRef Name, ClangTidyContext *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] d49974f - [InstCombine] Regenerate test checks (NFC)

2021-01-12 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2021-01-12T21:26:42+01:00
New Revision: d49974f9c98ebce5a679eced9f27add138b881fa

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

LOG: [InstCombine] Regenerate test checks (NFC)

Added: 


Modified: 
llvm/test/Transforms/InstCombine/2006-12-15-Range-Test.ll
llvm/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll
llvm/test/Transforms/InstCombine/2007-05-10-icmp-or.ll
llvm/test/Transforms/InstCombine/2007-11-15-CompareMiscomp.ll
llvm/test/Transforms/InstCombine/2008-01-13-AndCmpCmp.ll
llvm/test/Transforms/InstCombine/2008-02-28-OrFCmpCrash.ll
llvm/test/Transforms/InstCombine/2008-06-21-CompareMiscomp.ll
llvm/test/Transforms/InstCombine/2008-08-05-And.ll
llvm/test/Transforms/InstCombine/2012-02-28-ICmp.ll
llvm/test/Transforms/InstCombine/2012-03-10-InstCombine.ll
llvm/test/Transforms/InstCombine/range-check.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/2006-12-15-Range-Test.ll 
b/llvm/test/Transforms/InstCombine/2006-12-15-Range-Test.ll
index 784b3e4fe687..38f6523bec39 100644
--- a/llvm/test/Transforms/InstCombine/2006-12-15-Range-Test.ll
+++ b/llvm/test/Transforms/InstCombine/2006-12-15-Range-Test.ll
@@ -1,31 +1,44 @@
-; RUN: opt < %s -instcombine -S | \
-; RUN:   grep icmp | count 1
-; RUN: opt < %s -instcombine -S | \
-; RUN:   grep "icmp ugt" | count 1
-; END.
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
 
 target datalayout = "e-p:32:32"
 target triple = "i686-pc-linux-gnu"
 @r = external global [17 x i32] ; <[17 x i32]*> [#uses=1]
 
 define i1 @print_pgm_cond_true(i32 %tmp12.reload, i32* %tmp16.out) {
+; CHECK-LABEL: @print_pgm_cond_true(
+; CHECK-NEXT:  newFuncRoot:
+; CHECK-NEXT:br label [[COND_TRUE:%.*]]
+; CHECK:   bb27.exitStub:
+; CHECK-NEXT:store i32 [[TMP16:%.*]], i32* [[TMP16_OUT:%.*]], align 4
+; CHECK-NEXT:ret i1 true
+; CHECK:   cond_next23.exitStub:
+; CHECK-NEXT:store i32 [[TMP16]], i32* [[TMP16_OUT]], align 4
+; CHECK-NEXT:ret i1 false
+; CHECK:   cond_true:
+; CHECK-NEXT:[[TMP15:%.*]] = getelementptr [17 x i32], [17 x i32]* @r, i32 
0, i32 [[TMP12_RELOAD:%.*]]
+; CHECK-NEXT:[[TMP16]] = load i32, i32* [[TMP15]], align 4
+; CHECK-NEXT:[[TMP16_OFF:%.*]] = add i32 [[TMP16]], 31
+; CHECK-NEXT:[[TMP0:%.*]] = icmp ugt i32 [[TMP16_OFF]], 62
+; CHECK-NEXT:br i1 [[TMP0]], label [[BB27_EXITSTUB:%.*]], label 
[[COND_NEXT23_EXITSTUB:%.*]]
+;
 newFuncRoot:
-br label %cond_true
+  br label %cond_true
 
 bb27.exitStub:  ; preds = %cond_true
-store i32 %tmp16, i32* %tmp16.out
-ret i1 true
+  store i32 %tmp16, i32* %tmp16.out
+  ret i1 true
 
 cond_next23.exitStub:   ; preds = %cond_true
-store i32 %tmp16, i32* %tmp16.out
-ret i1 false
+  store i32 %tmp16, i32* %tmp16.out
+  ret i1 false
 
 cond_true:  ; preds = %newFuncRoot
-%tmp15 = getelementptr [17 x i32], [17 x i32]* @r, i32 0, i32 
%tmp12.reload ;  [#uses=1]
-%tmp16 = load i32, i32* %tmp15   ;  [#uses=4]
-%tmp18 = icmp slt i32 %tmp16, -31   ;  [#uses=1]
-%tmp21 = icmp sgt i32 %tmp16, 31;  [#uses=1]
-%bothcond = or i1 %tmp18, %tmp21;  [#uses=1]
-br i1 %bothcond, label %bb27.exitStub, label %cond_next23.exitStub
+  %tmp15 = getelementptr [17 x i32], [17 x i32]* @r, i32 0, i32 %tmp12.reload  
   ;  [#uses=1]
+  %tmp16 = load i32, i32* %tmp15   ;  [#uses=4]
+  %tmp18 = icmp slt i32 %tmp16, -31   ;  [#uses=1]
+  %tmp21 = icmp sgt i32 %tmp16, 31;  [#uses=1]
+  %bothcond = or i1 %tmp18, %tmp21;  [#uses=1]
+  br i1 %bothcond, label %bb27.exitStub, label %cond_next23.exitStub
 }
 

diff  --git a/llvm/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll 
b/llvm/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll
index 826d68aefc1a..6db886b25ede 100644
--- a/llvm/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll
+++ b/llvm/test/Transforms/InstCombine/2007-03-13-CompareMerge.ll
@@ -1,9 +1,15 @@
-; RUN: opt < %s -instcombine -S | grep "icmp sle"
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
 ; PR1244
 
 define i1 @test(i32 %c.3.i, i32 %d.292.2.i) {
-   %tmp266.i = icmp slt i32 %c.3.i, %d.292.2.i 
-   %tmp276.i = icmp eq i32 %c.3.i, %d.292.2.i 
-   %sel_tmp80 = or i1 %tmp266.i, %tmp276.i 
-   ret i1 %sel_tmp80
+; CHECK-LABEL: @test(
+; CHECK-NEXT:[[TMP1:%.*]] = icmp sle i32 [[C_3_I:%.*]], [[D_292_2_I:%.*]]
+; CHECK-NEXT:ret i1 [[TMP1]]
+;
+  %tmp266.i = icmp slt i32 %c.3.i, %

[llvm-branch-commits] [llvm] 9f61fbd - [LV] Relax assumption that LCSSA implies single entry

2021-01-12 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2021-01-12T12:34:52-08:00
New Revision: 9f61fbd75ae1757d77988b37562de4d6583579aa

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

LOG: [LV] Relax assumption that LCSSA implies single entry

This relates to the ongoing effort to support vectorization of multiple exit 
loops (see D93317).

The previous code assumed that LCSSA phis were always single entry before the 
vectorizer ran. This was correct, but only because the vectorizer allowed only 
a single exiting edge. There's nothing in the definition of LCSSA which 
requires single entry phis.

A common case where this comes up is with a loop with multiple exiting blocks 
which all reach a common exit block. (e.g. see the test updates)

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/first-order-recurrence-complex.ll
llvm/test/Transforms/LoopVectorize/loop-form.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 3906b11ba4b9..e3e522958c3a 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -1101,8 +1101,7 @@ bool LoopVectorizationLegality::canVectorizeLoopCFG(Loop 
*Lp,
   // TODO: This restriction can be relaxed in the near future, it's here solely
   // to allow separation of changes for review. We need to generalize the phi
   // update logic in a number of places.
-  BasicBlock *ExitBB = Lp->getUniqueExitBlock();
-  if (!ExitBB) {
+  if (!Lp->getUniqueExitBlock()) {
 reportVectorizationFailure("The loop must have a unique exit block",
 "loop control flow is not understood by vectorizer",
 "CFGNotUnderstood", ORE, TheLoop);
@@ -1110,24 +1109,7 @@ bool LoopVectorizationLegality::canVectorizeLoopCFG(Loop 
*Lp,
   Result = false;
 else
   return false;
-  } else {
-// The existing code assumes that LCSSA implies that phis are single entry
-// (which was true when we had at most a single exiting edge from the 
latch).
-// In general, there's nothing which prevents an LCSSA phi in exit block 
from
-// having two or more values if there are multiple exiting edges leading to
-// the exit block.  (TODO: implement general case)
-if (!llvm::empty(ExitBB->phis()) && !ExitBB->getSinglePredecessor()) {
-  reportVectorizationFailure("The loop must have no live-out values if "
- "it has more than one exiting block",
-  "loop control flow is not understood by vectorizer",
-  "CFGNotUnderstood", ORE, TheLoop);
-  if (DoExtraAnalysis)
-Result = false;
-  else
-return false;
-}
   }
-
   return Result;
 }
 

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index e6cadf8f8796..5ae400fb5dc9 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -633,10 +633,11 @@ class InnerLoopVectorizer {
   /// Clear NSW/NUW flags from reduction instructions if necessary.
   void clearReductionWrapFlags(RecurrenceDescriptor &RdxDesc);
 
-  /// The Loop exit block may have single value PHI nodes with some
-  /// incoming value. While vectorizing we only handled real values
-  /// that were defined inside the loop and we should have one value for
-  /// each predecessor of its parent basic block. See PR14725.
+  /// Fixup the LCSSA phi nodes in the unique exit block.  This simply
+  /// means we need to add the appropriate incoming value from the middle
+  /// block as exiting edges from the scalar epilogue loop (if present) are
+  /// already in place, and we exit the vector loop exclusively to the middle
+  /// block.
   void fixLCSSAPHIs();
 
   /// Iteratively sink the scalarized operands of a predicated instruction into
@@ -4149,11 +4150,14 @@ void 
InnerLoopVectorizer::fixFirstOrderRecurrence(PHINode *Phi) {
   // vector recurrence we extracted in the middle block. Since the loop is in
   // LCSSA form, we just need to find all the phi nodes for the original scalar
   // recurrence in the exit block, and then add an edge for the middle block.
-  for (PHINode &LCSSAPhi : LoopExitBlock->phis()) {
-if (LCSSAPhi.getIncomingValue(0) == Phi) {
+  // Note that LCSSA does not imply single entry when the original scalar loop
+  // had multiple exiting edges (as we always run the last iteration in the
+  // scalar epilogue); in that case, the exiting path through middle will be
+  // dynamically dead

[llvm-branch-commits] [clang] f706486 - Fix for crash in __builtin_return_address in template context.

2021-01-12 Thread Sunil Srivastava via llvm-branch-commits

Author: Sunil Srivastava
Date: 2021-01-12T12:37:18-08:00
New Revision: f706486eaf07020b11f2088274c757e4070fe6d1

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

LOG: Fix for crash in __builtin_return_address in template context.

The check for argument value needs to be guarded by !isValueDependent().

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/builtin-returnaddress.c

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 15b5934224f0..2d3d36f4adad 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1943,7 +1943,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 // -Wframe-address warning if non-zero passed to builtin
 // return/frame address.
 Expr::EvalResult Result;
-if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) &&
+if (!TheCall->getArg(0)->isValueDependent() &&
+TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) &&
 Result.Val.getInt() != 0)
   Diag(TheCall->getBeginLoc(), diag::warn_frame_address)
   << ((BuiltinID == Builtin::BI__builtin_return_address)

diff  --git a/clang/test/Sema/builtin-returnaddress.c 
b/clang/test/Sema/builtin-returnaddress.c
index 3ebbdc6048d8..16d2a517ac12 100644
--- a/clang/test/Sema/builtin-returnaddress.c
+++ b/clang/test/Sema/builtin-returnaddress.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -Wframe-address -verify %s
 
 void* a(unsigned x) {
 return __builtin_return_address(0);
@@ -17,3 +18,14 @@ void* d(unsigned x) {
 return __builtin_frame_address(1); // expected-warning{{calling 
'__builtin_frame_address' with a nonzero argument is unsafe}}
 }
 
+#ifdef __cplusplus
+template void *RA()
+{
+  return __builtin_return_address(N); // expected-warning{{calling 
'__builtin_return_address' with a nonzero argument is unsafe}}
+}
+
+void *foo()
+{
+ return RA<2>(); // expected-note{{in instantiation of function template 
specialization 'RA<2>' requested here}}
+}
+#endif



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


[llvm-branch-commits] [llvm] caafdf0 - [LV] Weaken spuriously strong assert in LoopVersioning

2021-01-12 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2021-01-12T12:57:13-08:00
New Revision: caafdf07bbccbe89219539e2b56043c2a98358f1

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

LOG: [LV] Weaken spuriously strong assert in LoopVersioning

LoopVectorize uses some utilities on LoopVersioning, but doesn't actually use 
it for, you know, versioning.  As a result, the precondition LoopVersioning 
expects is too strong for this user.  At the moment, LoopVectorize supports any 
loop with a unique exit block, so check the same precondition here.

Really, the whole class structure here is a mess.  We should separate the 
actual versioning from the metadata updates, but that's a bigger problem.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/LoopVersioning.cpp 
b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
index b54aee35d56d..599bd1feb2bc 100644
--- a/llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -44,7 +44,7 @@ LoopVersioning::LoopVersioning(const LoopAccessInfo &LAI,
   AliasChecks(Checks.begin(), Checks.end()),
   Preds(LAI.getPSE().getUnionPredicate()), LAI(LAI), LI(LI), DT(DT),
   SE(SE) {
-  assert(L->getExitBlock() && "No single exit block");
+  assert(L->getUniqueExitBlock() && "No single exit block");
 }
 
 void LoopVersioning::versionLoop(



___
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] 46507a9 - [SLP] reduce code duplication while matching reductions; NFC

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

Author: Sanjay Patel
Date: 2021-01-12T16:03:57-05:00
New Revision: 46507a96fc13146f73e5915a008055c5a59191c2

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

LOG: [SLP] reduce code duplication while matching reductions; NFC

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 bd673d112b3a..ff22572782e2 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6857,49 +6857,48 @@ class HorizontalReduction {
 
   // Visit left or right.
   Value *NextV = TreeN->getOperand(EdgeToVisit);
-  if (NextV != Phi) {
-auto *I = dyn_cast(NextV);
-OpData = getOperationData(I);
-// Continue analysis if the next operand is a reduction operation or
-// (possibly) a reduced value. If the reduced value opcode is not set,
-// the first met operation != reduction operation is considered as the
-// reduced value class.
-const bool IsRdxInst = OpData == RdxTreeInst;
-if (I && (!RdxLeafVal || OpData == RdxLeafVal || IsRdxInst)) {
-  // Only handle trees in the current basic block.
-  if (!RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst)) {
-// I is an extra argument for TreeN (its parent operation).
-markExtraArg(Stack.back(), I);
-continue;
-  }
+  auto *I = dyn_cast(NextV);
+  OpData = getOperationData(I);
+  // Continue analysis if the next operand is a reduction operation or
+  // (possibly) a reduced value. If the reduced value opcode is not set,
+  // the first met operation != reduction operation is considered as the
+  // reduced value class.
+  const bool IsRdxInst = OpData == RdxTreeInst;
+  if (I && I != Phi &&
+  (!RdxLeafVal || OpData == RdxLeafVal || IsRdxInst)) {
+// Only handle trees in the current basic block.
+if (!RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst)) {
+  // I is an extra argument for TreeN (its parent operation).
+  markExtraArg(Stack.back(), I);
+  continue;
+}
 
-  // Each tree node needs to have minimal number of users except for 
the
-  // ultimate reduction.
-  if (!RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) && I != B) {
-// I is an extra argument for TreeN (its parent operation).
-markExtraArg(Stack.back(), I);
-continue;
-  }
+// Each tree node needs to have minimal number of users except for the
+// ultimate reduction.
+if (!RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) && I != B) {
+  // I is an extra argument for TreeN (its parent operation).
+  markExtraArg(Stack.back(), I);
+  continue;
+}
 
-  if (IsRdxInst) {
-// We need to be able to reassociate the reduction operations.
-if (!OpData.isAssociative(I)) {
-  // I is an extra argument for TreeN (its parent operation).
-  markExtraArg(Stack.back(), I);
-  continue;
-}
-  } else if (RdxLeafVal && RdxLeafVal != OpData) {
-// Make sure that the opcodes of the operations that we are going 
to
-// reduce match.
+if (IsRdxInst) {
+  // We need to be able to reassociate the reduction operations.
+  if (!OpData.isAssociative(I)) {
 // I is an extra argument for TreeN (its parent operation).
 markExtraArg(Stack.back(), I);
 continue;
-  } else if (!RdxLeafVal) {
-RdxLeafVal = OpData;
   }
-  Stack.push_back(std::make_pair(I, OpData.getFirstOperandIndex()));
+} else if (RdxLeafVal && RdxLeafVal != OpData) {
+  // Make sure that the opcodes of the operations that we are going to
+  // reduce match.
+  // I is an extra argument for TreeN (its parent operation).
+  markExtraArg(Stack.back(), I);
   continue;
+} else if (!RdxLeafVal) {
+  RdxLeafVal = OpData;
 }
+Stack.push_back(std::make_pair(I, OpData.getFirstOperandIndex()));
+continue;
   }
   // NextV is an extra argument for TreeN (its parent operation).
   markExtraArg(Stack.back(), NextV);



___
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] 554be30 - [SLP] reduce code duplication in processing reductions; NFC

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

Author: Sanjay Patel
Date: 2021-01-12T16:03:57-05:00
New Revision: 554be30a42802d66807f93e4671a518c1c04e0f8

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

LOG: [SLP] reduce code duplication in processing reductions; NFC

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 ff22572782e2..04bdc74c7879 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6867,38 +6867,29 @@ class HorizontalReduction {
   if (I && I != Phi &&
   (!RdxLeafVal || OpData == RdxLeafVal || IsRdxInst)) {
 // Only handle trees in the current basic block.
-if (!RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst)) {
-  // I is an extra argument for TreeN (its parent operation).
-  markExtraArg(Stack.back(), I);
-  continue;
-}
-
 // Each tree node needs to have minimal number of users except for the
 // ultimate reduction.
-if (!RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) && I != B) {
-  // I is an extra argument for TreeN (its parent operation).
-  markExtraArg(Stack.back(), I);
-  continue;
-}
-
-if (IsRdxInst) {
-  // We need to be able to reassociate the reduction operations.
-  if (!OpData.isAssociative(I)) {
+if (RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst) &&
+RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) && I != B) {
+  if (IsRdxInst) {
+// We need to be able to reassociate the reduction operations.
+if (!OpData.isAssociative(I)) {
+  // I is an extra argument for TreeN (its parent operation).
+  markExtraArg(Stack.back(), I);
+  continue;
+}
+  } else if (RdxLeafVal && RdxLeafVal != OpData) {
+// Make sure that the opcodes of the operations that we are going 
to
+// reduce match.
 // I is an extra argument for TreeN (its parent operation).
 markExtraArg(Stack.back(), I);
 continue;
+  } else if (!RdxLeafVal) {
+RdxLeafVal = OpData;
   }
-} else if (RdxLeafVal && RdxLeafVal != OpData) {
-  // Make sure that the opcodes of the operations that we are going to
-  // reduce match.
-  // I is an extra argument for TreeN (its parent operation).
-  markExtraArg(Stack.back(), I);
+  Stack.push_back(std::make_pair(I, OpData.getFirstOperandIndex()));
   continue;
-} else if (!RdxLeafVal) {
-  RdxLeafVal = OpData;
 }
-Stack.push_back(std::make_pair(I, OpData.getFirstOperandIndex()));
-continue;
   }
   // NextV is an extra argument for TreeN (its parent operation).
   markExtraArg(Stack.back(), NextV);



___
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] 92fb5c4 - [SLP] rename variable to improve readability; NFC

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

Author: Sanjay Patel
Date: 2021-01-12T16:03:57-05:00
New Revision: 92fb5c49e8aa53ac97fa2fb1a891a4d7ccfd75c5

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

LOG: [SLP] rename variable to improve readability; NFC

The OperationData in the 2nd block (visiting the operands)
is completely independent of the 1st block.

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 04bdc74c7879..1ef762c9dfa7 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6826,7 +6826,7 @@ class HorizontalReduction {
 while (!Stack.empty()) {
   Instruction *TreeN = Stack.back().first;
   unsigned EdgeToVisit = Stack.back().second++;
-  OperationData OpData = getOperationData(TreeN);
+  const OperationData OpData = getOperationData(TreeN);
   bool IsReducedValue = OpData != RdxTreeInst;
 
   // Postorder vist.
@@ -6858,14 +6858,14 @@ class HorizontalReduction {
   // Visit left or right.
   Value *NextV = TreeN->getOperand(EdgeToVisit);
   auto *I = dyn_cast(NextV);
-  OpData = getOperationData(I);
+  const OperationData EdgeOpData = getOperationData(I);
   // Continue analysis if the next operand is a reduction operation or
   // (possibly) a reduced value. If the reduced value opcode is not set,
   // the first met operation != reduction operation is considered as the
   // reduced value class.
-  const bool IsRdxInst = OpData == RdxTreeInst;
+  const bool IsRdxInst = EdgeOpData == RdxTreeInst;
   if (I && I != Phi &&
-  (!RdxLeafVal || OpData == RdxLeafVal || IsRdxInst)) {
+  (!RdxLeafVal || EdgeOpData == RdxLeafVal || IsRdxInst)) {
 // Only handle trees in the current basic block.
 // Each tree node needs to have minimal number of users except for the
 // ultimate reduction.
@@ -6873,21 +6873,21 @@ class HorizontalReduction {
 RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) && I != B) {
   if (IsRdxInst) {
 // We need to be able to reassociate the reduction operations.
-if (!OpData.isAssociative(I)) {
+if (!EdgeOpData.isAssociative(I)) {
   // I is an extra argument for TreeN (its parent operation).
   markExtraArg(Stack.back(), I);
   continue;
 }
-  } else if (RdxLeafVal && RdxLeafVal != OpData) {
+  } else if (RdxLeafVal && RdxLeafVal != EdgeOpData) {
 // Make sure that the opcodes of the operations that we are going 
to
 // reduce match.
 // I is an extra argument for TreeN (its parent operation).
 markExtraArg(Stack.back(), I);
 continue;
   } else if (!RdxLeafVal) {
-RdxLeafVal = OpData;
+RdxLeafVal = EdgeOpData;
   }
-  Stack.push_back(std::make_pair(I, OpData.getFirstOperandIndex()));
+  Stack.push_back(std::make_pair(I, 
EdgeOpData.getFirstOperandIndex()));
   continue;
 }
   }



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


[llvm-branch-commits] [llvm] 9e7895a - [SLP] reduce code duplication while processing reductions; NFC

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

Author: Sanjay Patel
Date: 2021-01-12T16:03:57-05:00
New Revision: 9e7895a8682ce3ad98c006955d573d5f2fded4f6

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

LOG: [SLP] reduce code duplication while processing reductions; NFC

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 1ef762c9dfa7..403170447f5a 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6863,33 +6863,32 @@ class HorizontalReduction {
   // (possibly) a reduced value. If the reduced value opcode is not set,
   // the first met operation != reduction operation is considered as the
   // reduced value class.
+  // Only handle trees in the current basic block.
+  // Each tree node needs to have minimal number of users except for the
+  // ultimate reduction.
   const bool IsRdxInst = EdgeOpData == RdxTreeInst;
-  if (I && I != Phi &&
+  if (I && I != Phi && I != B &&
+  RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst) &&
+  RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) &&
   (!RdxLeafVal || EdgeOpData == RdxLeafVal || IsRdxInst)) {
-// Only handle trees in the current basic block.
-// Each tree node needs to have minimal number of users except for the
-// ultimate reduction.
-if (RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst) &&
-RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) && I != B) {
-  if (IsRdxInst) {
-// We need to be able to reassociate the reduction operations.
-if (!EdgeOpData.isAssociative(I)) {
-  // I is an extra argument for TreeN (its parent operation).
-  markExtraArg(Stack.back(), I);
-  continue;
-}
-  } else if (RdxLeafVal && RdxLeafVal != EdgeOpData) {
-// Make sure that the opcodes of the operations that we are going 
to
-// reduce match.
+if (IsRdxInst) {
+  // We need to be able to reassociate the reduction operations.
+  if (!EdgeOpData.isAssociative(I)) {
 // I is an extra argument for TreeN (its parent operation).
 markExtraArg(Stack.back(), I);
 continue;
-  } else if (!RdxLeafVal) {
-RdxLeafVal = EdgeOpData;
   }
-  Stack.push_back(std::make_pair(I, 
EdgeOpData.getFirstOperandIndex()));
+} else if (RdxLeafVal && RdxLeafVal != EdgeOpData) {
+  // Make sure that the opcodes of the operations that we are going to
+  // reduce match.
+  // I is an extra argument for TreeN (its parent operation).
+  markExtraArg(Stack.back(), I);
   continue;
+} else if (!RdxLeafVal) {
+  RdxLeafVal = EdgeOpData;
 }
+Stack.push_back(std::make_pair(I, EdgeOpData.getFirstOperandIndex()));
+continue;
   }
   // NextV is an extra argument for TreeN (its parent operation).
   markExtraArg(Stack.back(), NextV);



___
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] 7583ae4 - [RISCV] Add double test cases to vfmerge-rv32.ll. NFC

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

Author: Craig Topper
Date: 2021-01-12T13:09:48-08:00
New Revision: 7583ae48a3c37a78e57106e4feff6045aaa45584

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

LOG: [RISCV] Add double test cases to vfmerge-rv32.ll. NFC

Added: 


Modified: 
llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll 
b/llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll
index 5a7262c348c5..21a2b73f74ba 100644
--- a/llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/vfmerge-rv32.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=riscv32 -mattr=+experimental-v,+f,+experimental-zfh 
-verify-machineinstrs \
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-v,+d,+experimental-zfh 
-verify-machineinstrs \
 ; RUN:   --riscv-no-aliases < %s | FileCheck %s
 declare  @llvm.riscv.vfmerge.nxv1f16.nxv1f16(
   ,
@@ -440,6 +440,166 @@ entry:
   ret  %a
 }
 
+declare  @llvm.riscv.vfmerge.nxv1f64.nxv1f64(
+  ,
+  ,
+  ,
+  i32);
+
+define  
@intrinsic_vfmerge_vvm_nxv1f64_nxv1f64_nxv1f64( %0, 
 %1,  %2, i32 %3) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vvm_nxv1f64_nxv1f64_nxv1f64
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e64,m1
+; CHECK:   vmerge.vvm {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}, v0
+  %a = call  @llvm.riscv.vfmerge.nxv1f64.nxv1f64(
+ %0,
+ %1,
+ %2,
+i32 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vfmerge.nxv1f64.f64(
+  ,
+  double,
+  ,
+  i32);
+
+define  
@intrinsic_vfmerge_vfm_nxv1f64_nxv1f64_f64( %0, double %1, 
 %2, i32 %3) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vfm_nxv1f64_nxv1f64_f64
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e64,m1
+; CHECK:   vfmerge.vfm {{v[0-9]+}}, {{v[0-9]+}}, {{ft[0-9]+}}, v0
+  %a = call  @llvm.riscv.vfmerge.nxv1f64.f64(
+ %0,
+double %1,
+ %2,
+i32 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vfmerge.nxv2f64.nxv2f64(
+  ,
+  ,
+  ,
+  i32);
+
+define  
@intrinsic_vfmerge_vvm_nxv2f64_nxv2f64_nxv2f64( %0, 
 %1,  %2, i32 %3) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vvm_nxv2f64_nxv2f64_nxv2f64
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e64,m2
+; CHECK:   vmerge.vvm {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}, v0
+  %a = call  @llvm.riscv.vfmerge.nxv2f64.nxv2f64(
+ %0,
+ %1,
+ %2,
+i32 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vfmerge.nxv2f64.f64(
+  ,
+  double,
+  ,
+  i32);
+
+define  
@intrinsic_vfmerge_vfm_nxv2f64_nxv2f64_f64( %0, double %1, 
 %2, i32 %3) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vfm_nxv2f64_nxv2f64_f64
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e64,m2
+; CHECK:   vfmerge.vfm {{v[0-9]+}}, {{v[0-9]+}}, {{ft[0-9]+}}, v0
+  %a = call  @llvm.riscv.vfmerge.nxv2f64.f64(
+ %0,
+double %1,
+ %2,
+i32 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vfmerge.nxv4f64.nxv4f64(
+  ,
+  ,
+  ,
+  i32);
+
+define  
@intrinsic_vfmerge_vvm_nxv4f64_nxv4f64_nxv4f64( %0, 
 %1,  %2, i32 %3) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vvm_nxv4f64_nxv4f64_nxv4f64
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e64,m4
+; CHECK:   vmerge.vvm {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}, v0
+  %a = call  @llvm.riscv.vfmerge.nxv4f64.nxv4f64(
+ %0,
+ %1,
+ %2,
+i32 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vfmerge.nxv4f64.f64(
+  ,
+  double,
+  ,
+  i32);
+
+define  
@intrinsic_vfmerge_vfm_nxv4f64_nxv4f64_f64( %0, double %1, 
 %2, i32 %3) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vfm_nxv4f64_nxv4f64_f64
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e64,m4
+; CHECK:   vfmerge.vfm {{v[0-9]+}}, {{v[0-9]+}}, {{ft[0-9]+}}, v0
+  %a = call  @llvm.riscv.vfmerge.nxv4f64.f64(
+ %0,
+double %1,
+ %2,
+i32 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vfmerge.nxv8f64.nxv8f64(
+  ,
+  ,
+  ,
+  i32);
+
+define  
@intrinsic_vfmerge_vvm_nxv8f64_nxv8f64_nxv8f64( %0, 
 %1,  %2, i32 %3) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vvm_nxv8f64_nxv8f64_nxv8f64
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e64,m8
+; CHECK:   vmerge.vvm {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}, v0
+  %a = call  @llvm.riscv.vfmerge.nxv8f64.nxv8f64(
+ %0,
+ %1,
+ %2,
+i32 %3)
+
+  ret  %a
+}
+
+declare  @llvm.riscv.vfmerge.nxv8f64.f64(
+  ,
+  double,
+  ,
+  i32);
+
+define  
@intrinsic_vfmerge_vfm_nxv8f64_nxv8f64_f64( %0, double %1, 
 %2, i32 %3) nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmerge_vfm_nxv8f64_nxv8f64_f64
+; CHECK:   vsetvli {{.*}}, {{a[0-9]+}}, e64,m8
+; CHECK:   vfmerge.vfm {{v[0-9]+}}, {{v[0-9]+}}, {{ft[0-9]+}}, v0
+  %a = call  @llvm.riscv.vfmerge.nxv8f64.f64(
+ %0,
+double %1,
+ %2,
+i32 %3)
+
+  ret  %a
+}
+
 define  @intrinsic_vfmerge_vzm_nxv1f16_nxv1f16_f16( %0,  %1, i32 %2) nounwind {
 entry:
 ; CHECK-LABEL: 

[llvm-branch-commits] [llvm] e15f3dd - [InstCombine] Add tests for logical and/or poison implication (NFC)

2021-01-12 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2021-01-12T22:18:51+01:00
New Revision: e15f3ddcae65525176d1f152effb88cd3c6441a3

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

LOG: [InstCombine] Add tests for logical and/or poison implication (NFC)

These tests cover some cases where we can fold select to and/or
based on poison implication logic.

Added: 


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

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/select-and-or.ll 
b/llvm/test/Transforms/InstCombine/select-and-or.ll
index 5fab7cdb94a6..59fa170b73d4 100644
--- a/llvm/test/Transforms/InstCombine/select-and-or.ll
+++ b/llvm/test/Transforms/InstCombine/select-and-or.ll
@@ -85,3 +85,99 @@ define i1 @logical_or_not_cond_reuse(i1 %a, i1 %b) {
   %res = select i1 %a, i1 %a.not, i1 %b
   ret i1 %res
 }
+
+; Safe to convert to or due to poison implication.
+define i1 @logical_or_implies(i32 %x) {
+; CHECK-LABEL: @logical_or_implies(
+; CHECK-NEXT:[[C1:%.*]] = icmp eq i32 [[X:%.*]], 0
+; CHECK-NEXT:[[C2:%.*]] = icmp eq i32 [[X]], 42
+; CHECK-NEXT:[[RES:%.*]] = select i1 [[C1]], i1 true, i1 [[C2]]
+; CHECK-NEXT:ret i1 [[RES]]
+;
+  %c1 = icmp eq i32 %x, 0
+  %c2 = icmp eq i32 %x, 42
+  %res = select i1 %c1, i1 true, i1 %c2
+  ret i1 %res
+}
+
+; Will fold after conversion to or.
+define i1 @logical_or_implies_folds(i32 %x) {
+; CHECK-LABEL: @logical_or_implies_folds(
+; CHECK-NEXT:[[C1:%.*]] = icmp slt i32 [[X:%.*]], 0
+; CHECK-NEXT:[[C2:%.*]] = icmp sgt i32 [[X]], -1
+; CHECK-NEXT:[[RES:%.*]] = select i1 [[C1]], i1 true, i1 [[C2]]
+; CHECK-NEXT:ret i1 [[RES]]
+;
+  %c1 = icmp slt i32 %x, 0
+  %c2 = icmp sge i32 %x, 0
+  %res = select i1 %c1, i1 true, i1 %c2
+  ret i1 %res
+}
+
+; Safe to convert to and due to poison implication.
+define i1 @logical_and_implies(i32 %x) {
+; CHECK-LABEL: @logical_and_implies(
+; CHECK-NEXT:[[C1:%.*]] = icmp ne i32 [[X:%.*]], 0
+; CHECK-NEXT:[[C2:%.*]] = icmp ne i32 [[X]], 42
+; CHECK-NEXT:[[RES:%.*]] = select i1 [[C1]], i1 [[C2]], i1 false
+; CHECK-NEXT:ret i1 [[RES]]
+;
+  %c1 = icmp ne i32 %x, 0
+  %c2 = icmp ne i32 %x, 42
+  %res = select i1 %c1, i1 %c2, i1 false
+  ret i1 %res
+}
+
+; Will fold after conversion to and.
+define i1 @logical_and_implies_folds(i32 %x) {
+; CHECK-LABEL: @logical_and_implies_folds(
+; CHECK-NEXT:[[C1:%.*]] = icmp ugt i32 [[X:%.*]], 42
+; CHECK-NEXT:[[C2:%.*]] = icmp ne i32 [[X]], 0
+; CHECK-NEXT:[[RES:%.*]] = select i1 [[C1]], i1 [[C2]], i1 false
+; CHECK-NEXT:ret i1 [[RES]]
+;
+  %c1 = icmp ugt i32 %x, 42
+  %c2 = icmp ne i32 %x, 0
+  %res = select i1 %c1, i1 %c2, i1 false
+  ret i1 %res
+}
+
+; Noundef on condition has no effect.
+define i1 @logical_or_noundef_a(i1 noundef %a, i1 %b) {
+; CHECK-LABEL: @logical_or_noundef_a(
+; CHECK-NEXT:[[RES:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[B:%.*]]
+; CHECK-NEXT:ret i1 [[RES]]
+;
+  %res = select i1 %a, i1 true, i1 %b
+  ret i1 %res
+}
+
+; Noundef on false value allows conversion to or.
+define i1 @logical_or_noundef_b(i1 %a, i1 noundef %b) {
+; CHECK-LABEL: @logical_or_noundef_b(
+; CHECK-NEXT:[[RES:%.*]] = select i1 [[A:%.*]], i1 true, i1 [[B:%.*]]
+; CHECK-NEXT:ret i1 [[RES]]
+;
+  %res = select i1 %a, i1 true, i1 %b
+  ret i1 %res
+}
+
+; Noundef on condition has no effect.
+define i1 @logical_and_noundef_a(i1 noundef %a, i1 %b) {
+; CHECK-LABEL: @logical_and_noundef_a(
+; CHECK-NEXT:[[RES:%.*]] = select i1 [[A:%.*]], i1 [[B:%.*]], i1 false
+; CHECK-NEXT:ret i1 [[RES]]
+;
+  %res = select i1 %a, i1 %b, i1 false
+  ret i1 %res
+}
+
+; Noundef on false value allows conversion to and.
+define i1 @logical_and_noundef_b(i1 %a, i1 noundef %b) {
+; CHECK-LABEL: @logical_and_noundef_b(
+; CHECK-NEXT:[[RES:%.*]] = select i1 [[A:%.*]], i1 [[B:%.*]], i1 false
+; CHECK-NEXT:ret i1 [[RES]]
+;
+  %res = select i1 %a, i1 %b, i1 false
+  ret i1 %res
+}



___
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] 71ed4b6 - [RISCV] Legalize select when Zbt extension available

2021-01-12 Thread Sam Elliott via llvm-branch-commits

Author: Michael Munday
Date: 2021-01-12T21:24:38Z
New Revision: 71ed4b6ce57d8843ef705af8f98305976a8f107a

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

LOG: [RISCV] Legalize select when Zbt extension available

The custom expansion of select operations in the RISC-V backend
interferes with the matching of cmov instructions. Legalizing
select when the Zbt extension is available solves that problem.

Reviewed By: lenary, craig.topper

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
llvm/test/CodeGen/RISCV/rv32Zbb.ll
llvm/test/CodeGen/RISCV/rv32Zbbp.ll
llvm/test/CodeGen/RISCV/rv32Zbs.ll
llvm/test/CodeGen/RISCV/rv32Zbt.ll
llvm/test/CodeGen/RISCV/rv64Zbt.ll

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 03db9911c867..73bc83b558ad 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -162,7 +162,6 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
 
   setOperationAction(ISD::BR_JT, MVT::Other, Expand);
   setOperationAction(ISD::BR_CC, XLenVT, Expand);
-  setOperationAction(ISD::SELECT, XLenVT, Custom);
   setOperationAction(ISD::SELECT_CC, XLenVT, Expand);
 
   setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);
@@ -249,11 +248,14 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
   if (Subtarget.hasStdExtZbt()) {
 setOperationAction(ISD::FSHL, XLenVT, Legal);
 setOperationAction(ISD::FSHR, XLenVT, Legal);
+setOperationAction(ISD::SELECT, XLenVT, Legal);
 
 if (Subtarget.is64Bit()) {
   setOperationAction(ISD::FSHL, MVT::i32, Custom);
   setOperationAction(ISD::FSHR, MVT::i32, Custom);
 }
+  } else {
+setOperationAction(ISD::SELECT, XLenVT, Custom);
   }
 
   ISD::CondCode FPCCToExpand[] = {

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
index ce6cb6ba82ce..47740308518f 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -797,7 +797,23 @@ def : Pat<(rotl (riscv_grevi GPR:$rs1, (i32 24)), (i32 
16)), (GREVI GPR:$rs1, 8)
 let Predicates = [HasStdExtZbt] in {
 def : Pat<(or (and (not GPR:$rs2), GPR:$rs3), (and GPR:$rs2, GPR:$rs1)),
   (CMIX GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
-def : Pat<(riscv_selectcc GPR:$rs2, (XLenVT 0), (XLenVT 17), GPR:$rs3, 
GPR:$rs1),
+def : Pat<(select (XLenVT (setne GPR:$rs2, 0)), GPR:$rs1, GPR:$rs3),
+  (CMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
+def : Pat<(select (XLenVT (seteq GPR:$rs2, 0)), GPR:$rs3, GPR:$rs1),
+  (CMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
+def : Pat<(select (XLenVT (seteq GPR:$x, GPR:$y)), GPR:$rs1, GPR:$rs3),
+  (CMOV GPR:$rs1, (XOR GPR:$x, GPR:$y), GPR:$rs3)>;
+def : Pat<(select (XLenVT (setne GPR:$x, GPR:$y)), GPR:$rs3, GPR:$rs1),
+  (CMOV GPR:$rs1, (XOR GPR:$x, GPR:$y), GPR:$rs3)>;
+def : Pat<(select (XLenVT (setuge GPR:$x, GPR:$y)), GPR:$rs1, GPR:$rs3),
+  (CMOV GPR:$rs1, (SLTU GPR:$x, GPR:$y), GPR:$rs3)>;
+def : Pat<(select (XLenVT (setule GPR:$y, GPR:$x)), GPR:$rs1, GPR:$rs3),
+  (CMOV GPR:$rs1, (SLTU GPR:$x, GPR:$y), GPR:$rs3)>;
+def : Pat<(select (XLenVT (setge GPR:$x, GPR:$y)), GPR:$rs1, GPR:$rs3),
+  (CMOV GPR:$rs1, (SLT GPR:$x, GPR:$y), GPR:$rs3)>;
+def : Pat<(select (XLenVT (setle GPR:$y, GPR:$x)), GPR:$rs1, GPR:$rs3),
+  (CMOV GPR:$rs1, (SLT GPR:$x, GPR:$y), GPR:$rs3)>;
+def : Pat<(select GPR:$rs2, GPR:$rs3, GPR:$rs1),
   (CMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
 } // Predicates = [HasStdExtZbt]
 

diff  --git a/llvm/test/CodeGen/RISCV/rv32Zbb.ll 
b/llvm/test/CodeGen/RISCV/rv32Zbb.ll
index b95fcd5f5232..90ea5629aae6 100644
--- a/llvm/test/CodeGen/RISCV/rv32Zbb.ll
+++ b/llvm/test/CodeGen/RISCV/rv32Zbb.ll
@@ -60,14 +60,7 @@ define i64 @slo_i64(i64 %a, i64 %b) nounwind {
 ;
 ; RV32IB-LABEL: slo_i64:
 ; RV32IB:   # %bb.0:
-; RV32IB-NEXT:addi a3, a2, -32
 ; RV32IB-NEXT:not a0, a0
-; RV32IB-NEXT:bltz a3, .LBB1_2
-; RV32IB-NEXT:  # %bb.1:
-; RV32IB-NEXT:mv a2, zero
-; RV32IB-NEXT:sll a1, a0, a3
-; RV32IB-NEXT:j .LBB1_3
-; RV32IB-NEXT:  .LBB1_2:
 ; RV32IB-NEXT:not a1, a1
 ; RV32IB-NEXT:sll a1, a1, a2
 ; RV32IB-NEXT:addi a3, zero, 31
@@ -75,10 +68,15 @@ define i64 @slo_i64(i64 %a, i64 %b) nounwind {
 ; RV32IB-NEXT:srli a4, a0, 1
 ; RV32IB-NEXT:srl a3, a4, a3
 ; RV32IB-NEXT:or a1, a1, a3
-; RV32IB-NEXT:sll a2, a0, a2
-; RV32IB-NEXT:  .LBB1_3:
+; RV32IB-NEXT:addi a3, a2, -32
+; RV32IB-NEXT:sll a4, a0, a3
+; RV32IB-NEXT:slti a5, a3, 0
+; RV32IB-NEXT:cmov a

[llvm-branch-commits] [llvm] 23390e7 - [InstCombine] Handle logical and/or in assume optimization

2021-01-12 Thread Nikita Popov via llvm-branch-commits

Author: Nikita Popov
Date: 2021-01-12T22:36:40+01:00
New Revision: 23390e7a131a67fd70e26692fc83f62860dd1095

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

LOG: [InstCombine] Handle logical and/or in assume optimization

assume(a && b) can be converted to assume(a); assume(b) even if
the condition is logical. Same for assume(!(a || b)).

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/assume.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 8f2e694f3c5b..7d63b30d35f8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1478,14 +1478,14 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst 
&CI) {
 FunctionType *AssumeIntrinsicTy = II->getFunctionType();
 Value *AssumeIntrinsic = II->getCalledOperand();
 Value *A, *B;
-if (match(IIOperand, m_And(m_Value(A), m_Value(B {
+if (match(IIOperand, m_LogicalAnd(m_Value(A), m_Value(B {
   Builder.CreateCall(AssumeIntrinsicTy, AssumeIntrinsic, A, OpBundles,
  II->getName());
   Builder.CreateCall(AssumeIntrinsicTy, AssumeIntrinsic, B, II->getName());
   return eraseInstFromFunction(*II);
 }
 // assume(!(a || b)) -> assume(!a); assume(!b);
-if (match(IIOperand, m_Not(m_Or(m_Value(A), m_Value(B) {
+if (match(IIOperand, m_Not(m_LogicalOr(m_Value(A), m_Value(B) {
   Builder.CreateCall(AssumeIntrinsicTy, AssumeIntrinsic,
  Builder.CreateNot(A), OpBundles, II->getName());
   Builder.CreateCall(AssumeIntrinsicTy, AssumeIntrinsic,

diff  --git a/llvm/test/Transforms/InstCombine/assume.ll 
b/llvm/test/Transforms/InstCombine/assume.ll
index f46ffbec2ce6..b107af16bdc1 100644
--- a/llvm/test/Transforms/InstCombine/assume.ll
+++ b/llvm/test/Transforms/InstCombine/assume.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S -instcombine-infinite-loop-threshold=2 | 
FileCheck %s
+; RUN: opt < %s -instcombine -S -instcombine-infinite-loop-threshold=2 
-instcombine-unsafe-select-transform=0 | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
@@ -627,7 +627,7 @@ define i32 @unreachable_assume_logical(i32 %x, i32 %y) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[CMP0:%.*]] = icmp sgt i32 [[X:%.*]], 1
 ; CHECK-NEXT:[[CMP1:%.*]] = icmp eq i32 [[Y:%.*]], 1
-; CHECK-NEXT:[[OR:%.*]] = or i1 [[CMP0]], [[CMP1]]
+; CHECK-NEXT:[[OR:%.*]] = select i1 [[CMP0]], i1 true, i1 [[CMP1]]
 ; CHECK-NEXT:tail call void @llvm.assume(i1 [[OR]])
 ; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[X]], 1
 ; CHECK-NEXT:br i1 [[CMP2]], label [[IF:%.*]], label [[EXIT:%.*]]
@@ -704,7 +704,7 @@ define i32 @unreachable_assumes_and_store_logical(i32 %x, 
i32 %y, i32* %p) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[CMP0:%.*]] = icmp sgt i32 [[X:%.*]], 1
 ; CHECK-NEXT:[[CMP1:%.*]] = icmp eq i32 [[Y:%.*]], 1
-; CHECK-NEXT:[[OR:%.*]] = or i1 [[CMP0]], [[CMP1]]
+; CHECK-NEXT:[[OR:%.*]] = select i1 [[CMP0]], i1 true, i1 [[CMP1]]
 ; CHECK-NEXT:tail call void @llvm.assume(i1 [[OR]])
 ; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[X]], 1
 ; CHECK-NEXT:br i1 [[CMP2]], label [[IF:%.*]], label [[EXIT:%.*]]



___
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] 7fd1850 - [mlir] Update LLVM dialect type documentation

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

Author: Alex Zinenko
Date: 2021-01-12T22:38:24+01:00
New Revision: 7fd18508134112edb93852c16923a74bfff99cd2

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

LOG: [mlir] Update LLVM dialect type documentation

Recent commits reconfigured LLVM dialect types to use built-in types whenever
possible. Update the documentation accordingly.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/docs/Dialects/LLVM.md

Removed: 




diff  --git a/mlir/docs/Dialects/LLVM.md b/mlir/docs/Dialects/LLVM.md
index d232ffab148c..1b85091b0756 100644
--- a/mlir/docs/Dialects/LLVM.md
+++ b/mlir/docs/Dialects/LLVM.md
@@ -130,9 +130,9 @@ Examples:
 %3 = llvm.mlir.constant(dense<1.0> : vector<4xf32>) : vector<4xf32>
 ```
 
-Note that constants use built-in types within the initializer definition: MLIR
-attributes are typed and the attributes used for constants require a built-in
-type.
+Note that constants list the type twice. This is an artifact of the LLVM 
dialect
+not using built-in types, which are used for typed MLIR attributes. The syntax
+will be reevaluated after considering composite constants.
 
 ### Globals
 
@@ -186,33 +186,47 @@ attribute.
 
 ## Types
 
-LLVM dialect defines a set of types that correspond to LLVM IR types. The
-dialect type system is _closed_: types from other dialects are not allowed
-within LLVM dialect aggregate types. This property allows for more concise
-custom syntax and ensures easy translation to LLVM IR.
-
-Similarly to other MLIR context-owned objects, the creation and manipulation of
-LLVM dialect types is thread-safe.
+LLVM dialect uses built-in types whenever possible and defines a set of
+complementary types, which correspond to the LLVM IR types that cannot be
+directly represented with built-in types. Similarly to other MLIR context-owned
+objects, the creation and manipulation of LLVM dialect types is thread-safe.
 
 MLIR does not support module-scoped named type declarations, e.g. `%s = type
 {i32, i32}` in LLVM IR. Instead, types must be fully specified at each use,
 except for recursive types where only the first reference to a named type needs
-to be fully specified. MLIR type aliases are supported for top-level types, 
i.e.
-they cannot be used inside the type due to type system closedness.
+to be fully specified. MLIR [type aliases](LangRef.md#type-aliases) can be used
+to achieve more compact syntax.
 
 The general syntax of LLVM dialect types is `!llvm.`, followed by a type kind
 identifier (e.g., `ptr` for pointer or `struct` for structure) and by an
 optional list of type parameters in angle brackets. The dialect follows MLIR
 style for types with nested angle brackets and keyword specifiers rather than
-using 
diff erent bracket styles to 
diff erentiate types. Inside angle brackets,
-the `!llvm` prefix is omitted for brevity; thanks to closedness of the type
-system, all types are assumed to be defined in the LLVM dialect. For example,
-`!llvm.ptr>` is a pointer to a packed structure type
-containing an 8-bit and a 32-bit integer.
+using 
diff erent bracket styles to 
diff erentiate types. Types inside the angle
+brackets may omit the `!llvm.` prefix for brevity: the parser first attempts to
+find a type (starting with `!` or a built-in type) and falls back to accepting 
a
+keyword. For example, `!llvm.ptr>` and `!llvm.ptr>` are
+equivalent, with the latter being the canonical form, and denote a pointer to a
+pointer to a 32-bit integer.
+
+### Built-in Type Compatibility
+
+LLVM dialect accepts a subset of built-in types that are referred to as _LLVM
+dialect-compatible types_. The following types are compatible:
 
-### Simple Types
+-   Signless integers - `iN` (`IntegerType`).
+-   Floating point types - `bfloat`, `half`, `float`, `double` (`FloatType`).
+-   1D vectors of signless integers or floating point types - `vector`
+(`VectorType`).
 
-The following non-parametric types are supported.
+Note that only a subset of types that can be represented by a given class is
+compatible. For example, signed and unsigned integers are not compatible. LLVM
+provides a function, `bool LLVM::isCompatibleType(Type)`, that can be used as a
+compatibility check.
+
+### Additional Simple Types
+
+The following non-parametric types derived from the LLVM IR are available in 
the
+LLVM dialect:
 
 -   `!llvm.fp128` (`LLVMFP128Type`) - 128-bit floating-point value as per
 IEEE-754-2008.
@@ -231,19 +245,10 @@ The following non-parametric types are supported.
 These types represent a single value (or an absence thereof in case of `void`)
 and correspond to their LLVM IR counterparts.
 
-### Parametric Types
-
- Integer Types
+### Additional Parametric Types
 
-Integer types are parametric in 

[llvm-branch-commits] [llvm] 2a49b7c - [Inliner] Change inline remark format and update ReplayInlineAdvisor to use it

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

Author: modimo
Date: 2021-01-12T13:43:48-08:00
New Revision: 2a49b7c64a33566cf5db1a5b4042d6037ccc7cf5

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

LOG: [Inliner] Change inline remark format and update ReplayInlineAdvisor to 
use it

This change modifies the source location formatting from:
LineNumber.Discriminator
to:
LineNumber:ColumnNumber.Discriminator

The motivation here is to enhance location information for inline replay that 
currently exists for the SampleProfile inliner. This will be leveraged further 
in inline replay for the CGSCC inliner in the related diff.

The ReplayInlineAdvisor is also modified to read the new format and now takes 
into account the callee for greater accuracy.

Testing:
ninja check-llvm

Reviewed By: mtrofin

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

Added: 


Modified: 
clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
clang/test/Frontend/optimization-remark-with-hotness.c
llvm/include/llvm/Analysis/InlineAdvisor.h
llvm/include/llvm/Analysis/ReplayInlineAdvisor.h
llvm/lib/Analysis/InlineAdvisor.cpp
llvm/lib/Analysis/ReplayInlineAdvisor.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
llvm/test/Transforms/SampleProfile/Inputs/inline-replay.txt
llvm/test/Transforms/SampleProfile/inline-replay.ll
llvm/test/Transforms/SampleProfile/remarks-hotness.ll
llvm/test/Transforms/SampleProfile/remarks.ll

Removed: 




diff  --git a/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c 
b/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
index 76802bfdcdb8..5e4641d92313 100644
--- a/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
+++ b/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
@@ -73,7 +73,7 @@ void bar(int x) {
   // THRESHOLD-NOT: hotness
   // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization 
information
   // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided 
optimization information
-  // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inline attribute at callsite bar:8 (hotness:}}
+  // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inline attribute at callsite bar:8:10; (hotness:}}
   sum += foo(x, x - 2);
 }
 

diff  --git a/clang/test/Frontend/optimization-remark-with-hotness.c 
b/clang/test/Frontend/optimization-remark-with-hotness.c
index 96be3524db16..0961e6da11f4 100644
--- a/clang/test/Frontend/optimization-remark-with-hotness.c
+++ b/clang/test/Frontend/optimization-remark-with-hotness.c
@@ -66,7 +66,7 @@ void bar(int x) {
   // THRESHOLD-NOT: hotness
   // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization 
information
   // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided 
optimization information
-  // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inliner at callsite bar:8 (hotness:}}
+  // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inliner at callsite bar:8:10; (hotness:}}
   sum += foo(x, x - 2);
 }
 

diff  --git a/llvm/include/llvm/Analysis/InlineAdvisor.h 
b/llvm/include/llvm/Analysis/InlineAdvisor.h
index f051706dca16..2967aa911699 100644
--- a/llvm/include/llvm/Analysis/InlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -121,6 +121,25 @@ class InlineAdvice {
   bool Recorded = false;
 };
 
+class DefaultInlineAdvice : public InlineAdvice {
+public:
+  DefaultInlineAdvice(InlineAdvisor *Advisor, CallBase &CB,
+  Optional OIC, OptimizationRemarkEmitter &ORE,
+  bool EmitRemarks = true)
+  : InlineAdvice(Advisor, CB, ORE, OIC.hasValue()), OriginalCB(&CB),
+OIC(OIC), EmitRemarks(EmitRemarks) {}
+
+private:
+  void recordUnsuccessfulInliningImpl(const InlineResult &Result) override;
+  void recordInliningWithCalleeDeletedImpl() override;
+  void recordInliningImpl() override;
+
+private:
+  CallBase *const OriginalCB;
+  Optional OIC;
+  bool EmitRemarks;
+};
+
 /// Interface for deciding whether to inline a call site or not.
 class InlineAdvisor {
 public:

diff  --git a/llvm/include/llvm/Analysis/ReplayInlineAdvisor.h 
b/llvm/include/llvm/Analysis/ReplayInlineAdvisor.h
index 19e9079a20f5..daed84603541 100644
--- a/llvm/include/llvm/Analysis/ReplayInlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/ReplayInlineAdvisor.h
@@ -25,13 +25,14 @@ class OptimizationRemarkEmitter;
 class ReplayInlineAdvisor : public InlineAdvisor {
 public:
   ReplayInlineAdvisor(FunctionAnalysisManager &FAM, LLVMContext &Context,
-  StringRef RemarksFile);
+  StringRef RemarksFile, bool EmitRe

[llvm-branch-commits] [openmp] 68ff52f - [OpenMP] Fixed the link error that cannot find static data member

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

Author: Shilei Tian
Date: 2021-01-12T16:48:28-05:00
New Revision: 68ff52ffead2ba25cca442778ab19286000daad7

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

LOG: [OpenMP] Fixed the link error that cannot find static data member

Constant static data member can be defined in the class without another
define after the class in C++17. Although it is C++17, Clang can still handle it
even w/o the flag for C++17. Unluckily, GCC cannot handle that.

Reviewed By: jhuber6

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

Added: 


Modified: 
openmp/libomptarget/plugins/common/MemoryManager/MemoryManager.h

Removed: 




diff  --git a/openmp/libomptarget/plugins/common/MemoryManager/MemoryManager.h 
b/openmp/libomptarget/plugins/common/MemoryManager/MemoryManager.h
index 1f9cbeb00394..6e00728a658f 100644
--- a/openmp/libomptarget/plugins/common/MemoryManager/MemoryManager.h
+++ b/openmp/libomptarget/plugins/common/MemoryManager/MemoryManager.h
@@ -338,4 +338,9 @@ class MemoryManagerTy {
   }
 };
 
+// GCC still cannot handle the static data member like Clang so we still need
+// this part.
+constexpr const size_t MemoryManagerTy::BucketSize[];
+constexpr const int MemoryManagerTy::NumBuckets;
+
 #endif // LLVM_OPENMP_LIBOMPTARGET_PLUGINS_COMMON_MEMORYMANAGER_MEMORYMANAGER_H



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


[llvm-branch-commits] [llvm] d1fa7af - [AArch64] [Windows] Properly add :lo12: reloc specifiers when generating assembly

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

Author: Martin Storsjö
Date: 2021-01-12T23:56:03+02:00
New Revision: d1fa7afc7aefd822698fe86431d8184b1e8b6683

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

LOG: [AArch64] [Windows] Properly add :lo12: reloc specifiers when generating 
assembly

This makes sure that assembly output actually can be assembled.

Set the correct MCExpr relocations specifier VK_PAGEOFF - and also
set VK_PAGE consistently even though it's not visible in the assembly
output.

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

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
llvm/test/CodeGen/AArch64/cfguard-checks.ll
llvm/test/CodeGen/AArch64/dllimport.ll
llvm/test/CodeGen/AArch64/mingw-refptr.ll
llvm/test/CodeGen/AArch64/stack-protector-target.ll
llvm/test/CodeGen/AArch64/win-tls.ll
llvm/test/CodeGen/AArch64/win_cst_pool.ll
llvm/test/CodeGen/AArch64/windows-extern-weak.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp 
b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
index afd5ae6bcbf2..10e191ff44cf 100644
--- a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
@@ -203,6 +203,12 @@ MCOperand AArch64MCInstLower::lowerSymbolOperandCOFF(const 
MachineOperand &MO,
 RefFlags |= AArch64MCExpr::VK_SABS;
   } else {
 RefFlags |= AArch64MCExpr::VK_ABS;
+
+if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) == AArch64II::MO_PAGE)
+  RefFlags |= AArch64MCExpr::VK_PAGE;
+else if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) ==
+ AArch64II::MO_PAGEOFF)
+  RefFlags |= AArch64MCExpr::VK_PAGEOFF | AArch64MCExpr::VK_NC;
   }
 
   if ((MO.getTargetFlags() & AArch64II::MO_FRAGMENT) == AArch64II::MO_G3)

diff  --git a/llvm/test/CodeGen/AArch64/cfguard-checks.ll 
b/llvm/test/CodeGen/AArch64/cfguard-checks.ll
index cb31decd57ba..66ec4b6ed074 100644
--- a/llvm/test/CodeGen/AArch64/cfguard-checks.ll
+++ b/llvm/test/CodeGen/AArch64/cfguard-checks.ll
@@ -18,7 +18,7 @@ entry:
 
   ; CHECK-LABEL: func_guard_nocf
   ; CHECK:   adrp x8, target_func
-   ; CHECK:   add x8, x8, target_func
+   ; CHECK:   add x8, x8, :lo12:target_func
   ; CHECK-NOT:   __guard_check_icall_fptr
; CHECK:   blr x8
 }
@@ -37,9 +37,9 @@ entry:
   ; The call to __guard_check_icall_fptr should come immediately before the 
call to the target function.
   ; CHECK-LABEL: func_optnone_cf
; CHECK:adrp x8, target_func
-   ; CHECK:add x8, x8, target_func
+   ; CHECK:add x8, x8, :lo12:target_func
; CHECK:adrp x9, __guard_check_icall_fptr
-   ; CHECK:add x9, x9, __guard_check_icall_fptr
+   ; CHECK:add x9, x9, :lo12:__guard_check_icall_fptr
; CHECK:ldr x9, [x9]
; CHECK:mov x15, x8
; CHECK:blr x9
@@ -60,9 +60,9 @@ entry:
   ; The call to __guard_check_icall_fptr should come immediately before the 
call to the target function.
   ; CHECK-LABEL: func_cf
   ; CHECK:adrp x8, __guard_check_icall_fptr
-   ; CHECK:ldr x9, [x8, __guard_check_icall_fptr]
+   ; CHECK:ldr x9, [x8, :lo12:__guard_check_icall_fptr]
; CHECK:adrp x8, target_func
-   ; CHECK:add x8, x8, target_func
+   ; CHECK:add x8, x8, :lo12:target_func
; CHECK:mov x15, x8
; CHECK:blr x9
; CHECK-NEXT:   blr x8
@@ -89,9 +89,9 @@ lpad: ; preds = 
%entry
   ; The call to __guard_check_icall_fptr should come immediately before the 
call to the target function.
   ; CHECK-LABEL: func_cf_invoke
   ; CHECK:adrp x8, __guard_check_icall_fptr
-   ; CHECK:ldr x9, [x8, __guard_check_icall_fptr]
+   ; CHECK:ldr x9, [x8, :lo12:__guard_check_icall_fptr]
; CHECK:adrp x8, target_func
-   ; CHECK:add x8, x8, target_func
+   ; CHECK:add x8, x8, :lo12:target_func
; CHECK:mov x15, x8
; CHECK:blr x9
   ; CHECK-NEXT:   .Ltmp0:

diff  --git a/llvm/test/CodeGen/AArch64/dllimport.ll 
b/llvm/test/CodeGen/AArch64/dllimport.ll
index d72e987aec2d..ed90c805c53b 100644
--- a/llvm/test/CodeGen/AArch64/dllimport.ll
+++ b/llvm/test/CodeGen/AArch64/dllimport.ll
@@ -14,7 +14,7 @@ define i32 @get_var() {
 
 ; CHECK-LABEL: get_var
 ; CHECK: adrp x8, __imp_var
-; CHECK: ldr x8, [x8, __imp_var]
+; CHECK: ldr x8, [x8, :lo12:__imp_var]
 ; CHECK: ldr w0, [x8]
 ; CHECK: ret
 
@@ -25,10 +25,10 @@ define i32 @get_ext() {
 
 ; CHECK-LABEL: get_ext
 ; CHECK: adrp x8, ext
-; DAG-ISEL: ldr w0, [x8, ext]
-; FAST-ISEL: add x8, x8, ext
+; DAG-ISEL: ldr w0, [x8, :lo12:ext]
+; FAST

[llvm-branch-commits] [libcxx] 02f1d28 - [libcxx] Avoid overflows in the windows __libcpp_steady_clock_now()

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

Author: Martin Storsjö
Date: 2021-01-12T23:56:03+02:00
New Revision: 02f1d28ed6b8f33445dae3beed8b6cc8dada4312

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

LOG: [libcxx] Avoid overflows in the windows __libcpp_steady_clock_now()

As freq.QuadValue can be in the range of 1000 to 1920,
the multiplication before division makes the calculation overflow
and wrap to negative values every 16-30 minutes.

Instead count the whole seconds separately before adding the
scaled fractional seconds.

Add a testcase for steady_clock to check that the values returned for
now() compare as bigger than the zero time origin; this
corresponds to a testcase in Qt [1] [2] (that failed spuriously
due to this).

[1] https://bugreports.qt.io/browse/QTBUG-89539
[2] 
https://code.qt.io/cgit/qt/qtbase.git/tree/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp?id=f8de5e54022b8b7471131b7ad55c83b69b2684c0#n569

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

Added: 


Modified: 
libcxx/src/chrono.cpp
libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp

Removed: 




diff  --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp
index 1419cf2f74a8..5291d4fa8dc6 100644
--- a/libcxx/src/chrono.cpp
+++ b/libcxx/src/chrono.cpp
@@ -153,7 +153,10 @@ static steady_clock::time_point 
__libcpp_steady_clock_now() {
 
   LARGE_INTEGER counter;
   (void) QueryPerformanceCounter(&counter);
-  return steady_clock::time_point(steady_clock::duration(counter.QuadPart * 
nano::den / freq.QuadPart));
+  auto seconds = counter.QuadPart / freq.QuadPart;
+  auto fractions = counter.QuadPart % freq.QuadPart;
+  auto dur = seconds * nano::den + fractions * nano::den / freq.QuadPart;
+  return steady_clock::time_point(steady_clock::duration(dur));
 }
 
 #elif defined(CLOCK_MONOTONIC)

diff  --git 
a/libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp 
b/libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp
index 4b8104dd1a6f..14dc9a9832dc 100644
--- a/libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp
+++ b/libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp
@@ -25,6 +25,8 @@ int main(int, char**)
 C::time_point t1 = C::now();
 C::time_point t2 = C::now();
 assert(t2 >= t1);
+// make sure t2 didn't wrap around
+assert(t2 > std::chrono::time_point());
 
   return 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] 01f1273 - [OpenMP] Fixed a typo in openmp/CMakeLists.txt

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

Author: Shilei Tian
Date: 2021-01-12T17:00:49-05:00
New Revision: 01f1273fe2f0c246f17162de24a8b6e11bad23a8

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

LOG: [OpenMP] Fixed a typo in openmp/CMakeLists.txt

Added: 


Modified: 
openmp/CMakeLists.txt

Removed: 




diff  --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 12e8d542f9f6..67600bebdafb 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -73,7 +73,7 @@ if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS)
   if (LLVM_MAIN_INCLUDE_DIR)
 list(APPEND LIBOMPTARGET_LLVM_INCLUDE_DIRS ${LLVM_MAIN_INCLUDE_DIR})
   elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../llvm/include)
-list(APPENDset LIBOMPTARGET_LLVM_INCLUDE_DIRS 
${CMAKE_CURRENT_SOURCE_DIR}/../llvm/include)
+list(APPEND LIBOMPTARGET_LLVM_INCLUDE_DIRS 
${CMAKE_CURRENT_SOURCE_DIR}/../llvm/include)
   endif()
 endif()
 



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


[llvm-branch-commits] [llvm] 3d39709 - AMDGPU: Remove wrapper only call limitation

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

Author: Matt Arsenault
Date: 2021-01-12T17:12:49-05:00
New Revision: 3d397091591fca4aa16153bba22f031218bee47d

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

LOG: AMDGPU: Remove wrapper only call limitation

This seems to only have overridden cold handling, which we probably
shouldn't do. As far as I can tell the wrapper library functions are
still inlined as appropriate.

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
llvm/test/CodeGen/AMDGPU/amdgpu-inline.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
index 3b96a6a85879..4e689b392802 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
@@ -145,26 +145,6 @@ unsigned AMDGPUInliner::getInlineThreshold(CallBase &CB) 
const {
   return (unsigned)Thres;
 }
 
-// Check if call is just a wrapper around another call.
-// In this case we only have call and ret instructions.
-static bool isWrapperOnlyCall(CallBase &CB) {
-  Function *Callee = CB.getCalledFunction();
-  if (!Callee || Callee->size() != 1)
-return false;
-  const BasicBlock &BB = Callee->getEntryBlock();
-  if (const Instruction *I = BB.getFirstNonPHI()) {
-if (!isa(I)) {
-  return false;
-}
-if (isa(*std::next(I->getIterator( {
-  LLVM_DEBUG(dbgs() << "Wrapper only call detected: "
-<< Callee->getName() << '\n');
-  return true;
-}
-  }
-  return false;
-}
-
 InlineCost AMDGPUInliner::getInlineCost(CallBase &CB) {
   Function *Callee = CB.getCalledFunction();
   Function *Caller = CB.getCaller();
@@ -186,9 +166,6 @@ InlineCost AMDGPUInliner::getInlineCost(CallBase &CB) {
 return llvm::InlineCost::getNever(IsViable.getFailureReason());
   }
 
-  if (isWrapperOnlyCall(CB))
-return llvm::InlineCost::getAlways("wrapper-only call");
-
   InlineParams LocalParams = Params;
   LocalParams.DefaultThreshold = (int)getInlineThreshold(CB);
   bool RemarksEnabled = false;

diff  --git a/llvm/test/CodeGen/AMDGPU/amdgpu-inline.ll 
b/llvm/test/CodeGen/AMDGPU/amdgpu-inline.ll
index 243522e28dd7..dd06fc17e8ed 100644
--- a/llvm/test/CodeGen/AMDGPU/amdgpu-inline.ll
+++ b/llvm/test/CodeGen/AMDGPU/amdgpu-inline.ll
@@ -40,7 +40,7 @@ if.end:
   ret void
 }
 
-define coldcc float @sin_wrapper(float %x) {
+define float @sin_wrapper(float %x) {
 bb:
   %call = tail call float @_Z3sinf(float %x)
   ret float %call
@@ -83,7 +83,7 @@ entry:
   %and = and i32 %tid, %n
   %arrayidx11 = getelementptr inbounds [64 x float], [64 x float] 
addrspace(5)* %pvt_arr, i32 0, i32 %and
   %tmp12 = load float, float addrspace(5)* %arrayidx11, align 4
-  %c2 = call coldcc float @sin_wrapper(float %tmp12)
+  %c2 = call float @sin_wrapper(float %tmp12)
   store float %c2, float addrspace(5)* %arrayidx7, align 4
   %xor = xor i32 %tid, %n
   %arrayidx16 = getelementptr inbounds [64 x float], [64 x float] 
addrspace(5)* %pvt_arr, i32 0, i32 %xor



___
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] cf45731 - [Driver] Fix assertion failure when -fprofile-generate -fcs-profile-generate are used together

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

Author: Fangrui Song
Date: 2021-01-12T14:19:55-08:00
New Revision: cf45731f0eaead79e1ac501b397e330df41ec152

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

LOG: [Driver] Fix assertion failure when -fprofile-generate 
-fcs-profile-generate are used together

If conflicting `-fprofile-generate -fcs-profile-generate` are used together,
there is currently an assertion failure. Fix the failure.

Also add some driver tests.

Reviewed By: xur

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

Added: 
clang/test/Driver/fcs-profile-generate.c

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4a20936ddda1..c03b513150b3 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -766,9 +766,11 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
 D.Diag(diag::err_drv_argument_not_allowed_with)
 << ProfileGenerateArg->getSpelling() << ProfileUseArg->getSpelling();
 
-  if (CSPGOGenerateArg && PGOGenerateArg)
+  if (CSPGOGenerateArg && PGOGenerateArg) {
 D.Diag(diag::err_drv_argument_not_allowed_with)
 << CSPGOGenerateArg->getSpelling() << PGOGenerateArg->getSpelling();
+PGOGenerateArg = nullptr;
+  }
 
   if (ProfileGenerateArg) {
 if (ProfileGenerateArg->getOption().matches(

diff  --git a/clang/test/Driver/fcs-profile-generate.c 
b/clang/test/Driver/fcs-profile-generate.c
new file mode 100644
index ..6be7f758c3e6
--- /dev/null
+++ b/clang/test/Driver/fcs-profile-generate.c
@@ -0,0 +1,15 @@
+// RUN: %clang -### -c -fprofile-use=a.profdata -fcs-profile-generate %s 2>&1 
| FileCheck %s
+// CHECK:  "-fprofile-instrument=csllvm"
+// CHECK-NOT:  "-fprofile-instrument-path=
+// CHECK-SAME: "-fprofile-instrument-use-path=a.profdata"
+
+// RUN: %clang -### -c -fprofile-use=a.profdata -fcs-profile-generate=dir %s 
2>&1 | FileCheck %s --check-prefix=CHECK1
+// CHECK1: "-fprofile-instrument=csllvm"{{.*}} 
"-fprofile-instrument-path=dir{{/|}}default_%m.profraw" 
"-fprofile-instrument-use-path=a.profdata"
+
+/// Degradation case. This usage does not make much sense.
+// RUN: %clang -### -c -fcs-profile-generate %s 2>&1 | FileCheck %s 
--check-prefix=NOUSE
+// NOUSE: "-fprofile-instrument=csllvm"
+// NOUSE-NOT: "-fprofile-instrument-path=
+
+// RUN: %clang -### -c -fprofile-generate -fcs-profile-generate %s 2>&1 | 
FileCheck %s --check-prefix=CONFLICT
+// CONFLICT: error: invalid argument '-fcs-profile-generate' not allowed with 
'-fprofile-generate'



___
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] 55f2eee - [NFC] Disallow unused prefixes in MC/AMDGPU

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

Author: Mircea Trofin
Date: 2021-01-12T14:31:22-08:00
New Revision: 55f2eeebc96e7522e49e19074cbfbe4e7f074b5b

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

LOG: [NFC] Disallow unused prefixes in MC/AMDGPU

1 out of 2 patches.

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

Added: 


Modified: 
llvm/test/MC/AMDGPU/add-sub-no-carry.s
llvm/test/MC/AMDGPU/buf-fmt-d16-packed.s
llvm/test/MC/AMDGPU/buf-fmt-d16-unpacked.s
llvm/test/MC/AMDGPU/ds-gfx9.s
llvm/test/MC/AMDGPU/ds.s
llvm/test/MC/AMDGPU/flat-gfx10.s
llvm/test/MC/AMDGPU/flat-global.s
llvm/test/MC/AMDGPU/flat-scratch-instructions.s
llvm/test/MC/AMDGPU/gfx10_asm_dpp16.s
llvm/test/MC/AMDGPU/gfx10_asm_dpp8.s
llvm/test/MC/AMDGPU/gfx10_asm_ds.s
llvm/test/MC/AMDGPU/gfx10_asm_flat.s
llvm/test/MC/AMDGPU/gfx10_asm_mubuf.s
llvm/test/MC/AMDGPU/gfx10_asm_smem.s
llvm/test/MC/AMDGPU/gfx10_asm_sop.s
llvm/test/MC/AMDGPU/gfx10_asm_vop1.s
llvm/test/MC/AMDGPU/gfx10_asm_vop2.s
llvm/test/MC/AMDGPU/gfx10_asm_vopc.s
llvm/test/MC/AMDGPU/gfx10_asm_vopc_e64.s
llvm/test/MC/AMDGPU/gfx10_asm_vopc_sdwa.s
llvm/test/MC/AMDGPU/gfx10_asm_vopcx.s
llvm/test/MC/AMDGPU/hsa-metadata-kernel-args-v3.s
llvm/test/MC/AMDGPU/hsa-metadata-kernel-args.s
llvm/test/MC/AMDGPU/hsa-metadata-kernel-attrs-v3.s
llvm/test/MC/AMDGPU/hsa-metadata-kernel-attrs.s
llvm/test/MC/AMDGPU/hsa-metadata-kernel-code-props-v3.s
llvm/test/MC/AMDGPU/hsa-metadata-kernel-code-props.s
llvm/test/MC/AMDGPU/hsa-metadata-kernel-debug-props.s
llvm/test/MC/AMDGPU/hsa-wave-size.s
llvm/test/MC/AMDGPU/regression/bug28165.s
llvm/test/MC/AMDGPU/regression/bug28168.s
llvm/test/MC/AMDGPU/regression/bug28413.s
llvm/test/MC/AMDGPU/regression/bug28538.s

Removed: 




diff  --git a/llvm/test/MC/AMDGPU/add-sub-no-carry.s 
b/llvm/test/MC/AMDGPU/add-sub-no-carry.s
index 2e3ac9d24376..1768b73b60af 100644
--- a/llvm/test/MC/AMDGPU/add-sub-no-carry.s
+++ b/llvm/test/MC/AMDGPU/add-sub-no-carry.s
@@ -1,7 +1,7 @@
-// RUN: llvm-mc -arch=amdgcn -mcpu=gfx900 -show-encoding %s | FileCheck 
-check-prefixes=GFX9 %s
+// RUN: llvm-mc -arch=amdgcn -mcpu=gfx900 -show-encoding %s | FileCheck 
--check-prefix=GFX9 %s
 
-// RUN: not llvm-mc -arch=amdgcn -mcpu=fiji %s 2>&1 | FileCheck 
-check-prefixes=ERR-VI,ERR-SICIVI --implicit-check-not=error: %s
-// RUN: not llvm-mc -arch=amdgcn -mcpu=bonaire %s 2>&1 | FileCheck 
-check-prefixes=ERR-SICI,ERR-SICIVI --implicit-check-not=error: %s
+// RUN: not llvm-mc -arch=amdgcn -mcpu=fiji %s 2>&1 | FileCheck 
--check-prefix=ERR-VI --implicit-check-not=error: %s
+// RUN: not llvm-mc -arch=amdgcn -mcpu=bonaire %s 2>&1 | FileCheck 
--check-prefix=ERR-SICI --implicit-check-not=error: %s
 // FIXME: pre-gfx9 errors should be more useful
 
 

diff  --git a/llvm/test/MC/AMDGPU/buf-fmt-d16-packed.s 
b/llvm/test/MC/AMDGPU/buf-fmt-d16-packed.s
index ab51b14e5454..a9b5cfdfad64 100644
--- a/llvm/test/MC/AMDGPU/buf-fmt-d16-packed.s
+++ b/llvm/test/MC/AMDGPU/buf-fmt-d16-packed.s
@@ -1,7 +1,7 @@
-// RUN: llvm-mc -arch=amdgcn -mcpu=gfx810 -show-encoding %s | FileCheck 
-check-prefix=GCN -check-prefix=PACKED %s
-// RUN: llvm-mc -arch=amdgcn -mcpu=gfx900 -show-encoding %s | FileCheck 
-check-prefix=GCN -check-prefix=PACKED %s
+// RUN: llvm-mc -arch=amdgcn -mcpu=gfx810 -show-encoding %s | FileCheck 
-check-prefix=PACKED %s
+// RUN: llvm-mc -arch=amdgcn -mcpu=gfx900 -show-encoding %s | FileCheck 
-check-prefix=PACKED %s
 
-// RUN: not llvm-mc -arch=amdgcn -mcpu=fiji 2>&1 %s | FileCheck 
-check-prefix=UNPACKED-ERR -check-prefix=GCN-ERR --implicit-check-not=error: %s
+// RUN: not llvm-mc -arch=amdgcn -mcpu=fiji 2>&1 %s | FileCheck 
-check-prefix=UNPACKED-ERR --implicit-check-not=error: %s
 
 
 
//===--===//

diff  --git a/llvm/test/MC/AMDGPU/buf-fmt-d16-unpacked.s 
b/llvm/test/MC/AMDGPU/buf-fmt-d16-unpacked.s
index 78ca007171a5..045da853746d 100644
--- a/llvm/test/MC/AMDGPU/buf-fmt-d16-unpacked.s
+++ b/llvm/test/MC/AMDGPU/buf-fmt-d16-unpacked.s
@@ -1,6 +1,6 @@
-// RUN: llvm-mc -arch=amdgcn -mcpu=fiji -show-encoding %s | FileCheck 
-check-prefix=GCN -check-prefix=UNPACKED %s
-// RUN: not llvm-mc -arch=amdgcn -mcpu=gfx810 2>&1 %s | FileCheck 
-check-prefix=PACKED-ERR -check-prefix=GCN-ERR --implicit-check-not=error: %s
-// RUN: not llvm-mc -arch=amdgcn -mcpu=gfx900 2>&1 %s | FileCheck 
-check-prefix=PACKED-ERR -check-prefix=GCN-ERR --implicit-check-not=error: %s
+// RUN: llvm-mc -arch=amdgcn -mcpu=fiji -show-encoding %s | FileCheck 
-check-prefix=UNPACKED %s
+// RUN: not llvm-mc -arch=amdgcn -mcpu=gfx810 2>&1 %s | FileCheck 
-check-prefix=PACKED-ERR --implicit-check-not=error: %s
+// RUN: not llvm-mc -arch=amdgcn -mcpu=gfx9

[llvm-branch-commits] [llvm] a7130d8 - [ADT][NFC] Use empty base optimisation in BumpPtrAllocatorImpl

2021-01-12 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2021-01-12T22:43:48Z
New Revision: a7130d85e4b9e47b18a89eac3d47fd8c19d449c1

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

LOG: [ADT][NFC] Use empty base optimisation in BumpPtrAllocatorImpl

Most uses of this class just use the default MallocAllocator.
As this contains no fields, we can use the empty base optimisation for 
BumpPtrAllocatorImpl and save 8 bytes of padding for most use cases.

This prevents using a class that is marked as `final` as the `AllocatorT` 
template argument.
In one must use an allocator that has been marked as `final`, the simplest way 
around this is a proxy class.
The class should have all the methods that `AllocaterBase` expects and should 
forward the calls to your own allocator instance.

Reviewed By: dblaikie

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

Added: 


Modified: 
llvm/include/llvm/Support/Allocator.h

Removed: 




diff  --git a/llvm/include/llvm/Support/Allocator.h 
b/llvm/include/llvm/Support/Allocator.h
index 40c967ccc485..245432debce6 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -66,7 +66,8 @@ template 
 class BumpPtrAllocatorImpl
 : public AllocatorBase> {
+SizeThreshold, GrowthDelay>>,
+  private AllocatorT {
 public:
   static_assert(SizeThreshold <= SlabSize,
 "The SizeThreshold must be at most the SlabSize to ensure "
@@ -80,15 +81,15 @@ class BumpPtrAllocatorImpl
 
   template 
   BumpPtrAllocatorImpl(T &&Allocator)
-  : Allocator(std::forward(Allocator)) {}
+  : AllocatorT(std::forward(Allocator)) {}
 
   // Manually implement a move constructor as we must clear the old allocator's
   // slabs as a matter of correctness.
   BumpPtrAllocatorImpl(BumpPtrAllocatorImpl &&Old)
-  : CurPtr(Old.CurPtr), End(Old.End), Slabs(std::move(Old.Slabs)),
+  : AllocatorT(static_cast(Old)), CurPtr(Old.CurPtr),
+End(Old.End), Slabs(std::move(Old.Slabs)),
 CustomSizedSlabs(std::move(Old.CustomSizedSlabs)),
-BytesAllocated(Old.BytesAllocated), RedZoneSize(Old.RedZoneSize),
-Allocator(std::move(Old.Allocator)) {
+BytesAllocated(Old.BytesAllocated), RedZoneSize(Old.RedZoneSize) {
 Old.CurPtr = Old.End = nullptr;
 Old.BytesAllocated = 0;
 Old.Slabs.clear();
@@ -110,7 +111,7 @@ class BumpPtrAllocatorImpl
 RedZoneSize = RHS.RedZoneSize;
 Slabs = std::move(RHS.Slabs);
 CustomSizedSlabs = std::move(RHS.CustomSizedSlabs);
-Allocator = std::move(RHS.Allocator);
+AllocatorT::operator=(static_cast(RHS));
 
 RHS.CurPtr = RHS.End = nullptr;
 RHS.BytesAllocated = 0;
@@ -170,7 +171,8 @@ class BumpPtrAllocatorImpl
 // If Size is really big, allocate a separate slab for it.
 size_t PaddedSize = SizeToAllocate + Alignment.value() - 1;
 if (PaddedSize > SizeThreshold) {
-  void *NewSlab = Allocator.Allocate(PaddedSize, 
alignof(std::max_align_t));
+  void *NewSlab =
+  AllocatorT::Allocate(PaddedSize, alignof(std::max_align_t));
   // We own the new slab and don't want anyone reading anyting other than
   // pieces returned from this method.  So poison the whole slab.
   __asan_poison_memory_region(NewSlab, PaddedSize);
@@ -315,9 +317,6 @@ class BumpPtrAllocatorImpl
   /// a sanitizer.
   size_t RedZoneSize = 1;
 
-  /// The allocator instance we use to get slabs of memory.
-  AllocatorT Allocator;
-
   static size_t computeSlabSize(unsigned SlabIdx) {
 // Scale the actual allocated slab size based on the number of slabs
 // allocated. Every GrowthDelay slabs allocated, we double
@@ -333,7 +332,7 @@ class BumpPtrAllocatorImpl
 size_t AllocatedSlabSize = computeSlabSize(Slabs.size());
 
 void *NewSlab =
-Allocator.Allocate(AllocatedSlabSize, alignof(std::max_align_t));
+AllocatorT::Allocate(AllocatedSlabSize, alignof(std::max_align_t));
 // We own the new slab and don't want anyone reading anything other than
 // pieces returned from this method.  So poison the whole slab.
 __asan_poison_memory_region(NewSlab, AllocatedSlabSize);
@@ -349,7 +348,7 @@ class BumpPtrAllocatorImpl
 for (; I != E; ++I) {
   size_t AllocatedSlabSize =
   computeSlabSize(std::distance(Slabs.begin(), I));
-  Allocator.Deallocate(*I, AllocatedSlabSize, alignof(std::max_align_t));
+  AllocatorT::Deallocate(*I, AllocatedSlabSize, alignof(std::max_align_t));
 }
   }
 
@@ -358,7 +357,7 @@ class BumpPtrAllocatorImpl
 for (auto &PtrAndSize : CustomSizedSlabs) {
   void *Ptr = PtrAndSize.first;
   size_t Size = PtrAndSize.second;
-  Allocator.Deallocate(Ptr, Size, alignof(std::max_align_t));
+  AllocatorT::Dea

[llvm-branch-commits] [llvm] 1730b0f - [RISCV] Remove '.mask' from vcompress intrinsic name. NFC

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

Author: Craig Topper
Date: 2021-01-12T14:46:16-08:00
New Revision: 1730b0f66adaea6ed65d441dc2032013dd3c3664

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

LOG: [RISCV] Remove '.mask' from vcompress intrinsic name. NFC

It has a mask argument, but isn't a masked instruction. It doesn't
use the mask policy of or the v0.t syntax.

Added: 


Modified: 
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
llvm/test/CodeGen/RISCV/rvv/vcompress-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vcompress-rv64.ll

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td 
b/llvm/include/llvm/IR/IntrinsicsRISCV.td
index 8171be8a1ca8..e45be2b72796 100644
--- a/llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -740,7 +740,7 @@ let TargetPrefix = "riscv" in {
 
   defm vrgather : RISCVBinaryAAX;
 
-  def "int_riscv_vcompress_mask" : RISCVBinaryAAAMask;
+  def "int_riscv_vcompress" : RISCVBinaryAAAMask;
 
   defm vaaddu : RISCVSaturatingBinaryAAX;
   defm vaadd : RISCVSaturatingBinaryAAX;

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index 3604a25b0d6a..a715676183e2 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -947,7 +947,7 @@ multiclass VPseudoUnaryV_M {
 multiclass VPseudoUnaryV_V_AnyMask {
   foreach m = MxList.m in {
 let VLMul = m.value in
-  def _VM # "_" # m.MX # "_MASK" : VPseudoUnaryAnyMask;
+  def _VM # "_" # m.MX : VPseudoUnaryAnyMask;
   }
 }
 
@@ -1404,12 +1404,12 @@ class VPatUnaryAnyMask :
-  Pat<(result_type (!cast(intrinsic#"_mask")
+  Pat<(result_type (!cast(intrinsic)
(result_type result_reg_class:$merge),
(op1_type op1_reg_class:$rs1),
(mask_type VR:$rs2),
(XLenVT GPR:$vl))),
-   (!cast(inst#"_"#kind#"_"#vlmul.MX#"_MASK")
+   (!cast(inst#"_"#kind#"_"#vlmul.MX)
(result_type result_reg_class:$merge),
(op1_type op1_reg_class:$rs1),
(mask_type VR:$rs2),

diff  --git a/llvm/test/CodeGen/RISCV/rvv/vcompress-rv32.ll 
b/llvm/test/CodeGen/RISCV/rvv/vcompress-rv32.ll
index b8d42eeb9e6c..24b6d73d64c3 100644
--- a/llvm/test/CodeGen/RISCV/rvv/vcompress-rv32.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/vcompress-rv32.ll
@@ -1,20 +1,20 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-v,+f,+experimental-zfh 
-verify-machineinstrs \
 ; RUN:   --riscv-no-aliases < %s | FileCheck %s
-declare  @llvm.riscv.vcompress.mask.nxv1i8(
+declare  @llvm.riscv.vcompress.nxv1i8(
   ,
   ,
   ,
   i32);
 
-define  @intrinsic_vcompress_mask_vm_nxv1i8_nxv1i8( %0,  %1,  %2, i32 %3) nounwind {
-; CHECK-LABEL: intrinsic_vcompress_mask_vm_nxv1i8_nxv1i8:
+define  @intrinsic_vcompress_vm_nxv1i8_nxv1i8( %0,  %1,  %2, i32 %3) nounwind {
+; CHECK-LABEL: intrinsic_vcompress_vm_nxv1i8_nxv1i8:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vsetvli a0, a0, e8,mf8,tu,mu
 ; CHECK-NEXT:vcompress.vm v16, v17, v0
 ; CHECK-NEXT:jalr zero, 0(ra)
 entry:
-  %a = call  @llvm.riscv.vcompress.mask.nxv1i8(
+  %a = call  @llvm.riscv.vcompress.nxv1i8(
  %0,
  %1,
  %2,
@@ -23,20 +23,20 @@ entry:
   ret  %a
 }
 
-declare  @llvm.riscv.vcompress.mask.nxv2i8(
+declare  @llvm.riscv.vcompress.nxv2i8(
   ,
   ,
   ,
   i32);
 
-define  @intrinsic_vcompress_mask_vm_nxv2i8_nxv2i8( %0,  %1,  %2, i32 %3) nounwind {
-; CHECK-LABEL: intrinsic_vcompress_mask_vm_nxv2i8_nxv2i8:
+define  @intrinsic_vcompress_vm_nxv2i8_nxv2i8( %0,  %1,  %2, i32 %3) nounwind {
+; CHECK-LABEL: intrinsic_vcompress_vm_nxv2i8_nxv2i8:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vsetvli a0, a0, e8,mf4,tu,mu
 ; CHECK-NEXT:vcompress.vm v16, v17, v0
 ; CHECK-NEXT:jalr zero, 0(ra)
 entry:
-  %a = call  @llvm.riscv.vcompress.mask.nxv2i8(
+  %a = call  @llvm.riscv.vcompress.nxv2i8(
  %0,
  %1,
  %2,
@@ -45,20 +45,20 @@ entry:
   ret  %a
 }
 
-declare  @llvm.riscv.vcompress.mask.nxv4i8(
+declare  @llvm.riscv.vcompress.nxv4i8(
   ,
   ,
   ,
   i32);
 
-define  @intrinsic_vcompress_mask_vm_nxv4i8_nxv4i8( %0,  %1,  %2, i32 %3) nounwind {
-; CHECK-LABEL: intrinsic_vcompress_mask_vm_nxv4i8_nxv4i8:
+define  @intrinsic_vcompress_vm_nxv4i8_nxv4i8( %0,  %1,  %2, i32 %3) nounwind {
+; CHECK-LABEL: intrinsic_vcompress_vm_nxv4i8_nxv4i8:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vsetvli a0, a0, e8,mf2,tu,mu
 ; CHECK-NEXT:vcompress.vm v16, v17, v0
 ; CHECK-NEXT:jalr zero, 0(ra)
 entry:
-  %a = call  @llvm.riscv.vcompress.mask.nxv4i8(
+  %a = call  

[llvm-branch-commits] [lld] 6166b91 - [ELF][NFCI] small cleanup to OutputSections.h

2021-01-12 Thread Bob Haarman via llvm-branch-commits

Author: Bob Haarman
Date: 2021-01-12T23:09:16Z
New Revision: 6166b91e83716fbe930b2dc4e2a2217c52ee31a7

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

LOG: [ELF][NFCI] small cleanup to OutputSections.h

OutputSections.h used to close the lld::elf namespace only to
immediately open it again. This change merges both parts into
one.

Reviewed By: MaskRay

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

Added: 


Modified: 
lld/ELF/OutputSections.h

Removed: 




diff  --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 39bf48c091ca..69b7944d946a 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -135,12 +135,6 @@ struct Out {
   static OutputSection *finiArray;
 };
 
-} // namespace elf
-} // namespace lld
-
-namespace lld {
-namespace elf {
-
 uint64_t getHeaderSize();
 
 extern std::vector outputSections;



___
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] 175288a - Add sample-profile-suffix-elision-policy attribute with -funique-internal-linkage-names.

2021-01-12 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2021-01-12T15:15:53-08:00
New Revision: 175288a1afef2b6976455aab5ce51c66d28f8bca

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

LOG: Add sample-profile-suffix-elision-policy attribute with 
-funique-internal-linkage-names.

Adding sample-profile-suffix-elision-policy attribute to functions whose 
linkage names are uniquefied so that their unique name suffix won't be trimmed 
when applying AutoFDO profiles.

Reviewed By: dblaikie

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

Added: 


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

llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp 
b/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
index 2909403fdb10..c57cec6be676 100644
--- a/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
+++ b/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
@@ -43,6 +43,7 @@ static bool uniqueifyInternalLinkageNames(Module &M) {
   for (auto &F : M) {
 if (F.hasInternalLinkage()) {
   F.setName(F.getName() + ModuleNameHash);
+  F.addFnAttr("sample-profile-suffix-elision-policy", "selected");
   // Replace linkage names in the debug metadata.
   if (DISubprogram *SP = F.getSubprogram()) {
 if (SP->getRawLinkageName()) {

diff  --git 
a/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll
 
b/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll
index d07440d1b940..dcb49d9b7a51 100644
--- 
a/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll
+++ 
b/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll
@@ -42,8 +42,9 @@ entry:
 ; O2: Running pass: UniqueInternalLinkageNamesPass
 ; O2: Running pass: SampleProfileProbePass
 
-; UNIQUE: define internal i32 @foo.__uniq.{{[0-9]+}}()
+; UNIQUE: define internal i32 @foo.__uniq.{{[0-9]+}}() [[ATTR:#[0-9]+]]
 ; UNIQUE: ret {{.*}} @foo.__uniq.{{[0-9]+}} {{.*}}
+; UNIQUE: attributes [[ATTR]] = {{{.*}} 
"sample-profile-suffix-elision-policy"="selected" {{.*}}}
 
 ; DBG: distinct !DISubprogram(name: "foo", linkageName: 
"foo.__uniq.{{[0-9]+}}", scope: ![[#]]
 ; DBG: !DISubprogram(name: "foo", linkageName: "foo.__uniq.{{[0-9]+}}", scope: 
![[#]]



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


[llvm-branch-commits] [llvm] ddcb0aa - [MIPatternMatch] Add matcher for G_PTR_ADD

2021-01-12 Thread Jessica Paquette via llvm-branch-commits

Author: Jessica Paquette
Date: 2021-01-12T15:21:19-08:00
New Revision: ddcb0aae8b0dd87414105d264d1ee9eac9567476

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

LOG: [MIPatternMatch] Add matcher for G_PTR_ADD

Add a matcher which recognizes G_PTR_ADD and add a test.

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h 
b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
index 427906db6696..ed93dae24c05 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
@@ -220,6 +220,12 @@ m_GAdd(const LHS &L, const RHS &R) {
   return BinaryOp_match(L, R);
 }
 
+template 
+inline BinaryOp_match
+m_GPtrAdd(const LHS &L, const RHS &R) {
+  return BinaryOp_match(L, R);
+}
+
 template 
 inline BinaryOp_match m_GSub(const LHS &L,
 const RHS &R) {

diff  --git a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp 
b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
index f95b19f22e7b..a63a34f91545 100644
--- a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
@@ -47,6 +47,7 @@ TEST_F(AArch64GISelMITest, MatchBinaryOp) {
 return;
   LLT s32 = LLT::scalar(32);
   LLT s64 = LLT::scalar(64);
+  LLT p0 = LLT::pointer(0, 64);
   auto MIBAdd = B.buildAdd(s64, Copies[0], Copies[1]);
   // Test case for no bind.
   bool match =
@@ -145,6 +146,13 @@ TEST_F(AArch64GISelMITest, MatchBinaryOp) {
   EXPECT_TRUE(match);
   EXPECT_EQ(Src0, Copies[0]);
   EXPECT_EQ(Src1, TruncCopy1.getReg(0));
+
+  // Build a G_PTR_ADD and check that we can match it.
+  auto PtrAdd = B.buildPtrAdd(p0, {B.buildUndef(p0)}, Copies[0]);
+  match = mi_match(PtrAdd.getReg(0), *MRI, m_GPtrAdd(m_Reg(Src0), 
m_Reg(Src1)));
+  EXPECT_TRUE(match);
+  EXPECT_EQ(Src0, PtrAdd->getOperand(1).getReg());
+  EXPECT_EQ(Src1, Copies[0]);
 }
 
 TEST_F(AArch64GISelMITest, MatchICmp) {



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


[llvm-branch-commits] [compiler-rt] 8f5ec45 - [Sanitizer][Darwin] Fix test for macOS 11+ point releases

2021-01-12 Thread Julian Lettner via llvm-branch-commits

Author: Julian Lettner
Date: 2021-01-12T15:23:43-08:00
New Revision: 8f5ec4593754a58a4feb835a9d44d59c655bd0d1

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

LOG: [Sanitizer][Darwin] Fix test for macOS 11+ point releases

This test wrongly asserted that the minor version is always 0 when
running on macOS 11 and above.

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp 
b/compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp
index 090947eceb4a..b149567949b5 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_mac_test.cpp
@@ -56,12 +56,18 @@ TEST(SanitizerMac, GetMacosAlignedVersion) {
 #else
 TEST(SanitizerMac, GetMacosAlignedVersion) {
   MacosVersion vers = GetMacosAlignedVersion();
-  u16 kernel_major = GetDarwinKernelVersion().major;
-  bool macos_11 = (kernel_major >= 20);
-  u16 expected_major = macos_11 ? (kernel_major - 9) : 10;
-  u16 expected_minor = macos_11 ? 0 : (kernel_major - 4);
-  EXPECT_EQ(vers.major, expected_major);
-  EXPECT_EQ(vers.minor, expected_minor);
+  std::ostringstream oss;
+  oss << vers.major << '.' << vers.minor;
+  std::string actual = oss.str();
+
+  char buf[100];
+  size_t len = sizeof(buf);
+  int res = sysctlbyname("kern.osproductversion", buf, &len, nullptr, 0);
+  ASSERT_EQ(res, KERN_SUCCESS);
+  std::string expected(buf);
+
+  // Prefix match
+  ASSERT_EQ(expected.compare(0, actual.size(), actual), 0);
 }
 #endif
 



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


[llvm-branch-commits] [llvm] 5856123 - [NFC] Disallow unused prefixes under MC/AMDGPU

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

Author: Mircea Trofin
Date: 2021-01-12T15:24:44-08:00
New Revision: 585612355cdf836b434a5331b1263e961135a1ab

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

LOG: [NFC] Disallow unused prefixes under MC/AMDGPU

This patches remaining tests, and patches lit.local.cfg to block future
such cases (until we flip FileCheck's flag)

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

Added: 


Modified: 
llvm/test/MC/AMDGPU/isa-version-hsa.s
llvm/test/MC/AMDGPU/isa-version-pal.s
llvm/test/MC/AMDGPU/isa-version-unk.s
llvm/test/MC/AMDGPU/lit.local.cfg
llvm/test/MC/AMDGPU/literal16.s
llvm/test/MC/AMDGPU/literals.s
llvm/test/MC/AMDGPU/mtbuf-gfx10.s
llvm/test/MC/AMDGPU/mtbuf.s
llvm/test/MC/AMDGPU/mubuf-gfx9.s
llvm/test/MC/AMDGPU/mubuf.s
llvm/test/MC/AMDGPU/out-of-range-registers.s
llvm/test/MC/AMDGPU/reg-syntax-extra.s
llvm/test/MC/AMDGPU/smem.s
llvm/test/MC/AMDGPU/smrd.s
llvm/test/MC/AMDGPU/sop1-err.s
llvm/test/MC/AMDGPU/sop1.s
llvm/test/MC/AMDGPU/sop2.s
llvm/test/MC/AMDGPU/sopc.s
llvm/test/MC/AMDGPU/sopk-err.s
llvm/test/MC/AMDGPU/sopk.s
llvm/test/MC/AMDGPU/sopp-err.s
llvm/test/MC/AMDGPU/sopp.s
llvm/test/MC/AMDGPU/vintrp-err.s
llvm/test/MC/AMDGPU/vintrp.s
llvm/test/MC/AMDGPU/vop1.s
llvm/test/MC/AMDGPU/vop3-convert.s
llvm/test/MC/AMDGPU/vop3-gfx9.s
llvm/test/MC/AMDGPU/vop_dpp.s
llvm/test/MC/AMDGPU/vop_dpp_expr.s
llvm/test/MC/AMDGPU/vop_sdwa.s
llvm/test/MC/AMDGPU/xdl-insts-err.s

Removed: 




diff  --git a/llvm/test/MC/AMDGPU/isa-version-hsa.s 
b/llvm/test/MC/AMDGPU/isa-version-hsa.s
index 094ab1d4649f..7281487b0517 100644
--- a/llvm/test/MC/AMDGPU/isa-version-hsa.s
+++ b/llvm/test/MC/AMDGPU/isa-version-hsa.s
@@ -1,10 +1,10 @@
-// RUN: not llvm-mc -triple amdgcn-amd-unknown -mcpu=gfx802 %s 2>&1 | 
FileCheck --check-prefix=GCN --check-prefix=OSABI-UNK-ERR %s
-// RUN: not llvm-mc -triple amdgcn-amd-unknown -mcpu=iceland %s 2>&1 | 
FileCheck --check-prefix=GCN --check-prefix=OSABI-UNK-ERR %s
-// RUN: llvm-mc -triple amdgcn-amd-amdhsa --amdhsa-code-object-version=2 
-mcpu=gfx802 %s | FileCheck --check-prefix=GCN --check-prefix=OSABI-HSA %s
-// RUN: llvm-mc -triple amdgcn-amd-amdhsa --amdhsa-code-object-version=2 
-mcpu=iceland %s | FileCheck --check-prefix=GCN --check-prefix=OSABI-HSA %s
-// RUN: not llvm-mc -triple amdgcn-amd-amdhsa --amdhsa-code-object-version=2 
-mcpu=gfx803 %s 2>&1 | FileCheck --check-prefix=GCN 
--check-prefix=OSABI-HSA-ERR %s
-// RUN: not llvm-mc -triple amdgcn-amd-amdpal -mcpu=gfx802 %s 2>&1 | FileCheck 
--check-prefix=GCN --check-prefix=OSABI-PAL-ERR %s
-// RUN: not llvm-mc -triple amdgcn-amd-amdpal -mcpu=iceland %s 2>&1 | 
FileCheck --check-prefix=GCN --check-prefix=OSABI-PAL-ERR %s
+// RUN: not llvm-mc -triple amdgcn-amd-unknown -mcpu=gfx802 %s 2>&1 | 
FileCheck --check-prefix=OSABI-UNK-ERR %s
+// RUN: not llvm-mc -triple amdgcn-amd-unknown -mcpu=iceland %s 2>&1 | 
FileCheck --check-prefix=OSABI-UNK-ERR %s
+// RUN: llvm-mc -triple amdgcn-amd-amdhsa --amdhsa-code-object-version=2 
-mcpu=gfx802 %s | FileCheck --check-prefix=OSABI-HSA %s
+// RUN: llvm-mc -triple amdgcn-amd-amdhsa --amdhsa-code-object-version=2 
-mcpu=iceland %s | FileCheck --check-prefix=OSABI-HSA %s
+// RUN: not llvm-mc -triple amdgcn-amd-amdhsa --amdhsa-code-object-version=2 
-mcpu=gfx803 %s 2>&1 | FileCheck --check-prefix=OSABI-HSA-ERR %s
+// RUN: not llvm-mc -triple amdgcn-amd-amdpal -mcpu=gfx802 %s 2>&1 | FileCheck 
--check-prefix=OSABI-PAL-ERR %s
+// RUN: not llvm-mc -triple amdgcn-amd-amdpal -mcpu=iceland %s 2>&1 | 
FileCheck --check-prefix=OSABI-PAL-ERR %s
 
 // OSABI-HSA: .amd_amdgpu_isa "amdgcn-amd-amdhsa--gfx802"
 // OSABI-UNK-ERR: error: .amd_amdgpu_isa directive does not match triple 
and/or mcpu arguments specified through the command line

diff  --git a/llvm/test/MC/AMDGPU/isa-version-pal.s 
b/llvm/test/MC/AMDGPU/isa-version-pal.s
index 378b94f87f86..98b91ad8bda9 100644
--- a/llvm/test/MC/AMDGPU/isa-version-pal.s
+++ b/llvm/test/MC/AMDGPU/isa-version-pal.s
@@ -1,10 +1,10 @@
-// RUN: not llvm-mc -triple amdgcn-amd-unknown -mcpu=gfx802 %s 2>&1 | 
FileCheck --check-prefix=GCN --check-prefix=OSABI-UNK-ERR %s
-// RUN: not llvm-mc -triple amdgcn-amd-unknown -mcpu=iceland %s 2>&1 | 
FileCheck --check-prefix=GCN --check-prefix=OSABI-UNK-ERR %s
-// RUN: not llvm-mc -triple amdgcn-amd-amdhsa --amdhsa-code-object-version=2 
-mcpu=gfx802 %s 2>&1 | FileCheck --check-prefix=GCN 
--check-prefix=OSABI-HSA-ERR %s
-// RUN: not llvm-mc -triple amdgcn-amd-amdhsa --amdhsa-code-object-version=2 
-mcpu=iceland %s 2>&1 | FileCheck --check-prefix=GCN 
--check-prefix=OSABI-HSA-ERR %s
-// RUN: llvm-mc -triple amdgcn-amd-amdpal -mcpu=gfx802 %s | FileCheck 
--check-prefix=GCN --check-prefix=OSA

[llvm-branch-commits] [mlir] 0d88d7d - Delete unused function (was breaking the -Werror build)

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

Author: David Blaikie
Date: 2021-01-12T15:29:44-08:00
New Revision: 0d88d7d82bc44b211a8187650a06c6cd3492186a

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

LOG: Delete unused function (was breaking the -Werror build)

Added: 


Modified: 
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
index 8f02f3d83cf1..0deb4e3f59ae 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
@@ -350,32 +350,6 @@ bool mlir::linalg::isFusableInto(const 
LinalgDependenceGraph &graph,
   return true;
 }
 
-static bool isSameSubView(Value a, Value b) {
-  if (a == b)
-return true;
-  auto sva = a.getDefiningOp();
-  auto svb = b.getDefiningOp();
-  if (!sva || !svb)
-return false;
-  if (!isSameSubView(sva.getViewSource(), svb.getViewSource()))
-return false;
-  if (sva.getType() != svb.getType())
-return false;
-  if (sva.getNumOperands() != svb.getNumOperands())
-return false;
-  if (sva.static_offsets() != svb.static_offsets())
-return false;
-  if (sva.static_sizes() != svb.static_sizes())
-return false;
-  if (sva.static_strides() != svb.static_strides())
-return false;
-  /// Skip the "source" operand.
-  for (unsigned idx = 1, e = sva.getNumOperands(); idx != e; ++idx)
-if (sva.getOperand(idx) != svb.getOperand(idx))
-  return false;
-  return true;
-}
-
 static Optional
 findFusableProducer(OpOperand &consumerOpOperand,
 const LinalgDependenceGraph &dependenceGraph) {



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


[llvm-branch-commits] [libc] 04edcc0 - [libc] add isascii and toascii implementations

2021-01-12 Thread Michael Jones via llvm-branch-commits

Author: Michael Jones
Date: 2021-01-12T23:41:20Z
New Revision: 04edcc02638bc70772baa50a74e582bb8e029872

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

LOG: [libc] add isascii and toascii implementations

adding both at once since these are trivial functions.

Reviewed By: sivachandra

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

Added: 
libc/src/ctype/isascii.cpp
libc/src/ctype/isascii.h
libc/src/ctype/toascii.cpp
libc/src/ctype/toascii.h
libc/test/src/ctype/isascii_test.cpp
libc/test/src/ctype/toascii_test.cpp

Modified: 
libc/config/linux/aarch64/entrypoints.txt
libc/config/linux/x86_64/entrypoints.txt
libc/spec/gnu_ext.td
libc/spec/posix.td
libc/src/ctype/CMakeLists.txt
libc/test/src/ctype/CMakeLists.txt

Removed: 




diff  --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index 0db8c4b39caa..2b70cafd6fbf 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -2,6 +2,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 # ctype.h entrypoints
 libc.src.ctype.isalnum
 libc.src.ctype.isalpha
+libc.src.ctype.isascii
 libc.src.ctype.isblank
 libc.src.ctype.iscntrl
 libc.src.ctype.isdigit
@@ -12,6 +13,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 libc.src.ctype.isspace
 libc.src.ctype.isupper
 libc.src.ctype.isxdigit
+libc.src.ctype.toascii
 libc.src.ctype.tolower
 libc.src.ctype.toupper
 

diff  --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index a80a8b4f105b..7c5367a9d528 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -5,6 +5,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 # ctype.h entrypoints
 libc.src.ctype.isalnum
 libc.src.ctype.isalpha
+libc.src.ctype.isascii
 libc.src.ctype.isblank
 libc.src.ctype.iscntrl
 libc.src.ctype.isdigit
@@ -15,6 +16,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 libc.src.ctype.isspace
 libc.src.ctype.isupper
 libc.src.ctype.isxdigit
+libc.src.ctype.toascii
 libc.src.ctype.tolower
 libc.src.ctype.toupper
 

diff  --git a/libc/spec/gnu_ext.td b/libc/spec/gnu_ext.td
index d85c562d9256..0b0b8ca38c40 100644
--- a/libc/spec/gnu_ext.td
+++ b/libc/spec/gnu_ext.td
@@ -1,4 +1,18 @@
 def GnuExtensions : StandardSpec<"GNUExtensions"> {
+  HeaderSpec CType = HeaderSpec<
+"ctype.h",
+[], // Macros
+[], // Types
+[], // Enumerations
+[
+FunctionSpec<
+"toascii",
+RetValSpec,
+[ArgSpec]
+>,
+]
+  >;
+
   HeaderSpec Math = HeaderSpec<
   "math.h",
   [], // Macros
@@ -27,7 +41,10 @@ def GnuExtensions : StandardSpec<"GNUExtensions"> {
   ]
   >;
 
+
   let Headers = [
-Math, String,
+CType,
+Math, 
+String,
   ];
 }

diff  --git a/libc/spec/posix.td b/libc/spec/posix.td
index 1bf64f082c62..32f6ef5844b1 100644
--- a/libc/spec/posix.td
+++ b/libc/spec/posix.td
@@ -235,7 +235,22 @@ def POSIX : StandardSpec<"POSIX"> {
 ]
   >;
 
+  HeaderSpec CType = HeaderSpec<
+"ctype.h",
+[], // Macros
+[], // Types
+[], // Enumerations
+[
+FunctionSpec<
+"isascii",
+RetValSpec,
+[ArgSpec]
+>,
+]
+  >;
+
   let Headers = [
+CType,
 Errno,
 SysMMan,
 Signal,

diff  --git a/libc/src/ctype/CMakeLists.txt b/libc/src/ctype/CMakeLists.txt
index da8c4403d959..dd7ee24520f8 100644
--- a/libc/src/ctype/CMakeLists.txt
+++ b/libc/src/ctype/CMakeLists.txt
@@ -24,6 +24,14 @@ add_entrypoint_object(
 .ctype_utils
 )
 
+add_entrypoint_object(
+  isascii
+  SRCS
+isascii.cpp
+  HDRS
+isascii.h
+)
+
 add_entrypoint_object(
   isblank
   SRCS
@@ -126,6 +134,14 @@ add_entrypoint_object(
 .ctype_utils
 )
 
+add_entrypoint_object(
+  toascii
+  SRCS
+toascii.cpp
+  HDRS
+toascii.h
+)
+
 add_entrypoint_object(
   toupper
   SRCS

diff  --git a/libc/src/ctype/isascii.cpp b/libc/src/ctype/isascii.cpp
new file mode 100644
index ..c12915ecd6ee
--- /dev/null
+++ b/libc/src/ctype/isascii.cpp
@@ -0,0 +1,17 @@
+//===-- Implementation of 
isascii--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "src/ctype/isascii.h"
+
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(int, isascii, (int c)) { return (c & (~0x7f)) == 0; }
+
+} // namespace __llvm_libc

d

[llvm-branch-commits] [libc] 0c8466c - [libc][NFC] Use more specific comparison macros in LdExpTest.h.

2021-01-12 Thread Siva Chandra Reddy via llvm-branch-commits

Author: Siva Chandra Reddy
Date: 2021-01-12T16:13:10-08:00
New Revision: 0c8466c0015eb8e4061b177e125e588b2138cc8a

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

LOG: [libc][NFC] Use more specific comparison macros in LdExpTest.h.

Added: 


Modified: 
libc/test/src/math/LdExpTest.h

Removed: 




diff  --git a/libc/test/src/math/LdExpTest.h b/libc/test/src/math/LdExpTest.h
index b4be06bdaad7..0a910bddb371 100644
--- a/libc/test/src/math/LdExpTest.h
+++ b/libc/test/src/math/LdExpTest.h
@@ -131,11 +131,11 @@ class LdExpTestTemplate : public 
__llvm_libc::testing::Test {
 // The result should not be infinity.
 x = NormalFloat(-FPBits::exponentBias + 1, NormalFloat::one >> 10, 0);
 exp = FPBits::maxExponent + 5;
-ASSERT_EQ(isinf(func(x, exp)), 0);
+ASSERT_FALSE(FPBits(func(x, exp)).isInf());
 // But if the exp is large enough to oversome than the normalization shift,
 // then it should result in infinity.
 exp = FPBits::maxExponent + 15;
-ASSERT_NE(isinf(func(x, exp)), 0);
+ASSERT_FP_EQ(func(x, exp), inf);
   }
 };
 



___
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] 76643c4 - [LangRef] State that a nocapture pointer cannot be returned

2021-01-12 Thread Juneyoung Lee via llvm-branch-commits

Author: Juneyoung Lee
Date: 2021-01-13T09:30:54+09:00
New Revision: 76643c48cdddfa220680f1ab4a83829bd83faa7a

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

LOG: [LangRef] State that a nocapture pointer cannot be returned

This is a small patch stating that a nocapture pointer cannot be returned.

Discussed in D93189.

Reviewed By: jdoerfert

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

Added: 


Modified: 
llvm/docs/LangRef.rst

Removed: 




diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index ab5287014683..854c72191da2 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1193,7 +1193,8 @@ Currently, only the following parameter attributes are 
defined:
 
 ``nocapture``
 This indicates that the callee does not make any copies of the
-pointer that outlive the callee itself. This is not a valid
+pointer that outlive the callee itself in any form such as a pointer stored
+in the memory or as a return value. This is not a valid
 attribute for return values.  Addresses used in volatile operations
 are considered to be captured.
 



___
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] 25eb7b0 - [DAGCombiner] Fold BRCOND(FREEZE(COND)) to BRCOND(COND)

2021-01-12 Thread Juneyoung Lee via llvm-branch-commits

Author: Juneyoung Lee
Date: 2021-01-13T09:36:52+09:00
New Revision: 25eb7b08ba77a0b7c9c938490444bb8b5121233c

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

LOG: [DAGCombiner] Fold BRCOND(FREEZE(COND)) to BRCOND(COND)

This patch resolves the suboptimal codegen described in http://llvm.org/pr47873 
.
When CodeGenPrepare lowers select into a conditional branch, a freeze 
instruction is inserted.
It is then translated to `BRCOND(FREEZE(SETCC))` in SelDag.
The `FREEZE` in the middle of `SETCC` and `BRCOND` was causing a suboptimal 
code generation however.
This patch adds `BRCOND(FREEZE(cond))` -> `BRCOND(cond)` fold to DAGCombiner to 
remove the `FREEZE`.

To make this optimization sound, `BRCOND(UNDEF)` simply should 
nondeterministically jump to the branch or not, rather than raising UB.
It wasn't clear what happens when the condition was undef according to the 
comments in ISDOpcodes.h, however.
I updated the comments of `BRCOND` to make it explicit (as well as `BR_CC`, 
which is also a conditional branch instruction).

Note that it diverges from the semantics of `br` instruction in IR, which is 
explicitly UB.
Since the UB semantics was necessary to explain optimizations that use 
branching conditions, and SelDag doesn't seem to have such optimization, I 
think this divergence is okay.

Reviewed By: spatel

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/ISDOpcodes.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/select-prof-codegen.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h 
b/llvm/include/llvm/CodeGen/ISDOpcodes.h
index 5b35266dcbaa..5358b15437cc 100644
--- a/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -890,13 +890,18 @@ enum NodeType {
   /// BRCOND - Conditional branch.  The first operand is the chain, the
   /// second is the condition, the third is the block to branch to if the
   /// condition is true.  If the type of the condition is not i1, then the
-  /// high bits must conform to getBooleanContents.
+  /// high bits must conform to getBooleanContents. If the condition is undef,
+  /// it nondeterministically jumps to the block.
+  /// TODO: Its semantics w.r.t undef requires further discussion; we need to
+  /// make it sure that it is consistent with optimizations in MIR & the
+  /// meaning of IMPLICIT_DEF. See https://reviews.llvm.org/D92015
   BRCOND,
 
   /// BR_CC - Conditional branch.  The behavior is like that of SELECT_CC, in
   /// that the condition is represented as condition code, and two nodes to
   /// compare, rather than as a combined SetCC node.  The operands in order
-  /// are chain, cc, lhs, rhs, block to branch to if condition is true.
+  /// are chain, cc, lhs, rhs, block to branch to if condition is true. If
+  /// condition is undef, it nondeterministically jumps to the block.
   BR_CC,
 
   /// INLINEASM - Represents an inline asm block.  This node always has two

diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 9f55bd03fbe4..5d9bb4e4a98b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -14548,6 +14548,13 @@ SDValue DAGCombiner::visitBRCOND(SDNode *N) {
   SDValue N1 = N->getOperand(1);
   SDValue N2 = N->getOperand(2);
 
+  // BRCOND(FREEZE(cond)) is equivalent to BRCOND(cond) (both are
+  // nondeterministic jumps).
+  if (N1->getOpcode() == ISD::FREEZE && N1.hasOneUse()) {
+return DAG.getNode(ISD::BRCOND, SDLoc(N), MVT::Other, Chain,
+   N1->getOperand(0), N2);
+  }
+
   // If N is a constant we could fold this into a fallthrough or unconditional
   // branch. However that doesn't happen very often in normal code, because
   // Instcombine/SimplifyCFG should have handled the available opportunities.

diff  --git a/llvm/test/CodeGen/X86/select-prof-codegen.ll 
b/llvm/test/CodeGen/X86/select-prof-codegen.ll
index 22f7d728847b..5ae09afd239e 100644
--- a/llvm/test/CodeGen/X86/select-prof-codegen.ll
+++ b/llvm/test/CodeGen/X86/select-prof-codegen.ll
@@ -1,15 +1,13 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
 
-; TODO: Compiling the select should not create 'seta - testb $1 - jump' 
sequence.
+; Compiling the select should not create 'seta - testb $1 - jump' sequence.
 define i32 @f(i32 %x, i32 %y) {
 ; CHECK-LABEL: f:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:movl %edi, %eax
 ; CHECK-NEXT:cmpl %esi, %edi
-; CHECK-NEXT:seta %cl
-; CHECK-NEXT:testb $1, %cl
-; CHECK-NEXT:jne .LBB0_2
+; CHECK-NEXT:ja .LBB0_2
 

[llvm-branch-commits] [compiler-rt] 82655c1 - [MSan] Tweak CopyOrigin

2021-01-12 Thread Jianzhou Zhao via llvm-branch-commits

Author: Jianzhou Zhao
Date: 2021-01-13T01:22:05Z
New Revision: 82655c151450e0103a3aa60725639da607f9220c

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

LOG: [MSan] Tweak CopyOrigin

There could be some mis-alignments when copying origins not aligned.

I believe inaligned memcpy is rare so the cases do not matter too much
in practice.

1) About the change at line 50

Let dst be (void*)5,
then d=5, beg=4
so we need to write 3 (4+4-5) bytes from 5 to 7.

2) About the change around line 77.

Let dst be (void*)5,
because of lines 50-55, the bytes from 5-7 were already writen.
So the aligned copy is from 8.

Reviewed-by: eugenis
Differential Revision: https://reviews.llvm.org/D94552

Added: 


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

Removed: 




diff  --git a/compiler-rt/lib/msan/msan_poisoning.cpp 
b/compiler-rt/lib/msan/msan_poisoning.cpp
index ef3c74e0a35a..8f58432d528a 100644
--- a/compiler-rt/lib/msan/msan_poisoning.cpp
+++ b/compiler-rt/lib/msan/msan_poisoning.cpp
@@ -47,7 +47,7 @@ void CopyOrigin(const void *dst, const void *src, uptr size,
   uptr beg = d & ~3UL;
   // Copy left unaligned origin if that memory is poisoned.
   if (beg < d) {
-u32 o = GetOriginIfPoisoned((uptr)src, d - beg);
+u32 o = GetOriginIfPoisoned((uptr)src, beg + 4 - d);
 if (o) {
   if (__msan_get_track_origins() > 1) o = ChainOrigin(o, stack);
   *(u32 *)MEM_TO_ORIGIN(beg) = o;
@@ -71,12 +71,13 @@ void CopyOrigin(const void *dst, const void *src, uptr size,
   if (beg < end) {
 // Align src up.
 uptr s = ((uptr)src + 3) & ~3UL;
+uptr aligned_beg = ((uptr)dst + 3) & ~3UL;
 // FIXME: factor out to msan_copy_origin_aligned
 if (__msan_get_track_origins() > 1) {
   u32 *src = (u32 *)MEM_TO_ORIGIN(s);
   u32 *src_s = (u32 *)MEM_TO_SHADOW(s);
-  u32 *src_end = (u32 *)MEM_TO_ORIGIN(s + (end - beg));
-  u32 *dst = (u32 *)MEM_TO_ORIGIN(beg);
+  u32 *src_end = (u32 *)MEM_TO_ORIGIN(s + (end - aligned_beg));
+  u32 *dst = (u32 *)MEM_TO_ORIGIN(aligned_beg);
   u32 src_o = 0;
   u32 dst_o = 0;
   for (; src < src_end; ++src, ++src_s, ++dst) {
@@ -88,8 +89,9 @@ void CopyOrigin(const void *dst, const void *src, uptr size,
 *dst = dst_o;
   }
 } else {
-  REAL(memcpy)((void *)MEM_TO_ORIGIN(beg), (void *)MEM_TO_ORIGIN(s),
-   end - beg);
+  REAL(memcpy)
+  ((void *)MEM_TO_ORIGIN(aligned_beg), (void *)MEM_TO_ORIGIN(s),
+   end - aligned_beg);
 }
   }
 }



___
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] 25b3921 - [gn build] (manually) port 79f99ba65d96

2021-01-12 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2021-01-12T20:30:56-05:00
New Revision: 25b3921f2fcd8fb3241c2f79e488f25a6374b99f

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

LOG: [gn build] (manually) port 79f99ba65d96

Added: 


Modified: 
llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn 
b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index 64253c6e72df..f1f1f37686e2 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -209,6 +209,7 @@ copy("include") {
 "support/musl/xlocale.h",
 "support/newlib/xlocale.h",
 "support/nuttx/xlocale.h",
+"support/openbsd/xlocale.h",
 "support/solaris/floatingpoint.h",
 "support/solaris/wchar.h",
 "support/solaris/xlocale.h",



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


[llvm-branch-commits] [mlir] c0f3ea8 - [mlir][Python] Add checking process before create an AffineMap from a permutation.

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

Author: zhanghb97
Date: 2021-01-13T09:32:32+08:00
New Revision: c0f3ea8a08ca9a9ec473f6e9072ccf30dad5def8

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

LOG: [mlir][Python] Add checking process before create an AffineMap from a 
permutation.

An invalid permutation will trigger a C++ assertion when attempting to create 
an AffineMap from the permutation.
This patch adds an `isPermutation` function to check the given permutation 
before creating the AffineMap.

Reviewed By: mehdi_amini

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

Added: 


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

Removed: 




diff  --git a/mlir/lib/Bindings/Python/IRModules.cpp 
b/mlir/lib/Bindings/Python/IRModules.cpp
index 218099bedc6f..493ea5c1e47a 100644
--- a/mlir/lib/Bindings/Python/IRModules.cpp
+++ b/mlir/lib/Bindings/Python/IRModules.cpp
@@ -153,6 +153,21 @@ static MlirStringRef toMlirStringRef(const std::string &s) 
{
   return mlirStringRefCreate(s.data(), s.size());
 }
 
+template 
+static bool isPermutation(std::vector permutation) {
+  llvm::SmallVector seen(permutation.size(), false);
+  for (auto val : permutation) {
+if (val < permutation.size()) {
+  if (seen[val])
+return false;
+  seen[val] = true;
+  continue;
+}
+return false;
+  }
+  return true;
+}
+
 
//--
 // Collections.
 
//--
@@ -3914,6 +3929,9 @@ void mlir::python::populateIRSubmodule(py::module &m) {
   "get_permutation",
   [](std::vector permutation,
  DefaultingPyMlirContext context) {
+if (!isPermutation(permutation))
+  throw py::cast_error("Invalid permutation when attempting to "
+   "create an AffineMap");
 MlirAffineMap affineMap = mlirAffineMapPermutationGet(
 context->get(), permutation.size(), permutation.data());
 return PyAffineMap(context->getRef(), affineMap);

diff  --git a/mlir/test/Bindings/Python/ir_affine_map.py 
b/mlir/test/Bindings/Python/ir_affine_map.py
index fe37eb971555..0c99722dbf04 100644
--- a/mlir/test/Bindings/Python/ir_affine_map.py
+++ b/mlir/test/Bindings/Python/ir_affine_map.py
@@ -73,6 +73,12 @@ def testAffineMapGet():
   # CHECK: Invalid expression (None?) when attempting to create an 
AffineMap
   print(e)
 
+try:
+  AffineMap.get_permutation([1, 0, 1])
+except RuntimeError as e:
+  # CHECK: Invalid permutation when attempting to create an AffineMap
+  print(e)
+
 try:
   map3.get_submap([42])
 except ValueError as e:



___
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] 055644c - [X86][AMX] Prohibit pointer cast on load.

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

Author: Luo, Yuanke
Date: 2021-01-13T09:39:19+08:00
New Revision: 055644cc459eb204613ac788b73c51d5dab2fcbb

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

LOG: [X86][AMX] Prohibit pointer cast on load.

The load/store instruction will be transformed to amx intrinsics in the
pass of AMX type lowering. Prohibiting the pointer cast make that pass
happy.

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

Added: 
llvm/test/Transforms/InstCombine/X86/x86-amx-load-store.ll

Modified: 
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 910119af1f12..fb4170b511c1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -589,7 +589,16 @@ static Instruction 
*combineLoadToOperationType(InstCombinerImpl &IC,
   // Fold away bit casts of the loaded value by loading the desired type.
   // Note that we should not do this for pointer<->integer casts,
   // because that would result in type punning.
-  if (LI.hasOneUse())
+  if (LI.hasOneUse()) {
+// Don't transform when the type is x86_amx, it makes the pass that lower
+// x86_amx type happy.
+if (auto *BC = dyn_cast(LI.user_back())) {
+  assert(!LI.getType()->isX86_AMXTy() &&
+ "load from x86_amx* should not happen!");
+  if (BC->getType()->isX86_AMXTy())
+return nullptr;
+}
+
 if (auto* CI = dyn_cast(LI.user_back()))
   if (CI->isNoopCast(DL) && LI.getType()->isPtrOrPtrVectorTy() ==
 CI->getDestTy()->isPtrOrPtrVectorTy())
@@ -599,6 +608,7 @@ static Instruction 
*combineLoadToOperationType(InstCombinerImpl &IC,
   IC.eraseInstFromFunction(*CI);
   return &LI;
 }
+  }
 
   // FIXME: We should also canonicalize loads of vectors when their elements 
are
   // cast to other types.
@@ -1114,10 +1124,12 @@ static bool combineStoreToValueType(InstCombinerImpl 
&IC, StoreInst &SI) {
 
   // Fold away bit casts of the stored value by storing the original type.
   if (auto *BC = dyn_cast(V)) {
+assert(!BC->getType()->isX86_AMXTy() &&
+   "store to x86_amx* should not happen!");
 V = BC->getOperand(0);
-// Don't transform when the type is x86_amx, it make the pass that lower
+// Don't transform when the type is x86_amx, it makes the pass that lower
 // x86_amx type happy.
-if (BC->getType()->isX86_AMXTy() || V->getType()->isX86_AMXTy())
+if (V->getType()->isX86_AMXTy())
   return false;
 if (!SI.isAtomic() || isSupportedAtomicType(V->getType())) {
   combineStoreToNewValue(IC, SI, V);

diff  --git a/llvm/test/Transforms/InstCombine/X86/x86-amx-load-store.ll 
b/llvm/test/Transforms/InstCombine/X86/x86-amx-load-store.ll
new file mode 100644
index ..a51f7551911e
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/X86/x86-amx-load-store.ll
@@ -0,0 +1,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -instcombine -S < %s | FileCheck %s
+; RUN: opt -passes=instcombine -S < %s | FileCheck %s
+
+; Prohibit poiter cast for amx.
+define dso_local void @test_amx_load_store(<256 x i32>* %src, i8* %dst) {
+; CHECK-LABEL: @test_amx_load_store(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[VEC:%.*]] = load <256 x i32>, <256 x i32>* [[SRC:%.*]], 
align 64
+; CHECK-NEXT:[[BC:%.*]] = bitcast <256 x i32> [[VEC]] to x86_amx
+; CHECK-NEXT:tail call void @llvm.x86.tilestored64.internal(i16 16, i16 
16, i8* [[DST:%.*]], i64 64, x86_amx [[BC]])
+; CHECK-NEXT:ret void
+;
+entry:
+  %vec = load <256 x i32>, <256 x i32>* %src, align 64
+  %bc = bitcast <256 x i32> %vec to x86_amx
+  tail call void @llvm.x86.tilestored64.internal(i16 16, i16 16, i8* %dst, i64 
64, x86_amx %bc)
+  ret void
+}
+
+; Prohibit poiter cast for amx.
+define dso_local void @test_amx_load_store2(<256 x i32>* %dst, i8* %src) {
+; CHECK-LABEL: @test_amx_load_store2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[AMX:%.*]] = tail call x86_amx 
@llvm.x86.tileloadd64.internal(i16 16, i16 16, i8* [[SRC:%.*]], i64 64)
+; CHECK-NEXT:[[BC:%.*]] = bitcast x86_amx [[AMX]] to <256 x i32>
+; CHECK-NEXT:store <256 x i32> [[BC]], <256 x i32>* [[DST:%.*]], align 1024
+; CHECK-NEXT:ret void
+;
+entry:
+  %amx = tail call x86_amx @llvm.x86.tileloadd64.internal(i16 16, i16 16, i8* 
%src, i64 64)
+  %bc = bitcast x86_amx %amx to <256 x i32>
+  store <256 x i32> %bc, <256 x i32>* %dst
+  ret void
+}
+
+declare x86_amx @llvm.x86.tileloadd64.internal(i16, i16, i8*, i64)
+declare void @llvm.x86.tilestored64.internal(i16, i16, i8*,

[llvm-branch-commits] [llvm] 5c7dcd7 - [Coroutine] Update promise object's final layout index

2021-01-12 Thread Yuanfang Chen via llvm-branch-commits

Author: Yuanfang Chen
Date: 2021-01-12T17:44:02-08:00
New Revision: 5c7dcd7aead7b33ba065b98ab3573278feb42228

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

LOG: [Coroutine] Update promise object's final layout index

promise is a header field but it is not guaranteed that it would be the third
field of the frame due to `performOptimizedStructLayout`.

Reviewed By: lxfind

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

Added: 
llvm/test/Transforms/Coroutines/coro-spill-promise.ll

Modified: 
llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp 
b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 9c3c10660bd0..4823eea4154f 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -758,6 +758,15 @@ static StructType *buildFrameType(Function &F, coro::Shape 
&Shape,
   // Because multiple allocas may own the same field slot,
   // we add allocas to field here.
   B.addFieldForAllocas(F, FrameData, Shape);
+  // Add PromiseAlloca to Allocas list so that
+  // 1. updateLayoutIndex could update its index after
+  // `performOptimizedStructLayout`
+  // 2. it is processed in insertSpills.
+  if (Shape.ABI == coro::ABI::Switch && PromiseAlloca)
+// We assume that the promise alloca won't be modified before
+// CoroBegin and no alias will be create before CoroBegin.
+FrameData.Allocas.emplace_back(
+PromiseAlloca, DenseMap>{}, 
false);
   // Create an entry for every spilled value.
   for (auto &S : FrameData.Spills) {
 FieldIDType Id = B.addField(S.first->getType(), None);
@@ -2288,13 +2297,6 @@ void coro::buildCoroutineFrame(Function &F, Shape 
&Shape) {
   Shape.ABI == coro::ABI::Async)
 sinkSpillUsesAfterCoroBegin(F, FrameData, Shape.CoroBegin);
   Shape.FrameTy = buildFrameType(F, Shape, FrameData);
-  // Add PromiseAlloca to Allocas list so that it is processed in insertSpills.
-  if (Shape.ABI == coro::ABI::Switch && Shape.SwitchLowering.PromiseAlloca)
-// We assume that the promise alloca won't be modified before
-// CoroBegin and no alias will be create before CoroBegin.
-FrameData.Allocas.emplace_back(
-Shape.SwitchLowering.PromiseAlloca,
-DenseMap>{}, false);
   Shape.FramePtr = insertSpills(FrameData, Shape);
   lowerLocalAllocas(LocalAllocas, DeadInstructions);
 

diff  --git a/llvm/test/Transforms/Coroutines/coro-spill-promise.ll 
b/llvm/test/Transforms/Coroutines/coro-spill-promise.ll
new file mode 100644
index ..6a7cf47c55d8
--- /dev/null
+++ b/llvm/test/Transforms/Coroutines/coro-spill-promise.ll
@@ -0,0 +1,57 @@
+; Check that promise object is reloaded from the correct index of the coro 
frame.
+; RUN: opt < %s -coro-split -S | FileCheck %s
+; RUN: opt < %s -passes=coro-split -S | FileCheck %s
+
+%"class.task::promise_type" = type { [64 x i8] }
+
+declare void @consume(i32*)
+declare void @consume2(%"class.task::promise_type"*)
+
+define i8* @f() "coroutine.presplit"="1" {
+entry:
+  %data = alloca i32, align 4
+  %__promise = alloca %"class.task::promise_type", align 64
+  %pv = bitcast %"class.task::promise_type"* %__promise to i8*
+  %id = call token @llvm.coro.id(i32 0, i8* %pv, i8* null, i8* null)
+  %size = call i32 @llvm.coro.size.i32()
+  %alloc = call i8* @malloc(i32 %size)
+  %hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
+  call void @consume(i32* %data)
+  %0 = call i8 @llvm.coro.suspend(token none, i1 false)
+  switch i8 %0, label %suspend [i8 0, label %resume
+i8 1, label %cleanup]
+resume:
+  call void @consume(i32* %data)
+  call void @consume2(%"class.task::promise_type"* %__promise)
+  br label %cleanup
+
+cleanup:
+  %mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
+  call void @free(i8* %mem)
+  br label %suspend
+suspend:
+  call i1 @llvm.coro.end(i8* %hdl, i1 0)
+  ret i8* %hdl
+}
+
+; CHECK-LABEL: %f.Frame = type { void (%f.Frame*)*, void (%f.Frame*)*, i32, 
i1, [43 x i8], %"class.task::promise_type" }
+
+; CHECK-LABEL: @f.resume(
+; CHECK: %[[DATA:.+]] = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, 
i32 0, i32 5
+; CHECK: call void @consume2(%"class.task::promise_type"* %[[DATA]])
+; CHECK: ret void
+
+declare i8* @llvm.coro.free(token, i8*)
+declare i32 @llvm.coro.size.i32()
+declare i8  @llvm.coro.suspend(token, i1)
+declare void @llvm.coro.resume(i8*)
+declare void @llvm.coro.destroy(i8*)
+
+declare token @llvm.coro.id(i32, i8*, i8*, i8*)
+declare i1 @llvm.coro.alloc(token)
+declare i8* @llvm.coro.begin(token, i8*)
+declare i1 @llvm.coro.end(i8*, i1)
+
+declare noalias i8* @malloc(i32)
+declare double @print(double)
+declare void @free(i8*)



__

[llvm-branch-commits] [lld] 6529d7c - [PDB] Defer relocating .debug$S until commit time and parallelize it

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

Author: Reid Kleckner
Date: 2021-01-12T17:46:29-08:00
New Revision: 6529d7c5a45b1b9588e512013b02f891d71bc134

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

LOG: [PDB] Defer relocating .debug$S until commit time and parallelize it

This is a pretty classic optimization. Instead of processing symbol
records and copying them to temporary storage, do a first pass to
measure how large the module symbol stream will be, and then copy the
data into place in the PDB file. This requires defering relocation until
much later, which accounts for most of the complexity in this patch.

This patch avoids copying the contents of all live .debug$S sections
into heap memory, which is worth about 20% of private memory usage when
making PDBs. However, this is not an unmitigated performance win,
because it can be faster to read dense, temporary, heap data than it is
to iterate symbol records in object file backed memory a second time.

Results on release chrome.dll:
peak mem: 5164.89MB -> 4072.19MB (-1,092.7MB, -21.2%)
wall-j1:  0m30.844s -> 0m32.094s (slightly slower)
wall-j3:  0m20.968s -> 0m20.312s (slightly faster)
wall-j8:  0m19.062s -> 0m17.672s (meaningfully faster)

I gathered similar numbers for a debug, component build of content.dll
in Chrome, and the performance impact of this change was in the noise.
The memory usage reduction was visible and similar.

Because of the new parallelism in the PDB commit phase, more cores makes
the new approach faster. I'm assuming that most C++ developer machines
these days are at least quad core, so I think this is a win.

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

Added: 


Modified: 
lld/COFF/Chunks.cpp
lld/COFF/Chunks.h
lld/COFF/PDB.cpp
llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
llvm/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp
llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp

Removed: 




diff  --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index e04ceed505c2..f2cdc24b7bf1 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -369,47 +369,88 @@ void SectionChunk::writeTo(uint8_t *buf) const {
   continue;
 }
 
-uint8_t *off = buf + rel.VirtualAddress;
+applyRelocation(buf + rel.VirtualAddress, rel);
+  }
+}
 
-auto *sym =
-dyn_cast_or_null(file->getSymbol(rel.SymbolTableIndex));
+void SectionChunk::applyRelocation(uint8_t *off,
+   const coff_relocation &rel) const {
+  auto *sym = dyn_cast_or_null(file->getSymbol(rel.SymbolTableIndex));
 
-// Get the output section of the symbol for this relocation.  The output
-// section is needed to compute SECREL and SECTION relocations used in 
debug
-// info.
-Chunk *c = sym ? sym->getChunk() : nullptr;
-OutputSection *os = c ? c->getOutputSection() : nullptr;
-
-// Skip the relocation if it refers to a discarded section, and diagnose it
-// as an error if appropriate. If a symbol was discarded early, it may be
-// null. If it was discarded late, the output section will be null, unless
-// it was an absolute or synthetic symbol.
-if (!sym ||
-(!os && !isa(sym) && !isa(sym))) {
-  maybeReportRelocationToDiscarded(this, sym, rel);
-  continue;
-}
+  // Get the output section of the symbol for this relocation.  The output
+  // section is needed to compute SECREL and SECTION relocations used in debug
+  // info.
+  Chunk *c = sym ? sym->getChunk() : nullptr;
+  OutputSection *os = c ? c->getOutputSection() : nullptr;
 
-uint64_t s = sym->getRVA();
+  // Skip the relocation if it refers to a discarded section, and diagnose it
+  // as an error if appropriate. If a symbol was discarded early, it may be
+  // null. If it was discarded late, the output section will be null, unless
+  // it was an absolute or synthetic symbol.
+  if (!sym ||
+  (!os && !isa(sym) && !isa(sym))) {
+maybeReportRelocationToDiscarded(this, sym, rel);
+return;
+  }
 
-// Compute the RVA of the relocation for relative relocations.
-uint64_t p = rva + rel.VirtualAddress;
-switch (config->machine) {
-case AMD64:
-  applyRelX64(off, rel.Type, os, s, p);
-  break;
-case I386:
-  applyRelX86(off, rel.Type, os, s, p);
-  break;
-case ARMNT:
-  applyRelARM(off, rel.Type, os, s, p);
-  break;
-case ARM64:
-  applyRelARM64(off, rel.Type, os, s, p);
+  uint64_t s = sym->getRVA();
+
+  // Compute the RVA of the relocation for relative relocations.
+  uint64_t p = rva + rel.VirtualAddress;
+  switch (config->machine) {
+  case AMD64:
+applyRelX64(off, rel.Type, os, s, p);
+break;
+  case I386:
+applyRelX86(off, rel.Type, os, s, p);
+break;
+  case ARMNT:
+applyR

[llvm-branch-commits] [openmp] 6f0f022 - [OpenMP] Update allocator trait key/value definitions

2021-01-12 Thread Hansang Bae via llvm-branch-commits

Author: Hansang Bae
Date: 2021-01-12T20:09:45-06:00
New Revision: 6f0f0220380f83e8f3bf9832ffa795e9965fda2d

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

LOG: [OpenMP] Update allocator trait key/value definitions

Use new definitions introduced in 5.1 specification.

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

Added: 


Modified: 
openmp/runtime/src/include/omp.h.var
openmp/runtime/src/include/omp_lib.f90.var
openmp/runtime/src/include/omp_lib.h.var
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_alloc.cpp

Removed: 




diff  --git a/openmp/runtime/src/include/omp.h.var 
b/openmp/runtime/src/include/omp.h.var
index 8821377e29d8..4d055f905bcb 100644
--- a/openmp/runtime/src/include/omp.h.var
+++ b/openmp/runtime/src/include/omp.h.var
@@ -307,7 +307,7 @@
 typedef uintptr_t omp_uintptr_t;
 
 typedef enum {
-omp_atk_threadmodel = 1,
+omp_atk_sync_hint = 1,
 omp_atk_alignment = 2,
 omp_atk_access = 3,
 omp_atk_pool_size = 4,
@@ -320,10 +320,10 @@
 typedef enum {
 omp_atv_false = 0,
 omp_atv_true = 1,
-omp_atv_default = 2,
 omp_atv_contended = 3,
 omp_atv_uncontended = 4,
-omp_atv_sequential = 5,
+omp_atv_serialized = 5,
+omp_atv_sequential = omp_atv_serialized, // (deprecated)
 omp_atv_private = 6,
 omp_atv_all = 7,
 omp_atv_thread = 8,
@@ -338,6 +338,7 @@
 omp_atv_blocked = 17,
 omp_atv_interleaved = 18
 } omp_alloctrait_value_t;
+#define omp_atv_default ((omp_uintptr_t)-1)
 
 typedef struct {
 omp_alloctrait_key_t key;

diff  --git a/openmp/runtime/src/include/omp_lib.f90.var 
b/openmp/runtime/src/include/omp_lib.f90.var
index 24f8a2af4c5e..2fc8d7c3daa4 100644
--- a/openmp/runtime/src/include/omp_lib.f90.var
+++ b/openmp/runtime/src/include/omp_lib.f90.var
@@ -98,7 +98,7 @@
 integer (kind=omp_control_tool_result_kind), parameter :: 
omp_control_tool_success = 0
 integer (kind=omp_control_tool_result_kind), parameter :: 
omp_control_tool_ignored = 1
 
-integer (kind=omp_alloctrait_key_kind), parameter :: 
omp_atk_threadmodel = 1
+integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_sync_hint 
= 1
 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_alignment 
= 2
 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_access = 3
 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_pool_size 
= 4
@@ -107,12 +107,13 @@
 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_pinned = 7
 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_partition 
= 8
 
+integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_default = 
-1
 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_false = 0
 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_true = 1
-integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_default = 
2
 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_contended 
= 3
 integer (kind=omp_alloctrait_val_kind), parameter :: 
omp_atv_uncontended = 4
-integer (kind=omp_alloctrait_val_kind), parameter :: 
omp_atv_sequential = 5
+integer (kind=omp_alloctrait_val_kind), parameter :: 
omp_atv_serialized = 5
+integer (kind=omp_alloctrait_val_kind), parameter :: 
omp_atv_sequential = omp_atv_serialized
 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_private = 
6
 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_all = 7
 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_thread = 8

diff  --git a/openmp/runtime/src/include/omp_lib.h.var 
b/openmp/runtime/src/include/omp_lib.h.var
index 05140b04f273..3fb2d25b15f1 100644
--- a/openmp/runtime/src/include/omp_lib.h.var
+++ b/openmp/runtime/src/include/omp_lib.h.var
@@ -131,8 +131,8 @@
   integer(omp_control_tool_result_kind)omp_control_tool_ignored
   parameter(omp_control_tool_ignored=1)
 
-  integer(kind=omp_alloctrait_key_kind)omp_atk_threadmodel
-  parameter(omp_atk_threadmodel=1)
+  integer(kind=omp_alloctrait_key_kind)omp_atk_sync_hint
+  parameter(omp_atk_sync_hint=1)
   integer(kind=omp_alloctrait_key_kind)omp_atk_alignment
   parameter(omp_atk_alignment=2)
   integer(kind=omp_alloctrait_key_kind)omp_atk_access
@@ -148,18 +148,20 @@
   integer(kind=omp_alloctrait_key_kind)omp_atk_partition
   parameter(omp_atk_partition=8)
 
+  integer(kind=omp_alloctrait_val_kind)omp_atv_default
+  parameter(omp_atv_default=-1)
   ! Reserved for future use
   integer(kind=omp_alloctrait_val_kind)omp

[llvm-branch-commits] [llvm] acea470 - [gn build] Reorganize libcxx/include/BUILD.gn a bit

2021-01-12 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2021-01-12T21:30:06-05:00
New Revision: acea470c167fc40990d9a0f06d625a34d8a4a146

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

LOG: [gn build] Reorganize libcxx/include/BUILD.gn a bit

- Merge 6706342f48bea80 -- no more libcxx_needs_site_config, we now
  always need it
- Since it was always off in practice, write_config bitrot. Unbitrot
  it so that it works
- Remove copy step and let concat step write to final location
  immediately -- and fix copy destination directory

As a side effect, libcxx/include/BUILD.gn now has only a single
sources list, which means the cmake sync script should be able to
automatically sync additions and removals of .h files. On the flipside,
this means this file now must be updated after most changes to
libcxx/include/__config_site.in, and looking through the last few months
of changes this looks like it's going to be a wash.

Added: 


Modified: 
llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn 
b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index f1f1f37686e2..4d7cdbefb2e6 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -1,52 +1,68 @@
-import("//clang/resource_dir.gni")
 import("//libcxx/config.gni")
 import("//llvm/utils/gn/build/write_cmake_config.gni")
 
-libcxx_needs_site_config =
-libcxx_abi_version != 1 || libcxx_abi_namespace != "" || 
libcxx_abi_unstable
+write_cmake_config("write_config") {
+  input = "__config_site.in"
+  output = "$target_gen_dir/__config_site"
 
-if (libcxx_needs_site_config) {
-  write_cmake_config("write_config") {
-input = "__config_site.in"
-output = "$target_gen_dir/__config_site"
-
-values = []
-if (libcxx_abi_version != 1) {
-  values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ]
-}
-if (libcxx_abi_namespace != "") {
-  values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ]
-}
-if (libcxx_abi_unstable) {
-  values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
-}
+  values = [
+"_LIBCPP_ABI_FORCE_ITANIUM=",
+"_LIBCPP_ABI_FORCE_MICROSOFT=",
+"_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT=",
+"_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE=",
+"_LIBCPP_HAS_NO_STDIN=",
+"_LIBCPP_HAS_NO_STDOUT=",
+"_LIBCPP_HAS_NO_THREADS=",
+"_LIBCPP_HAS_NO_MONOTONIC_CLOCK=",
+"_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS=",
+"_LIBCPP_HAS_MUSL_LIBC=",
+"_LIBCPP_HAS_THREAD_API_PTHREAD=",
+"_LIBCPP_HAS_THREAD_API_EXTERNAL=",
+"_LIBCPP_HAS_THREAD_API_WIN32=",
+"_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL=",
+"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=",
+"_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS=1",
+"_LIBCPP_NO_VCRUNTIME=",
+"_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=",
+"_LIBCPP_ABI_NAMESPACE=",
+"_LIBCPP_HAS_PARALLEL_ALGORITHMS=",
+"_LIBCPP_HAS_NO_RANDOM_DEVICE=",
+"_LIBCPP_HAS_NO_LOCALIZATION=",
+"_LIBCPP_ABI_DEFINES=",
+  ]
+  if (libcxx_abi_version != 1) {
+values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ]
+  } else {
+values += [ "_LIBCPP_ABI_VERSION=" ]
   }
-
-  # Generate a custom __config header. The new header is created
-  # by prepending __config_site to the current __config header.
-  action("concat_config") {
-script = "//libcxx/utils/cat_files.py"
-inputs = [
-  "$target_gen_dir/__config_site",
-  "__config",
-]
-outputs = [ "$target_gen_dir/__config" ]
-args = [
-  "$target_gen_dir/__config_site",
-  "__config",
-  "-o",
-  "$target_gen_dir/__config",
-]
-deps = [ ":write_config" ]
+  if (libcxx_abi_namespace != "") {
+values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ]
   }
-
-  copy("copy_config") {
-sources = [ "$target_gen_dir/__config" ]
-outputs = [ "$clang_resource_dir/include/c++/v1/{{source_file_part}}" ]
-deps = [ ":concat_config" ]
+  if (libcxx_abi_unstable) {
+values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
+  } else {
+values += [ "_LIBCPP_ABI_UNSTABLE=" ]
   }
 }
 
+# Generate a custom __config header. The new header is created
+# by prepending __config_site to the current __config header.
+action("concat_config") {
+  script = "//libcxx/utils/cat_files.py"
+  inputs = [
+"$target_gen_dir/__config_site",
+"__config",
+  ]
+  outputs = [ "$root_build_dir/include/c++/v1/__config" ]
+  args = [
+rebase_path("$target_gen_dir/__config_site", root_build_dir),
+rebase_path("__config", root_build_dir),
+"-o",
+rebase_path(outputs[0], root_build_dir)
+  ]
+  deps = [ ":write_config" ]
+}
+
 copy("include") {
   sources = [
 "__availability",
@@ -235,7 +251,7 @@ copy("include") {
 "wchar.h",
 "wctyp

[llvm-branch-commits] [libcxx] 0066a09 - [libc++] Give extern templates default visibility on gcc

2021-01-12 Thread Shoaib Meenai via llvm-branch-commits

Author: Shoaib Meenai
Date: 2021-01-12T18:30:56-08:00
New Revision: 0066a09579ca90f60cb1947691e5a441f9f57a5d

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

LOG: [libc++] Give extern templates default visibility on gcc

Contrary to the current visibility macro documentation, it appears that
gcc does handle visibility attribute on extern templates correctly, e.g.
https://godbolt.org/g/EejuV7. We need this so that extern template
instantiations of classes not marked _LIBCPP_TEMPLATE_VIS (e.g.
__vector_base_common) are correctly exported with gcc when building with
hidden visibility.

Reviewed By: ldionne

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

Added: 


Modified: 
libcxx/docs/DesignDocs/VisibilityMacros.rst
libcxx/include/__config

Removed: 




diff  --git a/libcxx/docs/DesignDocs/VisibilityMacros.rst 
b/libcxx/docs/DesignDocs/VisibilityMacros.rst
index d0d4f0adb220..20237b74de6a 100644
--- a/libcxx/docs/DesignDocs/VisibilityMacros.rst
+++ b/libcxx/docs/DesignDocs/VisibilityMacros.rst
@@ -131,12 +131,6 @@ Visibility Macros
   specified on the primary template and to export the member functions produced
   by the explicit instantiation in the dylib.
 
-  **GCC Behavior**: GCC ignores visibility attributes applied the type in
-  extern template declarations and applying an attribute results in a warning.
-  However since `_LIBCPP_TEMPLATE_VIS` is the same as
-  `__attribute__((visibility("default"))` the visibility is already correct.
-  The macro has an empty definition with GCC.
-
   **Windows Behavior**: `extern template` and `dllexport` are fundamentally
   incompatible *on a class template* on Windows; the former suppresses
   instantiation, while the latter forces it. Specifying both on the same

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index f1606c6d3b1c..a6ed66857d75 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -718,7 +718,7 @@ typedef __char32_t char32_t;
 #endif
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && 
__has_attribute(__type_visibility__)
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ 
((__visibility__("default")))
 #  else
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS



___
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] bba3a82 - [OpenMP] Use persistent memory for omp_large_cap_mem

2021-01-12 Thread Hansang Bae via llvm-branch-commits

Author: Hansang Bae
Date: 2021-01-12T20:35:27-06:00
New Revision: bba3a82b56c0874757f2c1423bbdff08e2a88967

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

LOG: [OpenMP] Use persistent memory for omp_large_cap_mem

This change enables volatile use of persistent memory for omp_large_cap_mem*
on supported systems. It depends on libmemkind's support for persistent memory,
and requirements/details can be found at the following url.

https://pmem.io/2020/01/20/memkind-dax-kmem.html

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

Added: 


Modified: 
openmp/runtime/src/kmp_alloc.cpp

Removed: 




diff  --git a/openmp/runtime/src/kmp_alloc.cpp 
b/openmp/runtime/src/kmp_alloc.cpp
index b56e71881208..31981d5c1d55 100644
--- a/openmp/runtime/src/kmp_alloc.cpp
+++ b/openmp/runtime/src/kmp_alloc.cpp
@@ -1239,6 +1239,9 @@ static void **mk_hbw_preferred;
 static void **mk_hugetlb;
 static void **mk_hbw_hugetlb;
 static void **mk_hbw_preferred_hugetlb;
+static void **mk_dax_kmem;
+static void **mk_dax_kmem_all;
+static void **mk_dax_kmem_preferred;
 
 #if KMP_OS_UNIX && KMP_DYNAMIC_LIB
 static inline void chk_kind(void ***pkind) {
@@ -1279,25 +1282,21 @@ void __kmp_init_memkind() {
   mk_hbw_preferred_hugetlb =
   (void **)dlsym(h_memkind, "MEMKIND_HBW_PREFERRED_HUGETLB");
   chk_kind(&mk_hbw_preferred_hugetlb);
+  mk_dax_kmem = (void **)dlsym(h_memkind, "MEMKIND_DAX_KMEM");
+  chk_kind(&mk_dax_kmem);
+  mk_dax_kmem_all = (void **)dlsym(h_memkind, "MEMKIND_DAX_KMEM_ALL");
+  chk_kind(&mk_dax_kmem_all);
+  mk_dax_kmem_preferred =
+  (void **)dlsym(h_memkind, "MEMKIND_DAX_KMEM_PREFERRED");
+  chk_kind(&mk_dax_kmem_preferred);
   KE_TRACE(25, ("__kmp_init_memkind: memkind library initialized\n"));
   return; // success
 }
 dlclose(h_memkind); // failure
-h_memkind = NULL;
   }
-  kmp_mk_check = NULL;
-  kmp_mk_alloc = NULL;
-  kmp_mk_free = NULL;
-  mk_default = NULL;
-  mk_interleave = NULL;
-  mk_hbw = NULL;
-  mk_hbw_interleave = NULL;
-  mk_hbw_preferred = NULL;
-  mk_hugetlb = NULL;
-  mk_hbw_hugetlb = NULL;
-  mk_hbw_preferred_hugetlb = NULL;
-#else
+#else // !(KMP_OS_UNIX && KMP_DYNAMIC_LIB)
   kmp_mk_lib_name = "";
+#endif // !(KMP_OS_UNIX && KMP_DYNAMIC_LIB)
   h_memkind = NULL;
   kmp_mk_check = NULL;
   kmp_mk_alloc = NULL;
@@ -1310,7 +1309,9 @@ void __kmp_init_memkind() {
   mk_hugetlb = NULL;
   mk_hbw_hugetlb = NULL;
   mk_hbw_preferred_hugetlb = NULL;
-#endif
+  mk_dax_kmem = NULL;
+  mk_dax_kmem_all = NULL;
+  mk_dax_kmem_preferred = NULL;
 }
 
 void __kmp_fini_memkind() {
@@ -1332,6 +1333,9 @@ void __kmp_fini_memkind() {
   mk_hugetlb = NULL;
   mk_hbw_hugetlb = NULL;
   mk_hbw_preferred_hugetlb = NULL;
+  mk_dax_kmem = NULL;
+  mk_dax_kmem_all = NULL;
+  mk_dax_kmem_preferred = NULL;
 #endif
 }
 
@@ -1401,6 +1405,17 @@ omp_allocator_handle_t __kmpc_init_allocator(int gtid, 
omp_memspace_handle_t ms,
 __kmp_free(al);
 return omp_null_allocator;
   }
+} else if (ms == omp_large_cap_mem_space) {
+  if (mk_dax_kmem_all) {
+// All pmem nodes are visited
+al->memkind = mk_dax_kmem_all;
+  } else if (mk_dax_kmem) {
+// Only closest pmem node is visited
+al->memkind = mk_dax_kmem;
+  } else {
+__kmp_free(al);
+return omp_null_allocator;
+  }
 } else {
   if (al->memkind == (void *)omp_atv_interleaved && mk_interleave) {
 al->memkind = mk_interleave;
@@ -1473,6 +1488,8 @@ void *__kmpc_alloc(int gtid, size_t size, 
omp_allocator_handle_t allocator) {
   // pre-defined allocator
   if (allocator == omp_high_bw_mem_alloc && mk_hbw_preferred) {
 ptr = kmp_mk_alloc(*mk_hbw_preferred, desc.size_a);
+  } else if (allocator == omp_large_cap_mem_alloc && mk_dax_kmem_all) {
+ptr = kmp_mk_alloc(*mk_dax_kmem_all, desc.size_a);
   } else {
 ptr = kmp_mk_alloc(*mk_default, desc.size_a);
   }
@@ -1529,6 +1546,8 @@ void *__kmpc_alloc(int gtid, size_t size, 
omp_allocator_handle_t allocator) {
 // pre-defined allocator
 if (allocator == omp_high_bw_mem_alloc) {
   // ptr = NULL;
+} else if (allocator == omp_large_cap_mem_alloc) {
+  // warnings?
 } else {
   ptr = __kmp_thread_malloc(__kmp_thread_from_gtid(gtid), desc.size_a);
 }
@@ -1684,6 +1703,8 @@ void __kmpc_free(int gtid, void *ptr, const 
omp_allocator_handle_t allocator) {
   // pre-defined allocator
   if (oal == omp_high_bw_mem_alloc && mk_hbw_preferred) {
 kmp_mk_free(*mk_hbw_preferred, desc.ptr_alloc);
+  } else if (oal == omp_large_cap_mem_alloc && mk_dax_kmem_all) {
+kmp_mk_free(*mk_dax_kmem_all, desc.ptr_alloc);
   } else {
 kmp_mk_free(*mk_defa

[llvm-branch-commits] [llvm] 914e2f5 - [NFC] Use generic name for scalable vector stack ID.

2021-01-12 Thread Hsiangkai Wang via llvm-branch-commits

Author: Hsiangkai Wang
Date: 2021-01-13T10:57:43+08:00
New Revision: 914e2f5a02f4f896eec9a00f536d1118bf1d9961

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

LOG: [NFC] Use generic name for scalable vector stack ID.

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/MIRYamlMapping.h
llvm/include/llvm/CodeGen/TargetFrameLowering.h
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AArch64/AArch64FrameLowering.h
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
llvm/test/CodeGen/AArch64/debug-info-sve-dbg-declare.mir
llvm/test/CodeGen/AArch64/debug-info-sve-dbg-value.mir
llvm/test/CodeGen/AArch64/framelayout-sve-basepointer.mir
llvm/test/CodeGen/AArch64/framelayout-sve-calleesaves-fix.mir
llvm/test/CodeGen/AArch64/framelayout-sve-scavengingslot.mir
llvm/test/CodeGen/AArch64/framelayout-sve.mir
llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir
llvm/test/CodeGen/AArch64/spillfill-sve.mir
llvm/test/CodeGen/AArch64/sve-alloca-stackid.ll
llvm/test/CodeGen/AArch64/sve-calling-convention-byref.ll
llvm/test/CodeGen/AArch64/sve-localstackalloc.mir

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h 
b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index f7006517e3df..4a7406473b11 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -347,7 +347,7 @@ struct ScalarEnumerationTraits {
   static void enumeration(yaml::IO &IO, TargetStackID::Value &ID) {
 IO.enumCase(ID, "default", TargetStackID::Default);
 IO.enumCase(ID, "sgpr-spill", TargetStackID::SGPRSpill);
-IO.enumCase(ID, "sve-vec", TargetStackID::SVEVector);
+IO.enumCase(ID, "scalable-vector", TargetStackID::ScalableVector);
 IO.enumCase(ID, "noalloc", TargetStackID::NoAlloc);
   }
 };

diff  --git a/llvm/include/llvm/CodeGen/TargetFrameLowering.h 
b/llvm/include/llvm/CodeGen/TargetFrameLowering.h
index c6806793f248..792452f6e81d 100644
--- a/llvm/include/llvm/CodeGen/TargetFrameLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetFrameLowering.h
@@ -27,7 +27,7 @@ namespace TargetStackID {
   enum Value {
 Default = 0,
 SGPRSpill = 1,
-SVEVector = 2,
+ScalableVector = 2,
 NoAlloc = 255
   };
 }

diff  --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index 1687fd0116a5..65ee5016042c 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -249,7 +249,7 @@ static unsigned estimateRSStackSizeLimit(MachineFunction 
&MF) {
 
 TargetStackID::Value
 AArch64FrameLowering::getStackIDForScalableVectors() const {
-  return TargetStackID::SVEVector;
+  return TargetStackID::ScalableVector;
 }
 
 /// Returns the size of the fixed object area (allocated next to sp on entry)
@@ -496,7 +496,7 @@ void AArch64FrameLowering::emitCalleeSavedFrameMoves(
   continue;
 
 StackOffset Offset;
-if (MFI.getStackID(Info.getFrameIdx()) == TargetStackID::SVEVector) {
+if (MFI.getStackID(Info.getFrameIdx()) == TargetStackID::ScalableVector) {
   AArch64FunctionInfo *AFI = MF.getInfo();
   Offset =
   StackOffset::getScalable(MFI.getObjectOffset(Info.getFrameIdx())) -
@@ -1856,7 +1856,7 @@ StackOffset 
AArch64FrameLowering::resolveFrameIndexReference(
   const auto &MFI = MF.getFrameInfo();
   int64_t ObjectOffset = MFI.getObjectOffset(FI);
   bool isFixed = MFI.isFixedObjectIndex(FI);
-  bool isSVE = MFI.getStackID(FI) == TargetStackID::SVEVector;
+  bool isSVE = MFI.getStackID(FI) == TargetStackID::ScalableVector;
   return resolveFrameOffsetReference(MF, ObjectOffset, isFixed, isSVE, 
FrameReg,
  PreferFP, ForSimm);
 }
@@ -2412,7 +2412,7 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
 // Update the StackIDs of the SVE stack slots.
 MachineFrameInfo &MFI = MF.getFrameInfo();
 if (RPI.Type == RegPairInfo::ZPR || RPI.Type == RegPairInfo::PPR)
-  MFI.setStackID(RPI.FrameIdx, TargetStackID::SVEVector);
+  MFI.setStackID(RPI.FrameIdx, TargetStackID::ScalableVector);
 
   }
   return true;
@@ -2761,7 +2761,7 @@ static int64_t 
determineSVEStackObjectOffsets(MachineFrameInfo &MFI,
 #ifndef NDEBUG
   // First process all fixed stack objects.
   for (int I = MFI.getObjectIndexBegin(); I != 0; ++I)
-assert(MFI.getStackID(I) != TargetStackID::SVEVector &&
+assert(MFI.getStackID(I) != TargetStackID::ScalableVector &&
"SVE vectors should never be passed on the stack by value, only by "
"reference.");
 #en

[llvm-branch-commits] [llvm] e5553b9 - [dsymutil] Warn on timestmap mismatch between object file and debug map

2021-01-12 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2021-01-12T18:58:10-08:00
New Revision: e5553b9a6ab9f02f382a31cc5117b52c3bfaf77a

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

LOG: [dsymutil] Warn on timestmap mismatch between object file and debug map

Add a warning when the timestmap doesn't match between the object file
and the debug map entry. We were already emitting such warnings for
archive members and swift interface files. This patch also unifies the
warning across all three.

rdar://65614640

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

Added: 
llvm/test/tools/dsymutil/Inputs/basic.macho.x86_64.o

Modified: 
llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
llvm/test/tools/dsymutil/debug-map-parsing.test
llvm/tools/dsymutil/BinaryHolder.cpp
llvm/tools/dsymutil/BinaryHolder.h
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp

Removed: 




diff  --git a/llvm/test/tools/dsymutil/Inputs/basic.macho.x86_64.o 
b/llvm/test/tools/dsymutil/Inputs/basic.macho.x86_64.o
new file mode 100644
index ..e69de29bb2d1

diff  --git a/llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test 
b/llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
index 626208ff3496..43d930af7128 100644
--- a/llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
+++ b/llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
@@ -20,7 +20,7 @@ READOBJ-NEXT: |.|
 DWARFDUMP: __swift_ast
 
 RUN: dsymutil -oso-prepend-path %p/.. %p/../Inputs/swift-ast.macho.x86_64 
-no-output -verbose 2>&1 | FileCheck %s --check-prefix=TIMESTAMP
-TIMESTAMP: warning: Timestamp mismatch
+TIMESTAMP: warning: {{.*}}/swift-ast.swiftmodule: timestamp mismatch between 
swift interface file ({{.*}}) and debug map ({{.*}})
 
 RUN: dsymutil -s 
%T/swift-ast.dSYM/Contents/Resources/DWARF/swift-ast.macho.x86_64 | FileCheck 
%s --check-prefix=NAST
 NAST-NOT: N_AST

diff  --git a/llvm/test/tools/dsymutil/debug-map-parsing.test 
b/llvm/test/tools/dsymutil/debug-map-parsing.test
index fb4226093da1..703934d38503 100644
--- a/llvm/test/tools/dsymutil/debug-map-parsing.test
+++ b/llvm/test/tools/dsymutil/debug-map-parsing.test
@@ -1,3 +1,4 @@
+RUN: touch %p/Inputs/basic.macho.x86_64.o
 RUN: dsymutil -dump-debug-map -oso-prepend-path=%p 
%p/Inputs/basic.macho.x86_64 | FileCheck %s
 RUN: dsymutil -dump-debug-map -oso-prepend-path=%p 
%p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO
 RUN: dsymutil -verbose -dump-debug-map -oso-prepend-path=%p 
%p/Inputs/basic-archive.macho.x86_64 2>&1 | FileCheck %s 
--check-prefix=CHECK-ARCHIVE
@@ -46,6 +47,7 @@ opening the archive once if mulitple of its members are used).
 CHECK-ARCHIVE:  trying to open {{.*}}basic-archive.macho.x86_64'
 CHECK-ARCHIVE-NEXT:loaded object.
 CHECK-ARCHIVE-NEXT: trying to open {{.*}}/Inputs/basic1.macho.x86_64.o'
+CHECK-ARCHIVE-NEXT: warning: {{.*}}/Inputs/basic1.macho.x86_64.o: timestamp 
mismatch between object file ({{.*}}) and debug map ({{.*}})
 CHECK-ARCHIVE-NEXT:loaded object.
 CHECK-ARCHIVE-NEXT: trying to open {{.*}}/libbasic.a(basic2.macho.x86_64.o)'
 CHECK-ARCHIVE-NEXT:loaded archive {{.*}}/libbasic.a'

diff  --git a/llvm/tools/dsymutil/BinaryHolder.cpp 
b/llvm/tools/dsymutil/BinaryHolder.cpp
index df3cb7161a81..b401d519718c 100644
--- a/llvm/tools/dsymutil/BinaryHolder.cpp
+++ b/llvm/tools/dsymutil/BinaryHolder.cpp
@@ -87,7 +87,8 @@ Error 
BinaryHolder::ArchiveEntry::load(IntrusiveRefCntPtr VFS,
 }
 
 Error BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr VFS,
-  StringRef Filename, bool Verbose) {
+  StringRef Filename, TimestampTy 
Timestamp,
+  bool Verbose) {
   // Try to load regular binary and force it to be memory mapped.
   auto ErrOrBuff = (Filename == "-")
? MemoryBuffer::getSTDIN()
@@ -95,6 +96,17 @@ Error 
BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr VFS,
   if (auto Err = ErrOrBuff.getError())
 return errorCodeToError(Err);
 
+  if (Filename != "-" && Timestamp != sys::TimePoint<>()) {
+llvm::ErrorOr Stat = VFS->status(Filename);
+if (!Stat)
+  return errorCodeToError(Stat.getError());
+if (Timestamp != Stat->getLastModificationTime())
+  WithColor::warning() << Filename
+   << ": timestamp mismatch between object file ("
+   << Stat->getLastModificationTime()
+   << ") and debug map (" << Timestamp << ")\n";
+  }
+
   MemBuffer = std::move(*ErrOrBuff);
 
   if (Verbose)
@@ -182,7 +194,11 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef 
Filename,
   if (Timestamp != sys::TimePoint<>() &&
   Timestamp != ModTimeOrErr.get()) {
 if (Verbose)
- 

[llvm-branch-commits] [llvm] cd8a80d - [Orc] Add a unit test for asynchronous definition generation.

2021-01-12 Thread Lang Hames via llvm-branch-commits

Author: Lang Hames
Date: 2021-01-13T14:23:36+11:00
New Revision: cd8a80de96080da33d0a7d5d5821120ddcfc4ece

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

LOG: [Orc] Add a unit test for asynchronous definition generation.

Added: 


Modified: 
llvm/include/llvm/ExecutionEngine/Orc/Core.h
llvm/lib/ExecutionEngine/Orc/Core.cpp
llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h 
b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
index 3020694ee732..4a4b58ed32e3 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -850,6 +850,9 @@ class LookupState {
   friend class ExecutionSession;
 
 public:
+  LookupState();
+  LookupState(LookupState &&);
+  LookupState &operator=(LookupState &&);
   ~LookupState();
 
   /// Continue the lookup. This can be called by DefinitionGenerators

diff  --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp 
b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index 458dfc1ef421..3a18cd2ef761 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -577,7 +577,10 @@ 
LookupState::LookupState(std::unique_ptr IPLS)
 
 void LookupState::reset(InProgressLookupState *IPLS) { this->IPLS.reset(IPLS); 
}
 
-LookupState::~LookupState() {}
+LookupState::LookupState() = default;
+LookupState::LookupState(LookupState &&) = default;
+LookupState &LookupState::operator=(LookupState &&) = default;
+LookupState::~LookupState() = default;
 
 void LookupState::continueLookup(Error Err) {
   assert(IPLS && "Cannot call continueLookup on empty LookupState");

diff  --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp 
b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
index 866ed7656fb6..62c55cecf20e 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
@@ -110,7 +110,7 @@ TEST_F(CoreAPIsStandardTest, 
MaterializationSideEffctsOnlyBasic) {
 
   ES.lookup(
   LookupKind::Static, makeJITDylibSearchOrder(&JD),
-  SymbolLookupSet({Foo}, SymbolLookupFlags::WeaklyReferencedSymbol),
+  SymbolLookupSet(Foo, SymbolLookupFlags::WeaklyReferencedSymbol),
   SymbolState::Ready,
   [&](Expected LookupResult) {
 if (LookupResult)
@@ -1088,6 +1088,53 @@ TEST_F(CoreAPIsStandardTest, GeneratorTest) {
   << "Expected fallback def for Bar to be equal to BarSym";
 }
 
+TEST_F(CoreAPIsStandardTest, AsynchronousGeneratorTest) {
+  class TestGenerator : public DefinitionGenerator {
+  public:
+TestGenerator(LookupState &TLS) : TLS(TLS) {}
+Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD,
+JITDylibLookupFlags JDLookupFlags,
+const SymbolLookupSet &Name) override {
+  TLS = std::move(LS);
+  return Error::success();
+}
+
+  private:
+LookupState &TLS;
+  };
+
+  LookupState LS;
+  JD.addGenerator(std::make_unique(LS));
+
+  bool LookupCompleted = false;
+
+  ES.lookup(
+  LookupKind::Static, makeJITDylibSearchOrder(&JD), SymbolLookupSet(Foo),
+  SymbolState::Ready,
+  [&](Expected Result) {
+LookupCompleted = true;
+if (!Result) {
+  ADD_FAILURE() << "Lookup failed unexpected";
+  logAllUnhandledErrors(Result.takeError(), errs(), "");
+  return;
+}
+
+EXPECT_EQ(Result->size(), 1U) << "Unexpected number of results";
+EXPECT_EQ(Result->count(Foo), 1U) << "Expected result for Foo";
+EXPECT_EQ((*Result)[Foo].getAddress(), FooSym.getAddress())
+<< "Bad result for Foo";
+  },
+  NoDependenciesToRegister);
+
+  EXPECT_FALSE(LookupCompleted);
+
+  cantFail(JD.define(absoluteSymbols({{Foo, FooSym}})));
+
+  LS.continueLookup(Error::success());
+
+  EXPECT_TRUE(LookupCompleted);
+}
+
 TEST_F(CoreAPIsStandardTest, FailResolution) {
   auto MU = std::make_unique(
   SymbolFlagsMap({{Foo, JITSymbolFlags::Exported | JITSymbolFlags::Weak},



___
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] f454c9f - [InlineSpiller] Re-tie operands if folding failed

2021-01-12 Thread Serguei Katkov via llvm-branch-commits

Author: Serguei Katkov
Date: 2021-01-13T10:31:43+07:00
New Revision: f454c9f102a7f0df9d2802e30538192d4fe2f97a

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

LOG: [InlineSpiller] Re-tie operands if folding failed

InlineSpiller::foldMemoryOperand unties registers before an attempt to fold and
does not restore tied-ness in case of failure.

I do not have a particular test for demo of invalid behavior.
This is something of clean-up.
It is better to keep the behavior correct in case some time in future it 
happens.

Reviewers: reames, dantrushin
Reviewed By: dantrushin, reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D94389

Added: 


Modified: 
llvm/lib/CodeGen/InlineSpiller.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/InlineSpiller.cpp 
b/llvm/lib/CodeGen/InlineSpiller.cpp
index 236a70904690a..1892ca646788f 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -853,16 +853,13 @@ foldMemoryOperand(ArrayRef> Ops,
   continue;
 }
 
-if (UntieRegs && MO.isTied())
-  MI->untieRegOperand(Idx);
-
 if (!SpillSubRegs && MO.getSubReg())
   return false;
 // We cannot fold a load instruction into a def.
 if (LoadMI && MO.isDef())
   return false;
 // Tied use operands should not be passed to foldMemoryOperand.
-if (!MI->isRegTiedToDefOperand(Idx))
+if (UntieRegs || !MI->isRegTiedToDefOperand(Idx))
   FoldOps.push_back(Idx);
   }
 
@@ -873,11 +870,31 @@ foldMemoryOperand(ArrayRef> Ops,
 
   MachineInstrSpan MIS(MI, MI->getParent());
 
+  SmallVector > TiedOps;
+  if (UntieRegs)
+for (unsigned Idx : FoldOps) {
+  MachineOperand &MO = MI->getOperand(Idx);
+  if (!MO.isTied())
+continue;
+  unsigned Tied = MI->findTiedOperandIdx(Idx);
+  if (MO.isUse())
+TiedOps.emplace_back(Tied, Idx);
+  else {
+assert(MO.isDef() && "Tied to not use and def?");
+TiedOps.emplace_back(Idx, Tied);
+  }
+  MI->untieRegOperand(Idx);
+}
+
   MachineInstr *FoldMI =
   LoadMI ? TII.foldMemoryOperand(*MI, FoldOps, *LoadMI, &LIS)
  : TII.foldMemoryOperand(*MI, FoldOps, StackSlot, &LIS, &VRM);
-  if (!FoldMI)
+  if (!FoldMI) {
+// Re-tie operands.
+for (auto Tied : TiedOps)
+  MI->tieOperands(Tied.first, Tied.second);
 return false;
+  }
 
   // Remove LIS for any dead defs in the original MI not in FoldMI.
   for (MIBundleOperands MO(*MI); MO.isValid(); ++MO) {



___
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] 8a47d87 - [dsymutil] Copy eh_frame content into the dSYM companion file.

2021-01-12 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2021-01-12T19:50:34-08:00
New Revision: 8a47d875b071823455931bbc119ca1e49176

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

LOG: [dsymutil] Copy eh_frame content into the dSYM companion file.

Copy over the __eh_frame from the binary into the dSYM. This helps
kernel developers that are working with only dSYMs (i.e. no binaries)
when debugging a core file. This only kicks in when the __eh_frame
exists in the linked binary. Most of the time ld64 will remove the
section in favor of compact unwind info. When it is emitted, it's
generally small enough and should not bloat the dSYM.

rdar://69774935

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

Added: 
llvm/test/tools/dsymutil/Inputs/private/tmp/eh_frame/eh_frame.o
llvm/test/tools/dsymutil/Inputs/private/tmp/eh_frame/eh_frame.out
llvm/test/tools/dsymutil/X86/eh_frame.test

Modified: 
llvm/tools/dsymutil/MachOUtils.cpp

Removed: 




diff  --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/eh_frame/eh_frame.o 
b/llvm/test/tools/dsymutil/Inputs/private/tmp/eh_frame/eh_frame.o
new file mode 100644
index ..45ec4097c6a6
Binary files /dev/null and 
b/llvm/test/tools/dsymutil/Inputs/private/tmp/eh_frame/eh_frame.o 
diff er

diff  --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/eh_frame/eh_frame.out 
b/llvm/test/tools/dsymutil/Inputs/private/tmp/eh_frame/eh_frame.out
new file mode 100755
index ..1b5705db193d
Binary files /dev/null and 
b/llvm/test/tools/dsymutil/Inputs/private/tmp/eh_frame/eh_frame.out 
diff er

diff  --git a/llvm/test/tools/dsymutil/X86/eh_frame.test 
b/llvm/test/tools/dsymutil/X86/eh_frame.test
new file mode 100644
index ..1e31a51cc5c2
--- /dev/null
+++ b/llvm/test/tools/dsymutil/X86/eh_frame.test
@@ -0,0 +1,25 @@
+FIXME: Replace otool with llvm-objcopy --dump-section=__TEXT,__eh_frame.
+REQUIRES : system-darwin
+
+$ cat eh_frame.cpp
+int f1()
+{
+  volatile int i;
+  return i;
+}
+
+int main(int argc, char** argv)
+{
+  return f1();
+}
+
+$ clang eh_frame.cpp -g -c -o eh_frame.o
+$ ld -no_compact_unwind eh_frame.o -o eh_frame.out
+
+RUN: dsymutil -oso-prepend-path %p/../Inputs 
%p/../Inputs/private/tmp/eh_frame/eh_frame.out -o %t.dSYM
+RUN: dwarfdump --verify %t.dSYM
+RUN: otool -s __TEXT __eh_frame %p/../Inputs/private/tmp/eh_frame/eh_frame.out 
| FileCheck %s
+RUN: otool -s __TEXT __eh_frame %t.dSYM/Contents/Resources/DWARF/eh_frame.out 
| FileCheck %s
+
+CHECK: 14 00 00 00 00 00 00 00 01 7a 52 00 01 78 10 01
+CHECK: 10 0c 07 08 90 01 00 00

diff  --git a/llvm/tools/dsymutil/MachOUtils.cpp 
b/llvm/tools/dsymutil/MachOUtils.cpp
index 0f38525e45c2..943af430584d 100644
--- a/llvm/tools/dsymutil/MachOUtils.cpp
+++ b/llvm/tools/dsymutil/MachOUtils.cpp
@@ -239,27 +239,36 @@ getSection(const object::MachOObjectFile &Obj,
 // Transfer \a Segment from \a Obj to the output file. This calls into \a 
Writer
 // to write these load commands directly in the output file at the current
 // position.
+//
 // The function also tries to find a hole in the address map to fit the __DWARF
 // segment of \a DwarfSegmentSize size. \a EndAddress is updated to point at 
the
 // highest segment address.
+//
 // When the __LINKEDIT segment is transferred, its offset and size are set 
resp.
 // to \a LinkeditOffset and \a LinkeditSize.
+//
+// When the eh_frame section is transferred, its offset and size are set resp.
+// to \a EHFrameOffset and \a EHFrameSize.
 template 
 static void transferSegmentAndSections(
 const object::MachOObjectFile::LoadCommandInfo &LCI, SegmentTy Segment,
 const object::MachOObjectFile &Obj, MachObjectWriter &Writer,
-uint64_t LinkeditOffset, uint64_t LinkeditSize, uint64_t DwarfSegmentSize,
-uint64_t &GapForDwarf, uint64_t &EndAddress) {
+uint64_t LinkeditOffset, uint64_t LinkeditSize, uint64_t EHFrameOffset,
+uint64_t EHFrameSize, uint64_t DwarfSegmentSize, uint64_t &GapForDwarf,
+uint64_t &EndAddress) {
   if (StringRef("__DWARF") == Segment.segname)
 return;
 
-  Segment.fileoff = Segment.filesize = 0;
-
-  if (StringRef("__LINKEDIT") == Segment.segname) {
+  if (StringRef("__TEXT") == Segment.segname && EHFrameSize > 0) {
+Segment.fileoff = EHFrameOffset;
+Segment.filesize = EHFrameSize;
+  } else if (StringRef("__LINKEDIT") == Segment.segname) {
 Segment.fileoff = LinkeditOffset;
 Segment.filesize = LinkeditSize;
 // Resize vmsize by rounding to the page size.
 Segment.vmsize = alignTo(LinkeditSize, 0x1000);
+  } else {
+Segment.fileoff = Segment.filesize = 0;
   }
 
   // Check if the end address of the last segment and our current
@@ -280,7 +289,12 @@ static void transferSegmentAndSections(
   Writer.W.OS.write(reinterpret_cast(&Segment), sizeof(Segment));

[llvm-branch-commits] [openmp] 84e0b14 - [libomptarget][nvptx] Include omp_data.cu in bitcode deviceRTL

2021-01-12 Thread Jon Chesterfield via llvm-branch-commits

Author: Jon Chesterfield
Date: 2021-01-13T03:51:11Z
New Revision: 84e0b14a0a419f26d0a2f7389e06aa8e36569808

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

LOG: [libomptarget][nvptx] Include omp_data.cu in bitcode deviceRTL

[libomptarget][nvptx] Include omp_data.cu in bitcode deviceRTL

Reviewed By: tianshilei1992

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

Added: 


Modified: 
openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt

Removed: 




diff  --git a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt 
b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
index 425c674fb11e..ea11c8114166 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -56,6 +56,7 @@ if(LIBOMPTARGET_DEP_CUDA_FOUND)
   ${devicertl_common_directory}/src/data_sharing.cu
   ${devicertl_common_directory}/src/libcall.cu
   ${devicertl_common_directory}/src/loop.cu
+  ${devicertl_common_directory}/src/omp_data.cu
   ${devicertl_common_directory}/src/omptarget.cu
   ${devicertl_common_directory}/src/parallel.cu
   ${devicertl_common_directory}/src/reduction.cu
@@ -65,8 +66,6 @@ if(LIBOMPTARGET_DEP_CUDA_FOUND)
   src/target_impl.cu
   )
 
-  set(omp_data_objects ${devicertl_common_directory}/src/omp_data.cu)
-
   # Build library support for the highest compute capability the system 
supports
   # and always build support for sm_35 by default
   if (${LIBOMPTARGET_DEP_CUDA_ARCH} EQUAL 35)
@@ -105,7 +104,7 @@ if(LIBOMPTARGET_DEP_CUDA_FOUND)
   set(CUDA_SEPARABLE_COMPILATION ON)
   list(APPEND CUDA_NVCC_FLAGS -I${devicertl_base_directory}
   -I${devicertl_nvptx_directory}/src)
-  cuda_add_library(omptarget-nvptx STATIC ${cuda_src_files} ${omp_data_objects}
+  cuda_add_library(omptarget-nvptx STATIC ${cuda_src_files}
   OPTIONS ${CUDA_ARCH} ${CUDA_DEBUG} ${MAX_SM_DEFINITION})
 
   # Install device RTL under the lib destination folder.



___
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] ad735ba - [dsymutil] s/dwarfdump/llvm-dwarfdump/ in test

2021-01-12 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2021-01-12T19:59:13-08:00
New Revision: ad735badb69f389dd52e3ccef93694a0724e1293

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

LOG: [dsymutil] s/dwarfdump/llvm-dwarfdump/ in test

Added: 


Modified: 
llvm/test/tools/dsymutil/X86/eh_frame.test

Removed: 




diff  --git a/llvm/test/tools/dsymutil/X86/eh_frame.test 
b/llvm/test/tools/dsymutil/X86/eh_frame.test
index 1e31a51cc5c2..365fc678f31b 100644
--- a/llvm/test/tools/dsymutil/X86/eh_frame.test
+++ b/llvm/test/tools/dsymutil/X86/eh_frame.test
@@ -17,7 +17,7 @@ $ clang eh_frame.cpp -g -c -o eh_frame.o
 $ ld -no_compact_unwind eh_frame.o -o eh_frame.out
 
 RUN: dsymutil -oso-prepend-path %p/../Inputs 
%p/../Inputs/private/tmp/eh_frame/eh_frame.out -o %t.dSYM
-RUN: dwarfdump --verify %t.dSYM
+RUN: llvm-dwarfdump --verify %t.dSYM
 RUN: otool -s __TEXT __eh_frame %p/../Inputs/private/tmp/eh_frame/eh_frame.out 
| FileCheck %s
 RUN: otool -s __TEXT __eh_frame %t.dSYM/Contents/Resources/DWARF/eh_frame.out 
| FileCheck %s
 



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


[llvm-branch-commits] [llvm] 35e4998 - [dsymutil] Fix spurious space in REQUIRES: line

2021-01-12 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2021-01-12T20:13:44-08:00
New Revision: 35e4998f0c9a2f50567f5d2953db266c32fb1a25

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

LOG: [dsymutil] Fix spurious space in REQUIRES: line

This test is incorrectly running on non-darwin hosts.

Added: 


Modified: 
llvm/test/tools/dsymutil/X86/eh_frame.test

Removed: 




diff  --git a/llvm/test/tools/dsymutil/X86/eh_frame.test 
b/llvm/test/tools/dsymutil/X86/eh_frame.test
index 365fc678f31b..1a349dc983b2 100644
--- a/llvm/test/tools/dsymutil/X86/eh_frame.test
+++ b/llvm/test/tools/dsymutil/X86/eh_frame.test
@@ -1,5 +1,6 @@
+REQUIRES: system-darwin
+
 FIXME: Replace otool with llvm-objcopy --dump-section=__TEXT,__eh_frame.
-REQUIRES : system-darwin
 
 $ cat eh_frame.cpp
 int f1()



___
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] 790c75c - [AMDGPU] Add SI_EARLY_TERMINATE_SCC0 for early terminating shader

2021-01-12 Thread Carl Ritson via llvm-branch-commits

Author: Carl Ritson
Date: 2021-01-13T13:29:05+09:00
New Revision: 790c75c16373d37846c8433a69efd9b0d5e4ad12

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

LOG: [AMDGPU] Add SI_EARLY_TERMINATE_SCC0 for early terminating shader

Add pseudo instruction to allow early termination of pixel shader
anywhere based on the value of SCC.  The intention is to use this
when a mask of live lanes is updated, e.g. live lanes in WQM pass.
This facilitates early termination of shaders even when EXEC is
incomplete, e.g. in non-uniform control flow.

Reviewed By: foad

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

Added: 
llvm/test/CodeGen/AMDGPU/early-term.mir

Modified: 
llvm/lib/Target/AMDGPU/SIInsertSkips.cpp
llvm/lib/Target/AMDGPU/SIInstructions.td

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIInsertSkips.cpp 
b/llvm/lib/Target/AMDGPU/SIInsertSkips.cpp
index eb2e12f2dcda..e80325bddc43 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertSkips.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertSkips.cpp
@@ -49,6 +49,7 @@ class SIInsertSkips : public MachineFunctionPass {
   DebugLoc DL);
 
   bool kill(MachineInstr &MI);
+  void earlyTerm(MachineInstr &MI);
 
   bool skipMaskBranch(MachineInstr &MI, MachineBasicBlock &MBB);
 
@@ -145,19 +146,22 @@ bool 
SIInsertSkips::dominatesAllReachable(MachineBasicBlock &MBB) {
   return true;
 }
 
-static void generatePsEndPgm(MachineBasicBlock &MBB,
- MachineBasicBlock::iterator I, DebugLoc DL,
- const SIInstrInfo *TII) {
-  // Generate "null export; s_endpgm".
-  BuildMI(MBB, I, DL, TII->get(AMDGPU::EXP_DONE))
-  .addImm(AMDGPU::Exp::ET_NULL)
-  .addReg(AMDGPU::VGPR0, RegState::Undef)
-  .addReg(AMDGPU::VGPR0, RegState::Undef)
-  .addReg(AMDGPU::VGPR0, RegState::Undef)
-  .addReg(AMDGPU::VGPR0, RegState::Undef)
-  .addImm(1)  // vm
-  .addImm(0)  // compr
-  .addImm(0); // en
+static void generateEndPgm(MachineBasicBlock &MBB,
+   MachineBasicBlock::iterator I, DebugLoc DL,
+   const SIInstrInfo *TII, bool IsPS) {
+  // "null export"
+  if (IsPS) {
+BuildMI(MBB, I, DL, TII->get(AMDGPU::EXP_DONE))
+.addImm(AMDGPU::Exp::ET_NULL)
+.addReg(AMDGPU::VGPR0, RegState::Undef)
+.addReg(AMDGPU::VGPR0, RegState::Undef)
+.addReg(AMDGPU::VGPR0, RegState::Undef)
+.addReg(AMDGPU::VGPR0, RegState::Undef)
+.addImm(1)  // vm
+.addImm(0)  // compr
+.addImm(0); // en
+  }
+  // s_endpgm
   BuildMI(MBB, I, DL, TII->get(AMDGPU::S_ENDPGM)).addImm(0);
 }
 
@@ -169,7 +173,9 @@ void SIInsertSkips::ensureEarlyExitBlock(MachineBasicBlock 
&MBB,
   if (!EarlyExitBlock) {
 EarlyExitBlock = MF->CreateMachineBasicBlock();
 MF->insert(MF->end(), EarlyExitBlock);
-generatePsEndPgm(*EarlyExitBlock, EarlyExitBlock->end(), DL, TII);
+generateEndPgm(*EarlyExitBlock, EarlyExitBlock->end(), DL, TII,
+   MF->getFunction().getCallingConv() ==
+   CallingConv::AMDGPU_PS);
 EarlyExitClearsExec = false;
   }
 
@@ -178,7 +184,6 @@ void SIInsertSkips::ensureEarlyExitBlock(MachineBasicBlock 
&MBB,
 unsigned Mov = ST.isWave32() ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64;
 Register Exec = ST.isWave32() ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
 auto ExitI = EarlyExitBlock->getFirstNonPHI();
-assert(ExitI->getOpcode() == AMDGPU::EXP_DONE);
 BuildMI(*EarlyExitBlock, ExitI, DL, TII->get(Mov), Exec).addImm(0);
 EarlyExitClearsExec = true;
   }
@@ -224,7 +229,7 @@ void SIInsertSkips::skipIfDead(MachineBasicBlock &MBB,
   I == MBB.end() && !llvm::is_contained(MBB.successors(), &*NextBBI);
 
   if (NoSuccessor) {
-generatePsEndPgm(MBB, I, DL, TII);
+generateEndPgm(MBB, I, DL, TII, true);
   } else {
 ensureEarlyExitBlock(MBB, false);
 
@@ -368,6 +373,23 @@ bool SIInsertSkips::kill(MachineInstr &MI) {
   }
 }
 
+void SIInsertSkips::earlyTerm(MachineInstr &MI) {
+  MachineBasicBlock &MBB = *MI.getParent();
+  const DebugLoc DL = MI.getDebugLoc();
+
+  ensureEarlyExitBlock(MBB, true);
+
+  auto BranchMI = BuildMI(MBB, MI, DL, TII->get(AMDGPU::S_CBRANCH_SCC0))
+  .addMBB(EarlyExitBlock);
+  auto Next = std::next(MI.getIterator());
+
+  if (Next != MBB.end() && !Next->isTerminator())
+splitBlock(MBB, *BranchMI, MDT);
+
+  MBB.addSuccessor(EarlyExitBlock);
+  MDT->getBase().insertEdge(&MBB, EarlyExitBlock);
+}
+
 // Returns true if a branch over the block was inserted.
 bool SIInsertSkips::skipMaskBranch(MachineInstr &MI,
MachineBasicBlock &SrcMBB) {
@@ -393,6 +415,7 @@ bool SIInsertSkips::runOnMachineFunction(MachineFunction 
&MF) {
   SkipThreshold = 

[llvm-branch-commits] [llvm] 157efd8 - [Statepoint Lowering] Add an option to allow use gc values in regs for landing pad

2021-01-12 Thread Serguei Katkov via llvm-branch-commits

Author: Serguei Katkov
Date: 2021-01-13T11:39:34+07:00
New Revision: 157efd84abf812c1689ba6a9ecb4da2b87dde756

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

LOG: [Statepoint Lowering] Add an option to allow use gc values in regs for 
landing pad

Default value is not changed, so it is NFC actually.

The option allows to use gc values on registers in landing pads.

Reviewers: reames, dantrushin
Reviewed By: reames, dantrushin
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D94469

Added: 


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

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index 5638feaf1540..0172646c22ec 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -64,6 +64,10 @@ cl::opt UseRegistersForDeoptValues(
 "use-registers-for-deopt-values", cl::Hidden, cl::init(false),
 cl::desc("Allow using registers for non pointer deopt args"));
 
+cl::opt UseRegistersForGCPointersInLandingPad(
+"use-registers-for-gc-values-in-landing-pad", cl::Hidden, cl::init(false),
+cl::desc("Allow using registers for gc pointer in landing pad"));
+
 cl::opt MaxRegistersForGCPointers(
 "max-registers-for-gc-values", cl::Hidden, cl::init(0),
 cl::desc("Max number of VRegs allowed to pass GC pointer meta args in"));
@@ -549,14 +553,15 @@ lowerStatepointMetaArgs(SmallVectorImpl &Ops,
   // Pointers used on exceptional path of invoke statepoint.
   // We cannot assing them to VRegs.
   SmallSet LPadPointers;
-  if (auto *StInvoke = dyn_cast_or_null(SI.StatepointInstr)) {
-LandingPadInst *LPI = StInvoke->getLandingPadInst();
-for (auto *Relocate : SI.GCRelocates)
-  if (Relocate->getOperand(0) == LPI) {
-LPadPointers.insert(Builder.getValue(Relocate->getBasePtr()));
-LPadPointers.insert(Builder.getValue(Relocate->getDerivedPtr()));
-  }
-  }
+  if (!UseRegistersForGCPointersInLandingPad)
+if (auto *StInvoke = dyn_cast_or_null(SI.StatepointInstr)) {
+  LandingPadInst *LPI = StInvoke->getLandingPadInst();
+  for (auto *Relocate : SI.GCRelocates)
+if (Relocate->getOperand(0) == LPI) {
+  LPadPointers.insert(Builder.getValue(Relocate->getBasePtr()));
+  LPadPointers.insert(Builder.getValue(Relocate->getDerivedPtr()));
+}
+}
 
   LLVM_DEBUG(dbgs() << "Deciding how to lower GC Pointers:\n");
 



___
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] fba9805 - [Verifier] Extend statepoint verifier to cover more constants

2021-01-12 Thread Serguei Katkov via llvm-branch-commits

Author: Serguei Katkov
Date: 2021-01-13T11:51:48+07:00
New Revision: fba9805ba3491db03ad538ea2db2f225f57ff98e

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

LOG: [Verifier] Extend statepoint verifier to cover more constants

Also old mir tests are updated to meet last changes in STATEPOINT format.

Reviewers: reames, dantrushin
Reviewed By: reames, dantrushin
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D94482

Added: 


Modified: 
llvm/include/llvm/CodeGen/StackMaps.h
llvm/lib/CodeGen/MachineVerifier.cpp
llvm/lib/CodeGen/StackMaps.cpp
llvm/test/CodeGen/X86/non-value-mem-operand.mir
llvm/test/CodeGen/X86/statepoint-fixup-call.mir
llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/StackMaps.h 
b/llvm/include/llvm/CodeGen/StackMaps.h
index b91c75a2db73..928d7cc6cc04 100644
--- a/llvm/include/llvm/CodeGen/StackMaps.h
+++ b/llvm/include/llvm/CodeGen/StackMaps.h
@@ -225,6 +225,15 @@ class StatepointOpers {
 return MI->getOperand(getNumDeoptArgsIdx()).getImm();
   }
 
+  /// Get index of number of gc map entries.
+  unsigned getNumGcMapEntriesIdx();
+
+  /// Get index of number of gc allocas.
+  unsigned getNumAllocaIdx();
+
+  /// Get index of number of GC pointers.
+  unsigned getNumGCPtrIdx();
+
   /// Get index of first GC pointer operand of -1 if there are none.
   int getFirstGCPtrIdx();
 

diff  --git a/llvm/lib/CodeGen/MachineVerifier.cpp 
b/llvm/lib/CodeGen/MachineVerifier.cpp
index e69688da57b9..41fdf2f83444 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -1647,6 +1647,10 @@ void MachineVerifier::visitMachineInstrBefore(const 
MachineInstr *MI) {
 }
 
 auto VerifyStackMapConstant = [&](unsigned Offset) {
+  if (Offset >= MI->getNumOperands()) {
+report("stack map constant to STATEPOINT is out of range!", MI);
+return;
+  }
   if (!MI->getOperand(Offset - 1).isImm() ||
   MI->getOperand(Offset - 1).getImm() != StackMaps::ConstantOp ||
   !MI->getOperand(Offset).isImm())
@@ -1655,6 +1659,9 @@ void MachineVerifier::visitMachineInstrBefore(const 
MachineInstr *MI) {
 VerifyStackMapConstant(SO.getCCIdx());
 VerifyStackMapConstant(SO.getFlagsIdx());
 VerifyStackMapConstant(SO.getNumDeoptArgsIdx());
+VerifyStackMapConstant(SO.getNumGCPtrIdx());
+VerifyStackMapConstant(SO.getNumAllocaIdx());
+VerifyStackMapConstant(SO.getNumGcMapEntriesIdx());
 
 // TODO: verify we have properly encoded deopt arguments
   } break;

diff  --git a/llvm/lib/CodeGen/StackMaps.cpp b/llvm/lib/CodeGen/StackMaps.cpp
index 5645e3062d41..220e85fe90dc 100644
--- a/llvm/lib/CodeGen/StackMaps.cpp
+++ b/llvm/lib/CodeGen/StackMaps.cpp
@@ -91,41 +91,52 @@ unsigned PatchPointOpers::getNextScratchIdx(unsigned 
StartIdx) const {
   return ScratchIdx;
 }
 
-int StatepointOpers::getFirstGCPtrIdx() {
-  unsigned NumDeoptsIdx = getNumDeoptArgsIdx();
-  unsigned NumDeoptArgs = MI->getOperand(NumDeoptsIdx).getImm();
+unsigned StatepointOpers::getNumGcMapEntriesIdx() {
+  // Take index of num of allocas and skip all allocas records.
+  unsigned CurIdx = getNumAllocaIdx();
+  unsigned NumAllocas = getConstMetaVal(*MI, CurIdx - 1);
+  CurIdx++;
+  while (NumAllocas--)
+CurIdx = StackMaps::getNextMetaArgIdx(MI, CurIdx);
+  return CurIdx + 1; // skip 
+}
 
-  unsigned CurIdx = NumDeoptsIdx + 1;
+unsigned StatepointOpers::getNumAllocaIdx() {
+  // Take index of num of gc ptrs and skip all gc ptr records.
+  unsigned CurIdx = getNumGCPtrIdx();
+  unsigned NumGCPtrs = getConstMetaVal(*MI, CurIdx - 1);
+  CurIdx++;
+  while (NumGCPtrs--)
+CurIdx = StackMaps::getNextMetaArgIdx(MI, CurIdx);
+  return CurIdx + 1; // skip 
+}
+
+unsigned StatepointOpers::getNumGCPtrIdx() {
+  // Take index of num of deopt args and skip all deopt records.
+  unsigned CurIdx = getNumDeoptArgsIdx();
+  unsigned NumDeoptArgs = getConstMetaVal(*MI, CurIdx - 1);
+  CurIdx++;
   while (NumDeoptArgs--) {
 CurIdx = StackMaps::getNextMetaArgIdx(MI, CurIdx);
   }
-  ++CurIdx; // 
-  unsigned NumGCPtrs = MI->getOperand(CurIdx).getImm();
+  return CurIdx + 1; // skip 
+}
+
+int StatepointOpers::getFirstGCPtrIdx() {
+  unsigned NumGCPtrsIdx = getNumGCPtrIdx();
+  unsigned NumGCPtrs = getConstMetaVal(*MI, NumGCPtrsIdx - 1);
   if (NumGCPtrs == 0)
 return -1;
-  ++CurIdx; // 
-  assert(CurIdx < MI->getNumOperands() && "Index points past operand list");
-  return (int)CurIdx;
+  ++NumGCPtrsIdx; // skip 
+  assert(NumGCPtrsIdx < MI->getNumOperands());
+  return (int)NumGCPtrsIdx;
 }
 
 unsigned StatepointOpers::getGCPointerMap(
 SmallVectorImpl> &GCMap) {
-  int FirstGCIdx = getFirstGCPtrIdx();
-  if (FirstGCI

[llvm-branch-commits] [llvm] 12fc9ca - [llvm] Remove redundant string initialization (NFC)

2021-01-12 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-12T21:43:46-08:00
New Revision: 12fc9ca3a4037a26d4bc0ac98213c846ad96e51b

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

LOG: [llvm] Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

Added: 


Modified: 
llvm/include/llvm/LTO/Config.h
llvm/lib/Analysis/CallPrinter.cpp
llvm/lib/Analysis/ConstraintSystem.cpp
llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
llvm/lib/Target/Mips/MipsRegisterBankInfo.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/tools/llvm-objdump/MachODump.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/utils/TableGen/CodeGenInstruction.cpp
llvm/utils/TableGen/CodeGenMapTable.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
llvm/utils/TableGen/RISCVCompressInstEmitter.cpp

Removed: 




diff  --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h
index c4bf370fa3dd..1a7595d75404 100644
--- a/llvm/include/llvm/LTO/Config.h
+++ b/llvm/include/llvm/LTO/Config.h
@@ -114,10 +114,10 @@ struct Config {
   std::string SplitDwarfOutput;
 
   /// Optimization remarks file path.
-  std::string RemarksFilename = "";
+  std::string RemarksFilename;
 
   /// Optimization remarks pass filter.
-  std::string RemarksPasses = "";
+  std::string RemarksPasses;
 
   /// Whether to emit optimization remarks with hotness informations.
   bool RemarksWithHotness = false;
@@ -138,7 +138,7 @@ struct Config {
   llvm::Optional RemarksHotnessThreshold = 0;
 
   /// The format used for serializing remarks (default: YAML).
-  std::string RemarksFormat = "";
+  std::string RemarksFormat;
 
   /// Whether to emit the pass manager debuggging informations.
   bool DebugPassManager = false;

diff  --git a/llvm/lib/Analysis/CallPrinter.cpp 
b/llvm/lib/Analysis/CallPrinter.cpp
index c3922d556023..872a91ad7cbf 100644
--- a/llvm/lib/Analysis/CallPrinter.cpp
+++ b/llvm/lib/Analysis/CallPrinter.cpp
@@ -196,7 +196,7 @@ struct DOTGraphTraits : public 
DefaultDOTGraphTraits {
 Function *F = Node->getFunction();
 if (F == nullptr)
   return "";
-std::string attrs = "";
+std::string attrs;
 if (ShowHeatColors) {
   uint64_t freq = CGInfo->getFreq(F);
   std::string color = getHeatColor(freq, CGInfo->getMaxFreq());

diff  --git a/llvm/lib/Analysis/ConstraintSystem.cpp 
b/llvm/lib/Analysis/ConstraintSystem.cpp
index 1d582802f8e7..9739c6af5769 100644
--- a/llvm/lib/Analysis/ConstraintSystem.cpp
+++ b/llvm/lib/Analysis/ConstraintSystem.cpp
@@ -116,7 +116,7 @@ void ConstraintSystem::dump(ArrayRef Names) 
const {
 for (unsigned I = 1, S = Row.size(); I < S; ++I) {
   if (Row[I] == 0)
 continue;
-  std::string Coefficient = "";
+  std::string Coefficient;
   if (Row[I] != 1)
 Coefficient = std::to_string(Row[I]) + " * ";
   Parts.push_back(Coefficient + Names[I - 1]);

diff  --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp 
b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
index f32278d07052..25fae5487187 100644
--- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -41,7 +41,7 @@ static cl::opt
cl::desc("Record GlobalISel rule coverage files of this "
 "prefix if instrumentation was generated"));
 #else
-static const std::string CoveragePrefix = "";
+static const std::string CoveragePrefix;
 #endif
 
 char InstructionSelect::ID = 0;

diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp 
b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 7bc5c98b89bc..32e8393a88e5 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -917,7 +917,7 @@ MCSection 
*TargetLoweringObjectFileELF::getSectionForMachineBasicBlock(
   }
 
   unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;
-  std::string GroupName = "";
+  std::string GroupName;
   if (F.hasComdat()) {
 Flags |= ELF::SHF_GROUP;
 GroupName = F.getComdat()->getName().str();

diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp 
b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
index e5e512672daa..2fbe707ce8df 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
@@ -352,7 +352,7 @@ class RuntimeDyldCheckerExprEval {
 RemainingExpr = RemainingExpr.substr(1).ltrim();
 

[llvm-branch-commits] [llvm] 2c2d489 - [CodeGen] Remove unused function isRegLiveInExitBlocks (NFC)

2021-01-12 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-12T21:43:48-08:00
New Revision: 2c2d489b78c43072b65f3d8c88c91def4c69f320

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

LOG: [CodeGen] Remove unused function isRegLiveInExitBlocks (NFC)

The last use was removed on Jan 17, 2020 in commit
42350cd893a9cf6c199b17441dc2ba526c7cca71.

Added: 


Modified: 
llvm/include/llvm/CodeGen/MachineLoopUtils.h
llvm/lib/CodeGen/MachineLoopUtils.cpp

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/MachineLoopUtils.h 
b/llvm/include/llvm/CodeGen/MachineLoopUtils.h
index 2cb0134ca848..ec0b3529c0d6 100644
--- a/llvm/include/llvm/CodeGen/MachineLoopUtils.h
+++ b/llvm/include/llvm/CodeGen/MachineLoopUtils.h
@@ -37,10 +37,6 @@ MachineBasicBlock *PeelSingleBlockLoop(LoopPeelDirection 
Direction,
MachineRegisterInfo &MRI,
const TargetInstrInfo *TII);
 
-/// Return true if PhysReg is live outside the loop, i.e. determine if it
-/// is live in the loop exit blocks, and false otherwise.
-bool isRegLiveInExitBlocks(MachineLoop *Loop, int PhysReg);
-
 } // namespace llvm
 
 #endif // LLVM_LIB_CODEGEN_MACHINELOOPUTILS_H

diff  --git a/llvm/lib/CodeGen/MachineLoopUtils.cpp 
b/llvm/lib/CodeGen/MachineLoopUtils.cpp
index 2295e1ca6d4e..fdcc8472f1c2 100644
--- a/llvm/lib/CodeGen/MachineLoopUtils.cpp
+++ b/llvm/lib/CodeGen/MachineLoopUtils.cpp
@@ -130,14 +130,3 @@ MachineBasicBlock 
*llvm::PeelSingleBlockLoop(LoopPeelDirection Direction,
 
   return NewBB;
 }
-
-bool llvm::isRegLiveInExitBlocks(MachineLoop *Loop, int PhysReg) {
-  SmallVector ExitBlocks;
-  Loop->getExitBlocks(ExitBlocks);
-
-  for (auto *MBB : ExitBlocks)
-if (MBB->isLiveIn(PhysReg))
-  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] 8a20e2b - [llvm] Use Optional::getValueOr (NFC)

2021-01-12 Thread Kazu Hirata via llvm-branch-commits

Author: Kazu Hirata
Date: 2021-01-12T21:43:50-08:00
New Revision: 8a20e2b3d3e149f9e40dc34673fce7953d985c24

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

LOG: [llvm] Use Optional::getValueOr (NFC)

Added: 


Modified: 
llvm/lib/Analysis/InlineAdvisor.cpp
llvm/lib/Target/ARC/ARCTargetMachine.cpp
llvm/lib/Target/AVR/AVRTargetMachine.cpp
llvm/lib/Target/BPF/BPFTargetMachine.cpp
llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
llvm/lib/Target/Sparc/SparcTargetMachine.cpp
llvm/lib/Target/VE/VETargetMachine.cpp
llvm/lib/Target/XCore/XCoreTargetMachine.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/InlineAdvisor.cpp 
b/llvm/lib/Analysis/InlineAdvisor.cpp
index c427230404e6..342a9e757ac6 100644
--- a/llvm/lib/Analysis/InlineAdvisor.cpp
+++ b/llvm/lib/Analysis/InlineAdvisor.cpp
@@ -100,8 +100,7 @@ llvm::Optional static 
getDefaultInlineAdvice(
  GetBFI, PSI, RemarksEnabled ? &ORE : nullptr);
   };
   return llvm::shouldInline(CB, GetInlineCost, ORE,
-Params.EnableDeferral.hasValue() &&
-Params.EnableDeferral.getValue());
+Params.EnableDeferral.getValueOr(false));
 }
 
 std::unique_ptr DefaultInlineAdvisor::getAdvice(CallBase &CB) {

diff  --git a/llvm/lib/Target/ARC/ARCTargetMachine.cpp 
b/llvm/lib/Target/ARC/ARCTargetMachine.cpp
index 4a5b6fd4d5bf..b8c8949e18dd 100644
--- a/llvm/lib/Target/ARC/ARCTargetMachine.cpp
+++ b/llvm/lib/Target/ARC/ARCTargetMachine.cpp
@@ -21,9 +21,7 @@
 using namespace llvm;
 
 static Reloc::Model getRelocModel(Optional RM) {
-  if (!RM.hasValue())
-return Reloc::Static;
-  return *RM;
+  return RM.getValueOr(Reloc::Static);
 }
 
 /// ARCTargetMachine ctor - Create an ILP32 architecture model

diff  --git a/llvm/lib/Target/AVR/AVRTargetMachine.cpp 
b/llvm/lib/Target/AVR/AVRTargetMachine.cpp
index 0c7136e6f77e..0fa8623e2fb7 100644
--- a/llvm/lib/Target/AVR/AVRTargetMachine.cpp
+++ b/llvm/lib/Target/AVR/AVRTargetMachine.cpp
@@ -37,7 +37,7 @@ static StringRef getCPU(StringRef CPU) {
 }
 
 static Reloc::Model getEffectiveRelocModel(Optional RM) {
-  return RM.hasValue() ? *RM : Reloc::Static;
+  return RM.getValueOr(Reloc::Static);
 }
 
 AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT,

diff  --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp 
b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
index c35a3192282f..c0244b9f2c74 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
@@ -57,9 +57,7 @@ static std::string computeDataLayout(const Triple &TT) {
 }
 
 static Reloc::Model getEffectiveRelocModel(Optional RM) {
-  if (!RM.hasValue())
-return Reloc::PIC_;
-  return *RM;
+  return RM.getValueOr(Reloc::PIC_);
 }
 
 BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,

diff  --git a/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp 
b/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
index 3e4e1b083f7a..1c13796e84b6 100644
--- a/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
+++ b/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
@@ -44,7 +44,7 @@ CSKYTargetMachine::CSKYTargetMachine(const Target &T, const 
Triple &TT,
  Optional CM,
  CodeGenOpt::Level OL, bool JIT)
 : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
-!RM.hasValue() ? Reloc::Static : *RM,
+RM.getValueOr(Reloc::Static),
 getEffectiveCodeModel(CM, CodeModel::Small), OL),
   TLOF(std::make_unique()) {
   initAsmInfo();

diff  --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp 
b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
index ba0f45fe09f7..9195bb3dc725 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
@@ -187,9 +187,7 @@ namespace llvm {
 } // end namespace llvm;
 
 static Reloc::Model getEffectiveRelocModel(Optional RM) {
-  if (!RM.hasValue())
-return Reloc::Static;
-  return *RM;
+  return RM.getValueOr(Reloc::Static);
 }
 
 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTarget() {

diff  --git a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp 
b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
index 69387119f1f4..a31f59214ec7 100644
--- a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
+++ b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
@@ -48,9 +48,7 @@ static std::string computeDataLayout() {
 }
 
 static Relo

[llvm-branch-commits] [llvm] f1d5cbb - [dsymutil] Add preliminary support for DWARF 5.

2021-01-12 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2021-01-12T21:55:41-08:00
New Revision: f1d5cbbdee5526bc86eac0a5652b115d9bc158e5

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

LOG: [dsymutil] Add preliminary support for DWARF 5.

Currently dsymutil will silently fail when processing binaries with
Dwarf 5 debug info. This patch adds rudimentary support for Dwarf 5 in
dsymutil.

 - Recognize relocations in the debug_addr section.
 - Recognize (a subset of) Dwarf 5 form values.
 - Emits valid Dwarf 5 compile unit header chains.

To simplify things (and avoid having to emit indexed sections) I decided
to emit the relocated addresses directly in the debug info section.

 - DW_FORM_strx gets relocated and rewritten to DW_FORM_strp
 - DW_FORM_addrx gets relocated and rewritten to DW_FORM_addr

Obviously there's a lot of work left, but this should be a step in the
right direction.

rdar://62345491

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

Added: 
llvm/test/tools/dsymutil/Inputs/private/tmp/dwarf5/dwarf5.o
llvm/test/tools/dsymutil/Inputs/private/tmp/dwarf5/dwarf5.out
llvm/test/tools/dsymutil/X86/dwarf5.test

Modified: 
llvm/include/llvm/DWARFLinker/DWARFLinker.h
llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
llvm/include/llvm/DWARFLinker/DWARFStreamer.h
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp
llvm/lib/DWARFLinker/DWARFStreamer.cpp
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
llvm/tools/dsymutil/DwarfLinkerForBinary.h

Removed: 




diff  --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h 
b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
index 97faad6b6180..7281966fc608 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
@@ -85,6 +85,9 @@ class AddressesMap {
   virtual bool applyValidRelocs(MutableArrayRef Data, uint64_t 
BaseOffset,
 bool IsLittleEndian) = 0;
 
+  /// Relocate the given address offset if a valid relocation exists.
+  virtual llvm::Expected relocateIndexedAddr(uint64_t Offset) = 0;
+
   /// Returns all valid functions address ranges(i.e., those ranges
   /// which points to sections with code).
   virtual RangesTy &getValidAddressRanges() = 0;
@@ -183,7 +186,8 @@ class DwarfEmitter {
   ///
   /// As a side effect, this also switches the current Dwarf version
   /// of the MC layer to the one of U.getOrigUnit().
-  virtual void emitCompileUnitHeader(CompileUnit &Unit) = 0;
+  virtual void emitCompileUnitHeader(CompileUnit &Unit,
+ unsigned DwarfVersion) = 0;
 
   /// Recursively emit the DIE tree rooted at \p Die.
   virtual void emitDIE(DIE &Die) = 0;

diff  --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h 
b/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
index 549a0ce4e4b7..a6310bcb5df1 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
@@ -159,7 +159,7 @@ class CompileUnit {
   /// Compute the end offset for this unit. Must be called after the CU's DIEs
   /// have been cloned.  \returns the next unit offset (which is also the
   /// current debug_info section size).
-  uint64_t computeNextUnitOffset();
+  uint64_t computeNextUnitOffset(uint16_t DwarfVersion);
 
   /// Keep track of a forward reference to DIE \p Die in \p RefUnit by \p
   /// Attr. The attribute should be fixed up later to point to the absolute

diff  --git a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h 
b/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
index de58f5dedf24..7b0851159252 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
@@ -64,7 +64,7 @@ class DwarfStreamer : public DwarfEmitter {
   ///
   /// As a side effect, this also switches the current Dwarf version
   /// of the MC layer to the one of U.getOrigUnit().
-  void emitCompileUnitHeader(CompileUnit &Unit) override;
+  void emitCompileUnitHeader(CompileUnit &Unit, unsigned DwarfVersion) 
override;
 
   /// Recursively emit the DIE tree rooted at \p Die.
   void emitDIE(DIE &Die) override;

diff  --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp 
b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 1595b31cb4f9..a09cbf9c95ea 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -419,7 +419,6 @@ void DWARFLinker::cleanupAuxiliarryData(LinkContext 
&Context) {
   DIEAlloc.Reset();
 }
 
-
 /// Check if a variable describing DIE should be kept.
 /// \returns updated TraversalFlags.
 unsigned DWARFLinker::shouldKeepVariableDIE(AddressesMap &RelocMgr,
@@ -845,9 +844,12 @@ void DWARFLinker::assignAbbrev(DIEAbbrev &Abbrev) {
 unsigned DWARFLinker::DI

[llvm-branch-commits] [compiler-rt] 0b99385 - [MSan] Partially revert some changes from D94552

2021-01-12 Thread Jianzhou Zhao via llvm-branch-commits

Author: Jianzhou Zhao
Date: 2021-01-13T07:03:17Z
New Revision: 0b99385e151c7cb674d6d29acfe92680f7148434

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

LOG: [MSan] Partially revert some changes from D94552

Because of line 55, actually aligned_beg always equals to beg.

Added: 


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

Removed: 




diff  --git a/compiler-rt/lib/msan/msan_poisoning.cpp 
b/compiler-rt/lib/msan/msan_poisoning.cpp
index 8f58432d528a..d121d45a1951 100644
--- a/compiler-rt/lib/msan/msan_poisoning.cpp
+++ b/compiler-rt/lib/msan/msan_poisoning.cpp
@@ -71,13 +71,12 @@ void CopyOrigin(const void *dst, const void *src, uptr size,
   if (beg < end) {
 // Align src up.
 uptr s = ((uptr)src + 3) & ~3UL;
-uptr aligned_beg = ((uptr)dst + 3) & ~3UL;
 // FIXME: factor out to msan_copy_origin_aligned
 if (__msan_get_track_origins() > 1) {
   u32 *src = (u32 *)MEM_TO_ORIGIN(s);
   u32 *src_s = (u32 *)MEM_TO_SHADOW(s);
-  u32 *src_end = (u32 *)MEM_TO_ORIGIN(s + (end - aligned_beg));
-  u32 *dst = (u32 *)MEM_TO_ORIGIN(aligned_beg);
+  u32 *src_end = (u32 *)MEM_TO_ORIGIN(s + (end - beg));
+  u32 *dst = (u32 *)MEM_TO_ORIGIN(beg);
   u32 src_o = 0;
   u32 dst_o = 0;
   for (; src < src_end; ++src, ++src_s, ++dst) {
@@ -89,9 +88,8 @@ void CopyOrigin(const void *dst, const void *src, uptr size,
 *dst = dst_o;
   }
 } else {
-  REAL(memcpy)
-  ((void *)MEM_TO_ORIGIN(aligned_beg), (void *)MEM_TO_ORIGIN(s),
-   end - aligned_beg);
+  REAL(memcpy)((void *)MEM_TO_ORIGIN(beg), (void *)MEM_TO_ORIGIN(s),
+   end - beg);
 }
   }
 }



___
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] 93ad0ed - [ELF] Drop .rel[a].debug_gnu_pub{names, types} for --gdb-index --emit-relocs

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

Author: Fangrui Song
Date: 2021-01-12T00:07:28-08:00
New Revision: 93ad0edf674125f19177054d8331a5e8910d3d98

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

LOG: [ELF] Drop .rel[a].debug_gnu_pub{names,types} for --gdb-index --emit-relocs

Fixes PR48693: --emit-relocs keeps relocation sections. --gdb-index drops
.debug_gnu_pubnames and .debug_gnu_pubtypes but not their relocation sections.
This can cause a null pointer dereference in `getOutputSectionName`.

Also delete debug-gnu-pubnames.s which is covered by gdb-index.s

Reviewed By: grimar

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

Added: 


Modified: 
lld/ELF/SyntheticSections.cpp
lld/test/ELF/gdb-index.s

Removed: 
lld/test/ELF/debug-gnu-pubnames.s



diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 9b5fb3f26c59..9a875bd7ec3e 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2879,6 +2879,13 @@ template  GdbIndexSection 
*GdbIndexSection::create() {
 else if (isec->name == ".debug_info")
   files.insert(isec->file);
   }
+  // Drop .rel[a].debug_gnu_pub{names,types} for --emit-relocs.
+  llvm::erase_if(inputSections, [](InputSectionBase *s) {
+if (auto *isec = dyn_cast(s))
+  if (InputSectionBase *rel = isec->getRelocatedSection())
+return !rel->isLive();
+return !s->isLive();
+  });
 
   std::vector chunks(files.size());
   std::vector> nameAttrs(files.size());

diff  --git a/lld/test/ELF/debug-gnu-pubnames.s 
b/lld/test/ELF/debug-gnu-pubnames.s
deleted file mode 100644
index 51a289e52558..
--- a/lld/test/ELF/debug-gnu-pubnames.s
+++ /dev/null
@@ -1,18 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-
-# RUN: ld.lld %t.o -o %t1.exe
-# RUN: llvm-readobj --sections %t1.exe | FileCheck %s
-# CHECK: .debug_gnu_pubnames
-# CHECK: .debug_gnu_pubtypes
-
-# RUN: ld.lld --gdb-index %t.o -o %t2.exe
-# RUN: llvm-readobj --sections %t2.exe | FileCheck %s --check-prefix=GDB
-# GDB-NOT: .debug_gnu_pubnames
-# GDB-NOT: .debug_gnu_pubtypes
-
-.section .debug_gnu_pubnames,"",@progbits
-.long 0
-
-.section .debug_gnu_pubtypes,"",@progbits
-.long 0

diff  --git a/lld/test/ELF/gdb-index.s b/lld/test/ELF/gdb-index.s
index 546590ab359e..54a01a2c0d51 100644
--- a/lld/test/ELF/gdb-index.s
+++ b/lld/test/ELF/gdb-index.s
@@ -5,7 +5,14 @@
 
 # RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=DISASM
 # RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s --check-prefix=DWARF
-# RUN: llvm-readelf -sections %t | FileCheck %s --check-prefix=SECTION
+
+## Drop .debug_gnu_pubnames and .debug_gnu_pubtypes.
+## Also drop their relocation sections if --emit-relocs is specified.
+# RUN: ld.lld --gdb-index --emit-relocs %t1.o %t2.o -o %t1
+# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=SECTION
+
+# SECTION-NOT: .debug_gnu_pubnames
+# SECTION-NOT: .debug_gnu_pubtypes
 
 # RUN: llvm-mc -compress-debug-sections=zlib-gnu -filetype=obj 
-triple=x86_64-pc-linux \
 # RUN:   %p/Inputs/gdb-index.s -o %t2.o
@@ -46,8 +53,6 @@
 # DWARF-NEXT:1(0x8): 0x3000
 # DWARF-NEXT:2(0x10): 0x9000 0x9001
 
-# SECTION-NOT: debug_gnu_pubnames
-
 # RUN: ld.lld --gdb-index --no-gdb-index %t1.o %t2.o -o %t2
 # RUN: llvm-readobj --sections %t2 | FileCheck -check-prefix=NOGDB %s
 # NOGDB-NOT: Name: .gdb_index
@@ -111,7 +116,7 @@ entrypoint:
 .section .debug_gnu_pubnames,"",@progbits
 .long 0x1e
 .value 0x2
-.long 0
+.long .debug_info
 .long 0x33
 .long 0x18
 .byte 0x30
@@ -121,7 +126,7 @@ entrypoint:
 .section .debug_gnu_pubtypes,"",@progbits
 .long 0x17
 .value 0x2
-.long 0
+.long .debug_info
 .long 0x33
 .long 0x2b
 .byte 0x90



___
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] 1cc5235 - [WebAssembly] Misc. refactoring in CFGStackify (NFC)

2021-01-12 Thread Heejin Ahn via llvm-branch-commits

Author: Heejin Ahn
Date: 2021-01-12T00:36:27-08:00
New Revision: 1cc5235712f2ed847f0b593714446d440e0596ba

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

LOG: [WebAssembly] Misc. refactoring in CFGStackify (NFC)

Updating `ScopeTops` is something we frequently do in CFGStackify, so
this factors it out as a function. This also makes a few utility
functions templated so that they are not dependent on input vector
types and simplifies function parameters.

Reviewed By: tlively

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

Added: 


Modified: 
llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp

Removed: 




diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index dbf0f92381c6..9a6d8df8bdca 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -57,6 +57,11 @@ class WebAssemblyCFGStackify final : public 
MachineFunctionPass {
   // which holds the beginning of the scope. This will allow us to quickly skip
   // over scoped regions when walking blocks.
   SmallVector ScopeTops;
+  void updateScopeTops(MachineBasicBlock *Begin, MachineBasicBlock *End) {
+int EndNo = End->getNumber();
+if (!ScopeTops[EndNo] || ScopeTops[EndNo]->getNumber() > 
Begin->getNumber())
+  ScopeTops[EndNo] = Begin;
+  }
 
   // Placing markers.
   void placeMarkers(MachineFunction &MF);
@@ -135,10 +140,10 @@ static bool explicitlyBranchesTo(MachineBasicBlock *Pred,
 // contains instructions that should go before the marker, and AfterSet 
contains
 // ones that should go after the marker. In this function, AfterSet is only
 // used for sanity checking.
+template 
 static MachineBasicBlock::iterator
-getEarliestInsertPos(MachineBasicBlock *MBB,
- const SmallPtrSet &BeforeSet,
- const SmallPtrSet &AfterSet) {
+getEarliestInsertPos(MachineBasicBlock *MBB, const Container &BeforeSet,
+ const Container &AfterSet) {
   auto InsertPos = MBB->end();
   while (InsertPos != MBB->begin()) {
 if (BeforeSet.count(&*std::prev(InsertPos))) {
@@ -159,10 +164,10 @@ getEarliestInsertPos(MachineBasicBlock *MBB,
 // contains instructions that should go before the marker, and AfterSet 
contains
 // ones that should go after the marker. In this function, BeforeSet is only
 // used for sanity checking.
+template 
 static MachineBasicBlock::iterator
-getLatestInsertPos(MachineBasicBlock *MBB,
-   const SmallPtrSet &BeforeSet,
-   const SmallPtrSet &AfterSet) {
+getLatestInsertPos(MachineBasicBlock *MBB, const Container &BeforeSet,
+   const Container &AfterSet) {
   auto InsertPos = MBB->begin();
   while (InsertPos != MBB->end()) {
 if (AfterSet.count(&*InsertPos)) {
@@ -351,10 +356,7 @@ void 
WebAssemblyCFGStackify::placeBlockMarker(MachineBasicBlock &MBB) {
   registerScope(Begin, End);
 
   // Track the farthest-spanning scope that ends at this point.
-  int Number = MBB.getNumber();
-  if (!ScopeTops[Number] ||
-  ScopeTops[Number]->getNumber() > Header->getNumber())
-ScopeTops[Number] = Header;
+  updateScopeTops(Header, &MBB);
 }
 
 /// Insert a LOOP marker for a loop starting at MBB (if it's a loop header).
@@ -422,8 +424,7 @@ void 
WebAssemblyCFGStackify::placeLoopMarker(MachineBasicBlock &MBB) {
   assert((!ScopeTops[AfterLoop->getNumber()] ||
   ScopeTops[AfterLoop->getNumber()]->getNumber() < MBB.getNumber()) &&
  "With block sorting the outermost loop for a block should be first.");
-  if (!ScopeTops[AfterLoop->getNumber()])
-ScopeTops[AfterLoop->getNumber()] = &MBB;
+  updateScopeTops(&MBB, AfterLoop);
 }
 
 void WebAssemblyCFGStackify::placeTryMarker(MachineBasicBlock &MBB) {
@@ -622,11 +623,8 @@ void 
WebAssemblyCFGStackify::placeTryMarker(MachineBasicBlock &MBB) {
   // catch |
   //   end_block --|
   // end_try
-  for (int Number : {Cont->getNumber(), MBB.getNumber()}) {
-if (!ScopeTops[Number] ||
-ScopeTops[Number]->getNumber() > Header->getNumber())
-  ScopeTops[Number] = Header;
-  }
+  for (auto *End : {&MBB, Cont})
+updateScopeTops(Header, End);
 }
 
 void WebAssemblyCFGStackify::removeUnnecessaryInstrs(MachineFunction &MF) {
@@ -742,10 +740,12 @@ static unsigned getCopyOpcode(const TargetRegisterClass 
*RC) {
 // not yet been added. So 'LLVM_ATTRIBUTE_UNUSED' is added to suppress the
 // warning. Remove the attribute after the new functionality is added.
 LLVM_ATTRIBUTE_UNUSED static void
-unstackifyVRegsUsedInSplitBB(MachineBasicBlock &MBB, MachineBasicBlock &Split,
- WebAssemblyFunctionInfo &MFI,
- Machin

[llvm-branch-commits] [clang] 215ed9b - Adapt CastExpr::getSubExprAsWritten to ConstantExpr

2021-01-12 Thread Stephan Bergmann via llvm-branch-commits

Author: Stephan Bergmann
Date: 2021-01-12T09:41:03+01:00
New Revision: 215ed9b33ccbe9858aeb65b357bdcff354be

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

LOG: Adapt CastExpr::getSubExprAsWritten to ConstantExpr

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

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/unittests/Tooling/CastExprTest.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index a274bf37a407..94b6adf489fe 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1765,7 +1765,7 @@ Expr *CastExpr::getSubExprAsWritten() {
 // subexpression describing the call; strip it off.
 if (E->getCastKind() == CK_ConstructorConversion)
   SubExpr =
-skipImplicitTemporary(cast(SubExpr)->getArg(0));
+
skipImplicitTemporary(cast(SubExpr->IgnoreImplicit())->getArg(0));
 else if (E->getCastKind() == CK_UserDefinedConversion) {
   assert((isa(SubExpr) ||
   isa(SubExpr)) &&

diff  --git a/clang/unittests/Tooling/CastExprTest.cpp 
b/clang/unittests/Tooling/CastExprTest.cpp
index a9e78d2155b4..cda963a6a897 100644
--- a/clang/unittests/Tooling/CastExprTest.cpp
+++ b/clang/unittests/Tooling/CastExprTest.cpp
@@ -34,4 +34,24 @@ TEST(CastExprTest, 
GetSubExprAsWrittenThroughMaterializedTemporary) {
 "S1 f(S2 s) { return static_cast(s); }\n");
 }
 
+// Verify that getSubExprAsWritten looks through a ConstantExpr in a scenario
+// like
+//
+//   CXXFunctionalCastExpr functional cast to struct S 
+//   `-ConstantExpr 'S'
+// |-value: Struct
+// `-CXXConstructExpr 'S' 'void (int)'
+//   `-IntegerLiteral 'int' 0
+TEST(CastExprTest, GetSubExprAsWrittenThroughConstantExpr) {
+CastExprVisitor Visitor;
+Visitor.OnExplicitCast = [](ExplicitCastExpr *Expr) {
+  auto *Sub = Expr->getSubExprAsWritten();
+  EXPECT_TRUE(isa(Sub))
+<< "Expected IntegerLiteral, but saw " << Sub->getStmtClassName();
+};
+Visitor.runOver("struct S { consteval S(int) {} };\n"
+"S f() { return S(0); }\n",
+CastExprVisitor::Lang_CXX2a);
+}
+
 }



___
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] c8a914d - [LiveDebugValues] Fix comparison operator in VarLocBasedImpl

2021-01-12 Thread Sander de Smalen via llvm-branch-commits

Author: Sander de Smalen
Date: 2021-01-12T08:44:58Z
New Revision: c8a914db5c60dbeb5b638f30a9915855a67805f7

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

LOG: [LiveDebugValues] Fix comparison operator in VarLocBasedImpl

The issue was introduced in commit rG84a1120943a651184bae507fed5d648fee381ae4
and would cause a VarLoc's StackOffset to be compared with its own, instead of
the StackOffset from the other VarLoc. This patch fixes that.

Added: 


Modified: 
llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index 4811b8046797..e2daa46fe6b9 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -572,8 +572,9 @@ class VarLocBasedLDV : public LDVImpl {
Expr) <
std::make_tuple(
Other.Var, Other.Kind, Other.Loc.SpillLocation.SpillBase,
-   Loc.SpillLocation.SpillOffset.getFixed(),
-   Loc.SpillLocation.SpillOffset.getScalable(), Other.Expr);
+   Other.Loc.SpillLocation.SpillOffset.getFixed(),
+   Other.Loc.SpillLocation.SpillOffset.getScalable(),
+   Other.Expr);
   case RegisterKind:
   case ImmediateKind:
   case EntryValueKind:



___
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] 6a19549 - [AMDGPU] Fix failing assert with scratch ST mode

2021-01-12 Thread Sebastian Neubauer via llvm-branch-commits

Author: Sebastian Neubauer
Date: 2021-01-12T09:54:02+01:00
New Revision: 6a195491b6028185c7278718ac21bca309a6c4ea

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

LOG: [AMDGPU] Fix failing assert with scratch ST mode

In ST mode, flat scratch instructions have neither an sgpr nor a vgpr
for the address. This lead to an assertion when inserting hard clauses.

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetInstrInfo.h
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/test/CodeGen/AMDGPU/memory_clause.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h 
b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
index 1cf205f9f5a3..36afdefd27b2 100644
--- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -1298,10 +1298,11 @@ class TargetInstrInfo : public MCInstrInfo {
bool &OffsetIsScalable,
const TargetRegisterInfo *TRI) const;
 
-  /// Get the base operands and byte offset of an instruction that reads/writes
-  /// memory.
+  /// Get zero or more base operands and the byte offset of an instruction that
+  /// reads/writes memory. Note that there may be zero base operands if the
+  /// instruction accesses a constant address.
   /// It returns false if MI does not read/write memory.
-  /// It returns false if no base operands and offset was found.
+  /// It returns false if base operands and offset could not be determined.
   /// It is not guaranteed to always recognize base operands and offsets in all
   /// cases.
   virtual bool getMemOperandsWithOffsetWidth(

diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index eebee8e16bc3..6bf9db3f7b2c 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -387,7 +387,7 @@ bool SIInstrInfo::getMemOperandsWithOffsetWidth(
   }
 
   if (isFLAT(LdSt)) {
-// Instructions have either vaddr or saddr or both.
+// Instructions have either vaddr or saddr or both or none.
 BaseOp = getNamedOperand(LdSt, AMDGPU::OpName::vaddr);
 if (BaseOp)
   BaseOps.push_back(BaseOp);
@@ -443,11 +443,15 @@ bool SIInstrInfo::shouldClusterMemOps(ArrayRef BaseOps1,
   unsigned NumBytes) const {
   // If the mem ops (to be clustered) do not have the same base ptr, then they
   // should not be clustered
-  assert(!BaseOps1.empty() && !BaseOps2.empty());
-  const MachineInstr &FirstLdSt = *BaseOps1.front()->getParent();
-  const MachineInstr &SecondLdSt = *BaseOps2.front()->getParent();
-  if (!memOpsHaveSameBasePtr(FirstLdSt, BaseOps1, SecondLdSt, BaseOps2))
+  if (!BaseOps1.empty() && !BaseOps2.empty()) {
+const MachineInstr &FirstLdSt = *BaseOps1.front()->getParent();
+const MachineInstr &SecondLdSt = *BaseOps2.front()->getParent();
+if (!memOpsHaveSameBasePtr(FirstLdSt, BaseOps1, SecondLdSt, BaseOps2))
+  return false;
+  } else if (!BaseOps1.empty() || !BaseOps2.empty()) {
+// If only one base op is empty, they do not have the same base ptr
 return false;
+  }
 
   // In order to avoid regester pressure, on an average, the number of DWORDS
   // loaded together by all clustered mem ops should not exceed 8. This is an

diff  --git a/llvm/test/CodeGen/AMDGPU/memory_clause.ll 
b/llvm/test/CodeGen/AMDGPU/memory_clause.ll
index 2c5931ef57b6..154d8e3320ea 100644
--- a/llvm/test/CodeGen/AMDGPU/memory_clause.ll
+++ b/llvm/test/CodeGen/AMDGPU/memory_clause.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -march=amdgcn -mcpu=gfx902 -verify-machineinstrs < %s | FileCheck 
-check-prefix=GCN %s
+; RUN: llc -march=amdgcn -mcpu=gfx1030 -amdgpu-enable-flat-scratch 
-verify-machineinstrs < %s | FileCheck -check-prefix=GCN-SCRATCH %s
 
 define amdgpu_kernel void @vector_clause(<4 x i32> addrspace(1)* noalias 
nocapture readonly %arg, <4 x i32> addrspace(1)* noalias nocapture %arg1) {
 ; GCN-LABEL: vector_clause:
@@ -21,6 +22,31 @@ define amdgpu_kernel void @vector_clause(<4 x i32> 
addrspace(1)* noalias nocaptu
 ; GCN-NEXT:s_waitcnt vmcnt(3)
 ; GCN-NEXT:global_store_dwordx4 v16, v[12:15], s[4:5] offset:48
 ; GCN-NEXT:s_endpgm
+;
+; GCN-SCRATCH-LABEL: vector_clause:
+; GCN-SCRATCH:   ; %bb.0: ; %bb
+; GCN-SCRATCH-NEXT:s_add_u32 s2, s2, s5
+; GCN-SCRATCH-NEXT:s_addc_u32 s3, s3, 0
+; GCN-SCRATCH-NEXT:s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s2
+; GCN-SCRATCH-NEXT:s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s3
+; GCN-SCRATCH-NEXT:s_load_dwordx2 s[2:3], s[0:1], 0x24
+; GCN-SCRATCH-NEXT:v_lshlrev_b32_e32 v16, 4, v0
+; GCN-SCRATCH-NEXT:s

[llvm-branch-commits] [clang] 7ab8030 - [clang][cli] Remove -f[no-]trapping-math from -cc1 command line

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

Author: Jan Svoboda
Date: 2021-01-12T10:00:23+01:00
New Revision: 7ab803095ae58445996dc4694acb216e3a32ee64

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

LOG: [clang][cli] Remove -f[no-]trapping-math from -cc1 command line

This patch removes the -f[no-]trapping-math flags from the -cc1 command line. 
These flags are ignored in the command line parser and their semantics is fully 
handled by -ffp-exception-mode.

This patch does not remove -f[no-]trapping-math from the driver command line. 
The driver flags are being used and do affect compilation.

Reviewed By: dexonsmith, SjoerdMeijer

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp
clang/test/CodeGen/noexceptionsfpmath.c
clang/test/CodeGenCUDA/propagate-metadata.cu
clang/test/Driver/fast-math.c
clang/test/Driver/fp-model.c
clang/test/Parser/fp-floatcontrol-syntax.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b18c89931cee..35643701f97e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1600,8 +1600,8 @@ def frounding_math : Flag<["-"], "frounding-math">, 
Group, Flags<[CC1Op
   MarshallingInfoFlag<"LangOpts->FPRoundingMode", 
"llvm::RoundingMode::NearestTiesToEven">,
   Normalizer<"makeFlagToValueNormalizer(llvm::RoundingMode::Dynamic)">;
 def fno_rounding_math : Flag<["-"], "fno-rounding-math">, Group, 
Flags<[CC1Option]>;
-def ftrapping_math : Flag<["-"], "ftrapping-math">, Group, 
Flags<[CC1Option]>;
-def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group, 
Flags<[CC1Option]>;
+def ftrapping_math : Flag<["-"], "ftrapping-math">, Group;
+def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group;
 def ffp_contract : Joined<["-"], "ffp-contract=">, Group,
   Flags<[CC1Option]>, HelpText<"Form fused FP ops (e.g. FMAs):"
   " fast (fuses across statements disregarding pragmas)"

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index be4fe7f8eddd..4a20936ddda1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2833,9 +2833,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   if (TrappingMath) {
 // FP Exception Behavior is also set to strict
 assert(FPExceptionBehavior.equals("strict"));
-CmdArgs.push_back("-ftrapping-math");
-  } else if (TrappingMathPresent)
-CmdArgs.push_back("-fno-trapping-math");
+  }
 
   // The default is IEEE.
   if (DenormalFPMath != llvm::DenormalMode::getIEEE()) {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 07906f4a36ef..cc3b038a7746 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2684,14 +2684,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
-  if (Args.hasArg(OPT_ftrapping_math)) {
-Opts.setFPExceptionMode(LangOptions::FPE_Strict);
-  }
-
-  if (Args.hasArg(OPT_fno_trapping_math)) {
-Opts.setFPExceptionMode(LangOptions::FPE_Ignore);
-  }
-
   LangOptions::FPExceptionModeKind FPEB = LangOptions::FPE_Ignore;
   if (Arg *A = Args.getLastArg(OPT_ffp_exception_behavior_EQ)) {
 StringRef Val = A->getValue();

diff  --git a/clang/test/CodeGen/fpconstrained.c 
b/clang/test/CodeGen/fpconstrained.c
index 0307ebbd357f..643c0120eac5 100644
--- a/clang/test/CodeGen/fpconstrained.c
+++ b/clang/test/CodeGen/fpconstrained.c
@@ -1,11 +1,11 @@
-// RUN: %clang_cc1 -ftrapping-math -frounding-math 
-ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm 
-o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s 
-check-prefix=PRECISE
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -emit-llvm -o - %s | 
FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -ffast-math -emit-llvm -o - %s | FileCheck %s 
-check-prefix=FASTNOCONTRACT
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s 
-check-prefix=FAST
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm 

[llvm-branch-commits] [llvm] e8287cb - [Test] Add failing test for PR48725

2021-01-12 Thread Max Kazantsev via llvm-branch-commits

Author: Max Kazantsev
Date: 2021-01-12T16:06:34+07:00
New Revision: e8287cb2b2923af9da72fd953e2ec5495c33861a

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

LOG: [Test] Add failing test for PR48725

Added: 
llvm/test/Transforms/LoopStrengthReduce/pr48725.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/LoopStrengthReduce/pr48725.ll 
b/llvm/test/Transforms/LoopStrengthReduce/pr48725.ll
new file mode 100644
index ..ef25b92ffd1c
--- /dev/null
+++ b/llvm/test/Transforms/LoopStrengthReduce/pr48725.ll
@@ -0,0 +1,102 @@
+; RUN: opt -S -loop-reduce < %s | FileCheck %s
+; XFAIL: *
+
+source_filename = "./simple.ll"
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK-LABEL: test
+define void @test() {
+bb:
+  br label %bb1
+
+bb1:  ; preds = %bb1, %bb
+  %tmp = phi i32 [ undef, %bb ], [ %tmp87, %bb1 ]
+  %tmp2 = phi i32 [ undef, %bb ], [ %tmp86, %bb1 ]
+  %tmp3 = mul i32 %tmp, undef
+  %tmp4 = xor i32 %tmp3, -1
+  %tmp5 = add i32 %tmp, %tmp4
+  %tmp6 = add i32 %tmp2, -1
+  %tmp7 = add i32 %tmp5, %tmp6
+  %tmp8 = mul i32 %tmp7, %tmp3
+  %tmp9 = xor i32 %tmp8, -1
+  %tmp10 = add i32 %tmp7, %tmp9
+  %tmp11 = add i32 %tmp10, undef
+  %tmp12 = mul i32 %tmp11, %tmp8
+  %tmp13 = xor i32 %tmp12, -1
+  %tmp14 = add i32 %tmp11, %tmp13
+  %tmp15 = add i32 %tmp14, undef
+  %tmp16 = mul i32 %tmp15, %tmp12
+  %tmp17 = add i32 %tmp15, undef
+  %tmp18 = add i32 %tmp17, undef
+  %tmp19 = mul i32 %tmp18, %tmp16
+  %tmp20 = xor i32 %tmp19, -1
+  %tmp21 = add i32 %tmp18, %tmp20
+  %tmp22 = add i32 %tmp21, undef
+  %tmp23 = mul i32 %tmp22, %tmp19
+  %tmp24 = xor i32 %tmp23, -1
+  %tmp25 = add i32 %tmp22, %tmp24
+  %tmp26 = add i32 %tmp25, undef
+  %tmp27 = mul i32 %tmp26, %tmp23
+  %tmp28 = xor i32 %tmp27, -1
+  %tmp29 = add i32 %tmp26, %tmp28
+  %tmp30 = add i32 %tmp29, undef
+  %tmp31 = mul i32 %tmp30, %tmp27
+  %tmp32 = xor i32 %tmp31, -1
+  %tmp33 = add i32 %tmp30, %tmp32
+  %tmp34 = add i32 %tmp33, undef
+  %tmp35 = mul i32 %tmp34, %tmp31
+  %tmp36 = xor i32 %tmp35, -1
+  %tmp37 = add i32 %tmp34, %tmp36
+  %tmp38 = add i32 %tmp2, -9
+  %tmp39 = add i32 %tmp37, %tmp38
+  %tmp40 = mul i32 %tmp39, %tmp35
+  %tmp41 = xor i32 %tmp40, -1
+  %tmp42 = add i32 %tmp39, %tmp41
+  %tmp43 = add i32 %tmp42, undef
+  %tmp44 = mul i32 %tmp43, %tmp40
+  %tmp45 = xor i32 %tmp44, -1
+  %tmp46 = add i32 %tmp43, %tmp45
+  %tmp47 = add i32 %tmp46, undef
+  %tmp48 = mul i32 %tmp47, %tmp44
+  %tmp49 = xor i32 %tmp48, -1
+  %tmp50 = add i32 %tmp47, %tmp49
+  %tmp51 = add i32 %tmp50, undef
+  %tmp52 = mul i32 %tmp51, %tmp48
+  %tmp53 = xor i32 %tmp52, -1
+  %tmp54 = add i32 %tmp51, %tmp53
+  %tmp55 = add i32 %tmp54, undef
+  %tmp56 = mul i32 %tmp55, %tmp52
+  %tmp57 = xor i32 %tmp56, -1
+  %tmp58 = add i32 %tmp55, %tmp57
+  %tmp59 = add i32 %tmp2, -14
+  %tmp60 = add i32 %tmp58, %tmp59
+  %tmp61 = mul i32 %tmp60, %tmp56
+  %tmp62 = xor i32 %tmp61, -1
+  %tmp63 = add i32 %tmp60, %tmp62
+  %tmp64 = add i32 %tmp63, undef
+  %tmp65 = mul i32 %tmp64, %tmp61
+  %tmp66 = xor i32 %tmp65, -1
+  %tmp67 = add i32 %tmp64, %tmp66
+  %tmp68 = add i32 %tmp67, undef
+  %tmp69 = mul i32 %tmp68, %tmp65
+  %tmp70 = xor i32 %tmp69, -1
+  %tmp71 = add i32 %tmp68, %tmp70
+  %tmp72 = add i32 %tmp71, undef
+  %tmp73 = mul i32 %tmp72, %tmp69
+  %tmp74 = xor i32 %tmp73, -1
+  %tmp75 = add i32 %tmp72, %tmp74
+  %tmp76 = add i32 %tmp75, undef
+  %tmp77 = mul i32 %tmp76, %tmp73
+  %tmp78 = xor i32 %tmp77, -1
+  %tmp79 = add i32 %tmp76, %tmp78
+  %tmp80 = add i32 %tmp79, undef
+  %tmp81 = mul i32 %tmp80, %tmp77
+  %tmp82 = xor i32 %tmp81, -1
+  %tmp83 = add i32 %tmp80, %tmp82
+  %tmp84 = add i32 %tmp83, undef
+  %tmp85 = add i32 %tmp84, undef
+  %tmp86 = add i32 %tmp2, -21
+  %tmp87 = add i32 %tmp85, %tmp86
+  br label %bb1
+}



___
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] c93b955 - [WebAssembly] Remove more unnecessary brs in CFGStackify

2021-01-12 Thread Heejin Ahn via llvm-branch-commits

Author: Heejin Ahn
Date: 2021-01-12T01:18:10-08:00
New Revision: c93b95593907c28cbcfde3d8266801587e110b42

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

LOG: [WebAssembly] Remove more unnecessary brs in CFGStackify

After placing markers, we removed some unnecessary branches, but it only
handled the simplest case. This makes more unnecessary branches to be
removed.

Reviewed By: dschuff, tlively

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

Added: 


Modified: 
llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll

Removed: 




diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index 9a6d8df8bdca6..a8e0c3efea0e2 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -637,11 +637,32 @@ void 
WebAssemblyCFGStackify::removeUnnecessaryInstrs(MachineFunction &MF) {
   //   try
   // ...
   // br bb2  <- Not necessary
-  // bb1:
+  // bb1 (ehpad):
   //   catch
   // ...
-  // bb2:
+  // bb2:<- Continuation BB
   //   end
+  //
+  // A more involved case: When the BB where 'end' is located is an another EH
+  // pad, the Cont (= continuation) BB is that EH pad's 'end' BB. For example,
+  // bb0:
+  //   try
+  // try
+  //   ...
+  //   br bb3  <- Not necessary
+  // bb1 (ehpad):
+  // catch
+  // bb2 (ehpad):
+  // end
+  //   catch
+  // ...
+  // bb3:<- Continuation BB
+  //   end
+  //
+  // When the EH pad at hand is bb1, its matching end_try is in bb2. But it is
+  // another EH pad, so bb0's continuation BB becomes bb3. So 'br bb3' in the
+  // code can be deleted. This is why we run 'while' until 'Cont' is not an EH
+  // pad.
   for (auto &MBB : MF) {
 if (!MBB.isEHPad())
   continue;
@@ -649,7 +670,14 @@ void 
WebAssemblyCFGStackify::removeUnnecessaryInstrs(MachineFunction &MF) {
 MachineBasicBlock *TBB = nullptr, *FBB = nullptr;
 SmallVector Cond;
 MachineBasicBlock *EHPadLayoutPred = MBB.getPrevNode();
-MachineBasicBlock *Cont = BeginToEnd[EHPadToTry[&MBB]]->getParent();
+
+MachineBasicBlock *Cont = &MBB;
+while (Cont->isEHPad()) {
+  MachineInstr *Try = EHPadToTry[Cont];
+  MachineInstr *EndTry = BeginToEnd[Try];
+  Cont = EndTry->getParent();
+}
+
 bool Analyzable = !TII.analyzeBranch(*EHPadLayoutPred, TBB, FBB, Cond);
 // This condition means either
 // 1. This BB ends with a single unconditional branch whose destinaion is

diff  --git a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll 
b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll
index 3079d9e15b82f..209aaea2aaf69 100644
--- a/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll
+++ b/llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll
@@ -935,7 +935,18 @@ last: ; preds 
= %bb0
 }
 
 ; Tests if CFGStackify's removeUnnecessaryInstrs() removes unnecessary branches
-; correctly.
+; correctly. The code is in the form below, where 'br' is unnecessary because
+; after running the 'try' body the control flow will fall through to bb2 
anyway.
+
+; bb0:
+;   try
+; ...
+; br bb2  <- Not necessary
+; bb1 (ehpad):
+;   catch
+; ...
+; bb2:<- Continuation BB
+;   end
 ; CHECK-LABEL: test17
 define void @test17(i32 %n) personality i8* bitcast (i32 (...)* 
@__gxx_wasm_personality_v0 to i8*) {
 entry:
@@ -974,17 +985,91 @@ try.cont: ; preds 
= %catch.start, %for.e
   ret void
 }
 
+; void foo();
+; void test18() {
+;   try {
+; foo();
+; try {
+;   foo();
+; } catch (...) {
+; }
+;   } catch (...) {
+;   }
+; }
+;
+; This tests whether the 'br' can be removed in code in the form as follows.
+; Here 'br' is inside an inner try, whose 'end' is in another EH pad. In this
+; case, after running an inner try body, the control flow should fall through 
to
+; bb3, so the 'br' in the code is unnecessary.
+
+; bb0:
+;   try
+; try
+;   ...
+;   br bb3  <- Not necessary
+; bb1:
+; catch
+; bb2:
+; end_try
+;   catch
+; ...
+; bb3:<- Continuation BB
+;   end
+;
+; CHECK-LABEL: test18
+define void @test18() personality i8* bitcast (i32 (...)* 
@__gxx_wasm_personality_v0 to i8*) {
+; CHECK: call foo
+entry:
+  invoke void @foo()
+  to label %invoke.cont unwind label %catch.dispatch3
+
+; CHECK: call foo
+; CHECK-NOT: br
+invoke.cont:  ; preds = %entry
+  invoke void @foo()
+  to label %try.cont8 unwind label %catch.dispatch
+
+catch.dispatch:   ; preds

  1   2   >