[llvm-branch-commits] [llvm] bdef1f8 - [llvm-readobj] - Dump the ELF file type better.

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

Author: Georgii Rymar
Date: 2020-12-23T11:13:19+03:00
New Revision: bdef1f87aba656a64b34f76d2a6613b6e9299a03

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

LOG: [llvm-readobj] - Dump the ELF file type better.

Currently llvm-readelf might print "OS Specific/Processor Specific/"
hint when dumping the ELF file type. The patch teaches llvm-readobj to do the 
same.

This fixes https://bugs.llvm.org/show_bug.cgi?id=40868

I am removing `Object/elf-unknown-type.test` test because it is not in the 
right place,
it is outdated and very limited.
The `readobj/ELF/file-types.test` checks the functionality much better.

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

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/file-types.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 
llvm/test/Object/elf-unknown-type.test



diff  --git a/llvm/test/Object/elf-unknown-type.test 
b/llvm/test/Object/elf-unknown-type.test
deleted file mode 100644
index 508e831ae90e..
--- a/llvm/test/Object/elf-unknown-type.test
+++ /dev/null
@@ -1,10 +0,0 @@
-# RUN: yaml2obj %s | llvm-readobj --file-headers - | FileCheck %s
-
-!ELF
-FileHeader: !FileHeader
-  Class: ELFCLASS64
-  Data: ELFDATA2LSB
-  Type: 42
-  Machine: EM_X86_64
-
-# CHECK: Type: 0x2A

diff  --git a/llvm/test/tools/llvm-readobj/ELF/file-types.test 
b/llvm/test/tools/llvm-readobj/ELF/file-types.test
index 767ce4d646ff..f06f302b8642 100644
--- a/llvm/test/tools/llvm-readobj/ELF/file-types.test
+++ b/llvm/test/tools/llvm-readobj/ELF/file-types.test
@@ -62,7 +62,7 @@ FileHeader:
 # RUN: llvm-readelf -h %t.unknown | FileCheck %s --match-full-lines 
--check-prefix GNU-UNNKNOWN
 
 # LLVM-UNNKNOWN: ElfHeader {
-# LLVM-UNNKNOWN:   Type: 0xFDFF
+# LLVM-UNNKNOWN:   Type: Unknown (0xFDFF)
 
 # GNU-UNNKNOWN: ELF Header:
 # GNU-UNNKNOWN:   Type: : fdff
@@ -72,7 +72,7 @@ FileHeader:
 # RUN: llvm-readelf -h %t6 | FileCheck %s --match-full-lines --check-prefix 
GNU-LOOS
 
 # LLVM-LOOS: ElfHeader {
-# LLVM-LOOS:   Type: 0xFE00
+# LLVM-LOOS:   Type: OS Specific (0xFE00)
 
 # GNU-LOOS: ELF Header:
 # GNU-LOOS:   Type: OS Specific: (fe00)
@@ -82,7 +82,7 @@ FileHeader:
 # RUN: llvm-readelf -h %t7 | FileCheck %s --match-full-lines --check-prefix 
GNU-HIOS
 
 # LLVM-HIOS: ElfHeader {
-# LLVM-HIOS:   Type: 0xFEFF
+# LLVM-HIOS:   Type: OS Specific (0xFEFF)
 
 # GNU-HIOS: ELF Header:
 # GNU-HIOS:   Type: OS Specific: (feff)
@@ -92,7 +92,7 @@ FileHeader:
 # RUN: llvm-readelf -h %t8 | FileCheck %s --match-full-lines --check-prefix 
GNU-LOPROC
 
 # LLVM-LOPROC: ElfHeader {
-# LLVM-LOPROC:   Type: 0xFF00
+# LLVM-LOPROC:   Type: Processor Specific (0xFF00)
 
 # GNU-LOPROC: ELF Header:
 # GNU-LOPROC:   Type: Processor Specific: (ff00)
@@ -102,7 +102,7 @@ FileHeader:
 # RUN: llvm-readelf -h %t9 | FileCheck %s --match-full-lines --check-prefix 
GNU-HIPROC
 
 # LLVM-HIPROC: ElfHeader {
-# LLVM-HIPROC:   Type: 0x
+# LLVM-HIPROC:   Type: Processor Specific (0x)
 
 # GNU-HIPROC: ELF Header:
 # GNU-HIPROC:   Type: Processor Specific: ()

diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index a82494ad1b4d..00f8c3fcefac 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3515,6 +3515,15 @@ static std::string 
getSectionHeaderTableIndexString(const ELFFile &Obj,
  to_string((*ArrOrErr)[0].sh_link) + ")";
 }
 
+static const EnumEntry *getObjectFileEnumEntry(unsigned Type) {
+  auto It = llvm::find_if(ElfObjectFileType, [&](const EnumEntry &E) 
{
+return E.Value == Type;
+  });
+  if (It != makeArrayRef(ElfObjectFileType).end())
+return It;
+  return nullptr;
+}
+
 template  void GNUStyle::printFileHeaders() {
   const Elf_Ehdr &e = this->Obj.getHeader();
   OS << "ELF Header:\n";
@@ -3539,17 +3548,15 @@ template  void 
GNUStyle::printFileHeaders() {
   printFields(OS,
   "ABI Version:", std::to_string(e.e_ident[ELF::EI_ABIVERSION]));
 
-  Str = printEnum(e.e_type, makeArrayRef(ElfObjectFileType));
-  if (makeArrayRef(ElfObjectFileType).end() ==
-  llvm::find_if(ElfObjectFileType, [&](const EnumEntry &E) {
-return E.Value == e.e_type;
-  })) {
+  if (const EnumEntry *E = getObjectFileEnumEntry(e.e_type)) {
+Str = E->AltName.str();
+  } else {
 if (e.e_type >= ET_LOPROC)
-  Str = "Processor Specific: (" + Str + ")";
+  Str = "Processor Specific: (" + to_hexString(e.e_type, false) + ")";
 else if (e.e_type >= ET_LOOS)
-  Str = "OS Specific: (" + Str + ")";
+  Str = "OS Specific: (" + to_hexString(e.e_type, false) + ")";
 else
-  Str = ": " + Str;
+  Str = ": " + to_hexString(e.e_type, false);
   }
   printFields(OS, "Type:", Str);
 
@@ -6343,7 +6350,19 @@ template  void 
LLVMSt

[llvm-branch-commits] [mlir] 65ba0cd - [mlir] Modernize std-to-llvm operation conversion doc

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

Author: Alex Zinenko
Date: 2020-12-23T11:19:58+01:00
New Revision: 65ba0cd3955f8c609ff314dc0cda7bc8ded4a083

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

LOG: [mlir] Modernize std-to-llvm operation conversion doc

This was long overdue. Replace the outdated type syntax with the new syntax,
and update the description of how memref load/stores are handled to reflect the
latest changes in the implementation.

Reviewed By: herhut

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

Added: 
mlir/docs/LLVMDialectMemRefConvention.md

Modified: 
mlir/docs/ConversionToLLVMDialect.md

Removed: 




diff  --git a/mlir/docs/ConversionToLLVMDialect.md 
b/mlir/docs/ConversionToLLVMDialect.md
index 778eea6184c9..2b5f98b37686 100644
--- a/mlir/docs/ConversionToLLVMDialect.md
+++ b/mlir/docs/ConversionToLLVMDialect.md
@@ -280,470 +280,3 @@ Examples:
 !llvm.func, ptr, i64)>,
struct<(ptr, ptr, i64)>)> ()>
 ```
-
-## Calling Convention for Standard Calls
-
-
-
-### Result Packing
-
-In case of multi-result functions, the returned values are inserted into a
-structure-typed value before being returned and extracted from it at the call
-site. This transformation is a part of the conversion and is transparent to the
-defines and uses of the values being returned.
-
-Example:
-
-```mlir
-func @foo(%arg0: i32, %arg1: i64) -> (i32, i64) {
-  return %arg0, %arg1 : i32, i64
-}
-func @bar() {
-  %0 = constant 42 : i32
-  %1 = constant 17 : i64
-  %2:2 = call @foo(%0, %1) : (i32, i64) -> (i32, i64)
-  "use_i32"(%2#0) : (i32) -> ()
-  "use_i64"(%2#1) : (i64) -> ()
-}
-
-// is transformed into
-
-func @foo(%arg0: !llvm.i32, %arg1: !llvm.i64) -> !llvm<"{i32, i64}"> {
-  // insert the vales into a structure
-  %0 = llvm.mlir.undef :  !llvm<"{i32, i64}">
-  %1 = llvm.insertvalue %arg0, %0[0] : !llvm<"{i32, i64}">
-  %2 = llvm.insertvalue %arg1, %1[1] : !llvm<"{i32, i64}">
-
-  // return the structure value
-  llvm.return %2 : !llvm<"{i32, i64}">
-}
-func @bar() {
-  %0 = llvm.mlir.constant(42 : i32) : !llvm.i32
-  %1 = llvm.mlir.constant(17) : !llvm.i64
-
-  // call and extract the values from the structure
-  %2 = llvm.call @bar(%0, %1) : (%arg0: !llvm.i32, %arg1: !llvm.i32) -> 
!llvm<"{i32, i64}">
-  %3 = llvm.extractvalue %2[0] : !llvm<"{i32, i64}">
-  %4 = llvm.extractvalue %2[1] : !llvm<"{i32, i64}">
-
-  // use as before
-  "use_i32"(%3) : (!llvm.i32) -> ()
-  "use_i64"(%4) : (!llvm.i64) -> ()
-}
-```
-
-### Calling Convention for Ranked `memref`
-
-Function _arguments_ of `memref` type, ranked or unranked, are _expanded_ into 
a
-list of arguments of non-aggregate types that the memref descriptor defined
-above comprises. That is, the outer struct type and the inner array types are
-replaced with individual arguments.
-
-This convention is implemented in the conversion of `std.func` and `std.call` 
to
-the LLVM dialect, with the former unpacking the descriptor into a set of
-individual values and the latter packing those values back into a descriptor so
-as to make it transparently usable by other operations. Conversions from other
-dialects should take this convention into account.
-
-This specific convention is motivated by the necessity to specify alignment and
-aliasing attributes on the raw pointers underpinning the memref.
-
-Examples:
-
-```mlir
-func @foo(%arg0: memref) -> () {
-  "use"(%arg0) : (memref) -> ()
-  return
-}
-
-// Gets converted to the following.
-
-llvm.func @foo(%arg0: !llvm<"float*">,   // Allocated pointer.
-   %arg1: !llvm<"float*">,   // Aligned pointer.
-   %arg2: !llvm.i64, // Offset.
-   %arg3: !llvm.i64, // Size in dim 0.
-   %arg4: !llvm.i64) {   // Stride in dim 0.
-  // Populate memref descriptor structure.
-  %0 = llvm.mlir.undef : !llvm<"{ float*, float*, i64, [1 x i64], [1 x i64] }">
-  %1 = llvm.insertvalue %arg0, %0[0] : !llvm<"{ float*, float*, i64, [1 x 
i64], [1 x i64] }">
-  %2 = llvm.insertvalue %arg1, %1[1] : !llvm<"{ float*, float*, i64, [1 x 
i64], [1 x i64] }">
-  %3 = llvm.insertvalue %arg2, %2[2] : !llvm<"{ float*, float*, i64, [1 x 
i64], [1 x i64] }">
-  %4 = llvm.insertvalue %arg3, %3[3, 0] : !llvm<"{ float*, float*, i64, [1 x 
i64], [1 x i64] }">
-  %5 = llvm.insertvalue %arg4, %4[4, 0] : !llvm<"{ float*, float*, i64, [1 x 
i64], [1 x i64] }">
-
-  // Descriptor is now usable as a single value.
-  "use"(%5) : (!llvm<"{ float*, float*, i64, [1 x i64], [1 x i64] }">) -> ()
-  llvm.return
-}
-```
-
-```mlir
-func @bar() {
-  %0 = "get"() : () -> (memref)
-  call @foo(%0) : (memref) -> ()
-  return
-}
-
-// Gets converted to the following.
-
-llvm.func @bar() {
-  %0 = "get"() : () -> !llvm<"{ float*, float*, i64, [1 x i64], [1 x i64] }">
-
-  // Unpack the me

[llvm-branch-commits] [mlir] 8451d48 - [mlir] NFC: Remove ConvertToLLVMPattern::getDataPtr(). All call sites use getStridedElementPtr() now.

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

Author: Christian Sigg
Date: 2020-12-23T11:35:01+01:00
New Revision: 8451d4872ed70d307e21bc437d51ecf9be0cdd08

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

LOG: [mlir] NFC: Remove ConvertToLLVMPattern::getDataPtr(). All call sites use 
getStridedElementPtr() now.

Reviewed By: ftynse

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

Added: 


Modified: 
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp

Removed: 




diff  --git 
a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h 
b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index 63ff16a84ab8..63547db56e6d 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -512,11 +512,6 @@ class ConvertToLLVMPattern : public ConversionPattern {
  ValueRange indices,
  ConversionPatternRewriter &rewriter) const;
 
-  // Forwards to getStridedElementPtr. TODO: remove.
-  Value getDataPtr(Location loc, MemRefType type, Value memRefDesc,
-   ValueRange indices,
-   ConversionPatternRewriter &rewriter) const;
-
   /// Returns if the givem memref type is supported.
   bool isSupportedMemRefType(MemRefType type) const;
 

diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp 
b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index e37e7e2dc0c1..97e763fc08c4 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1085,12 +1085,6 @@ Value ConvertToLLVMPattern::getStridedElementPtr(
: base;
 }
 
-Value ConvertToLLVMPattern::getDataPtr(
-Location loc, MemRefType type, Value memRefDesc, ValueRange indices,
-ConversionPatternRewriter &rewriter) const {
-  return getStridedElementPtr(loc, type, memRefDesc, indices, rewriter);
-}
-
 // Check if the MemRefType `type` is supported by the lowering. We currently
 // only support memrefs with identity maps.
 bool ConvertToLLVMPattern::isSupportedMemRefType(MemRefType type) const {



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


[llvm-branch-commits] [mlir] 32a884c - [mlir] Add translation of omp.wsloop to LLVM IR

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

Author: Alex Zinenko
Date: 2020-12-23T11:52:28+01:00
New Revision: 32a884c9c52c1216d57835e557233b238d601726

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

LOG: [mlir] Add translation of omp.wsloop to LLVM IR

Introduce a translation of OpenMP workshare loop construct to LLVM IR. This is
a minimalist version to enable the pipeline and currently only supports static
loop schedule (default in the specification) on non-collapsed loops. Other
features will be added on per-need basis.

Reviewed By: kiranchandramohan

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

Added: 


Modified: 
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Target/openmp-llvm.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index f915afcf32c9..6c6230f0c2e8 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -185,6 +185,11 @@ def WsLoopOp : OpenMP_Op<"wsloop", 
[AttrSizedOperandSegments]> {
   ];
 
   let regions = (region AnyRegion:$region);
+
+  let extraClassDeclaration = [{
+/// Returns the number of loops in the workshape loop nest.
+unsigned getNumLoops() { return lowerBound().size(); }
+  }];
 }
 
 def YieldOp : OpenMP_Op<"yield", [NoSideEffect, ReturnLike, Terminator,

diff  --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h 
b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index d3d289414b38..5259ed7fe182 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -100,6 +100,9 @@ class ModuleTranslation {
llvm::BasicBlock &continuationIP,
llvm::IRBuilder<> &builder,
LogicalResult &bodyGenStatus);
+  virtual LogicalResult convertOmpWsLoop(Operation &opInst,
+ llvm::IRBuilder<> &builder);
+
   /// Converts the type from MLIR LLVM dialect to LLVM.
   llvm::Type *convertType(LLVMType type);
 

diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp 
b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index ae0745b0be28..0b2cf7de270f 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -536,6 +536,126 @@ LogicalResult 
ModuleTranslation::convertOmpMaster(Operation &opInst,
   return success();
 }
 
+/// Converts an OpenMP workshare loop into LLVM IR using OpenMPIRBuilder.
+LogicalResult ModuleTranslation::convertOmpWsLoop(Operation &opInst,
+  llvm::IRBuilder<> &builder) {
+  auto loop = cast(opInst);
+  // TODO: this should be in the op verifier instead.
+  if (loop.lowerBound().empty())
+return failure();
+
+  if (loop.getNumLoops() != 1)
+return opInst.emitOpError("collapsed loops not yet supported");
+
+  if (loop.schedule_val().hasValue() &&
+  omp::symbolizeClauseScheduleKind(loop.schedule_val().getValue()) !=
+  omp::ClauseScheduleKind::Static)
+return opInst.emitOpError(
+"only static (default) loop schedule is currently supported");
+
+  llvm::Function *func = builder.GetInsertBlock()->getParent();
+  llvm::LLVMContext &llvmContext = llvmModule->getContext();
+
+  // Find the loop configuration.
+  llvm::Value *lowerBound = valueMapping.lookup(loop.lowerBound()[0]);
+  llvm::Value *upperBound = valueMapping.lookup(loop.upperBound()[0]);
+  llvm::Value *step = valueMapping.lookup(loop.step()[0]);
+  llvm::Type *ivType = step->getType();
+  llvm::Value *chunk = loop.schedule_chunk_var()
+   ? valueMapping[loop.schedule_chunk_var()]
+   : llvm::ConstantInt::get(ivType, 1);
+
+  // Set up the source location value for OpenMP runtime.
+  llvm::DISubprogram *subprogram =
+  builder.GetInsertBlock()->getParent()->getSubprogram();
+  const llvm::DILocation *diLoc =
+  debugTranslation->translateLoc(opInst.getLoc(), subprogram);
+  llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder.saveIP(),
+llvm::DebugLoc(diLoc));
+
+  // Generator of the canonical loop body. Produces an SESE region of basic
+  // blocks.
+  // TODO: support error propagation in OpenMPIRBuilder and use it instead of
+  // relying on captured variables.
+  LogicalResult bodyGenStatus = success();
+  auto bodyGen = [&](llvm::OpenMPIRBuilder::InsertPointTy ip, llvm::Value *iv) 
{
+llvm::IRBuilder<>::InsertPointGuard guard(builder);
+
+// Make sure further conversions know about the induction variable.
+value

[llvm-branch-commits] [mlir] 19a0d0a - [mlir] Rename ConvertToLLVMPattern::isSupportedMemRefType() to isConvertibleAndHasIdentityMaps().

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

Author: Christian Sigg
Date: 2020-12-23T12:23:29+01:00
New Revision: 19a0d0a40ce991836d930ecf8614ad21a1c3c32c

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

LOG: [mlir] Rename ConvertToLLVMPattern::isSupportedMemRefType() to 
isConvertibleAndHasIdentityMaps().

Reviewed By: ftynse, herhut

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

Added: 


Modified: 
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp

Removed: 




diff  --git 
a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h 
b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index 63547db56e6d..d5c1e923fab9 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -512,8 +512,9 @@ class ConvertToLLVMPattern : public ConversionPattern {
  ValueRange indices,
  ConversionPatternRewriter &rewriter) const;
 
-  /// Returns if the givem memref type is supported.
-  bool isSupportedMemRefType(MemRefType type) const;
+  /// Returns if the given memref has identity maps and the element type is
+  /// convertible to LLVM.
+  bool isConvertibleAndHasIdentityMaps(MemRefType type) const;
 
   /// Returns the type of a pointer to an element of the memref.
   Type getElementPtrType(MemRefType type) const;

diff  --git a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp 
b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
index bbb2bf1e04ff..d35aa0346f74 100644
--- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
+++ b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
@@ -369,7 +369,7 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   MemRefType memRefType = allocOp.getType();
 
   if (failed(areAllLLVMTypes(allocOp, operands, rewriter)) ||
-  !isSupportedMemRefType(memRefType) ||
+  !isConvertibleAndHasIdentityMaps(memRefType) ||
   failed(isAsyncWithOneDependency(rewriter, allocOp)))
 return failure();
 
@@ -670,7 +670,7 @@ LogicalResult 
ConvertMemcpyOpToGpuRuntimeCallPattern::matchAndRewrite(
   auto memRefType = memcpyOp.src().getType().cast();
 
   if (failed(areAllLLVMTypes(memcpyOp, operands, rewriter)) ||
-  !isSupportedMemRefType(memRefType) ||
+  !isConvertibleAndHasIdentityMaps(memRefType) ||
   failed(isAsyncWithOneDependency(rewriter, memcpyOp)))
 return failure();
 

diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp 
b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 97e763fc08c4..f4d1df81565b 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1087,7 +1087,8 @@ Value ConvertToLLVMPattern::getStridedElementPtr(
 
 // Check if the MemRefType `type` is supported by the lowering. We currently
 // only support memrefs with identity maps.
-bool ConvertToLLVMPattern::isSupportedMemRefType(MemRefType type) const {
+bool ConvertToLLVMPattern::isConvertibleAndHasIdentityMaps(
+MemRefType type) const {
   if (!typeConverter->convertType(type.getElementType()))
 return false;
   return type.getAffineMaps().empty() ||
@@ -1105,7 +1106,7 @@ void ConvertToLLVMPattern::getMemRefDescriptorSizes(
 Location loc, MemRefType memRefType, ArrayRef dynamicSizes,
 ConversionPatternRewriter &rewriter, SmallVectorImpl &sizes,
 SmallVectorImpl &strides, Value &sizeBytes) const {
-  assert(isSupportedMemRefType(memRefType) &&
+  assert(isConvertibleAndHasIdentityMaps(memRefType) &&
  "layout maps must have been normalized away");
 
   sizes.reserve(memRefType.getRank());
@@ -1977,7 +1978,7 @@ struct AllocLikeOpLowering : public ConvertToLLVMPattern {
 
   LogicalResult match(Operation *op) const override {
 MemRefType memRefType = getMemRefResultType(op);
-return success(isSupportedMemRefType(memRefType));
+return success(isConvertibleAndHasIdentityMaps(memRefType));
   }
 
   // An `alloc` is converted into a definition of a memref descriptor value and
@@ -2411,7 +2412,7 @@ struct GlobalMemrefOpLowering : public 
ConvertOpToLLVMPattern {
   matchAndRewrite(GlobalMemrefOp global, ArrayRef operands,
   ConversionPatternRewriter &rewriter) const override {
 MemRefType type = global.type().cast();
-if (!isSupportedMemRefType(type))
+if (!isConvertibleAndHasIdentityMaps(type))
   return failure();
 
 LLVM::LLVMType arrayTy =
@@ -3031,12 +3032,12 @@ struct RankOpLowering : public 
ConvertOpToLLVMPattern

[llvm-branch-commits] [clang] 25a02c3 - Revert "PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of"

2020-12-23 Thread Adrian Kuegel via llvm-branch-commits

Author: Adrian Kuegel
Date: 2020-12-23T12:31:52+01:00
New Revision: 25a02c3d1a688d3cd18faef96c75fa553efbbac7

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

LOG: Revert "PR24076, PR33655, C++ CWG 1558: Consider the 
instantiation-dependence of"

This reverts commit d3bf0bb18952d830fe6df6f791a64552b271000b.
This causes compilation in certain cases to fail.
Reproducer TBD.

Added: 


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

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



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

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

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

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

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

[llvm-branch-commits] [clang] eb9483b - [format] Add overload to parseConfiguration that accept llvm::MemoryBufferRef

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

Author: Nathan James
Date: 2020-12-23T12:08:29Z
New Revision: eb9483b21053656b885f13ccfe41bfa76eb3df45

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

LOG: [format] Add overload to parseConfiguration that accept 
llvm::MemoryBufferRef

This overload should be used for better diagnostics when parsing configurations.
Now a failure to parse will list the filename (or ) instead of 
just `YAML`.

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/test/Format/error-config.cpp

Removed: 




diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index fd5c0e32c5c2..208fc105d4b6 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2879,7 +2879,8 @@ struct FormatStyle {
 private:
   FormatStyleSet StyleSet;
 
-  friend std::error_code parseConfiguration(StringRef Text, FormatStyle *Style,
+  friend std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
+FormatStyle *Style,
 bool AllowUnknownOptions);
 };
 
@@ -2938,9 +2939,17 @@ bool getPredefinedStyle(StringRef Name, 
FormatStyle::LanguageKind Language,
 ///
 /// If AllowUnknownOptions is true, no errors are emitted if unknown
 /// format options are occured.
-std::error_code parseConfiguration(StringRef Text, FormatStyle *Style,
+std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
+   FormatStyle *Style,
bool AllowUnknownOptions = false);
 
+/// Like above but accepts an unnamed buffer.
+inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,
+  bool AllowUnknownOptions = false) {
+  return parseConfiguration(llvm::MemoryBufferRef(Config, "YAML"), Style,
+AllowUnknownOptions);
+}
+
 /// Gets configuration in a YAML string.
 std::string configurationAsText(const FormatStyle &Style);
 

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 23eee19b1640..55abc12c61c4 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1327,16 +1327,17 @@ bool getPredefinedStyle(StringRef Name, 
FormatStyle::LanguageKind Language,
   return true;
 }
 
-std::error_code parseConfiguration(StringRef Text, FormatStyle *Style,
+std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
+   FormatStyle *Style,
bool AllowUnknownOptions) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
   assert(Language != FormatStyle::LK_None);
-  if (Text.trim().empty())
+  if (Config.getBuffer().trim().empty())
 return make_error_code(ParseError::Error);
   Style->StyleSet.Clear();
   std::vector Styles;
-  llvm::yaml::Input Input(Text);
+  llvm::yaml::Input Input(Config);
   // DocumentListTraits> uses the context to get default
   // values for the fields, keys for which are missing from the configuration.
   // Mapping also uses the context to get the language to find the correct
@@ -2864,8 +2865,9 @@ llvm::Expected getStyle(StringRef StyleName, 
StringRef FileName,
 
   if (StyleName.startswith("{")) {
 // Parse YAML/JSON style from the command line.
-if (std::error_code ec =
-parseConfiguration(StyleName, &Style, AllowUnknownOptions))
+if (std::error_code ec = parseConfiguration(
+llvm::MemoryBufferRef(StyleName, ""), &Style,
+AllowUnknownOptions))
   return make_string_error("Error parsing -style: " + ec.message());
 return Style;
   }
@@ -2909,8 +2911,8 @@ llvm::Expected getStyle(StringRef StyleName, 
StringRef FileName,
 FS->getBufferForFile(ConfigFile.str());
 if (std::error_code EC = Text.getError())
   return make_string_error(EC.message());
-if (std::error_code ec = parseConfiguration(
-Text.get()->getBuffer(), &Style, AllowUnknownOptions)) {
+if (std::error_code ec =
+parseConfiguration(*Text.get(), &Style, AllowUnknownOptions)) {
   if (ec == ParseError::Unsuitable) {
 if (!UnsuitableConfigFiles.empty())
   UnsuitableConfigFiles.append(", ");

diff  --git a/clang/test/Format/error-config.cpp 
b/clang/test/Format/error-config.cpp
index 7fbc869f3a3c..9f73a9eb9507 100644
--- a/clang/test/Format/error-config.cpp
+++ b/clang/test/Format/error-config.cpp
@@ -1,10 +1,10 @@
 // RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=C

[llvm-branch-commits] [mlir] 7ed9cfc - [mlir] Remove static constructors from LLVMType

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

Author: Alex Zinenko
Date: 2020-12-23T13:12:47+01:00
New Revision: 7ed9cfc7b19fdba9eb441ce1a8ba82cda14d76a8

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

LOG: [mlir] Remove static constructors from LLVMType

LLVMType contains numerous static constructors that were initially introduced
for API compatibility with LLVM. Most of these merely forward to arguments to
`SpecificType::get` (MLIR defines classes for all types, unlike LLVM IR), while
some introduce subtle semantics differences due to different modeling of MLIR
types (e.g., structs are not auto-renamed in case of conflicts). Furthermore,
these constructors don't match MLIR idioms and actively prevent us from making
the LLVM dialect type system more open. Remove them and use `SpecificType::get`
instead.

Depends On D93680

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h
mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/lib/Transforms/TestConvertCallOp.cpp

Removed: 




diff  --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp 
b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
index a04b3ecd4dae..6fbf29f4128d 100644
--- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
+++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
@@ -111,10 +111,11 @@ class PrintOpLowering : public ConversionPattern {
 
 // Create a function declaration for printf, the signature is:
 //   * `i32 (i8*, ...)`
-auto llvmI32Ty = LLVM::LLVMType::getInt32Ty(context);
-auto llvmI8PtrTy = LLVM::LLVMType::getInt8PtrTy(context);
-auto llvmFnType = LLVM::LLVMType::getFunctionTy(llvmI32Ty, llvmI8PtrTy,
-/*isVarArg=*/true);
+auto llvmI32Ty = LLVM::LLVMIntegerType::get(context, 32);
+auto llvmI8PtrTy =
+LLVM::LLVMPointerType::get(LLVM::LLVMIntegerType::get(context, 8));
+auto llvmFnType = LLVM::LLVMFunctionType::get(llvmI32Ty, llvmI8PtrTy,
+  /*isVarArg=*/true);
 
 // Insert the printf function into the body of the parent module.
 PatternRewriter::InsertionGuard insertGuard(rewriter);
@@ -133,8 +134,8 @@ class PrintOpLowering : public ConversionPattern {
 if (!(global = module.lookupSymbol(name))) {
   OpBuilder::InsertionGuard insertGuard(builder);
   builder.setInsertionPointToStart(module.getBody());
-  auto type = LLVM::LLVMType::getArrayTy(
-  LLVM::LLVMType::getInt8Ty(builder.getContext()), value.size());
+  auto type = LLVM::LLVMArrayType::get(
+  LLVM::LLVMIntegerType::get(builder.getContext(), 8), value.size());
   global = builder.create(loc, type, /*isConstant=*/true,
   LLVM::Linkage::Internal, name,
   builder.getStringAttr(value));
@@ -143,11 +144,13 @@ class PrintOpLowering : public ConversionPattern {
 // Get the pointer to the first character in the global string.
 Value globalPtr = builder.create(loc, global);
 Value cst0 = builder.create(
-loc, LLVM::LLVMType::getInt64Ty(builder.getContext()),
+loc, LLVM::LLVMIntegerType::get(builder.getContext(), 64),
 builder.getIntegerAttr(builder.getIndexType(), 0));
 return builder.create(
-loc, LLVM::LLVMType::getInt8PtrTy(builder.getContext()), globalPtr,
-ArrayRef({cst0, cst0}));
+loc,
+LLVM::LLVMPointerType::get(
+LLVM::LLVMIntegerType::get(builder.getContext(), 8)),
+globalPtr, ArrayRef({cst0, cst0}));
   }
 };
 } // end anonymous namespace

diff  --git 

[llvm-branch-commits] [llvm] c3acda0 - [VE] Vector 'and' isel and tests

2020-12-23 Thread Simon Moll via llvm-branch-commits

Author: Simon Moll
Date: 2020-12-23T13:29:29+01:00
New Revision: c3acda0798f9b10ac3187ad941bbd8af82fb84a1

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

LOG: [VE] Vector 'and' isel and tests

Reviewed By: kaz7

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

Added: 
llvm/test/CodeGen/VE/Vector/vec_and.ll

Modified: 
llvm/lib/Target/VE/VVPInstrInfo.td
llvm/lib/Target/VE/VVPInstrPatternsVec.td
llvm/lib/Target/VE/VVPNodes.def

Removed: 




diff  --git a/llvm/lib/Target/VE/VVPInstrInfo.td 
b/llvm/lib/Target/VE/VVPInstrInfo.td
index 81fbfe03b48f..2c88d5099a7b 100644
--- a/llvm/lib/Target/VE/VVPInstrInfo.td
+++ b/llvm/lib/Target/VE/VVPInstrInfo.td
@@ -40,4 +40,7 @@ class vvp_commutative :
 def vvp_add: SDNode<"VEISD::VVP_ADD",  SDTIntBinOpVVP>;
 def c_vvp_add  : vvp_commutative;
 
+def vvp_and: SDNode<"VEISD::VVP_AND",  SDTIntBinOpVVP>;
+def c_vvp_and  : vvp_commutative;
+
 // } Binary Operators

diff  --git a/llvm/lib/Target/VE/VVPInstrPatternsVec.td 
b/llvm/lib/Target/VE/VVPInstrPatternsVec.td
index 2345173314a4..7003fb387670 100644
--- a/llvm/lib/Target/VE/VVPInstrPatternsVec.td
+++ b/llvm/lib/Target/VE/VVPInstrPatternsVec.td
@@ -66,3 +66,6 @@ multiclass VectorBinaryArith_ShortLong<
 defm : VectorBinaryArith_ShortLong;
+defm : VectorBinaryArith_ShortLong;

diff  --git a/llvm/lib/Target/VE/VVPNodes.def b/llvm/lib/Target/VE/VVPNodes.def
index 4319b332388e..1f9cbd790235 100644
--- a/llvm/lib/Target/VE/VVPNodes.def
+++ b/llvm/lib/Target/VE/VVPNodes.def
@@ -27,6 +27,7 @@
 // Integer arithmetic.
 ADD_BINARY_VVP_OP(VVP_ADD,ADD)
 
+ADD_BINARY_VVP_OP(VVP_AND,AND)
 
 #undef ADD_BINARY_VVP_OP
 #undef ADD_VVP_OP

diff  --git a/llvm/test/CodeGen/VE/Vector/vec_and.ll 
b/llvm/test/CodeGen/VE/Vector/vec_and.ll
new file mode 100644
index ..8597e1aa511e
--- /dev/null
+++ b/llvm/test/CodeGen/VE/Vector/vec_and.ll
@@ -0,0 +1,132 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=ve -mattr=+vpu | FileCheck %s
+
+; <256 x i32>
+
+; Function Attrs: nounwind
+define fastcc <256 x i32> @and_vv_v256i32(<256 x i32> %x, <256 x i32> %y) {
+; CHECK-LABEL: and_vv_v256i32:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:lea %s0, 256
+; CHECK-NEXT:lvl %s0
+; CHECK-NEXT:pvand.lo %v0, %v0, %v1
+; CHECK-NEXT:b.l.t (, %s10)
+  %z = and <256 x i32> %x, %y
+  ret <256 x i32> %z
+}
+
+; Function Attrs: nounwind
+define fastcc <256 x i32> @and_sv_v256i32(i32 %x, <256 x i32> %y) {
+; CHECK-LABEL: and_sv_v256i32:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:and %s0, %s0, (32)0
+; CHECK-NEXT:lea %s1, 256
+; CHECK-NEXT:lvl %s1
+; CHECK-NEXT:pvand.lo %v0, %s0, %v0
+; CHECK-NEXT:b.l.t (, %s10)
+  %xins = insertelement <256 x i32> undef, i32 %x, i32 0
+  %vx = shufflevector <256 x i32> %xins, <256 x i32> undef, <256 x i32> 
zeroinitializer
+  %z = and <256 x i32> %vx, %y
+  ret <256 x i32> %z
+}
+
+; Function Attrs: nounwind
+define fastcc <256 x i32> @and_vs_v256i32(<256 x i32> %x, i32 %y) {
+; CHECK-LABEL: and_vs_v256i32:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:and %s0, %s0, (32)0
+; CHECK-NEXT:lea %s1, 256
+; CHECK-NEXT:lvl %s1
+; CHECK-NEXT:pvand.lo %v0, %s0, %v0
+; CHECK-NEXT:b.l.t (, %s10)
+  %yins = insertelement <256 x i32> undef, i32 %y, i32 0
+  %vy = shufflevector <256 x i32> %yins, <256 x i32> undef, <256 x i32> 
zeroinitializer
+  %z = and <256 x i32> %x, %vy
+  ret <256 x i32> %z
+}
+
+
+
+; <256 x i64>
+
+; Function Attrs: nounwind
+define fastcc <256 x i64> @and_vv_v256i64(<256 x i64> %x, <256 x i64> %y) {
+; CHECK-LABEL: and_vv_v256i64:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:lea %s0, 256
+; CHECK-NEXT:lvl %s0
+; CHECK-NEXT:vand %v0, %v0, %v1
+; CHECK-NEXT:b.l.t (, %s10)
+  %z = and <256 x i64> %x, %y
+  ret <256 x i64> %z
+}
+
+; Function Attrs: nounwind
+define fastcc <256 x i64> @and_sv_v256i64(i64 %x, <256 x i64> %y) {
+; CHECK-LABEL: and_sv_v256i64:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:lea %s1, 256
+; CHECK-NEXT:lvl %s1
+; CHECK-NEXT:vand %v0, %s0, %v0
+; CHECK-NEXT:b.l.t (, %s10)
+  %xins = insertelement <256 x i64> undef, i64 %x, i32 0
+  %vx = shufflevector <256 x i64> %xins, <256 x i64> undef, <256 x i32> 
zeroinitializer
+  %z = and <256 x i64> %vx, %y
+  ret <256 x i64> %z
+}
+
+; Function Attrs: nounwind
+define fastcc <256 x i64> @and_vs_v256i64(<256 x i64> %x, i64 %y) {
+; CHECK-LABEL: and_vs_v256i64:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:lea %s1, 256
+; CHECK-NEXT:lvl %s1
+; CHECK-NEXT:vand %v0, %s0, %v0
+; CHECK-NEXT:b.l.t (, %s10)
+  %yins = insertelement <256 x i64> undef, i64 %y, i32 0
+  %vy = shufflevector <256 x i64> %yins, <256 x i64> undef, <256 x i32> 
zeroinitializer
+  %z = and <256 x i64> %x, %vy
+  r

[llvm-branch-commits] [llvm] acaa6e4 - [NFC] Uniquify 'const' in TargetTransformInfoImpl.h

2020-12-23 Thread Simon Moll via llvm-branch-commits

Author: Simon Moll
Date: 2020-12-23T14:21:41+01:00
New Revision: acaa6e4260cb5b2aa88f465eafea320d5f3f249c

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

LOG: [NFC] Uniquify 'const' in TargetTransformInfoImpl.h

Some member functions of class TargetTransformInfoImplBase in
TargetTransformInfoImpl.h are marked const while others are not. Yet all
of the should be marked const since they are just providing default TTI
values. This patch fixes the inconsistency.

Authored-by: Jinzheng Tu 

Reviewed By: simoll

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

Added: 


Modified: 
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Removed: 




diff  --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h 
b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 6415e7bfe7c3..620bfb885b54 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -46,7 +46,7 @@ class TargetTransformInfoImplBase {
 
   int getGEPCost(Type *PointeeType, const Value *Ptr,
  ArrayRef Operands,
- TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) {
+ TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) const 
{
 // In the basic model, we just assume that all-constant GEPs will be folded
 // into their uses via addressing modes.
 for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx)
@@ -59,28 +59,30 @@ class TargetTransformInfoImplBase {
   unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI,
 unsigned &JTSize,
 ProfileSummaryInfo *PSI,
-BlockFrequencyInfo *BFI) {
+BlockFrequencyInfo *BFI) const {
 (void)PSI;
 (void)BFI;
 JTSize = 0;
 return SI.getNumCases();
   }
 
-  unsigned getInliningThresholdMultiplier() { return 1; }
+  unsigned getInliningThresholdMultiplier() const { return 1; }
 
-  int getInlinerVectorBonusPercent() { return 150; }
+  int getInlinerVectorBonusPercent() const { return 150; }
 
-  unsigned getMemcpyCost(const Instruction *I) { return TTI::TCC_Expensive; }
+  unsigned getMemcpyCost(const Instruction *I) const {
+return TTI::TCC_Expensive;
+  }
 
-  bool hasBranchDivergence() { return false; }
+  bool hasBranchDivergence() const { return false; }
 
-  bool useGPUDivergenceAnalysis() { return false; }
+  bool useGPUDivergenceAnalysis() const { return false; }
 
-  bool isSourceOfDivergence(const Value *V) { return false; }
+  bool isSourceOfDivergence(const Value *V) const { return false; }
 
-  bool isAlwaysUniform(const Value *V) { return false; }
+  bool isAlwaysUniform(const Value *V) const { return false; }
 
-  unsigned getFlatAddressSpace() { return -1; }
+  unsigned getFlatAddressSpace() const { return -1; }
 
   bool collectFlatAddressOperands(SmallVectorImpl &OpIndexes,
   Intrinsic::ID IID) const {
@@ -96,7 +98,7 @@ class TargetTransformInfoImplBase {
 return nullptr;
   }
 
-  bool isLoweredToCall(const Function *F) {
+  bool isLoweredToCall(const Function *F) const {
 assert(F && "A concrete function must be provided to this routine.");
 
 // FIXME: These should almost certainly not be handled here, and instead
@@ -134,7 +136,7 @@ class TargetTransformInfoImplBase {
 
   bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
 AssumptionCache &AC, TargetLibraryInfo 
*LibInfo,
-HardwareLoopInfo &HWLoopInfo) {
+HardwareLoopInfo &HWLoopInfo) const {
 return false;
   }
 
@@ -170,39 +172,39 @@ class TargetTransformInfoImplBase {
   }
 
   void getUnrollingPreferences(Loop *, ScalarEvolution &,
-   TTI::UnrollingPreferences &) {}
+   TTI::UnrollingPreferences &) const {}
 
   void getPeelingPreferences(Loop *, ScalarEvolution &,
- TTI::PeelingPreferences &) {}
+ TTI::PeelingPreferences &) const {}
 
-  bool isLegalAddImmediate(int64_t Imm) { return false; }
+  bool isLegalAddImmediate(int64_t Imm) const { return false; }
 
-  bool isLegalICmpImmediate(int64_t Imm) { return false; }
+  bool isLegalICmpImmediate(int64_t Imm) const { return false; }
 
   bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
  bool HasBaseReg, int64_t Scale, unsigned 
AddrSpace,
- Instruction *I = nullptr) {
+ Instruction *I = nullptr) const {
 // Guess that on

[llvm-branch-commits] [llvm] a9f14cd - [ARM] Add bank conflict hazarding

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

Author: David Penry
Date: 2020-12-23T14:00:59Z
New Revision: a9f14cdc6203c05425f8b17228ff368f7fd9ae29

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

LOG: [ARM] Add bank conflict hazarding

Adds ARMBankConflictHazardRecognizer. This hazard recognizer
looks for a few situations where the same base pointer is used and
then checks whether the offsets lead to a bank conflict. Two
parameters are also added to permit overriding of the target
assumptions:

arm-data-bank-mask= - Mask of bits which are to be checked for
conflicts.  If all these bits are equal in the offsets, there is a
conflict.
arm-assume-itcm-bankconflict= - Assume that there will be bank
conflicts on any loads to a constant pool.

This hazard recognizer is enabled for Cortex-M7, where the Technical
Reference Manual states that there are two DTCM banks banked using bit
2 and one ITCM bank.

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

Added: 
llvm/test/CodeGen/Thumb2/schedm7-hazard.ll

Modified: 
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
llvm/lib/Target/ARM/ARMBaseInstrInfo.h
llvm/lib/Target/ARM/ARMHazardRecognizer.cpp
llvm/lib/Target/ARM/ARMHazardRecognizer.h
llvm/lib/Target/ARM/ARMSubtarget.cpp
llvm/lib/Target/ARM/ARMSubtarget.h

Removed: 




diff  --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td
index 8111346c74f6..5d626e7d8e5a 100644
--- a/llvm/lib/Target/ARM/ARM.td
+++ b/llvm/lib/Target/ARM/ARM.td
@@ -660,7 +660,8 @@ def ProcR52 : SubtargetFeature<"r52", "ARMProcFamily", 
"CortexR52",
 
 def ProcM3  : SubtargetFeature<"m3", "ARMProcFamily", "CortexM3",
"Cortex-M3 ARM processors", []>;
-
+def ProcM7  : SubtargetFeature<"m7", "ARMProcFamily", "CortexM7",
+   "Cortex-M7 ARM processors", []>;
 
 
//===--===//
 // ARM Helper classes.
@@ -1191,6 +1192,7 @@ def : ProcessorModel<"cortex-m4", CortexM4Model,
[ARMv7em,
  
FeatureHasNoBranchPredictor]>;
 
 def : ProcessorModel<"cortex-m7", CortexM7Model,[ARMv7em,
+ ProcM7,
  FeatureFPARMv8_D16,
  FeatureUseMISched]>;
 

diff  --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp 
b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
index def631276950..563f2d38edf0 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -134,6 +134,31 @@ ARMBaseInstrInfo::CreateTargetHazardRecognizer(const 
TargetSubtargetInfo *STI,
   return TargetInstrInfo::CreateTargetHazardRecognizer(STI, DAG);
 }
 
+// Called during:
+// - pre-RA scheduling
+// - post-RA scheduling when FeatureUseMISched is set
+ScheduleHazardRecognizer *ARMBaseInstrInfo::CreateTargetMIHazardRecognizer(
+const InstrItineraryData *II, const ScheduleDAGMI *DAG) const {
+  MultiHazardRecognizer *MHR = new MultiHazardRecognizer();
+
+  // We would like to restrict this hazard recognizer to only
+  // post-RA scheduling; we can tell that we're post-RA because we don't
+  // track VRegLiveness.
+  // Cortex-M7: TRM indicates that there is a single ITCM bank and two DTCM
+  //banks banked on bit 2.  Assume that TCMs are in use.
+  if (Subtarget.isCortexM7() && !DAG->hasVRegLiveness())
+MHR->AddHazardRecognizer(
+std::make_unique(DAG, 0x4, true));
+
+  // Not inserting ARMHazardRecognizerFPMLx because that would change
+  // legacy behavior
+
+  auto BHR = TargetInstrInfo::CreateTargetMIHazardRecognizer(II, DAG);
+  MHR->AddHazardRecognizer(std::unique_ptr(BHR));
+  return MHR;
+}
+
+// Called during post-RA scheduling when FeatureUseMISched is not set
 ScheduleHazardRecognizer *ARMBaseInstrInfo::
 CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II,
const ScheduleDAG *DAG) const {

diff  --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h 
b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
index 9b6572848ebe..deb008025b1d 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
@@ -131,6 +131,10 @@ class ARMBaseInstrInfo : public ARMGenInstrInfo {
   CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI,
const ScheduleDAG *DAG) const override;
 
+  ScheduleHazardRecognizer *
+  CreateTargetMIHazardRecognizer(const InstrItineraryData *II,
+ const ScheduleDAGMI *DAG) const override;
+
   ScheduleHazardRecognizer *
   CreateTargetPostRAHazardRecognizer(const InstrItinerary

[llvm-branch-commits] [openmp] 6e60346 - [OpenMP] Fixing Typo in Documentation

2020-12-23 Thread Joseph Huber via llvm-branch-commits

Author: Joseph Huber
Date: 2020-12-23T09:17:51-05:00
New Revision: 6e603464959d43e0e430d0f8ac5522b073d68ba1

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

LOG: [OpenMP] Fixing Typo in Documentation

Added: 


Modified: 
openmp/docs/design/Runtimes.rst

Removed: 




diff  --git a/openmp/docs/design/Runtimes.rst b/openmp/docs/design/Runtimes.rst
index 39ed256c4856..2e5f2bfe0384 100644
--- a/openmp/docs/design/Runtimes.rst
+++ b/openmp/docs/design/Runtimes.rst
@@ -67,7 +67,7 @@ will be completely disabled.
 LIBOMPTARGET_INFO
 "
 
-``LIBOMPTARGET_INFO`` allows the user to request 
diff erent types runtime
+``LIBOMPTARGET_INFO`` allows the user to request 
diff erent types of runtime
 information from ``libomptarget``. ``LIBOMPTARGET_INFO`` uses a 32-bit field to
 enable or disable 
diff erent types of information. This includes information
 about data-mappings and kernel execution. It is recommended to build your



___
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] 031743c - [clang-format] PR48539 ReflowComments breaks Qt translation comments

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

Author: mydeveloperday
Date: 2020-12-23T14:45:14Z
New Revision: 031743cb5b3c6c2df85a67d8533ef72a95e76cdc

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

LOG: [clang-format] PR48539 ReflowComments breaks Qt translation comments

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

Add support for Qt Translator Comments to reflow

When reflown and a part of the comments are added on a new line, it should 
repeat these extra characters as part of the comment token.

Reviewed By: curdeius, HazardyKnusperkeks

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

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index ea5cc31af07a..6a240fdec8b9 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -41,8 +41,8 @@ static bool IsBlank(char C) {
 
 static StringRef getLineCommentIndentPrefix(StringRef Comment,
 const FormatStyle &Style) {
-  static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///", 
"//",
-"//!"};
+  static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///",
+"//",   "//!",  "//:"};
   static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
""};
   ArrayRef KnownPrefixes(KnownCStylePrefixes);

diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index 27dfe71367b3..457e7321ec75 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -702,6 +702,12 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
"  // long 1 2 3 4 5 6\n"
"}",
getLLVMStyleWithColumns(20)));
+
+  EXPECT_EQ("//: A comment that\n"
+"//: doesn't fit on\n"
+"//: one line",
+format("//: A comment that doesn't fit on one line",
+   getLLVMStyleWithColumns(20)));
 }
 
 TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {



___
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] 5426b2f - [clang-format] PR48535 clang-format Incorrectly Removes Space After C Style Cast When Type Is Not a Pointer

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

Author: mydeveloperday
Date: 2020-12-23T14:45:14Z
New Revision: 5426b2f9ed9f6f3a3e1d6452325f7a49a5d08ec4

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

LOG: [clang-format] PR48535 clang-format Incorrectly Removes Space After C 
Style Cast When Type Is Not a Pointer

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

using `SpaceAfterCStyleCast: true`

```
size_t idx = (size_t) a;
size_t idx = (size_t) (a - 1);
```

is formatted as:

```
size_t idx = (size_t) a;
size_t idx = (size_t)(a - 1);
```

This revision aims to improve that by improving the function which tries to 
identify a CastRParen

Reviewed By: curdeius

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 733ca1e0e852..a0cb86cfcebf 100755
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1915,6 +1915,13 @@ class AnnotatingParser {
 if (Tok.Next->isOneOf(tok::identifier, tok::kw_this))
   return true;
 
+if (Tok.Next->is(tok::l_paren) &&
+!(Tok.Previous && Tok.Previous->is(tok::identifier) &&
+  Tok.Previous->Previous &&
+  Tok.Previous->Previous->isOneOf(tok::arrowstar, tok::arrow,
+  tok::star)))
+  return true;
+
 if (!Tok.Next->Next)
   return false;
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index d2aed304f213..ee757c14eafb 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11989,6 +11989,20 @@ TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
"  do_something((int) i);\n"
"} while (something( ));",
Spaces);
+
+  verifyFormat("size_t idx = (size_t) (ptr - ((char *) file));", Spaces);
+  verifyFormat("size_t idx = (size_t) a;", Spaces);
+  verifyFormat("size_t idx = (size_t) (a - 1);", Spaces);
+  verifyFormat("size_t idx = (a->*foo)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (*foo)(a - 1);", Spaces);
+  Spaces.SpaceAfterCStyleCast = false;
+  verifyFormat("size_t idx = (size_t)(ptr - ((char *)file));", Spaces);
+  verifyFormat("size_t idx = (size_t)a;", Spaces);
+  verifyFormat("size_t idx = (size_t)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (a->*foo)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces);
+  verifyFormat("size_t idx = (*foo)(a - 1);", Spaces);
 }
 
 TEST_F(FormatTest, ConfigurableSpacesInSquareBrackets) {



___
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] 1d0dc9b - [MLIR][SPIRV] Add rewrite pattern to convert select+cmp into GLSL clamp.

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

Author: ergawy
Date: 2020-12-23T15:47:19+01:00
New Revision: 1d0dc9be6d72915d2bb632c7a46645289405dcbf

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

LOG: [MLIR][SPIRV] Add rewrite pattern to convert select+cmp into GLSL clamp.

Adds rewrite patterns to convert select+cmp instructions into clamp
instructions whenever possible. Support is added to convert:

- FOrdLessThan, FOrdLessThanEqual to GLSLFClampOp.
- SLessThan, SLessThanEqual to GLSLSClampOp.
- ULessThan, ULessThanEqual to GLSLUClampOp.

Reviewed By: mravishankar

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

Added: 
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLCanonicalization.h
mlir/lib/Dialect/SPIRV/IR/SPIRVGLSLCanonicalization.cpp
mlir/test/Dialect/SPIRV/Transforms/glsl_canonicalize.mlir
mlir/test/lib/Dialect/SPIRV/TestGLSLCanonicalization.cpp

Modified: 
mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt
mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td
mlir/test/lib/Dialect/SPIRV/CMakeLists.txt
mlir/tools/mlir-opt/mlir-opt.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLCanonicalization.h 
b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLCanonicalization.h
new file mode 100644
index ..1921dbbcfc70
--- /dev/null
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLCanonicalization.h
@@ -0,0 +1,31 @@
+//===- SPIRVGLSLCanonicalization.h - GLSL-specific patterns -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file declares a function to register SPIR-V GLSL-specific
+// canonicalization patterns.
+//
+//===--===//
+
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVGLSLCANONICALIZATION_H_
+#define MLIR_DIALECT_SPIRV_IR_SPIRVGLSLCANONICALIZATION_H_
+
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/PatternMatch.h"
+
+//===--===//
+// GLSL canonicalization patterns
+//===--===//
+
+namespace mlir {
+namespace spirv {
+void populateSPIRVGLSLCanonicalizationPatterns(
+mlir::OwningRewritePatternList &results, mlir::MLIRContext *context);
+} // namespace spirv
+} // namespace mlir
+
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVGLSLCANONICALIZATION_H_

diff  --git a/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt 
b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt
index dbf62425878b..42c0047168b9 100644
--- a/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt
+++ b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt
@@ -5,6 +5,7 @@ add_public_tablegen_target(MLIRSPIRVCanonicalizationIncGen)
 add_mlir_dialect_library(MLIRSPIRV
   SPIRVAttributes.cpp
   SPIRVCanonicalization.cpp
+  SPIRVGLSLCanonicalization.cpp
   SPIRVDialect.cpp
   SPIRVEnums.cpp
   SPIRVOps.cpp

diff  --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td 
b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td
index 125e97360865..6e0ee4488fa1 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td
@@ -38,3 +38,33 @@ def ConvertLogicalNotOfLogicalEqual : Pat<
 def ConvertLogicalNotOfLogicalNotEqual : Pat<
 (SPV_LogicalNotOp (SPV_LogicalNotEqualOp $lhs, $rhs)),
 (SPV_LogicalEqualOp $lhs, $rhs)>;
+
+//===--===//
+// Re-write spv.Select + spv. to a suitable variant of
+// spv.
+//===--===//
+
+def ValuesAreEqual : Constraint>;
+
+foreach CmpClampPair = [
+[SPV_FOrdLessThanOp, SPV_GLSLFClampOp],
+[SPV_FOrdLessThanEqualOp, SPV_GLSLFClampOp],
+[SPV_SLessThanOp, SPV_GLSLSClampOp],
+[SPV_SLessThanEqualOp, SPV_GLSLSClampOp],
+[SPV_ULessThanOp, SPV_GLSLUClampOp],
+[SPV_ULessThanEqualOp, SPV_GLSLUClampOp]] in {
+def ConvertComparisonIntoClamp#CmpClampPair[0] : Pat<
+(SPV_SelectOp
+(CmpClampPair[0]
+(SPV_SelectOp:$middle0
+(CmpClampPair[0] $min, $input),
+$input,
+$min
+),
+$max
+),
+$middle1,
+$max),
+(CmpClampPair[1] $input, $min, $max),
+[(ValuesAreEqual $middle0, $middle1)]>;
+}

diff  --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVGLSLCanonicalization.cpp 
b/mlir/lib/Dialect/SPIRV/IR/SPIRVGLSLCanonicalization.cpp
new file mode 100644
index ..0aa413941efd
--- /dev/null
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVGLSLCanonica

[llvm-branch-commits] [clang-tools-extra] 2522fa0 - [clangd] Do not take stale definition from the static index.

2020-12-23 Thread Aleksandr Platonov via llvm-branch-commits

Author: Aleksandr Platonov
Date: 2020-12-23T18:21:38+03:00
New Revision: 2522fa053b62520ae48b4b27117ca003a2c878ab

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

LOG: [clangd] Do not take stale definition from the static index.

This is follow up to D93393.
Without this patch clangd takes the symbol definition from the static index if 
this definition was removed from the dynamic index.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Merge.cpp
clang-tools-extra/clangd/unittests/IndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Merge.cpp 
b/clang-tools-extra/clangd/index/Merge.cpp
index 97babacf2b38..f66f47499624 100644
--- a/clang-tools-extra/clangd/index/Merge.cpp
+++ b/clang-tools-extra/clangd/index/Merge.cpp
@@ -76,7 +76,13 @@ void MergedIndex::lookup(
   Dynamic->lookup(Req, [&](const Symbol &S) { B.insert(S); });
 
   auto RemainingIDs = Req.IDs;
+  auto DynamicContainsFile = Dynamic->indexedFiles();
   Static->lookup(Req, [&](const Symbol &S) {
+// We expect the definition to see the canonical declaration, so it seems
+// to be enough to check only the definition if it exists.
+if (DynamicContainsFile(S.Definition ? S.Definition.FileURI
+ : S.CanonicalDeclaration.FileURI))
+  return;
 const Symbol *Sym = B.find(S.ID);
 RemainingIDs.erase(S.ID);
 if (!Sym)

diff  --git a/clang-tools-extra/clangd/unittests/IndexTests.cpp 
b/clang-tools-extra/clangd/unittests/IndexTests.cpp
index 8efc637d1250..ce4845e3e144 100644
--- a/clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -290,6 +290,40 @@ TEST(MergeIndexTest, Lookup) {
   EXPECT_THAT(lookup(M, {}), UnorderedElementsAre());
 }
 
+TEST(MergeIndexTest, LookupRemovedDefinition) {
+  FileIndex DynamicIndex, StaticIndex;
+  MergedIndex Merge(&DynamicIndex, &StaticIndex);
+
+  const char *HeaderCode = "class Foo;";
+  auto HeaderSymbols = TestTU::withHeaderCode(HeaderCode).headerSymbols();
+  auto Foo = findSymbol(HeaderSymbols, "Foo");
+
+  // Build static index for test.cc with Foo definition
+  TestTU Test;
+  Test.HeaderCode = HeaderCode;
+  Test.Code = "class Foo {};";
+  Test.Filename = "test.cc";
+  auto AST = Test.build();
+  StaticIndex.updateMain(testPath(Test.Filename), AST);
+
+  // Remove Foo definition from test.cc, i.e. build dynamic index for test.cc
+  // without Foo definition.
+  Test.Code = "class Foo;";
+  AST = Test.build();
+  DynamicIndex.updateMain(testPath(Test.Filename), AST);
+
+  // Merged index should not return the symbol definition if this definition
+  // location is inside a file from the dynamic index.
+  LookupRequest LookupReq;
+  LookupReq.IDs = {Foo.ID};
+  unsigned SymbolCounter = 0;
+  Merge.lookup(LookupReq, [&](const Symbol &Sym) {
+++SymbolCounter;
+EXPECT_FALSE(Sym.Definition);
+  });
+  EXPECT_EQ(SymbolCounter, 1u);
+}
+
 TEST(MergeIndexTest, FuzzyFind) {
   auto I = MemIndex::build(generateSymbols({"ns::A", "ns::B"}), RefSlab(),
RelationSlab()),



___
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] e122a71 - [TableGen] Add the !substr() bang operator

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

Author: Paul C. Anagnostopoulos
Date: 2020-12-23T10:59:33-05:00
New Revision: e122a71a0a284e669c970e80214c6b3082aa2534

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

LOG: [TableGen] Add the !substr() bang operator

Update the documentation and add a test.

Build failed: Change SIZE_MAX to std::numeric_limits::max().

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

Added: 
llvm/test/TableGen/substr.td

Modified: 
llvm/docs/TableGen/ProgRef.rst
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGLexer.cpp
llvm/lib/TableGen/TGLexer.h
llvm/lib/TableGen/TGParser.cpp
llvm/lib/TableGen/TGParser.h

Removed: 




diff  --git a/llvm/docs/TableGen/ProgRef.rst b/llvm/docs/TableGen/ProgRef.rst
index 342b91a0c437..f2ee7a7e549a 100644
--- a/llvm/docs/TableGen/ProgRef.rst
+++ b/llvm/docs/TableGen/ProgRef.rst
@@ -216,7 +216,8 @@ TableGen provides "bang operators" that have a wide variety 
of uses:
: !interleave !isa !le  !listconcat  !listsplat
: !lt !mul !ne  !not !or
: !setdagop   !shl !size!sra !srl
-   : !strconcat  !sub !subst   !tail!xor
+   : !strconcat  !sub !subst   !substr  !tail
+   : !xor
 
 The ``!cond`` operator has a slightly 
diff erent
 syntax compared to other bang operators, so it is defined separately:
@@ -1723,6 +1724,13 @@ and non-0 as true.
 record if the *target* record name equals the *value* record name; 
otherwise it
 produces the *value*.
 
+``!substr(``\ *string*\ ``,`` *start*\ [``,`` *length*]\ ``)``
+This operator extracts a substring of the given *string*. The starting
+position of the substring is specified by *start*, which can range
+between 0 and the length of the string. The length of the substring
+is specified by *length*; if not specified, the rest of the string is
+extracted. The *start* and *length* arguments must be integers.
+
 ``!tail(``\ *a*\ ``)``
 This operator produces a new list with all the elements
 of the list *a* except for the zeroth one. (See also ``!head``.)

diff  --git a/llvm/include/llvm/TableGen/Record.h 
b/llvm/include/llvm/TableGen/Record.h
index 3010b4dad09a..a0c5b2778547 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -829,7 +829,7 @@ class BinOpInit : public OpInit, public FoldingSetNode {
 /// !op (X, Y, Z) - Combine two inits.
 class TernOpInit : public OpInit, public FoldingSetNode {
 public:
-  enum TernaryOp : uint8_t { SUBST, FOREACH, FILTER, IF, DAG };
+  enum TernaryOp : uint8_t { SUBST, FOREACH, FILTER, IF, DAG, SUBSTR };
 
 private:
   Init *LHS, *MHS, *RHS;

diff  --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index cbdce04494f3..9c0464d4e1bf 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -1325,6 +1325,27 @@ Init *TernOpInit::Fold(Record *CurRec) const {
 }
 break;
   }
+
+  case SUBSTR: {
+StringInit *LHSs = dyn_cast(LHS);
+IntInit *MHSi = dyn_cast(MHS);
+IntInit *RHSi = dyn_cast(RHS);
+if (LHSs && MHSi && RHSi) {
+  int64_t StringSize = LHSs->getValue().size();
+  int64_t Start = MHSi->getValue();
+  int64_t Length = RHSi->getValue();
+  if (Start < 0 || Start > StringSize)
+PrintError(CurRec->getLoc(),
+   Twine("!substr start position is out of range 0...") +
+   std::to_string(StringSize) + ": " +
+   std::to_string(Start));
+  if (Length < 0)
+PrintError(CurRec->getLoc(), "!substr length must be nonnegative");
+  return StringInit::get(LHSs->getValue().substr(Start, Length),
+ LHSs->getFormat());
+}
+break;
+  }
   }
 
   return const_cast(this);
@@ -1364,11 +1385,12 @@ std::string TernOpInit::getAsString() const {
   std::string Result;
   bool UnquotedLHS = false;
   switch (getOpcode()) {
-  case SUBST: Result = "!subst"; break;
-  case FOREACH: Result = "!foreach"; UnquotedLHS = true; break;
+  case DAG: Result = "!dag"; break;
   case FILTER: Result = "!filter"; UnquotedLHS = true; break;
+  case FOREACH: Result = "!foreach"; UnquotedLHS = true; break;
   case IF: Result = "!if"; break;
-  case DAG: Result = "!dag"; break;
+  case SUBST: Result = "!subst"; break;
+  case SUBSTR: Result = "!substr"; break;
   }
   return (Result + "(" +
   (UnquotedLHS ? LHS->getAsUnquotedString() : LHS->getAsString()) +

diff  --git a/llvm/lib/TableGen/TGLexer.cpp b/llvm/lib/TableGen/TGLexer.cpp
index df0df96f40eb..a45ef6dc10c1 100644
--- a/llvm/lib/TableGen/TGLexer.cpp
+++ 

[llvm-branch-commits] [lld] 9d1140e - [lld-macho] Simulator & DriverKit executables should always be PIE

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

Author: Jez Ng
Date: 2020-12-23T11:24:12-05:00
New Revision: 9d1140e18e6f662636ac715b7dca202a969e9845

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

LOG: [lld-macho] Simulator & DriverKit executables should always be PIE

We didn't have support for parsing DriverKit in our `-platform`
flag, so add that too. Also remove a bunch of unnecessary namespace
prefixes.

Reviewed By: #lld-macho, thakis

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

Added: 


Modified: 
lld/MachO/Driver.cpp
lld/test/MachO/platform-version.s
lld/test/MachO/x86-64-reloc-unsigned.s

Removed: 




diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index edc9fe001ab5..9780443fb85a 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -548,20 +548,19 @@ static void handlePlatformVersion(const opt::Arg *arg) {
 
   // TODO(compnerd) see if we can generate this case list via XMACROS
   config->platform.kind =
-  llvm::StringSwitch(lowerDash(platformStr))
-  .Cases("macos", "1", llvm::MachO::PlatformKind::macOS)
-  .Cases("ios", "2", llvm::MachO::PlatformKind::iOS)
-  .Cases("tvos", "3", llvm::MachO::PlatformKind::tvOS)
-  .Cases("watchos", "4", llvm::MachO::PlatformKind::watchOS)
-  .Cases("bridgeos", "5", llvm::MachO::PlatformKind::bridgeOS)
-  .Cases("mac-catalyst", "6", llvm::MachO::PlatformKind::macCatalyst)
-  .Cases("ios-simulator", "7", llvm::MachO::PlatformKind::iOSSimulator)
-  .Cases("tvos-simulator", "8",
- llvm::MachO::PlatformKind::tvOSSimulator)
-  .Cases("watchos-simulator", "9",
- llvm::MachO::PlatformKind::watchOSSimulator)
-  .Default(llvm::MachO::PlatformKind::unknown);
-  if (config->platform.kind == llvm::MachO::PlatformKind::unknown)
+  StringSwitch(lowerDash(platformStr))
+  .Cases("macos", "1", PlatformKind::macOS)
+  .Cases("ios", "2", PlatformKind::iOS)
+  .Cases("tvos", "3", PlatformKind::tvOS)
+  .Cases("watchos", "4", PlatformKind::watchOS)
+  .Cases("bridgeos", "5", PlatformKind::bridgeOS)
+  .Cases("mac-catalyst", "6", PlatformKind::macCatalyst)
+  .Cases("ios-simulator", "7", PlatformKind::iOSSimulator)
+  .Cases("tvos-simulator", "8", PlatformKind::tvOSSimulator)
+  .Cases("watchos-simulator", "9", PlatformKind::watchOSSimulator)
+  .Cases("driverkit", "10", PlatformKind::driverKit)
+  .Default(PlatformKind::unknown);
+  if (config->platform.kind == PlatformKind::unknown)
 error(Twine("malformed platform: ") + platformStr);
   // TODO: check validity of version strings, which varies by platform
   // NOTE: ld64 accepts version strings with 5 components
@@ -637,10 +636,14 @@ static bool isPie(opt::InputArgList &args) {
   // to PIE from 10.7, arm64 should always be PIE, etc
   assert(config->arch == AK_x86_64 || config->arch == AK_x86_64h);
 
-  if (config->platform.kind == MachO::PlatformKind::macOS &&
+  PlatformKind kind = config->platform.kind;
+  if (kind == PlatformKind::macOS &&
   config->platform.minimum >= VersionTuple(10, 6))
 return true;
 
+  if (kind == PlatformKind::iOSSimulator || kind == PlatformKind::driverKit)
+return true;
+
   return args.hasArg(OPT_pie);
 }
 

diff  --git a/lld/test/MachO/platform-version.s 
b/lld/test/MachO/platform-version.s
index 326a74428cf4..0bfc46930c5b 100644
--- a/lld/test/MachO/platform-version.s
+++ b/lld/test/MachO/platform-version.s
@@ -55,7 +55,7 @@
 # RUN:-platform_version 0 1 5 \
 # RUN: | FileCheck --check-prefix=FAIL-PLATFORM %s
 # RUN: not %lld -o %t %t.o 2>&1 \
-# RUN:-platform_version 10 1 5 \
+# RUN:-platform_version 11 1 5 \
 # RUN: | FileCheck --check-prefix=FAIL-PLATFORM %s
 # FAIL-PLATFORM: malformed platform: {{.*}}
 # FAIL-PLATFORM-NOT: malformed {{minimum|sdk}} version: {{.*}}

diff  --git a/lld/test/MachO/x86-64-reloc-unsigned.s 
b/lld/test/MachO/x86-64-reloc-unsigned.s
index f1afc0cb7043..5fdbdf1f0627 100644
--- a/lld/test/MachO/x86-64-reloc-unsigned.s
+++ b/lld/test/MachO/x86-64-reloc-unsigned.s
@@ -14,6 +14,10 @@
 # RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
 # RUN: %lld -platform_version macos 10.5.0 11.0 -o %t-no-pie %t.o
 # RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s 
--check-prefix=NO-PIE
+# RUN: %lld -platform_version ios-simulator 11.0.0 14.2 -o %t-pie %t.o
+# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
+# RUN: %lld -platform_version driverkit 19.0 20.0 -o %t-pie %t.o
+# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
 
 # CHECK:   Contents of section __DATA,foo:
 # CHECK-NEXT:  11000 0810 0100

[llvm-branch-commits] [openmp] 631501b - [OpenMP] Fixing typo on memory size in Documenation

2020-12-23 Thread Joseph Huber via llvm-branch-commits

Author: Joseph Huber
Date: 2020-12-23T11:46:26-05:00
New Revision: 631501b1f90e8a90faeadbd535a557633a5af71b

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

LOG: [OpenMP] Fixing typo on memory size in Documenation

Added: 


Modified: 
openmp/docs/design/Runtimes.rst

Removed: 




diff  --git a/openmp/docs/design/Runtimes.rst b/openmp/docs/design/Runtimes.rst
index 2e5f2bfe0384..c9f3a55c0067 100644
--- a/openmp/docs/design/Runtimes.rst
+++ b/openmp/docs/design/Runtimes.rst
@@ -60,7 +60,7 @@ LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD
 ``LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD`` sets the threshold size for which the
 ``libomptarget`` memory manager will handle the allocation. Any allocations
 larger than this threshold will not use the memory manager and be freed after
-the device kernel exits The default threshold value is ``8Kb``. If
+the device kernel exits. The default threshold value is ``8KB``. If
 ``LIBOMPTARGET_MEMORY_MANAGER_THRESHOLD`` is set to ``0`` the memory manager
 will be completely disabled.
 



___
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] 42980a7 - [mlir][spirv] Convert functions returning one value

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

Author: Lei Zhang
Date: 2020-12-23T13:27:31-05:00
New Revision: 42980a789d2212f774dbb12c2555452d328089a6

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

LOG: [mlir][spirv] Convert functions returning one value

Reviewed By: hanchung, ThomasRaoux

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

Added: 


Modified: 
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp 
b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
index d15623568212..470f4143f2c5 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
@@ -924,10 +924,14 @@ LoadOpPattern::matchAndRewrite(LoadOp loadOp, 
ArrayRef operands,
 LogicalResult
 ReturnOpPattern::matchAndRewrite(ReturnOp returnOp, ArrayRef operands,
  ConversionPatternRewriter &rewriter) const {
-  if (returnOp.getNumOperands()) {
+  if (returnOp.getNumOperands() > 1)
 return failure();
+
+  if (returnOp.getNumOperands() == 1) {
+rewriter.replaceOpWithNewOp(returnOp, operands[0]);
+  } else {
+rewriter.replaceOpWithNewOp(returnOp);
   }
-  rewriter.replaceOpWithNewOp(returnOp);
   return success();
 }
 

diff  --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp 
b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
index b310d5df7b26..9393f3df6425 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
@@ -473,23 +473,27 @@ LogicalResult
 FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef operands,
   ConversionPatternRewriter &rewriter) const {
   auto fnType = funcOp.getType();
-  // TODO: support converting functions with one result.
-  if (fnType.getNumResults())
+  if (fnType.getNumResults() > 1)
 return failure();
 
   TypeConverter::SignatureConversion signatureConverter(fnType.getNumInputs());
-  for (auto argType : enumerate(funcOp.getType().getInputs())) {
+  for (auto argType : enumerate(fnType.getInputs())) {
 auto convertedType = typeConverter.convertType(argType.value());
 if (!convertedType)
   return failure();
 signatureConverter.addInputs(argType.index(), convertedType);
   }
 
+  Type resultType;
+  if (fnType.getNumResults() == 1)
+resultType = typeConverter.convertType(fnType.getResult(0));
+
   // Create the converted spv.func op.
   auto newFuncOp = rewriter.create(
   funcOp.getLoc(), funcOp.getName(),
   rewriter.getFunctionType(signatureConverter.getConvertedTypes(),
-   llvm::None));
+   resultType ? TypeRange(resultType)
+  : TypeRange()));
 
   // Copy over all attributes other than the function name and type.
   for (const auto &namedAttr : funcOp.getAttrs()) {

diff  --git a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir 
b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
index 10e43ef4acd7..850e22465d44 100644
--- a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
+++ b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
@@ -954,3 +954,29 @@ func @store_i16(%arg0: memref<10xi16>, %index: index, 
%value: i16) {
 }
 
 } // end module
+
+// -
+
+//===--===//
+// std.return
+//===--===//
+
+module attributes {
+  spv.target_env = #spv.target_env<#spv.vce, {}>
+} {
+
+// CHECK-LABEL: spv.func @return_one_val
+//  CHECK-SAME: (%[[ARG:.+]]: f32)
+func @return_one_val(%arg0: f32) -> f32 {
+  // CHECK: spv.ReturnValue %[[ARG]] : f32
+  return %arg0: f32
+}
+
+// Check that multiple-return functions are not converted.
+// CHECK-LABEL: func @return_multi_val
+func @return_multi_val(%arg0: f32) -> (f32, f32) {
+  // CHECK: return
+  return %arg0, %arg0: f32, f32
+}
+
+}



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


[llvm-branch-commits] [lldb] fcf9479 - [lldb] Don't instrument demangling.

2020-12-23 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-23T10:43:13-08:00
New Revision: fcf9479f7d65754cf311d8e5be1046f1ace28945

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

LOG: [lldb] Don't instrument demangling.

Don't instrument demangling calls. These functions are very hot and
instrumenting them quickly results in too much data to be useful.

Added: 


Modified: 
lldb/source/Core/Mangled.cpp

Removed: 




diff  --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index eaad0f3ebf45..627be94a303c 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -14,7 +14,6 @@
 #include "lldb/Utility/Logging.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Stream.h"
-#include "lldb/Utility/Timer.h"
 #include "lldb/lldb-enumerations.h"
 
 #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
@@ -227,10 +226,6 @@ static char *GetItaniumDemangledStr(const char *M) {
 // makes use of ItaniumPartialDemangler's rich demangle info
 bool Mangled::DemangleWithRichManglingInfo(
 RichManglingContext &context, SkipMangledNameFn *skip_mangled_name) {
-  // We need to generate and cache the demangled name.
-  LLDB_SCOPED_TIMERF("Mangled::DemangleWithRichNameIndexInfo (m_mangled = %s)",
- m_mangled.GetCString());
-
   // Others are not meant to arrive here. ObjC names or C's main() for example
   // have their names stored in m_demangled, while m_mangled is empty.
   assert(m_mangled);
@@ -296,10 +291,6 @@ ConstString Mangled::GetDemangledName() const {
   // Check to make sure we have a valid mangled name and that we haven't
   // already decoded our mangled name.
   if (m_mangled && m_demangled.IsNull()) {
-// We need to generate and cache the demangled name.
-LLDB_SCOPED_TIMERF("Mangled::GetDemangledName (m_mangled = %s)",
-   m_mangled.GetCString());
-
 // Don't bother running anything that isn't mangled
 const char *mangled_name = m_mangled.GetCString();
 ManglingScheme mangling_scheme = 
GetManglingScheme(m_mangled.GetStringRef());



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


[llvm-branch-commits] [lldb] a944887 - [lldb] Refactor and simplify GetCommandSPExact interface

2020-12-23 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-23T10:43:13-08:00
New Revision: a9448872fec52fc57249934b02a4d4f15f223051

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

LOG: [lldb] Refactor and simplify GetCommandSPExact interface

GetCommandSPExact is called exaclty once with include_aliases set to
true, so make it a default argument. Use early returns to simplify the
implementation.

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index d35f7e22b9ea..c4f9dd2fdb37 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -265,7 +265,7 @@ class CommandInterpreter : public Broadcaster,
   bool can_replace);
 
   lldb::CommandObjectSP GetCommandSPExact(llvm::StringRef cmd,
-  bool include_aliases) const;
+  bool include_aliases = false) const;
 
   CommandObject *GetCommandObject(llvm::StringRef cmd,
   StringList *matches = nullptr,

diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index 0c441dd69c48..3b3cdde6ab9a 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -464,7 +464,7 @@ rather than using a positional placeholder:"
 OptionArgVectorSP(new OptionArgVector);
 
 if (CommandObjectSP cmd_obj_sp =
-m_interpreter.GetCommandSPExact(cmd_obj.GetCommandName(), false)) {
+m_interpreter.GetCommandSPExact(cmd_obj.GetCommandName())) {
   if (m_interpreter.AliasExists(alias_command) ||
   m_interpreter.UserCommandExists(alias_command)) {
 result.AppendWarningWithFormat(
@@ -558,10 +558,9 @@ rather than using a positional placeholder:"
 
 if (!args.empty()) {
   CommandObjectSP tmp_sp =
-  m_interpreter.GetCommandSPExact(cmd_obj->GetCommandName(), false);
+  m_interpreter.GetCommandSPExact(cmd_obj->GetCommandName());
   if (use_subcommand)
-tmp_sp = m_interpreter.GetCommandSPExact(sub_cmd_obj->GetCommandName(),
- false);
+tmp_sp = 
m_interpreter.GetCommandSPExact(sub_cmd_obj->GetCommandName());
 
   args.GetCommandString(args_string);
 }

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index f5303f6867cd..fb503fe0afb0 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -234,48 +234,48 @@ void CommandInterpreter::Initialize() {
   OptionArgVectorSP alias_arguments_vector_sp(new OptionArgVector);
 
   // Set up some initial aliases.
-  CommandObjectSP cmd_obj_sp = GetCommandSPExact("quit", false);
+  CommandObjectSP cmd_obj_sp = GetCommandSPExact("quit");
   if (cmd_obj_sp) {
 AddAlias("q", cmd_obj_sp);
 AddAlias("exit", cmd_obj_sp);
   }
 
-  cmd_obj_sp = GetCommandSPExact("_regexp-attach", false);
+  cmd_obj_sp = GetCommandSPExact("_regexp-attach");
   if (cmd_obj_sp)
 AddAlias("attach", cmd_obj_sp)->SetSyntax(cmd_obj_sp->GetSyntax());
 
-  cmd_obj_sp = GetCommandSPExact("process detach", false);
+  cmd_obj_sp = GetCommandSPExact("process detach");
   if (cmd_obj_sp) {
 AddAlias("detach", cmd_obj_sp);
   }
 
-  cmd_obj_sp = GetCommandSPExact("process continue", false);
+  cmd_obj_sp = GetCommandSPExact("process continue");
   if (cmd_obj_sp) {
 AddAlias("c", cmd_obj_sp);
 AddAlias("continue", cmd_obj_sp);
   }
 
-  cmd_obj_sp = GetCommandSPExact("_regexp-break", false);
+  cmd_obj_sp = GetCommandSPExact("_regexp-break");
   if (cmd_obj_sp)
 AddAlias("b", cmd_obj_sp)->SetSyntax(cmd_obj_sp->GetSyntax());
 
-  cmd_obj_sp = GetCommandSPExact("_regexp-tbreak", false);
+  cmd_obj_sp = GetCommandSPExact("_regexp-tbreak");
   if (cmd_obj_sp)
 AddAlias("tbreak", cmd_obj_sp)->SetSyntax(cmd_obj_sp->GetSyntax());
 
-  cmd_obj_sp = GetCommandSPExact("thread step-inst", false);
+  cmd_obj_sp = GetCommandSPExact("thread step-inst");
   if (cmd_obj_sp) {
 AddAlias("stepi", cmd_obj_sp);
 AddAlias("si", cmd_obj_sp);
   }
 
-  cmd_obj_sp = GetCommandSPExact("thread step-inst-over", false);
+  cmd_obj_sp = GetCommandSPExact("thread step-inst-over");
   if (cmd_obj_sp) {
 AddAlias("nexti", cmd_obj_sp);
 AddAlias("ni", cmd_obj_sp);
   }
 
-  cmd_obj_sp = GetCommandSPExact("thread step-in", false);
+  cmd_obj_sp = Ge

[llvm-branch-commits] [llvm] e0110a4 - [RISCV] Add intrinsics for vfmv.v.f

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

Author: Craig Topper
Date: 2020-12-23T10:50:48-08:00
New Revision: e0110a47402348f63b7e10dcf210bdf342a3bf9c

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

LOG: [RISCV] Add intrinsics for vfmv.v.f

Also include a special case pattern to use vmv.v.x vd, zero when
the argument is 0.0.

Reviewed By: khchen

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

Added: 
llvm/test/CodeGen/RISCV/rvv/vfmv.v.f-rv32.ll
llvm/test/CodeGen/RISCV/rvv/vfmv.v.f-rv64.ll

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

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td 
b/llvm/include/llvm/IR/IntrinsicsRISCV.td
index 13f883713cd3..37e463dedfcb 100644
--- a/llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -528,6 +528,10 @@ let TargetPrefix = "riscv" in {
 [IntrNoMem]>, RISCVVIntrinsic {
 let ExtendOperand = 1;
   }
+  def int_riscv_vfmv_v_f : Intrinsic<[llvm_anyfloat_ty],
+ [LLVMVectorElementType<0>, 
llvm_anyint_ty],
+ [IntrNoMem]>, RISCVVIntrinsic;
+
   def int_riscv_vmv_x_s : Intrinsic<[LLVMVectorElementType<0>],
 [llvm_anyint_ty],
 [IntrNoMem]>, RISCVVIntrinsic;

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index 50142b0373ee..c3b720a013ed 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -779,6 +779,14 @@ multiclass VPseudoUnaryV_V_X_I_NoDummyMask {
   }
 }
 
+multiclass VPseudoUnaryV_F_NoDummyMask {
+  foreach m = MxList.m in {
+let VLMul = m.value in {
+  def "_F_" # m.MX : VPseudoUnaryNoDummyMask;
+}
+  }
+}
+
 // The destination EEW is 1.
 // The source EEW is 8, 16, 32, or 64.
 // When the destination EEW is 
diff erent from source EEW, we need to use
@@ -1995,12 +2003,16 @@ defm PseudoVMFLE   : 
VPseudoBinaryM_VV_VX;
 defm PseudoVMFGT   : VPseudoBinaryM_VX;
 defm PseudoVMFGE   : VPseudoBinaryM_VX;
 
+//===--===//
+// 14.14. Vector Floating-Point Move Instruction
+//===--===//
+defm PseudoVFMV_V  : VPseudoUnaryV_F_NoDummyMask;
+
 
//===--===//
 // 14.15. Vector Floating-Point Merge Instruction
 
//===--===//
 defm PseudoVFMERGE : VPseudoBinaryV_XM;
-
 } // Predicates = [HasStdExtV, HasStdExtF]
 
 
//===--===//
@@ -2414,6 +2426,23 @@ defm "" : VPatBinaryM_VV_VX<"int_riscv_vmfne", 
"PseudoVMFNE", AllFloatVectors>;
 defm "" : VPatBinaryM_VX<"int_riscv_vmfgt", "PseudoVMFGT", AllFloatVectors>;
 defm "" : VPatBinaryM_VX<"int_riscv_vmfge", "PseudoVMFGE", AllFloatVectors>;
 
+//===--===//
+// 14.14. Vector Floating-Point Move Instruction
+//===--===//
+foreach fvti = AllFloatVectors in {
+  // If we're splatting fpimm0, use vmv.v.x vd, x0.
+  def : Pat<(fvti.Vector (int_riscv_vfmv_v_f
+ (fvti.Scalar (fpimm0)), GPR:$vl)),
+(!cast("PseudoVMV_V_X_"#fvti.LMul.MX)
+ X0, (NoX0 GPR:$vl), fvti.SEW)>;
+
+  def : Pat<(fvti.Vector (int_riscv_vfmv_v_f
+ (fvti.Scalar fvti.ScalarRegClass:$rs2), GPR:$vl)),
+(!cast("PseudoVFMV_V_F_"#fvti.LMul.MX)
+ ToFPR32.ret,
+ (NoX0 GPR:$vl), fvti.SEW)>;
+}
+
 
//===--===//
 // 14.15. Vector Floating-Point Merge Instruction
 
//===--===//

diff  --git a/llvm/test/CodeGen/RISCV/rvv/vfmv.v.f-rv32.ll 
b/llvm/test/CodeGen/RISCV/rvv/vfmv.v.f-rv32.ll
new file mode 100644
index ..521c6b4ccbf9
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/rvv/vfmv.v.f-rv32.ll
@@ -0,0 +1,421 @@
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-v,+d,+experimental-zfh 
-target-abi ilp32d -verify-machineinstrs \
+; RUN:   --riscv-no-aliases < %s | FileCheck %s
+declare  @llvm.riscv.vfmv.v.f.nxv1f16.f16(
+  half,
+  i32);
+
+define  @intrinsic_vfmv.v.f_f_nxv1f16_f16(half %0, i32 %1) 
nounwind {
+entry:
+; CHECK-LABEL: intrinsic_vfmv.v.f_f_nxv1f16_f16
+; CHECK:   vsetvli {{.*}}, a0, e16,mf4,ta,mu
+; CHECK:   vfmv.v.f

[llvm-branch-commits] [clang] b920adf - This is a test commit

2020-12-23 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2020-12-23T12:57:27-06:00
New Revision: b920adf3b4f16bef8dde937b67874d8e8ac1030e

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

LOG: This is a test commit

Added: 


Modified: 
clang/lib/CodeGen/README.txt

Removed: 




diff  --git a/clang/lib/CodeGen/README.txt b/clang/lib/CodeGen/README.txt
index e6d61095bf23..e4fd7816d65c 100644
--- a/clang/lib/CodeGen/README.txt
+++ b/clang/lib/CodeGen/README.txt
@@ -16,6 +16,7 @@ extension. For example, if the bitfield width is 8 and it is
 appropriately aligned then is is a lot shorter to just load the char
 directly.
 
+
 //===-===//
 
 It may be worth avoiding creation of alloca's for formal arguments



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


[llvm-branch-commits] [flang] 3b3a9d2 - Updated GettingInvolved.md to reflect Flang Biweekly Call changes

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

Author: AlexisPerry
Date: 2020-12-23T11:59:12-07:00
New Revision: 3b3a9d24188a0b04bd4d47d7308da0f64430dffe

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

LOG: Updated GettingInvolved.md to reflect Flang Biweekly Call changes

   - updated the link to join the meeting to reflect the new WebEx information
   - Added a note about the new Google Doc for keeping track of notes, and who
 to contact if you experience access issues with the document
   - Left a reference to the minutes from previous meetings being available
 through a search of the flang-dev mailing list

Reviewed By: jdoerfert

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

Added: 


Modified: 
flang/docs/GettingInvolved.md

Removed: 




diff  --git a/flang/docs/GettingInvolved.md b/flang/docs/GettingInvolved.md
index c8dbbf106fac..24e2383a895e 100644
--- a/flang/docs/GettingInvolved.md
+++ b/flang/docs/GettingInvolved.md
@@ -45,9 +45,11 @@ To understand the status of various developments in Flang 
please join the respec
 ### Flang Community Biweekly Call
 
 -   General updates on the Flang Project, both LLVM Flang and current Flang.
--   Join [Flang Community Biweekly 
Call](https://nvmeet.webex.com/nvmeet/j.php?MTID=mb4edb8c799f69ec2dc0554acc969a162)
+-   Join [Flang Community Biweekly 
Call](https://lanl-us.webex.com/lanl-us/j.php?MTID=m44f29d1fa15eab5cbedc54a5df6c12ae)
 -   Time: On Wednesdays 8:30 Pacific Time, on the weeks alternating with 
regular Flang Community Technical Biweekly Call.
--   Minutes: They are sent to 
[flang-dev](http://lists.llvm.org/mailman/listinfo/flang-dev). Search for 
`Flang Biweekly Sync - Notes`.
+-   Meeting minutes are available in this [Google 
Doc](https://docs.google.com/document/d/10T-S2J3GrahpG4Ooif93NSTz2zBW0MQc_RlwHi0-afY/edit?usp=sharing).
+If you can not access the Google Doc, please send an email to Alexis 
Perry-Holby at ape...@lanl.gov requesting to be added to the access list.
+-   Minutes from older meetings were sent to 
[flang-dev](http://lists.llvm.org/mailman/listinfo/flang-dev). Search for 
`Flang Biweekly Sync - Notes`.
 
 ### Flang Community Technical Biweekly Call
 



___
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] b1191c8 - [IROutliner] Adding support for elevating constants that are not the same in each region to arguments

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

Author: Andrew Litteken
Date: 2020-12-23T13:03:05-06:00
New Revision: b1191c843804c2b2b98ebc88a890589ab7f9af23

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

LOG: [IROutliner] Adding support for elevating constants that are not the same 
in each region to arguments

When there are constants that have the same structural location, but not
the same value, between different regions, we cannot simply outline the
region. Instead, we find the constants that are not the same in each
location, and promote them to arguments to be passed into the respective
functions. At each call site, we pass the constant in as an argument
regardless of type.

Added/Edited Tests:

llvm/test/Transforms/IROutliner/outlining-constants-vs-registers.ll
llvm/test/Transforms/IROutliner/outlining-different-constants.ll
llvm/test/Transforms/IROutliner/outlining-different-globals.ll

Reviewers: paquette, jroelofs

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

Added: 


Modified: 
llvm/include/llvm/Transforms/IPO/IROutliner.h
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/test/Transforms/IROutliner/outlining-constants-vs-registers.ll
llvm/test/Transforms/IROutliner/outlining-different-constants.ll
llvm/test/Transforms/IROutliner/outlining-different-globals.ll

Removed: 




diff  --git a/llvm/include/llvm/Transforms/IPO/IROutliner.h 
b/llvm/include/llvm/Transforms/IPO/IROutliner.h
index 01f870097972..87f276d82df7 100644
--- a/llvm/include/llvm/Transforms/IPO/IROutliner.h
+++ b/llvm/include/llvm/Transforms/IPO/IROutliner.h
@@ -81,6 +81,12 @@ struct OutlinableRegion {
   DenseMap ExtractedArgToAgg;
   DenseMap AggArgToExtracted;
 
+  /// Mapping of the argument number in the deduplicated function
+  /// to a given constant, which is used when creating the arguments to the 
call
+  /// to the newly created deduplicated function.  This is handled separately
+  /// since the CodeExtractor does not recognize constants.
+  DenseMap AggArgToConstant;
+
   /// Used to create an outlined function.
   CodeExtractor *CE = nullptr;
 
@@ -180,8 +186,11 @@ class IROutliner {
   /// function if needed.
   ///
   /// \param [in] M - The module to outline from.
-  /// \param [in,out] Region - The region to be extracted
-  void findAddInputsOutputs(Module &M, OutlinableRegion &Region);
+  /// \param [in,out] Region - The region to be extracted.
+  /// \param [in] NotSame - The global value numbers of the Values in the 
region
+  /// that do not have the same Constant in each strucutrally similar region.
+  void findAddInputsOutputs(Module &M, OutlinableRegion &Region,
+DenseSet &NotSame);
 
   /// Extract \p Region into its own function.
   ///

diff  --git a/llvm/lib/Transforms/IPO/IROutliner.cpp 
b/llvm/lib/Transforms/IPO/IROutliner.cpp
index c879031faf5a..5b19d0718ab6 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -211,6 +211,8 @@ static bool
 collectRegionsConstants(OutlinableRegion &Region,
 DenseMap &GVNToConstant,
 DenseSet &NotSame) {
+  bool ConstantsTheSame = true;
+
   IRSimilarityCandidate &C = *Region.Candidate;
   for (IRInstructionData &ID : C) {
 
@@ -222,11 +224,10 @@ collectRegionsConstants(OutlinableRegion &Region,
   assert(GVNOpt.hasValue() && "Expected a GVN for operand?");
   unsigned GVN = GVNOpt.getValue();
 
-  // If this global value has been found to not be the same, it could have
-  // just been a register, check that it is not a constant value.
+  // Check if this global value has been found to not be the same already.
   if (NotSame.find(GVN) != NotSame.end()) {
 if (isa(V))
-  return false;
+  ConstantsTheSame = false;
 continue;
   }
 
@@ -239,30 +240,27 @@ collectRegionsConstants(OutlinableRegion &Region,
 if (ConstantMatches.getValue())
   continue;
 else
-  return false;
+  ConstantsTheSame = false;
   }
 
   // While this value is a register, it might not have been previously,
   // make sure we don't already have a constant mapped to this global value
   // number.
   if (GVNToConstant.find(GVN) != GVNToConstant.end())
-return false;
+ConstantsTheSame = false;
 
   NotSame.insert(GVN);
 }
   }
 
-  return true;
+  return ConstantsTheSame;
 }
 
 void OutlinableGroup::findSameConstants(DenseSet &NotSame) {
   DenseMap GVNToConstant;
 
   for (OutlinableRegion *Region : Regions)
-if (!collectRegionsConstants(*Region, GVNToConstant, NotSame)) {
-  IgnoreGroup = true;
-  return;
-}
+collectRegionsConstants(*Region, GVNToConstant, NotSame);
 }
 
 Function *IROutliner::createFunction(Modu

[llvm-branch-commits] [clang] bbd758a - Revert "This is a test commit"

2020-12-23 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2020-12-23T13:04:37-06:00
New Revision: bbd758a7913b1c374ca26e5a734a01200754fe0e

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

LOG: Revert "This is a test commit"

This reverts commit b920adf3b4f16bef8dde937b67874d8e8ac1030e.

Added: 


Modified: 
clang/lib/CodeGen/README.txt

Removed: 




diff  --git a/clang/lib/CodeGen/README.txt b/clang/lib/CodeGen/README.txt
index e4fd7816d65c..e6d61095bf23 100644
--- a/clang/lib/CodeGen/README.txt
+++ b/clang/lib/CodeGen/README.txt
@@ -16,7 +16,6 @@ extension. For example, if the bitfield width is 8 and it is
 appropriately aligned then is is a lot shorter to just load the char
 directly.
 
-
 //===-===//
 
 It may be worth avoiding creation of alloca's for formal arguments



___
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] 1876a29 - Revert more changes that landed on top of 741978d727

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

Author: Nico Weber
Date: 2020-12-23T14:20:21-05:00
New Revision: 1876a2914fe0bedf50f7be6a305f5bf35493e496

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

LOG: Revert more changes that landed on top of 741978d727

This should've been in 7ad666798f12456d9 but wasn't.

Squashes these twoc commits:
Revert "[clang][cli] Let denormalizer decide how to render the option based on 
the option class"
This reverts commit 70410a264949101ced3ce3458f37dd4cc2f5af85.

Revert "[clang][cli] Implement `getAllArgValues` marshalling"
This reverts commit 63a24816f561a5d8e28ca7054892bd8602618be4.

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7f63a5577262..af209eb9089d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1839,8 +1839,7 @@ def fsystem_module : Flag<["-"], "fsystem-module">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag<"FrontendOpts.IsSystemModule">;
 def fmodule_map_file : Joined<["-"], "fmodule-map-file=">,
   Group, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
-  HelpText<"Load this module map file">,
-  MarshallingInfoStringVector<"FrontendOpts.ModuleMapFiles">;
+  HelpText<"Load this module map file">;
 def fmodule_file : Joined<["-"], "fmodule-file=">,
   Group, Flags<[NoXarchOption,CC1Option]>, 
MetaVarName<"[=]">,
   HelpText<"Specify the mapping of module name to precompiled module file, or 
load a module file if name is omitted.">;
@@ -4625,7 +4624,7 @@ def arcmt_action_EQ : Joined<["-"], "arcmt-action=">, 
Flags<[CC1Option, NoDriver
   NormalizedValuesScope<"FrontendOptions">,
   NormalizedValues<["ARCMT_Check", "ARCMT_Modify", "ARCMT_Migrate"]>,
   MarshallingInfoString<"FrontendOpts.ARCMTAction", "ARCMT_None">,
-  AutoNormalizeEnum;
+  AutoNormalizeEnumJoined;
 
 def opt_record_file : Separate<["-"], "opt-record-file">,
   HelpText<"File name to use for YAML optimization record output">;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index a7a5a73eebdd..06d8d2e27c9b 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -152,8 +152,8 @@ static Optional 
normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
 /// argument.
 static void denormalizeSimpleFlag(SmallVectorImpl &Args,
   const char *Spelling,
-  CompilerInvocation::StringAllocator,
-  Option::OptionClass, unsigned, /*T*/...) {
+  CompilerInvocation::StringAllocator, 
unsigned,
+  /*T*/...) {
   Args.push_back(Spelling);
 }
 
@@ -193,41 +193,12 @@ static auto makeBooleanOptionNormalizer(bool Value, bool 
OtherValue,
 
 static auto makeBooleanOptionDenormalizer(bool Value) {
   return [Value](SmallVectorImpl &Args, const char *Spelling,
- CompilerInvocation::StringAllocator, Option::OptionClass,
- unsigned, bool KeyPath) {
+ CompilerInvocation::StringAllocator, unsigned, bool KeyPath) {
 if (KeyPath == Value)
   Args.push_back(Spelling);
   };
 }
 
-static void denormalizeStringImpl(SmallVectorImpl &Args,
-  const char *Spelling,
-  CompilerInvocation::StringAllocator SA,
-  Option::OptionClass OptClass, unsigned,
-  Twine Value) {
-  switch (OptClass) {
-  case Option::SeparateClass:
-  case Option::JoinedOrSeparateClass:
-Args.push_back(Spelling);
-Args.push_back(SA(Value));
-break;
-  case Option::JoinedClass:
-Args.push_back(SA(Twine(Spelling) + Value));
-break;
-  default:
-llvm_unreachable("Cannot denormalize an option with option class "
- "incompatible with string denormalization.");
-  }
-}
-
-template 
-static void
-denormalizeString(SmallVectorImpl &Args, const char *Spelling,
-  CompilerInvocation::StringAllocator SA,
-  Option::OptionClass OptClass, unsigned TableIndex, T Value) {
-  denormalizeStringImpl(Args, Spelling, SA, OptClass, TableIndex, 
Twine(Value));
-}
-
 static Optional
 findValueTableByName(const SimpleEnumValueTable &Table, StringRef Name) {
   for (int I = 0, E = Table.Size; I != E; ++I)
@@ -269,13 +240,12 @@ static llvm::Optional 
normalizeSimpleEnum(OptSpecifier Opt,
 static void denormalizeSimpleEnumImpl(SmallVectorImpl &Args,

[llvm-branch-commits] [mlir] 7418688 - [mlir][vector] Add more vector Ops canonicalization

2020-12-23 Thread Thomas Raoux via llvm-branch-commits

Author: Thomas Raoux
Date: 2020-12-23T11:25:01-08:00
New Revision: 74186880ba99b37c0375e9d87df818beee8b4ff2

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

LOG: [mlir][vector] Add more vector Ops canonicalization

Add canonicalization for BroadcastOp, ExtractStrideSlicesOp and ShapeCastOp

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Vector/VectorOps.td
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/test/Dialect/Vector/canonicalize.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Vector/VectorOps.td 
b/mlir/include/mlir/Dialect/Vector/VectorOps.td
index 13aba2076ee9..e031f87cfb8e 100644
--- a/mlir/include/mlir/Dialect/Vector/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/VectorOps.td
@@ -271,6 +271,7 @@ def Vector_BroadcastOp :
   }];
   let assemblyFormat = "$source attr-dict `:` type($source) `to` 
type($vector)";
   let hasFolder = 1;
+  let hasCanonicalizer = 1;
 }
 
 def Vector_ShuffleOp :

diff  --git a/mlir/lib/Dialect/Vector/VectorOps.cpp 
b/mlir/lib/Dialect/Vector/VectorOps.cpp
index a3ad355d30b2..539e00d58dbf 100644
--- a/mlir/lib/Dialect/Vector/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/VectorOps.cpp
@@ -1110,6 +1110,36 @@ OpFoldResult BroadcastOp::fold(ArrayRef 
operands) {
   return {};
 }
 
+namespace {
+
+// BroadcastOp can only add dimensions or broadcast a dimension from 1 to N. In
+// the degenerated case where the broadcast only adds dimensions of size 1 it
+// can be replaced by a ShapeCastOp. This canonicalization checks if the total
+// number of elements is the same before and after the broadcast to detect if
+// the only change in the vector type are new dimensions of size 1.
+class BroadcastToShapeCast final : public OpRewritePattern {
+public:
+  using OpRewritePattern::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(BroadcastOp broadcastOp,
+PatternRewriter &rewriter) const override {
+auto srcVecType = broadcastOp.getSourceType().dyn_cast();
+if (!srcVecType || broadcastOp.getVectorType().getNumElements() !=
+   srcVecType.getNumElements())
+  return failure();
+rewriter.replaceOpWithNewOp(
+broadcastOp, broadcastOp.getVectorType(), broadcastOp.source());
+return success();
+  }
+};
+
+} // namespace
+
+void BroadcastOp::getCanonicalizationPatterns(
+OwningRewritePatternList &results, MLIRContext *context) {
+  results.insert(context);
+}
+
 
//===--===//
 // ShuffleOp
 
//===--===//
@@ -1768,7 +1798,8 @@ void 
ExtractStridedSliceOp::getOffsets(SmallVectorImpl &results) {
 
 namespace {
 
-// Pattern to rewrite a ExtractStridedSliceOp(ConstantMaskOp) -> 
ConstantMaskOp.
+// Pattern to rewrite an ExtractStridedSliceOp(ConstantMaskOp) to
+// ConstantMaskOp.
 class StridedSliceConstantMaskFolder final
 : public OpRewritePattern {
 public:
@@ -1847,14 +1878,70 @@ class StridedSliceConstantFolder final
   }
 };
 
+// Helper that returns a subset of `arrayAttr` as a vector of int64_t.
+static SmallVector getI64SubArray(ArrayAttr arrayAttr,
+  unsigned dropFront = 0,
+  unsigned dropBack = 0) {
+  assert(arrayAttr.size() > dropFront + dropBack && "Out of bounds");
+  auto range = arrayAttr.getAsRange();
+  SmallVector res;
+  res.reserve(arrayAttr.size() - dropFront - dropBack);
+  for (auto it = range.begin() + dropFront, eit = range.end() - dropBack;
+   it != eit; ++it)
+res.push_back((*it).getValue().getSExtValue());
+  return res;
+}
+
+// Pattern to rewrite an ExtractStridedSliceOp(BroadcastOp) to
+// BroadcastOp(ExtractStrideSliceOp).
+class StridedSliceBroadcast final
+: public OpRewritePattern {
+public:
+  using OpRewritePattern::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(ExtractStridedSliceOp op,
+PatternRewriter &rewriter) const override {
+auto broadcast = op.vector().getDefiningOp();
+if (!broadcast)
+  return failure();
+auto srcVecType = broadcast.source().getType().dyn_cast();
+unsigned srcRrank = srcVecType ? srcVecType.getRank() : 0;
+auto dstVecType = op.getType().cast();
+unsigned dstRank = dstVecType.getRank();
+unsigned rankDiff = dstRank - srcRrank;
+// Check if the most inner dimensions of the source of the broacast are the
+// same as the destination of the extract. If this is the case we can just
+// use a broadcast as the original dimensions are untouched.
+bool lowerDimMatch = true;
+for (unsigned i = 0; i < srcRrank; i++) {
+

[llvm-branch-commits] [clang] 4c37453 - clang: Build and run FrontendTests with CLANG_ENABLE_STATIC_ANALYZER=OFF too

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

Author: Nico Weber
Date: 2020-12-23T14:27:09-05:00
New Revision: 4c37453a04f942dd676af1eda5d0760d4ffe8927

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

LOG: clang: Build and run FrontendTests with CLANG_ENABLE_STATIC_ANALYZER=OFF 
too

They seem to pass fine with the analyzer off, and with this I would've
noticed my last check-clang break locally.

Added: 


Modified: 
clang/unittests/CMakeLists.txt
llvm/utils/gn/secondary/clang/unittests/BUILD.gn

Removed: 




diff  --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index 4c222e24599f..bb635dfff991 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -24,13 +24,13 @@ add_subdirectory(Driver)
 if(CLANG_ENABLE_STATIC_ANALYZER)
   add_subdirectory(Analysis)
   add_subdirectory(StaticAnalyzer)
-  add_subdirectory(Frontend)
 endif()
 add_subdirectory(ASTMatchers)
 add_subdirectory(AST)
 add_subdirectory(CrossTU)
 add_subdirectory(Tooling)
 add_subdirectory(Format)
+add_subdirectory(Frontend)
 add_subdirectory(Rewrite)
 add_subdirectory(Sema)
 add_subdirectory(CodeGen)

diff  --git a/llvm/utils/gn/secondary/clang/unittests/BUILD.gn 
b/llvm/utils/gn/secondary/clang/unittests/BUILD.gn
index d1382919b5e2..23f5d2dfac85 100644
--- a/llvm/utils/gn/secondary/clang/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/unittests/BUILD.gn
@@ -10,6 +10,7 @@ group("unittests") {
 "CrossTU:CrossTUTests",
 "Driver:ClangDriverTests",
 "Format:FormatTests",
+"Frontend:FrontendTests",
 "Index:IndexTests",
 "Lex:LexTests",
 "Rename:ClangRenameTests",
@@ -22,7 +23,6 @@ group("unittests") {
   if (clang_enable_static_analyzer) {
 deps += [
   "Analysis:ClangAnalysisTests",
-  "Frontend:FrontendTests",
   "StaticAnalyzer:StaticAnalysisTests",
 ]
   }



___
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] e124844 - [LoopIdiom] Introduce 'left-shift until bittest' idiom

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

Author: Roman Lebedev
Date: 2020-12-23T22:28:09+03:00
New Revision: e124844709228a076483d8b6101bbb362caf625f

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

LOG: [LoopIdiom] Introduce 'left-shift until bittest' idiom

The motivation here is the following inner loop in fp16/fp24 -> fp32 expander,
that runs as part of the floating-point DNG decompression in RawSpeed library:
https://github.com/darktable-org/rawspeed/blob/cd380bb9a209bd2e7a0e7022b0cab04528d151e7/src/librawspeed/decompressors/DeflateDecompressor.cpp#L112-L115
```
  while (!(fp32_fraction & (1 << 23))) {
fp32_exponent -= 1;
fp32_fraction <<= 1;
  }
```
(https://godbolt.org/z/r13YMh)
As one might notice, that loop is currently uncountable, and that whole code 
stays scalar.
Yet, it is rather trivial to make that loop countable:
 https://godbolt.org/z/do8WMz
and we can prove that via alive2:
 https://alive2.llvm.org/ce/z/7vQnji (ha nice, isn't it?)
... and that allow for the whole fp16->fp32 code to vectorize:
 https://godbolt.org/z/7hYr13

Now, while i'd love to get there, i feel like i should take it in steps.

For now, this introduces support for the most basic case,
where the bit position is known as a variable,
and the loop *will* go away (has no live-outs other than the recurrence,
no extra instructions in the loop).

I have added sufficient (i believe) test coverage,
and alive2 is happy with those transforms.

Reviewed By: craig.topper

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp 
b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 15d1e8da5baa..e87ebaf4ad94 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -79,6 +79,7 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/IR/PatternMatch.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
@@ -106,6 +107,9 @@ using namespace llvm;
 
 STATISTIC(NumMemSet, "Number of memset's formed from loop stores");
 STATISTIC(NumMemCpy, "Number of memcpy's formed from loop load+stores");
+STATISTIC(
+NumShiftUntilBitTest,
+"Number of uncountable loops recognized as 'shift until bitttest' idiom");
 
 bool DisableLIRP::All;
 static cl::opt
@@ -227,6 +231,8 @@ class LoopIdiomRecognize {
 const DebugLoc &DL, bool ZeroCheck,
 bool IsCntPhiUsedOutsideLoop);
 
+  bool recognizeShiftUntilBitTest();
+
   /// @}
 };
 
@@ -1228,7 +1234,8 @@ bool LoopIdiomRecognize::runOnNoncountableLoop() {
 << "] Noncountable Loop %"
 << CurLoop->getHeader()->getName() << "\n");
 
-  return recognizePopcount() || recognizeAndInsertFFS();
+  return recognizePopcount() || recognizeAndInsertFFS() ||
+ recognizeShiftUntilBitTest();
 }
 
 /// Check if the given conditional branch is based on the comparison between
@@ -1911,3 +1918,300 @@ void 
LoopIdiomRecognize::transformLoopToPopcount(BasicBlock *PreCondBB,
   //   loop. The loop would otherwise not be deleted even if it becomes empty.
   SE->forgetLoop(CurLoop);
 }
+
+/// Match loop-invariant value.
+template  struct match_LoopInvariant {
+  SubPattern_t SubPattern;
+  const Loop *L;
+
+  match_LoopInvariant(const SubPattern_t &SP, const Loop *L)
+  : SubPattern(SP), L(L) {}
+
+  template  bool match(ITy *V) {
+return L->isLoopInvariant(V) && SubPattern.match(V);
+  }
+};
+
+/// Matches if the value is loop-invariant.
+template 
+inline match_LoopInvariant m_LoopInvariant(const Ty &M, const Loop *L) {
+  return match_LoopInvariant(M, L);
+}
+
+/// Return true if the idiom is detected in the loop.
+///
+/// The core idiom we are trying to detect is:
+/// \code
+///   entry:
+/// <...>
+/// %bitmask = shl i32 1, %bitpos
+/// br label %loop
+///
+///   loop:
+/// %x.curr = phi i32 [ %x, %entry ], [ %x.next, %loop ]
+/// %x.curr.bitmasked = and i32 %x.curr, %bitmask
+/// %x.curr.isbitunset = icmp eq i32 %x.curr.bitmasked, 0
+/// %x.next = shl i32 %x.curr, 1
+/// br i1 %x.curr.isbitunset, label %loop, label %end
+///
+///   end:
+/// %x.curr.res = phi i32 [ %x.curr, %loop ] <...>
+/// %x.next.res = phi i32 [ %x.next, %loop ] <...>
+/// <...>
+/// \endcode
+static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, Value *&BaseX,
+ Value *&BitMask, Value *&BitPos,
+ Value *&CurrX, Value *&NextX) {

[llvm-branch-commits] [llvm] cb2e598 - [LoopIdiom] 'left-shift until bittest' idiom: support constant bit mask

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

Author: Roman Lebedev
Date: 2020-12-23T22:28:09+03:00
New Revision: cb2e5980bae3bead524895f4f36e4f71cd764a1b

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

LOG: [LoopIdiom] 'left-shift until bittest' idiom: support constant bit mask

The handing of the case where the mask is a constant is trivial,
if said constant is a power of two, the bit in question is log2(mask),
rest just works.

Reviewed By: craig.topper

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp 
b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index e87ebaf4ad94..f71f320aceb5 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -2000,9 +2000,14 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, 
Value *&BaseX,
  m_LoopInvariant(m_Shl(m_One(), m_Value(BitPos)),
  CurLoop;
   };
+  auto MatchConstantBitMask = [&]() {
+return ICmpInst::isEquality(Pred) && match(CmpRHS, m_Zero()) &&
+   match(CmpLHS, m_And(m_Value(CurrX),
+   m_CombineAnd(m_Value(BitMask), m_Power2( &&
+   (BitPos = ConstantExpr::getExactLogBase2(cast(BitMask)));
+  };
 
-  if (!MatchVariableBitMask()) {
-// FIXME: support constant bit mask.
+  if (!MatchVariableBitMask() && !MatchConstantBitMask()) {
 // FIXME: support sign bit test (use llvm::decomposeBitTestICmp()).
 LLVM_DEBUG(dbgs() << DEBUG_TYPE " Bad backedge comparison.\n");
 return false;

diff  --git a/llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll 
b/llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll
index 3b128aa7b1d2..b5061efe73a5 100644
--- a/llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll
+++ b/llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll
@@ -144,22 +144,47 @@ end:
 }
 
 define i32 @p2_constant_mask_24thbit(i32 %x) {
-; ALL-LABEL: @p2_constant_mask_24thbit(
-; ALL-NEXT:  entry:
-; ALL-NEXT:br label [[LOOP:%.*]], [[DBG46:!dbg !.*]]
-; ALL:   loop:
-; ALL-NEXT:[[X_CURR:%.*]] = phi i32 [ [[X:%.*]], [[ENTRY:%.*]] ], [ 
[[X_NEXT:%.*]], [[LOOP]] ], [[DBG47:!dbg !.*]]
-; ALL-NEXT:call void @llvm.dbg.value(metadata i32 [[X_CURR]], 
[[META42:metadata !.*]], metadata !DIExpression()), [[DBG47]]
-; ALL-NEXT:[[X_CURR_BITMASKED:%.*]] = and i32 [[X_CURR]], 16777216, 
[[DBG48:!dbg !.*]]
-; ALL-NEXT:call void @llvm.dbg.value(metadata i32 [[X_CURR_BITMASKED]], 
[[META43:metadata !.*]], metadata !DIExpression()), [[DBG48]]
-; ALL-NEXT:[[X_CURR_ISBITUNSET:%.*]] = icmp eq i32 [[X_CURR_BITMASKED]], 
0, [[DBG49:!dbg !.*]]
-; ALL-NEXT:call void @llvm.dbg.value(metadata i1 [[X_CURR_ISBITUNSET]], 
[[META44:metadata !.*]], metadata !DIExpression()), [[DBG49]]
-; ALL-NEXT:[[X_NEXT]] = shl i32 [[X_CURR]], 1, [[DBG50:!dbg !.*]]
-; ALL-NEXT:call void @llvm.dbg.value(metadata i32 [[X_NEXT]], 
[[META45:metadata !.*]], metadata !DIExpression()), [[DBG50]]
-; ALL-NEXT:br i1 [[X_CURR_ISBITUNSET]], label [[LOOP]], label [[END:%.*]], 
[[DBG51:!dbg !.*]]
-; ALL:   end:
-; ALL-NEXT:[[X_CURR_LCSSA:%.*]] = phi i32 [ [[X_CURR]], [[LOOP]] ], 
[[DBG47]]
-; ALL-NEXT:ret i32 [[X_CURR_LCSSA]], [[DBG52:!dbg !.*]]
+; LZCNT-LABEL: @p2_constant_mask_24thbit(
+; LZCNT-NEXT:  entry:
+; LZCNT-NEXT:[[X_MASKED:%.*]] = and i32 [[X:%.*]], 33554431, [[DBG46:!dbg 
!.*]]
+; LZCNT-NEXT:[[X_MASKED_NUMLEADINGZEROS:%.*]] = call i32 
@llvm.ctlz.i32(i32 [[X_MASKED]], i1 true), [[DBG46]]
+; LZCNT-NEXT:[[X_MASKED_NUMACTIVEBITS:%.*]] = sub i32 32, 
[[X_MASKED_NUMLEADINGZEROS]], [[DBG46]]
+; LZCNT-NEXT:[[X_MASKED_LEADINGONEPOS:%.*]] = add i32 
[[X_MASKED_NUMACTIVEBITS]], -1, [[DBG46]]
+; LZCNT-NEXT:[[LOOP_BACKEDGETAKENCOUNT:%.*]] = sub i32 24, 
[[X_MASKED_LEADINGONEPOS]], [[DBG46]]
+; LZCNT-NEXT:[[LOOP_TRIPCOUNT:%.*]] = add nuw i32 
[[LOOP_BACKEDGETAKENCOUNT]], 1, [[DBG46]]
+; LZCNT-NEXT:[[X_CURR:%.*]] = shl i32 [[X]], [[LOOP_BACKEDGETAKENCOUNT]], 
[[DBG46]]
+; LZCNT-NEXT:[[X_NEXT:%.*]] = shl i32 [[X]], [[LOOP_TRIPCOUNT]], [[DBG46]]
+; LZCNT-NEXT:br label [[LOOP:%.*]], [[DBG47:!dbg !.*]]
+; LZCNT:   loop:
+; LZCNT-NEXT:[[TMP0:%.*]] = phi i32 [ [[X]], [[ENTRY:%.*]] ], [ 
[[X_NEXT]], [[LOOP]] ], [[DBG46]]
+; LZCNT-NEXT:call void @llvm.dbg.value(metadata i32 [[X_CURR]], 
[[META42:metadata !.*]], metadata !DIExpression()), [[DBG46]]
+; LZCNT-NEXT:[[X_CURR_BITMASKED:%.*]] = and i32 [[X_CURR]], 16777216, 
[[DBG48:!dbg !.*]]
+; LZCNT-NEXT:call void @

[llvm-branch-commits] [llvm] a0ddc61 - [LoopIdiom] 'left-shift until bittest' idiom: support canonical sign bit mask

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

Author: Roman Lebedev
Date: 2020-12-23T22:28:09+03:00
New Revision: a0ddc61c5b95be2585b6b4981cf8634d7a00e4a6

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

LOG: [LoopIdiom] 'left-shift until bittest' idiom: support canonical sign bit 
mask

If the bitmask is for sign bit, instcombine would have canonicalized
the pattern into a proper sign bit check. Supporting that is still
simple, but requires a bit of a roundtrip - we first have to use
`decomposeBitTestICmp()`, and the rest again just works.

Reviewed By: craig.topper

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp 
b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index f71f320aceb5..02556fb79dc5 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -47,6 +47,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/Analysis/CmpInstAnalysis.h"
 #include "llvm/Analysis/LoopAccessAnalysis.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/LoopPass.h"
@@ -1961,7 +1962,8 @@ inline match_LoopInvariant m_LoopInvariant(const Ty 
&M, const Loop *L) {
 /// \endcode
 static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, Value *&BaseX,
  Value *&BitMask, Value *&BitPos,
- Value *&CurrX, Value *&NextX) {
+ Value *&CurrX, Value *&NextX,
+ size_t &CanonicalHeaderSize) {
   LLVM_DEBUG(dbgs() << DEBUG_TYPE
  " Performing shift-until-bittest idiom detection.\n");
 
@@ -1992,6 +1994,7 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, 
Value *&BaseX,
   // Step 2: Check if the backedge's condition is in desirable form.
 
   auto MatchVariableBitMask = [&]() {
+CanonicalHeaderSize = 5;
 return ICmpInst::isEquality(Pred) && match(CmpRHS, m_Zero()) &&
match(CmpLHS,
  m_c_And(m_Value(CurrX),
@@ -2001,14 +2004,24 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, 
Value *&BaseX,
  CurLoop;
   };
   auto MatchConstantBitMask = [&]() {
+CanonicalHeaderSize = 5;
 return ICmpInst::isEquality(Pred) && match(CmpRHS, m_Zero()) &&
match(CmpLHS, m_And(m_Value(CurrX),
m_CombineAnd(m_Value(BitMask), m_Power2( &&
(BitPos = ConstantExpr::getExactLogBase2(cast(BitMask)));
   };
+  auto MatchDecomposableConstantBitMask = [&]() {
+CanonicalHeaderSize = 4;
+
+APInt Mask;
+return llvm::decomposeBitTestICmp(CmpLHS, CmpRHS, Pred, CurrX, Mask) &&
+   ICmpInst::isEquality(Pred) && Mask.isPowerOf2() &&
+   (BitMask = ConstantInt::get(CurrX->getType(), Mask)) &&
+   (BitPos = ConstantInt::get(CurrX->getType(), Mask.logBase2()));
+  };
 
-  if (!MatchVariableBitMask() && !MatchConstantBitMask()) {
-// FIXME: support sign bit test (use llvm::decomposeBitTestICmp()).
+  if (!MatchVariableBitMask() && !MatchConstantBitMask() &&
+  !MatchDecomposableConstantBitMask()) {
 LLVM_DEBUG(dbgs() << DEBUG_TYPE " Bad backedge comparison.\n");
 return false;
   }
@@ -2097,8 +2110,9 @@ bool LoopIdiomRecognize::recognizeShiftUntilBitTest() {
   bool MadeChange = false;
 
   Value *X, *BitMask, *BitPos, *XCurr, *XNext;
-  if (!detectShiftUntilBitTestIdiom(CurLoop, X, BitMask, BitPos, XCurr,
-XNext)) {
+  size_t CanonicalHeaderSize;
+  if (!detectShiftUntilBitTestIdiom(CurLoop, X, BitMask, BitPos, XCurr, XNext,
+CanonicalHeaderSize)) {
 LLVM_DEBUG(dbgs() << DEBUG_TYPE
" shift-until-bittest idiom detection failed.\n");
 return MadeChange;
@@ -2118,7 +2132,6 @@ bool LoopIdiomRecognize::recognizeShiftUntilBitTest() {
   // The loop must not have any other instructions other than the idiom itself.
   // FIXME: we could just rewrite the loop with countable trip count.
   size_t HeaderSize = LoopHeaderBB->sizeWithoutDebug();
-  constexpr size_t CanonicalHeaderSize = 5;
   assert(HeaderSize >= CanonicalHeaderSize);
   if (HeaderSize > CanonicalHeaderSize) {
 LLVM_DEBUG(dbgs() << DEBUG_TYPE " Won't be able to delete loop!\n");

diff  --git a/llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll 
b/llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll
index b5061efe73a5..53d33cb7a005 100644
--- a/llvm/test/Transforms/Lo

[llvm-branch-commits] [llvm] 2b61e7c - [LoopIdiom] 'left-shift until bittest' idiom: support rewriting loop as countable, allow extra cruft

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

Author: Roman Lebedev
Date: 2020-12-23T22:28:10+03:00
New Revision: 2b61e7c68cda16159b186fea1a1b1252b94b7e16

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

LOG: [LoopIdiom] 'left-shift until bittest' idiom: support rewriting loop as 
countable, allow extra cruft

The current state of the transform is still not enough to support
my motivational pattern, because it has one more "induction variable".

I have delayed posting this patch, because originally even just rewriting
the loop as countable wasn't enough to nicely transform my motivational pattern,
because i expected that extra IV to be rewritten afterwards,
but it wasn't happening until i fixed that in D91800.

So, this patch allows the  'left-shift until bittest' loop idiom
as long as the inserted ops are cheap,
and lifts any and all extra use checks on the instructions.

Reviewed By: craig.topper

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp 
b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 02556fb79dc5..9ab896f58141 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -1953,6 +1953,7 @@ inline match_LoopInvariant m_LoopInvariant(const Ty 
&M, const Loop *L) {
 /// %x.curr.bitmasked = and i32 %x.curr, %bitmask
 /// %x.curr.isbitunset = icmp eq i32 %x.curr.bitmasked, 0
 /// %x.next = shl i32 %x.curr, 1
+/// <...>
 /// br i1 %x.curr.isbitunset, label %loop, label %end
 ///
 ///   end:
@@ -1962,8 +1963,7 @@ inline match_LoopInvariant m_LoopInvariant(const Ty 
&M, const Loop *L) {
 /// \endcode
 static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, Value *&BaseX,
  Value *&BitMask, Value *&BitPos,
- Value *&CurrX, Value *&NextX,
- size_t &CanonicalHeaderSize) {
+ Value *&CurrX, Value *&NextX) {
   LLVM_DEBUG(dbgs() << DEBUG_TYPE
  " Performing shift-until-bittest idiom detection.\n");
 
@@ -1994,7 +1994,6 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, 
Value *&BaseX,
   // Step 2: Check if the backedge's condition is in desirable form.
 
   auto MatchVariableBitMask = [&]() {
-CanonicalHeaderSize = 5;
 return ICmpInst::isEquality(Pred) && match(CmpRHS, m_Zero()) &&
match(CmpLHS,
  m_c_And(m_Value(CurrX),
@@ -2004,15 +2003,12 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, 
Value *&BaseX,
  CurLoop;
   };
   auto MatchConstantBitMask = [&]() {
-CanonicalHeaderSize = 5;
 return ICmpInst::isEquality(Pred) && match(CmpRHS, m_Zero()) &&
match(CmpLHS, m_And(m_Value(CurrX),
m_CombineAnd(m_Value(BitMask), m_Power2( &&
(BitPos = ConstantExpr::getExactLogBase2(cast(BitMask)));
   };
   auto MatchDecomposableConstantBitMask = [&]() {
-CanonicalHeaderSize = 4;
-
 APInt Mask;
 return llvm::decomposeBitTestICmp(CmpLHS, CmpRHS, Pred, CurrX, Mask) &&
ICmpInst::isEquality(Pred) && Mask.isPowerOf2() &&
@@ -2076,6 +2072,7 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, 
Value *&BaseX,
 /// %x.curr.bitmasked = and i32 %x.curr, %bitmask
 /// %x.curr.isbitunset = icmp eq i32 %x.curr.bitmasked, 0
 /// %x.next = shl i32 %x.curr, 1
+/// <...>
 /// br i1 %x.curr.isbitunset, label %loop, label %end
 ///
 ///   end:
@@ -2099,7 +2096,14 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, 
Value *&BaseX,
 /// %tripcount = add i32 %backedgetakencount, 1
 /// %x.curr = shl i32 %x, %backedgetakencount
 /// %x.next = shl i32 %x, %tripcount
-/// br label %end
+/// br label %loop
+///
+///   loop:
+/// %loop.iv = phi i32 [ 0, %entry ], [ %loop.iv.next, %loop ]
+/// %loop.iv.next = add nuw i32 %loop.iv, 1
+/// %loop.ivcheck = icmp eq i32 %loop.iv.next, %tripcount
+/// <...>
+/// br i1 %loop.ivcheck, label %end, label %loop
 ///
 ///   end:
 /// %x.curr.res = phi i32 [ %x.curr, %loop ] <...>
@@ -2110,9 +2114,8 @@ bool LoopIdiomRecognize::recognizeShiftUntilBitTest() {
   bool MadeChange = false;
 
   Value *X, *BitMask, *BitPos, *XCurr, *XNext;
-  size_t CanonicalHeaderSize;
-  if (!detectShiftUntilBitTestIdiom(CurLoop, X, BitMask, BitPos, XCurr, XNext,
-CanonicalHeaderSize)) {
+  if (!detectShiftUntilBitTestIdiom(CurLoop, X, BitMask, BitPos, XCurr,
+ 

[llvm-branch-commits] [mlir] a16fbff - [mlir][spirv] Create a pass for testing SCFToSPIRV patterns

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

Author: Lei Zhang
Date: 2020-12-23T14:31:55-05:00
New Revision: a16fbff17d329c3f2cc1e49d501f61b3996e9b8a

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

LOG: [mlir][spirv] Create a pass for testing SCFToSPIRV patterns

Previously all SCF to SPIR-V conversion patterns were tested as
the -convert-gpu-to-spirv pass. That obscured the structure we
want. This commit fixed it.

Reviewed By: ThomasRaoux, hanchung

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

Added: 
mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRVPass.h
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRVPass.cpp
mlir/test/Conversion/GPUToSPIRV/entry-point.mlir
mlir/test/Conversion/SCFToSPIRV/for.mlir
mlir/test/Conversion/SCFToSPIRV/if.mlir

Modified: 
mlir/include/mlir/Conversion/Passes.h
mlir/include/mlir/Conversion/Passes.td
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt

Removed: 
mlir/test/Conversion/GPUToSPIRV/if.mlir
mlir/test/Conversion/GPUToSPIRV/loop.mlir
mlir/test/Conversion/GPUToSPIRV/test_spirv_entry_point.mlir



diff  --git a/mlir/include/mlir/Conversion/Passes.h 
b/mlir/include/mlir/Conversion/Passes.h
index cc4f59c12496..21b35804ab36 100644
--- a/mlir/include/mlir/Conversion/Passes.h
+++ b/mlir/include/mlir/Conversion/Passes.h
@@ -23,6 +23,7 @@
 #include "mlir/Conversion/PDLToPDLInterp/PDLToPDLInterp.h"
 #include "mlir/Conversion/SCFToGPU/SCFToGPUPass.h"
 #include "mlir/Conversion/SCFToOpenMP/SCFToOpenMP.h"
+#include "mlir/Conversion/SCFToSPIRV/SCFToSPIRVPass.h"
 #include "mlir/Conversion/SCFToStandard/SCFToStandard.h"
 #include "mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.h"
 #include "mlir/Conversion/ShapeToStandard/ShapeToStandard.h"

diff  --git a/mlir/include/mlir/Conversion/Passes.td 
b/mlir/include/mlir/Conversion/Passes.td
index b364700bd849..2dc438534a44 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -230,6 +230,23 @@ def ConvertSCFToOpenMP : 
FunctionPass<"convert-scf-to-openmp"> {
   let dependentDialects = ["omp::OpenMPDialect"];
 }
 
+//===--===//
+// SCFToSPIRV
+//===--===//
+
+def SCFToSPIRV : Pass<"convert-scf-to-spirv", "ModuleOp"> {
+  let summary = "Convert SCF dialect to SPIR-V dialect.";
+  let description = [{
+This pass converts SCF ops into SPIR-V structured control flow ops.
+SPIR-V structured control flow ops does not support yielding values.
+So for SCF ops yielding values, SPIR-V variables are created for
+holding the values and load/store operations are emitted for updating
+them.
+  }];
+  let constructor = "mlir::createConvertSCFToSPIRVPass()";
+  let dependentDialects = ["spirv::SPIRVDialect"];
+}
+
 
//===--===//
 // SCFToStandard
 
//===--===//

diff  --git a/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRVPass.h 
b/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRVPass.h
new file mode 100644
index ..94705d2200c4
--- /dev/null
+++ b/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRVPass.h
@@ -0,0 +1,21 @@
+//===- SCFToSPIRVPass.h - SCF to SPIR-V Conversion Pass -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef MLIR_CONVERSION_SCFTOSPIRV_SCFTOSPIRVPASS_H
+#define MLIR_CONVERSION_SCFTOSPIRV_SCFTOSPIRVPASS_H
+
+#include "mlir/Pass/Pass.h"
+
+namespace mlir {
+
+/// Creates a pass to convert SCF ops into SPIR-V ops.
+std::unique_ptr> createConvertSCFToSPIRVPass();
+
+} // namespace mlir
+
+#endif // MLIR_CONVERSION_SCFTOSPIRV_SCFTOSPIRVPASS_H

diff  --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp 
b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
index 973aa3d79bd8..2c2a47fcc5ed 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
@@ -12,12 +12,11 @@
 
//===--===//
 
 #include "mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h"
+
 #include "../PassDetail.h"
 #include "mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h"
-#include "mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h"
 #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h"
 #include "mlir/Dialect/GPU/GPUDialec

[llvm-branch-commits] [lld] 34e70d7 - Append ".__part." to every basic block section symbol.

2020-12-23 Thread Sriraman Tallam via llvm-branch-commits

Author: Sriraman Tallam
Date: 2020-12-23T11:35:44-08:00
New Revision: 34e70d722dfd0e73d460802e8d43d3a885d24784

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

LOG: Append ".__part." to every basic block section symbol.

Every basic block section symbol created by -fbasic-block-sections will contain
".__part." to know that this symbol corresponds to a basic block fragment of
the function.

This patch solves two problems:

a) Like D89617, we want function symbols with suffixes to be properly qualified
   so that external tools like profile aggregators know exactly what this
   symbol corresponds to.
b) The current basic block naming just adds a ".N" to the symbol name where N is
   some integer. This collides with how clang creates __cxx_global_var_init.N.
   clang creates these symbol names to call constructor functions and basic
   block symbol naming should not use the same style.

Fixed all the test cases and added an extra test for __cxx_global_var_init
breakage.

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

Added: 
llvm/test/CodeGen/X86/basic-block-sections_2.ll

Modified: 
clang/test/CodeGen/basic-block-sections.c
lld/test/ELF/lto/basic-block-sections.ll
llvm/lib/CodeGen/MachineBasicBlock.cpp
llvm/test/CodeGen/X86/basic-block-sections-blockaddress-taken.ll
llvm/test/CodeGen/X86/basic-block-sections-clusters-branches.ll
llvm/test/CodeGen/X86/basic-block-sections-clusters-eh.ll
llvm/test/CodeGen/X86/basic-block-sections-clusters.ll
llvm/test/CodeGen/X86/basic-block-sections-directjumps.ll
llvm/test/CodeGen/X86/basic-block-sections-eh.ll
llvm/test/CodeGen/X86/basic-block-sections-list.ll
llvm/test/CodeGen/X86/basic-block-sections-listbb.ll
llvm/test/CodeGen/X86/basic-block-sections-mir-parse.mir
llvm/test/CodeGen/X86/basic-block-sections-unreachable.ll
llvm/test/CodeGen/X86/basic-block-sections.ll
llvm/test/CodeGen/X86/cfi-basic-block-sections-1.ll

llvm/test/CodeGen/X86/cfi-inserter-basic-block-sections-callee-save-registers.ll
llvm/test/CodeGen/X86/gcc_except_table_bb_sections.ll
llvm/test/DebugInfo/X86/basic-block-sections_1.ll

Removed: 




diff  --git a/clang/test/CodeGen/basic-block-sections.c 
b/clang/test/CodeGen/basic-block-sections.c
index 805539f06f08..70cdeeebb0d3 100644
--- a/clang/test/CodeGen/basic-block-sections.c
+++ b/clang/test/CodeGen/basic-block-sections.c
@@ -31,14 +31,14 @@ int another(int a) {
 // BB_WORLD: .section .text.world,"ax",@progbits{{$}}
 // BB_WORLD: world:
 // BB_WORLD: .section .text.world,"ax",@progbits,unique
-// BB_WORLD: world.1:
+// BB_WORLD: world.__part.1:
 // BB_WORLD: .section .text.another,"ax",@progbits
 // BB_ALL: .section .text.another,"ax",@progbits,unique
-// BB_ALL: another.1:
+// BB_ALL: another.__part.1:
 // BB_LIST-NOT: .section .text.another,"ax",@progbits,unique
 // BB_LIST: another:
-// BB_LIST-NOT: another.1:
+// BB_LIST-NOT: another.__part.1:
 //
-// UNIQUE: .section .text.world.world.1,
-// UNIQUE: .section .text.another.another.1,
+// UNIQUE: .section .text.world.world.__part.1,
+// UNIQUE: .section .text.another.another.__part.1,
 // ERROR: error:  unable to load basic block sections function list: 
'{{[Nn]}}o such file or directory'

diff  --git a/lld/test/ELF/lto/basic-block-sections.ll 
b/lld/test/ELF/lto/basic-block-sections.ll
index 1f932ac50a87..35b638ac488a 100644
--- a/lld/test/ELF/lto/basic-block-sections.ll
+++ b/lld/test/ELF/lto/basic-block-sections.ll
@@ -11,12 +11,12 @@
 ; SECNAMES: Name: .text.foo {{.*}}
 
 ; SECNAMES-FULL: Name: .text.foo {{.*}}
-; SECNAMES-FULL: Name: .text.foo.foo.1 {{.*}}
-; SECNAMES-FULL: Name: .text.foo.foo.2 {{.*}}
+; SECNAMES-FULL: Name: .text.foo.foo.__part.1 {{.*}}
+; SECNAMES-FULL: Name: .text.foo.foo.__part.2 {{.*}}
 
 ; SYMS: foo
-; SYMS: foo.1
-; SYMS: foo.2
+; SYMS: foo.__part.1
+; SYMS: foo.__part.2
 
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"

diff  --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp 
b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 0278999a8f72..14a270f994b4 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -71,7 +71,10 @@ MCSymbol *MachineBasicBlock::getSymbol() const {
   } else if (SectionID == MBBSectionID::ExceptionSectionID) {
 Suffix += ".eh";
   } else {
-Suffix += "." + std::to_string(SectionID.Number);
+// For symbols that represent basic block sections, we add ".__part." 
to
+// allow tools like symbolizers to know that this represents a part of
+// the original function.
+Suffix = (Suffix + Twine(".__part.") + Twine(SectionID.Number)).str();
   }
   CachedM

[llvm-branch-commits] [mlir] 930c74f - [mlir][spirv] NFC: rename SPIR-V conversion files for consistency

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

Author: Lei Zhang
Date: 2020-12-23T14:36:46-05:00
New Revision: 930c74f12d799c95e37a107bb692148b36493806

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

LOG: [mlir][spirv] NFC: rename SPIR-V conversion files for consistency

This commit renames various SPIR-V related conversion files for
consistency. It drops the "Convert" prefix to various files and
fixes various comment headers.

Reviewed By: hanchung, ThomasRaoux

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

Added: 
mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h
mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h
mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h
mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
mlir/include/mlir/Conversion/StandardToSPIRV/StandardToSPIRV.h
mlir/include/mlir/Conversion/StandardToSPIRV/StandardToSPIRVPass.h
mlir/include/mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h
mlir/include/mlir/Conversion/VectorToSPIRV/VectorToSPIRVPass.h
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRVPass.cpp
mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp
mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp
mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRVPass.cpp
mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRVPass.cpp

Modified: 
mlir/docs/Dialects/SPIR-V.md
mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h
mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h
mlir/include/mlir/Conversion/Passes.h
mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h
mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRVPass.h
mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRVPass.cpp
mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt
mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
mlir/lib/Conversion/VectorToSPIRV/CMakeLists.txt
mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp
mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp

Removed: 
mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h
mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h
mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.h
mlir/include/mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.h
mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h
mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h
mlir/include/mlir/Conversion/VectorToSPIRV/ConvertVectorToSPIRV.h
mlir/include/mlir/Conversion/VectorToSPIRV/ConvertVectorToSPIRVPass.h
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp



diff  --git a/mlir/docs/Dialects/SPIR-V.md b/mlir/docs/Dialects/SPIR-V.md
index f30d82fd2810..acace47c2c6f 100644
--- a/mlir/docs/Dialects/SPIR-V.md
+++ b/mlir/docs/Dialects/SPIR-V.md
@@ -1145,7 +1145,7 @@ in a few places:
 are at [lib/Conversion/StandardToSPIRV][MlirStdToSpirvLibs].
 
 These dialect to dialect conversions have their dedicated libraries,
-`MLIRGPUToSPIRVTransforms` and `MLIRStandardToSPIRVTransforms`, respectively.
+`MLIRGPUToSPIRV` and `MLIRStandardToSPIRV`, respectively.
 
 There are also common utilities when targeting SPIR-V from any dialect:
 

diff  --git a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h 
b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h
similarity index 73%
rename from mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h
rename to mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h
index 8bdb228c9ccc..ad5dac003897 100644
--- a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h
+++ b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h
@@ -1,4 +1,4 @@
-//===- ConvertGPUToSPIRV.h - GPU Ops to SPIR-V dialect patterns C++ 
-*-===//
+//===- GPUToSPIRV.h - GPU to SPIR-V Patterns *- C++ 
-*-===//
 //
 // Part of the LLVM Project, under 

[llvm-branch-commits] [llvm] 897990e - [IROutliner] Use isa instead of dyn_cast where the casted value isn't used. NFC

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

Author: Craig Topper
Date: 2020-12-23T11:40:15-08:00
New Revision: 897990e614c8d609b2f62dde4f82eb3e96f9f0be

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

LOG: [IROutliner] Use isa instead of dyn_cast where the casted value isn't 
used. NFC

Fixes unused variable warnings.

Added: 


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

Removed: 




diff  --git a/llvm/lib/Transforms/IPO/IROutliner.cpp 
b/llvm/lib/Transforms/IPO/IROutliner.cpp
index 5b19d0718ab6..12a30744a652 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -297,7 +297,7 @@ static BasicBlock *moveFunctionData(Function &Old, Function 
&New) {
 CurrBB->removeFromParent();
 CurrBB->insertInto(&New);
 Instruction *I = CurrBB->getTerminator();
-if (ReturnInst *RI = dyn_cast(I))
+if (isa(I))
   NewEnd = &(*CurrBB);
   }
 
@@ -325,7 +325,7 @@ static void findConstants(IRSimilarityCandidate &C, 
DenseSet &NotSame,
   // Since these are stored before any outlining, they will be in the
   // global value numbering.
   unsigned GVN = C.getGVN(V).getValue();
-  if (Constant *CST = dyn_cast(V))
+  if (isa(V))
 if (NotSame.find(GVN) != NotSame.end() &&
 Seen.find(GVN) == Seen.end()) {
   Inputs.push_back(GVN);



___
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] ae895ac - [mlir][spirv] De-template deserialization

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

Author: Lei Zhang
Date: 2020-12-23T14:45:46-05:00
New Revision: ae895ac4b9fa86b9471617357f66c0cd6cdb70b8

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

LOG: [mlir][spirv] De-template deserialization

Previously for each op we generate a separate deserialization
method for it. Those deserialization methods duplicate the logic
of parsing operands/results/attributes and such.

This commit creates a generic method and let suitable op-specific
deserialization method to call into it.

wc -l SPIRVSerialization.inc: before 13290; after: 8304 (So -4986)

Reviewed By: hanchung, ThomasRaoux

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

Added: 


Modified: 
mlir/lib/Target/SPIRV/Deserialization.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

Removed: 




diff  --git a/mlir/lib/Target/SPIRV/Deserialization.cpp 
b/mlir/lib/Target/SPIRV/Deserialization.cpp
index 94ea19f94123..30f46f6fc605 100644
--- a/mlir/lib/Target/SPIRV/Deserialization.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization.cpp
@@ -34,6 +34,10 @@ using namespace mlir;
 
 #define DEBUG_TYPE "spirv-deserialization"
 
+//===--===//
+// Utility Functions
+//===--===//
+
 /// Decodes a string literal in `words` starting at `wordIndex`. Update the
 /// latter to point to the position in words after the string literal.
 static inline StringRef decodeStringLiteral(ArrayRef words,
@@ -55,6 +59,10 @@ static inline bool isFnEntryBlock(Block *block) {
 }
 
 namespace {
+//===--===//
+// Utility Definitions
+//===--===//
+
 /// A struct for containing a header block's merge and continue targets.
 ///
 /// This struct is used to track original structured control flow info from
@@ -124,6 +132,10 @@ struct DeferredStructTypeInfo {
   SmallVector 
memberDecorationsInfo;
 };
 
+//===--===//
+// Deserializer Declaration
+//===--===//
+
 /// A SPIR-V module serializer.
 ///
 /// A SPIR-V binary module is a single linear stream of instructions; each
@@ -423,6 +435,14 @@ class Deserializer {
ArrayRef operands,
bool deferInstructions = true);
 
+  /// Processes a SPIR-V instruction from the given `operands`. It should
+  /// deserialize into an op with the given `opName` and `numOperands`.
+  /// This method is a generic one for dispatching any SPIR-V ops without
+  /// variadic operands and attributes in TableGen definitions.
+  LogicalResult processOpWithoutGrammarAttr(ArrayRef words,
+StringRef opName, bool hasResult,
+unsigned numOperands);
+
   /// Processes a OpUndef instruction. Adds a spv.Undef operation at the 
current
   /// insertion point.
   LogicalResult processUndef(ArrayRef operands);
@@ -580,6 +600,10 @@ class Deserializer {
 };
 } // namespace
 
+//===--===//
+// Deserializer Method Definitions
+//===--===//
+
 Deserializer::Deserializer(ArrayRef binary, MLIRContext *context)
 : binary(binary), context(context), unknownLoc(UnknownLoc::get(context)),
   module(createModuleOp()), opBuilder(module->body()) {}
@@ -2497,6 +2521,87 @@ LogicalResult 
Deserializer::processInstruction(spirv::Opcode opcode,
   return dispatchToAutogenDeserialization(opcode, operands);
 }
 
+LogicalResult
+Deserializer::processOpWithoutGrammarAttr(ArrayRef words,
+  StringRef opName, bool hasResult,
+  unsigned numOperands) {
+  SmallVector resultTypes;
+  uint32_t valueID = 0;
+
+  size_t wordIndex= 0;
+  if (hasResult) {
+if (wordIndex >= words.size())
+  return emitError(unknownLoc,
+   "expected result type  while deserializing for ")
+ << opName;
+
+// Decode the type 
+auto type = getType(words[wordIndex]);
+if (!type)
+  return emitError(unknownLoc, "unknown type result : ")
+ << words[wordIndex];
+resultTypes.push_back(type);
+++wordIndex;
+
+// Decode the result 
+if (wordIndex >= words.size())
+  return emitError(unknownLoc,
+   "expected result  while deserializing for ")
+ << opName;
+valueID = words[wordIndex];
+++wordIndex;
+  }
+

[llvm-branch-commits] [mlir] fc41777 - [mlir][spirv] De-template serialization

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

Author: Lei Zhang
Date: 2020-12-23T14:54:26-05:00
New Revision: fc4102aae1cb88512a6aa45382736766fadf

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

LOG: [mlir][spirv] De-template serialization

Previously for each op we generate a separate serialization
method for it. Those serialization methods duplicate the logic
of parsing operands/results/attributes and such.

This commit creates a generic method and let suitable op-specific
serialization method to call into it.

wc -l SPIRVSerialization.inc: before 8304; after: 5597 (So -2707)

Reviewed By: hanchung, ThomasRaoux

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

Added: 


Modified: 
mlir/lib/Target/SPIRV/Serialization.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

Removed: 




diff  --git a/mlir/lib/Target/SPIRV/Serialization.cpp 
b/mlir/lib/Target/SPIRV/Serialization.cpp
index db00f5ecf899..c530cccd4232 100644
--- a/mlir/lib/Target/SPIRV/Serialization.cpp
+++ b/mlir/lib/Target/SPIRV/Serialization.cpp
@@ -364,15 +364,23 @@ class Serializer {
   /// Main dispatch method for serializing an operation.
   LogicalResult processOperation(Operation *op);
 
-  /// Method to dispatch to the serialization function for an operation in
-  /// SPIR-V dialect that is a mirror of an instruction in the SPIR-V spec.
-  /// This is auto-generated from ODS. Dispatch is handled for all operations
-  /// in SPIR-V dialect that have hasOpcode == 1.
+  /// Serializes an operation `op` as core instruction with `opcode` if
+  /// `extInstSet` is empty. Otherwise serializes it as an extended instruction
+  /// with `opcode` from `extInstSet`.
+  /// This method is a generic one for dispatching any SPIR-V ops that has no
+  /// variadic operands and attributes in TableGen definitions.
+  LogicalResult processOpWithoutGrammarAttr(Operation *op, StringRef 
extInstSet,
+uint32_t opcode);
+
+  /// Dispatches to the serialization function for an operation in SPIR-V
+  /// dialect that is a mirror of an instruction in the SPIR-V spec. This is
+  /// auto-generated from ODS. Dispatch is handled for all operations in SPIR-V
+  /// dialect that have hasOpcode == 1.
   LogicalResult dispatchToAutogenSerialization(Operation *op);
 
-  /// Method to serialize an operation in the SPIR-V dialect that is a mirror 
of
-  /// an instruction in the SPIR-V spec. This is auto generated if hasOpcode ==
-  /// 1 and autogenSerialization == 1 in ODS.
+  /// Serializes an operation in the SPIR-V dialect that is a mirror of an
+  /// instruction in the SPIR-V spec. This is auto generated if hasOpcode == 1
+  /// and autogenSerialization == 1 in ODS.
   template 
   LogicalResult processOp(OpTy op) {
 return op.emitError("unsupported op serialization");
@@ -1930,6 +1938,46 @@ LogicalResult Serializer::processOperation(Operation 
*opInst) {
   [&](Operation *op) { return dispatchToAutogenSerialization(op); });
 }
 
+LogicalResult Serializer::processOpWithoutGrammarAttr(Operation *op,
+  StringRef extInstSet,
+  uint32_t opcode) {
+  SmallVector operands;
+  Location loc = op->getLoc();
+
+  uint32_t resultID = 0;
+  if (op->getNumResults() != 0) {
+uint32_t resultTypeID = 0;
+if (failed(processType(loc, op->getResult(0).getType(), resultTypeID)))
+  return failure();
+operands.push_back(resultTypeID);
+
+resultID = getNextID();
+operands.push_back(resultID);
+valueIDMap[op->getResult(0)] = resultID;
+  };
+
+  for (Value operand : op->getOperands())
+operands.push_back(getValueID(operand));
+
+  emitDebugLine(functionBody, loc);
+
+  if (extInstSet.empty()) {
+encodeInstructionInto(functionBody, static_cast(opcode),
+  operands);
+  } else {
+encodeExtensionInstruction(op, extInstSet, opcode, operands);
+  }
+
+  if (op->getNumResults() != 0) {
+for (auto attr : op->getAttrs()) {
+  if (failed(processDecoration(loc, resultID, attr)))
+return failure();
+}
+  }
+
+  return success();
+}
+
 namespace {
 template <>
 LogicalResult

diff  --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp 
b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
index ab520114e7f5..74fe1e0fdb08 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -647,8 +647,7 @@ static void emitDecorationSerialization(const Operator &op, 
StringRef tabs,
 // All non-argument attributes translated into OpDecorate instruction
 os << tabs << formatv("for (auto attr : {0}->getAttrs()) {{\n", opVar);
 os << tabs
-   << formatv("  if (llvm::any_of({0}, [&](StringRef elided)", 
elidedAttrs);
-os << " {return 

[llvm-branch-commits] [llvm] de127d8 - [InstCombine] Add tests for PR48577 (NFC)

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

Author: Nikita Popov
Date: 2020-12-23T21:03:22+01:00
New Revision: de127d83d81228de36c487a6da28502b458e9924

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

LOG: [InstCombine] Add tests for PR48577 (NFC)

Added: 


Modified: 
llvm/test/Transforms/InstCombine/load.ll
llvm/test/Transforms/InstCombine/store.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/load.ll 
b/llvm/test/Transforms/InstCombine/load.ll
index 79adbe117333..a6a2155be0b5 100644
--- a/llvm/test/Transforms/InstCombine/load.ll
+++ b/llvm/test/Transforms/InstCombine/load.ll
@@ -57,13 +57,23 @@ define i32 @test5(i1 %C) {
   ret i32 %Z
 }
 
-define i32 @test7(i32 %X) {
-; CHECK-LABEL: @test7(
+define i32 @load_gep_null_inbounds(i64 %X) {
+; CHECK-LABEL: @load_gep_null_inbounds(
 ; CHECK-NEXT:store i32 undef, i32* null, align 536870912
 ; CHECK-NEXT:ret i32 undef
 ;
-  %V = getelementptr i32, i32* null, i32 %X;  [#uses=1]
-  %R = load i32, i32* %V   ;  [#uses=1]
+  %V = getelementptr inbounds i32, i32* null, i64 %X
+  %R = load i32, i32* %V
+  ret i32 %R
+}
+
+define i32 @load_gep_null_not_inbounds(i64 %X) {
+; CHECK-LABEL: @load_gep_null_not_inbounds(
+; CHECK-NEXT:store i32 undef, i32* null, align 536870912
+; CHECK-NEXT:ret i32 undef
+;
+  %V = getelementptr i32, i32* null, i64 %X
+  %R = load i32, i32* %V
   ret i32 %R
 }
 

diff  --git a/llvm/test/Transforms/InstCombine/store.ll 
b/llvm/test/Transforms/InstCombine/store.ll
index 575fb0432d6c..cda08f89501a 100644
--- a/llvm/test/Transforms/InstCombine/store.ll
+++ b/llvm/test/Transforms/InstCombine/store.ll
@@ -23,8 +23,19 @@ define void @test2(i32* %P) {
   ret void
 }
 
-define void @store_at_gep_off_null(i64 %offset) {
-; CHECK-LABEL: @store_at_gep_off_null(
+define void @store_at_gep_off_null_inbounds(i64 %offset) {
+; CHECK-LABEL: @store_at_gep_off_null_inbounds(
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr inbounds i32, i32* null, i64 
[[OFFSET:%.*]]
+; CHECK-NEXT:store i32 undef, i32* [[PTR]], align 4
+; CHECK-NEXT:ret void
+;
+  %ptr = getelementptr inbounds i32, i32 *null, i64 %offset
+  store i32 24, i32* %ptr
+  ret void
+}
+
+define void @store_at_gep_off_null_not_inbounds(i64 %offset) {
+; CHECK-LABEL: @store_at_gep_off_null_not_inbounds(
 ; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, i32* null, i64 [[OFFSET:%.*]]
 ; CHECK-NEXT:store i32 undef, i32* [[PTR]], align 4
 ; CHECK-NEXT:ret void
@@ -36,11 +47,11 @@ define void @store_at_gep_off_null(i64 %offset) {
 
 define void @store_at_gep_off_no_null_opt(i64 %offset) #0 {
 ; CHECK-LABEL: @store_at_gep_off_no_null_opt(
-; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, i32* null, i64 [[OFFSET:%.*]]
+; CHECK-NEXT:[[PTR:%.*]] = getelementptr inbounds i32, i32* null, i64 
[[OFFSET:%.*]]
 ; CHECK-NEXT:store i32 24, i32* [[PTR]], align 4
 ; CHECK-NEXT:ret void
 ;
-  %ptr = getelementptr i32, i32 *null, i64 %offset
+  %ptr = getelementptr inbounds i32, i32 *null, i64 %offset
   store i32 24, i32* %ptr
   ret void
 }
@@ -130,14 +141,14 @@ define void @test6(i32 %n, float* %a, i32* %gi) nounwind 
uwtable ssp {
 ; CHECK-NEXT:br label [[FOR_COND:%.*]]
 ; CHECK:   for.cond:
 ; CHECK-NEXT:[[STOREMERGE:%.*]] = phi i32 [ 42, [[ENTRY:%.*]] ], [ 
[[INC:%.*]], [[FOR_BODY:%.*]] ]
-; CHECK-NEXT:store i32 [[STOREMERGE]], i32* [[GI:%.*]], align 4, !tbaa !0
+; CHECK-NEXT:store i32 [[STOREMERGE]], i32* [[GI:%.*]], align 4, 
[[TBAA0:!tbaa !.*]]
 ; CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[STOREMERGE]], [[N:%.*]]
 ; CHECK-NEXT:br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
 ; CHECK:   for.body:
 ; CHECK-NEXT:[[IDXPROM:%.*]] = sext i32 [[STOREMERGE]] to i64
 ; CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds float, float* 
[[A:%.*]], i64 [[IDXPROM]]
-; CHECK-NEXT:store float 0.00e+00, float* [[ARRAYIDX]], align 4, !tbaa 
!4
-; CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[GI]], align 4, !tbaa !0
+; CHECK-NEXT:store float 0.00e+00, float* [[ARRAYIDX]], align 4, 
[[TBAA4:!tbaa !.*]]
+; CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[GI]], align 4, [[TBAA0]]
 ; CHECK-NEXT:[[INC]] = add nsw i32 [[TMP0]], 1
 ; CHECK-NEXT:br label [[FOR_COND]]
 ; CHECK:   for.end:



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


[llvm-branch-commits] [llvm] 899faa5 - [InstCombine] Check inbounds in load/store of gep null transform (PR48577)

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

Author: Nikita Popov
Date: 2020-12-23T21:03:22+01:00
New Revision: 899faa50f206073cdd8eeaaa130ffa15f850e656

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

LOG: [InstCombine] Check inbounds in load/store of gep null transform (PR48577)

If the GEP isn't inbounds, then accessing a GEP of null location
is generally not UB.

While this is a minimal fix, the GEP of null handling should
probably be its own fold.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/load.ll
llvm/test/Transforms/InstCombine/store.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index ac617ecd4fd1..71f165abe52e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -908,7 +908,8 @@ static bool canSimplifyNullStoreOrGEP(StoreInst &SI) {
 
   auto *Ptr = SI.getPointerOperand();
   if (GetElementPtrInst *GEPI = dyn_cast(Ptr))
-Ptr = GEPI->getOperand(0);
+if (GEPI->isInBounds())
+  Ptr = GEPI->getOperand(0);
   return (isa(Ptr) &&
   !NullPointerIsDefined(SI.getFunction(), 
SI.getPointerAddressSpace()));
 }
@@ -916,7 +917,7 @@ static bool canSimplifyNullStoreOrGEP(StoreInst &SI) {
 static bool canSimplifyNullLoadOrGEP(LoadInst &LI, Value *Op) {
   if (GetElementPtrInst *GEPI = dyn_cast(Op)) {
 const Value *GEPI0 = GEPI->getOperand(0);
-if (isa(GEPI0) &&
+if (isa(GEPI0) && GEPI->isInBounds() &&
 !NullPointerIsDefined(LI.getFunction(), 
GEPI->getPointerAddressSpace()))
   return true;
   }

diff  --git a/llvm/test/Transforms/InstCombine/load.ll 
b/llvm/test/Transforms/InstCombine/load.ll
index a6a2155be0b5..e4ba908599c9 100644
--- a/llvm/test/Transforms/InstCombine/load.ll
+++ b/llvm/test/Transforms/InstCombine/load.ll
@@ -69,8 +69,9 @@ define i32 @load_gep_null_inbounds(i64 %X) {
 
 define i32 @load_gep_null_not_inbounds(i64 %X) {
 ; CHECK-LABEL: @load_gep_null_not_inbounds(
-; CHECK-NEXT:store i32 undef, i32* null, align 536870912
-; CHECK-NEXT:ret i32 undef
+; CHECK-NEXT:[[V:%.*]] = getelementptr i32, i32* null, i64 [[X:%.*]]
+; CHECK-NEXT:[[R:%.*]] = load i32, i32* [[V]], align 4
+; CHECK-NEXT:ret i32 [[R]]
 ;
   %V = getelementptr i32, i32* null, i64 %X
   %R = load i32, i32* %V

diff  --git a/llvm/test/Transforms/InstCombine/store.ll 
b/llvm/test/Transforms/InstCombine/store.ll
index cda08f89501a..d3842f4bb469 100644
--- a/llvm/test/Transforms/InstCombine/store.ll
+++ b/llvm/test/Transforms/InstCombine/store.ll
@@ -37,7 +37,7 @@ define void @store_at_gep_off_null_inbounds(i64 %offset) {
 define void @store_at_gep_off_null_not_inbounds(i64 %offset) {
 ; CHECK-LABEL: @store_at_gep_off_null_not_inbounds(
 ; CHECK-NEXT:[[PTR:%.*]] = getelementptr i32, i32* null, i64 [[OFFSET:%.*]]
-; CHECK-NEXT:store i32 undef, i32* [[PTR]], align 4
+; CHECK-NEXT:store i32 24, i32* [[PTR]], align 4
 ; CHECK-NEXT:ret void
 ;
   %ptr = getelementptr i32, i32 *null, i64 %offset



___
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] c7e825b - [format][NFC] Use unsigned char as the base of all enums in FormatStyle

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

Author: Nathan James
Date: 2020-12-23T20:27:44Z
New Revision: c7e825b910a96c42bda1de4e7fb34c369da76625

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

LOG: [format][NFC] Use unsigned char as the base of all enums in FormatStyle

This removes alot of unnecessary padding, trimming the size of the struct from 
728->608 on 64 bit platforms.

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/docs/tools/dump_format_style.py
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/tools/dump_format_style.py 
b/clang/docs/tools/dump_format_style.py
index 61167979b3e6..d01c823a9a20 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -144,7 +144,7 @@ class State(object):
 comment += clean_comment_line(line)
   elif line.startswith('enum'):
 state = State.InEnum
-name = re.sub(r'enum\s+(\w+)\s*\{', '\\1', line)
+name = re.sub(r'enum\s+(\w+)\s*(:((\s*\w+)+)\s*)?\{', '\\1', line)
 enum = Enum(name, comment)
   elif line.startswith('struct'):
 state = State.InNestedStruct

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 208fc105d4b6..9b8309213261 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -56,7 +56,7 @@ struct FormatStyle {
   int AccessModifierOffset;
 
   /// Different styles for aligning after open brackets.
-  enum BracketAlignmentStyle {
+  enum BracketAlignmentStyle : unsigned char {
 /// Align parameters on the open bracket, e.g.:
 /// \code
 ///   someLongFunction(argument1,
@@ -131,7 +131,7 @@ struct FormatStyle {
   bool AlignConsecutiveDeclarations;
 
   /// Different styles for aligning escaped newlines.
-  enum EscapedNewlineAlignmentStyle {
+  enum EscapedNewlineAlignmentStyle : unsigned char {
 /// Don't align escaped newlines.
 /// \code
 ///   #define A \
@@ -165,7 +165,7 @@ struct FormatStyle {
   EscapedNewlineAlignmentStyle AlignEscapedNewlines;
 
   /// Different styles for aligning operands.
-  enum OperandAlignmentStyle {
+  enum OperandAlignmentStyle : unsigned char {
 /// Do not align operands of binary and ternary expressions.
 /// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
 /// the start of the line.
@@ -275,7 +275,7 @@ struct FormatStyle {
 
   /// Different styles for merging short blocks containing at most one
   /// statement.
-  enum ShortBlockStyle {
+  enum ShortBlockStyle : unsigned char {
 /// Never merge blocks into a single line.
 /// \code
 ///   while (true) {
@@ -320,7 +320,7 @@ struct FormatStyle {
 
   /// Different styles for merging short functions containing at most one
   /// statement.
-  enum ShortFunctionStyle {
+  enum ShortFunctionStyle : unsigned char {
 /// Never merge functions into a single line.
 SFS_None,
 /// Only merge functions defined inside a class. Same as "inline",
@@ -371,7 +371,7 @@ struct FormatStyle {
   ShortFunctionStyle AllowShortFunctionsOnASingleLine;
 
   /// Different styles for handling short if lines
-  enum ShortIfStyle {
+  enum ShortIfStyle : unsigned char {
 /// Never put short ifs on the same line.
 /// \code
 ///   if (a)
@@ -405,7 +405,7 @@ struct FormatStyle {
 
   /// Different styles for merging short lambdas containing at most one
   /// statement.
-  enum ShortLambdaStyle {
+  enum ShortLambdaStyle : unsigned char {
 /// Never merge lambdas into a single line.
 SLS_None,
 /// Only merge empty lambdas.
@@ -442,7 +442,7 @@ struct FormatStyle {
 
   /// Different ways to break after the function definition return type.
   /// This option is **deprecated** and is retained for backwards 
compatibility.
-  enum DefinitionReturnTypeBreakingStyle {
+  enum DefinitionReturnTypeBreakingStyle : unsigned char {
 /// Break after return type automatically.
 /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
 DRTBS_None,
@@ -454,7 +454,7 @@ struct FormatStyle {
 
   /// Different ways to break after the function definition or
   /// declaration return type.
-  enum ReturnTypeBreakingStyle {
+  enum ReturnTypeBreakingStyle : unsigned char {
 /// Break after return type automatically.
 /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
 /// \code
@@ -545,7 +545,7 @@ struct FormatStyle {
   bool AlwaysBreakBeforeMultilineStrings;
 
   /// Different ways to break after the template declaration.
-  enum BreakTemplateDeclarationsStyle {
+  enum BreakTemplateDeclarationsStyle : unsigned char {
 /// Do not force break before declaration.
 /// ``PenaltyBreakTemplateDeclaration`` is ta

[llvm-branch-commits] [llvm] 87087a0 - [InstCombine] Add tests for gep of null (NFC)

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

Author: Nikita Popov
Date: 2020-12-23T21:41:53+01:00
New Revision: 87087a02ae49a907e0ec9e6dfe62c9b9ca232936

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

LOG: [InstCombine] Add tests for gep of null (NFC)

We were only considering the gep of null pattern in conjunction
with a load/store. Also test it independently.

Added: 


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

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/getelementptr.ll 
b/llvm/test/Transforms/InstCombine/getelementptr.ll
index 85ef011b3212..b4124c5edf5e 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -1237,4 +1237,31 @@ define i32* @PR45084_extra_use(i1 %cond, %struct.f** %p) 
{
   ret i32* %gep
 }
 
+define i8* @gep_null_inbounds(i64 %idx) {
+; CHECK-LABEL: @gep_null_inbounds(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* null, i64 
[[IDX:%.*]]
+; CHECK-NEXT:ret i8* [[GEP]]
+;
+  %gep = getelementptr inbounds i8, i8* null, i64 %idx
+  ret i8* %gep
+}
+
+define i8* @gep_null_not_inbounds(i64 %idx) {
+; CHECK-LABEL: @gep_null_not_inbounds(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr i8, i8* null, i64 [[IDX:%.*]]
+; CHECK-NEXT:ret i8* [[GEP]]
+;
+  %gep = getelementptr i8, i8* null, i64 %idx
+  ret i8* %gep
+}
+
+define i8* @gep_null_defined(i64 %idx) null_pointer_is_valid {
+; CHECK-LABEL: @gep_null_defined(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* null, i64 
[[IDX:%.*]]
+; CHECK-NEXT:ret i8* [[GEP]]
+;
+  %gep = getelementptr inbounds i8, i8* null, i64 %idx
+  ret i8* %gep
+}
+
 !0 = !{!"branch_weights", i32 2, i32 10}



___
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] eb79fd3 - [InstCombine] Fold gep inbounds of null to null

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

Author: Nikita Popov
Date: 2020-12-23T21:41:53+01:00
New Revision: eb79fd3c928dbbb97f7937963361c1dad2bf8222

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

LOG: [InstCombine] Fold gep inbounds of null to null

Effectively, this is what we were previously already doing when
the GEP was used in conjunction with a load or store, but this
fold can also be applied more generally:

> The only in bounds address for a null pointer in the default
> address-space is the null pointer itself.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/getelementptr.ll
llvm/test/Transforms/InstCombine/store.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 71f165abe52e..153947802f80 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -903,29 +903,14 @@ static Instruction 
*replaceGEPIdxWithZero(InstCombinerImpl &IC, Value *Ptr,
 }
 
 static bool canSimplifyNullStoreOrGEP(StoreInst &SI) {
-  if (NullPointerIsDefined(SI.getFunction(), SI.getPointerAddressSpace()))
-return false;
-
-  auto *Ptr = SI.getPointerOperand();
-  if (GetElementPtrInst *GEPI = dyn_cast(Ptr))
-if (GEPI->isInBounds())
-  Ptr = GEPI->getOperand(0);
-  return (isa(Ptr) &&
-  !NullPointerIsDefined(SI.getFunction(), 
SI.getPointerAddressSpace()));
+  return isa(SI.getPointerOperand()) &&
+ !NullPointerIsDefined(SI.getFunction(), SI.getPointerAddressSpace());
 }
 
 static bool canSimplifyNullLoadOrGEP(LoadInst &LI, Value *Op) {
-  if (GetElementPtrInst *GEPI = dyn_cast(Op)) {
-const Value *GEPI0 = GEPI->getOperand(0);
-if (isa(GEPI0) && GEPI->isInBounds() &&
-!NullPointerIsDefined(LI.getFunction(), 
GEPI->getPointerAddressSpace()))
-  return true;
-  }
-  if (isa(Op) ||
-  (isa(Op) &&
-   !NullPointerIsDefined(LI.getFunction(), LI.getPointerAddressSpace(
-return true;
-  return false;
+  return isa(Op) ||
+ (isa(Op) &&
+  !NullPointerIsDefined(LI.getFunction(), 
LI.getPointerAddressSpace()));
 }
 
 Instruction *InstCombinerImpl::visitLoadInst(LoadInst &LI) {

diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp 
b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index ec932aaf0b9e..7bde3845522f 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1855,6 +1855,12 @@ Instruction 
*InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
 
   Value *PtrOp = GEP.getOperand(0);
 
+  // The only pointer that is inbounds of null is null.
+  if (isa(PtrOp) && GEP.isInBounds() &&
+  !NullPointerIsDefined(GEP.getFunction(),
+PtrOp->getType()->getPointerAddressSpace()))
+return replaceInstUsesWith(GEP, PtrOp);
+
   // Eliminate unneeded casts for indices, and replace indices which displace
   // by multiples of a zero size type with zero.
   bool MadeChange = false;

diff  --git a/llvm/test/Transforms/InstCombine/getelementptr.ll 
b/llvm/test/Transforms/InstCombine/getelementptr.ll
index b4124c5edf5e..6524c3c03639 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -1239,8 +1239,7 @@ define i32* @PR45084_extra_use(i1 %cond, %struct.f** %p) {
 
 define i8* @gep_null_inbounds(i64 %idx) {
 ; CHECK-LABEL: @gep_null_inbounds(
-; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* null, i64 
[[IDX:%.*]]
-; CHECK-NEXT:ret i8* [[GEP]]
+; CHECK-NEXT:ret i8* null
 ;
   %gep = getelementptr inbounds i8, i8* null, i64 %idx
   ret i8* %gep

diff  --git a/llvm/test/Transforms/InstCombine/store.ll 
b/llvm/test/Transforms/InstCombine/store.ll
index d3842f4bb469..a94ce92d214e 100644
--- a/llvm/test/Transforms/InstCombine/store.ll
+++ b/llvm/test/Transforms/InstCombine/store.ll
@@ -25,8 +25,7 @@ define void @test2(i32* %P) {
 
 define void @store_at_gep_off_null_inbounds(i64 %offset) {
 ; CHECK-LABEL: @store_at_gep_off_null_inbounds(
-; CHECK-NEXT:[[PTR:%.*]] = getelementptr inbounds i32, i32* null, i64 
[[OFFSET:%.*]]
-; CHECK-NEXT:store i32 undef, i32* [[PTR]], align 4
+; CHECK-NEXT:store i32 undef, i32* null, align 536870912
 ; CHECK-NEXT:ret void
 ;
   %ptr = getelementptr inbounds i32, i32 *null, i64 %offset



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

[llvm-branch-commits] [llvm] 759b8c1 - [InstCombine] Handle different pointer types when folding gep of null

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

Author: Nikita Popov
Date: 2020-12-23T21:58:26+01:00
New Revision: 759b8c11c398c20f12503356f8aef604e0bf82be

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

LOG: [InstCombine] Handle different pointer types when folding gep of null

The source pointer type is not necessarily the same as the result
pointer type, so we can't simply return the original null pointer,
it might be a different one.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/getelementptr.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp 
b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 7bde3845522f..8ace625e1fad 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1859,7 +1859,8 @@ Instruction 
*InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
   if (isa(PtrOp) && GEP.isInBounds() &&
   !NullPointerIsDefined(GEP.getFunction(),
 PtrOp->getType()->getPointerAddressSpace()))
-return replaceInstUsesWith(GEP, PtrOp);
+if (auto *PtrTy = dyn_cast(GEPType))
+  return replaceInstUsesWith(GEP, ConstantPointerNull::get(PtrTy));
 
   // Eliminate unneeded casts for indices, and replace indices which displace
   // by multiples of a zero size type with zero.

diff  --git a/llvm/test/Transforms/InstCombine/getelementptr.ll 
b/llvm/test/Transforms/InstCombine/getelementptr.ll
index 6524c3c03639..f1af3fda79e7 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -1263,4 +1263,12 @@ define i8* @gep_null_defined(i64 %idx) 
null_pointer_is_valid {
   ret i8* %gep
 }
 
+define i8* @gep_null_inbounds_
diff erent_type(i64 %idx1, i64 %idx2) {
+; CHECK-LABEL: @gep_null_inbounds_
diff erent_type(
+; CHECK-NEXT:ret i8* null
+;
+  %gep = getelementptr inbounds [0 x i8], [0 x i8]* null, i64 %idx1, i64 %idx2
+  ret i8* %gep
+}
+
 !0 = !{!"branch_weights", i32 2, i32 10}



___
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] cce473e - [IRSim] Adding commutativity matching to structure checking

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

Author: Andrew Litteken
Date: 2020-12-23T15:02:00-06:00
New Revision: cce473e0c56408237ea9ac5e24df918afab91ec9

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

LOG: [IRSim] Adding commutativity matching to structure checking

Certain instructions, such as adds and multiplies can have the operands
flipped and still be considered the same. When we are analyzing
structure, this gives slightly more flexibility to create a mapping from
one region to another. We can add both operands in a corresponding
instruction to an operand rather than just the exact match. We then try
to eliminate items from the set, until there is only one valid mapping
between the regions of code.

We do this for adds, multiplies, and equality checking. However, this is
not done for floating point instructions, since the order can still
matter in some cases.

Tests:

llvm/test/Transforms/IROutliner/outlining-commutative-fp.ll
llvm/test/Transforms/IROutliner/outlining-commutative.ll
llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

Reviewers: jroelofs, paquette

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

Added: 
llvm/test/Transforms/IROutliner/outlining-commutative-fp.ll
llvm/test/Transforms/IROutliner/outlining-commutative.ll

Modified: 
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h 
b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index 30f32492937a..4bc5a17b57e5 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -504,7 +504,20 @@ class IRSimilarityCandidate {
   /// \param B - The second IRInstructionCandidate, operand values, and current
   /// operand mappings to compare.
   /// \returns true if the IRSimilarityCandidates operands are compatible.
-  static bool compareOperandMapping(OperandMapping A, OperandMapping B);
+  static bool compareNonCommutativeOperandMapping(OperandMapping A,
+  OperandMapping B);
+
+  /// Compare the operands in \p A and \p B and check that the current mapping
+  /// of global value numbers from \p A to \p B and \p B to \A is consistent
+  /// given that the operands are commutative.
+  ///
+  /// \param A - The first IRInstructionCandidate, operand values, and current
+  /// operand mappings to compare.
+  /// \param B - The second IRInstructionCandidate, operand values, and current
+  /// operand mappings to compare.
+  /// \returns true if the IRSimilarityCandidates operands are compatible.
+  static bool compareCommutativeOperandMapping(OperandMapping A,
+   OperandMapping B);
 
   /// Compare the start and end indices of the two IRSimilarityCandidates for
   /// whether they overlap. If the start instruction of one

diff  --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp 
b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index 41e234651349..28b0382bba36 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -15,6 +15,7 @@
 #include "llvm/Analysis/IRSimilarityIdentifier.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Operator.h"
 #include "llvm/IR/User.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/SuffixTree.h"
@@ -241,6 +242,96 @@ bool IRSimilarityCandidate::isSimilar(const 
IRSimilarityCandidate &A,
 });
 }
 
+/// Determine if one or more of the assigned global value numbers for the
+/// operands in \p TargetValueNumbers is in the current mapping set for operand
+/// numbers in \p SourceOperands.  The set of possible corresponding global
+/// value numbers are replaced with the most recent version of compatible
+/// values.
+///
+/// \param [in] SourceValueToNumberMapping - The mapping of a Value to global
+/// value number for the source IRInstructionCandidate.
+/// \param [in, out] CurrentSrcTgtNumberMapping - The current mapping of source
+/// IRSimilarityCandidate global value numbers to a set of possible numbers in
+/// the target.
+/// \param [in] SourceOperands - The operands in the original
+/// IRSimilarityCandidate in the current instruction.
+/// \param [in] TargetValueNumbers - The global value numbers of the operands 
in
+/// the corresponding Instruction in the other IRSimilarityCandidate.
+/// \returns true if there exists a possible mapping between the source
+/// Instruction operands and the target Instruction operands, and false if not.
+static bool checkNumberingAndReplaceCommutative(
+  const DenseMap &SourceValueToNumberMapping,
+  DenseMap>

[llvm-branch-commits] [llvm] 0503926 - [IRSim] Adding support for isomorphic predicates

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

Author: Andrew Litteken
Date: 2020-12-23T15:02:00-06:00
New Revision: 050392660249c70c00e909ae4a7151ba2c766235

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

LOG: [IRSim] Adding support for isomorphic predicates

Some predicates, can be considered the same as long as the operands are
flipped. For example, a > b gives the same result as b > a. This maps
instructions in a greater than form, to their appropriate less than
form, swapping the operands in the IRInstructionData only, allowing for
more flexible matching.

Tests:

llvm/test/Transforms/IROutliner/outlining-isomorphic-predicates.ll
llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

Reviewers: jroelofs, paquette

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

Added: 
llvm/test/Transforms/IROutliner/outlining-isomorphic-predicates.ll

Modified: 
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h 
b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index 4bc5a17b57e5..99a5fcb3a578 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -122,6 +122,11 @@ struct IRInstructionData : ilist_node {
   /// considered similar.
   bool Legal;
 
+  /// This is only relevant if we are wrapping a CmpInst where we needed to
+  /// change the predicate of a compare instruction from a greater than form
+  /// to a less than form.  It is None otherwise.
+  Optional RevisedPredicate;
+
   /// Gather the information that is 
diff icult to gather for an Instruction, or
   /// is changed. i.e. the operands of an Instruction and the Types of those
   /// operands. This extra information allows for similarity matching to make
@@ -129,6 +134,17 @@ struct IRInstructionData : ilist_node {
   /// Instruction performs the same operation.
   IRInstructionData(Instruction &I, bool Legality, IRInstructionDataList &IDL);
 
+  /// Get the predicate that the compare instruction is using for hashing the
+  /// instruction. the IRInstructionData must be wrapping a CmpInst.
+  CmpInst::Predicate getPredicate() const;
+
+  /// A function that swaps the predicates to their less than form if they are
+  /// in a greater than form. Otherwise, the predicate is unchanged.
+  ///
+  /// \param CI - The comparison operation to find a consistent preidcate for.
+  /// \return the consistent comparison predicate. 
+  static CmpInst::Predicate predicateForConsistency(CmpInst *CI);
+
   /// Hashes \p Value based on its opcode, types, and operand types.
   /// Two IRInstructionData instances produce the same hash when they perform
   /// the same operation.
@@ -161,6 +177,12 @@ struct IRInstructionData : ilist_node {
 for (Value *V : ID.OperVals)
   OperTypes.push_back(V->getType());
 
+if (isa(ID.Inst))
+  return llvm::hash_combine(
+  llvm::hash_value(ID.Inst->getOpcode()),
+  llvm::hash_value(ID.Inst->getType()),
+  llvm::hash_value(ID.getPredicate()),
+  llvm::hash_combine_range(OperTypes.begin(), OperTypes.end()));
 return llvm::hash_combine(
 llvm::hash_value(ID.Inst->getOpcode()),
 llvm::hash_value(ID.Inst->getType()),

diff  --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp 
b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index 28b0382bba36..4ee152450c05 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -26,15 +26,84 @@ using namespace IRSimilarity;
 IRInstructionData::IRInstructionData(Instruction &I, bool Legality,
  IRInstructionDataList &IDList)
 : Inst(&I), Legal(Legality), IDL(&IDList) {
-  // Here we collect the operands to be used to determine whether two
-  // instructions are similar to one another.
-  for (Use &OI : I.operands())
+  // We check for whether we have a comparison instruction.  If it is, we
+  // find the "less than" version of the predicate for consistency for
+  // comparison instructions throught the program.
+  if (CmpInst *C = dyn_cast(&I)) {
+CmpInst::Predicate Predicate = predicateForConsistency(C);
+if (Predicate != C->getPredicate())
+  RevisedPredicate = Predicate;
+  }
+
+  // Here we collect the operands and their types for determining whether
+  // the structure of the operand use matches between two 
diff erent candidates.
+  for (Use &OI : I.operands()) {
+if (isa(I) && RevisedPredicate.hasValue()) {
+  // If we have a CmpInst where the predicate is reversed, it means the
+  // operands must be reversed as well.
+  OperVals.insert(OperVals.begin(), OI.get())

[llvm-branch-commits] [llvm] f807935 - [InstCombine] canonicalizeAbsNabs(): don't propagate NSW flag for NABS patter

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

Author: Roman Lebedev
Date: 2020-12-24T00:06:09+03:00
New Revision: f8079355c604fead0f8538548bd7eb51fcc81e31

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

LOG: [InstCombine] canonicalizeAbsNabs(): don't propagate NSW flag for NABS 
patter

As Nuno is noting in post-commit review in
https://reviews.llvm.org/D87188#2467915
it is not correct to keep NSW for negated abs pattern,
so don't do that.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/abs-1.ll
llvm/test/Transforms/InstCombine/abs_abs.ll
llvm/test/Transforms/InstCombine/select_meta.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index fe21f300a417..075667629c5f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1058,15 +1058,16 @@ static Instruction *canonicalizeAbsNabs(SelectInst 
&Sel, ICmpInst &Cmp,
   SPF != SelectPatternFlavor::SPF_NABS)
 return nullptr;
 
-  bool IntMinIsPoison = match(RHS, m_NSWNeg(m_Specific(LHS)));
+  // Note that NSW flag can only be propagated for normal, non-negated abs!
+  bool IntMinIsPoison = SPF == SelectPatternFlavor::SPF_ABS &&
+match(RHS, m_NSWNeg(m_Specific(LHS)));
   Constant *IntMinIsPoisonC =
   ConstantInt::get(Type::getInt1Ty(Sel.getContext()), IntMinIsPoison);
   Instruction *Abs =
   IC.Builder.CreateBinaryIntrinsic(Intrinsic::abs, LHS, IntMinIsPoisonC);
 
   if (SPF == SelectPatternFlavor::SPF_NABS)
-return IntMinIsPoison ? BinaryOperator::CreateNSWNeg(Abs)
-  : BinaryOperator::CreateNeg(Abs);
+return BinaryOperator::CreateNeg(Abs); // Always without NSW flag!
 
   return IC.replaceInstUsesWith(Sel, Abs);
 }

diff  --git a/llvm/test/Transforms/InstCombine/abs-1.ll 
b/llvm/test/Transforms/InstCombine/abs-1.ll
index fbc0fc1a835c..7e5eadf5b25e 100644
--- a/llvm/test/Transforms/InstCombine/abs-1.ll
+++ b/llvm/test/Transforms/InstCombine/abs-1.ll
@@ -226,8 +226,8 @@ define <2 x i8> @nabs_canonical_2_vec_undef_elts(<2 x i8> 
%x) {
 
 define i8 @nabs_canonical_3(i8 %x) {
 ; CHECK-LABEL: @nabs_canonical_3(
-; CHECK-NEXT:[[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 true)
-; CHECK-NEXT:[[ABS:%.*]] = sub nsw i8 0, [[TMP1]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT:[[ABS:%.*]] = sub i8 0, [[TMP1]]
 ; CHECK-NEXT:ret i8 [[ABS]]
 ;
   %cmp = icmp slt i8 %x, 0
@@ -251,7 +251,7 @@ define i8 @nabs_canonical_4(i8 %x) {
 define i32 @nabs_canonical_5(i8 %x) {
 ; CHECK-LABEL: @nabs_canonical_5(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[X:%.*]] to i32
-; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[CONV]], i1 true)
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[CONV]], i1 false)
 ; CHECK-NEXT:[[ABS:%.*]] = sub nsw i32 0, [[TMP1]]
 ; CHECK-NEXT:ret i32 [[ABS]]
 ;

diff  --git a/llvm/test/Transforms/InstCombine/abs_abs.ll 
b/llvm/test/Transforms/InstCombine/abs_abs.ll
index f2faf35a2515..cb0118261bb6 100644
--- a/llvm/test/Transforms/InstCombine/abs_abs.ll
+++ b/llvm/test/Transforms/InstCombine/abs_abs.ll
@@ -319,9 +319,9 @@ define <2 x i32> @abs_abs_x03_vec(<2 x i32> %x, <2 x i32> 
%y) {
 
 define i32 @nabs_nabs_x01(i32 %x) {
 ; CHECK-LABEL: @nabs_nabs_x01(
-; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
-; CHECK-NEXT:[[COND:%.*]] = sub nsw i32 0, [[TMP1]]
-; CHECK-NEXT:ret i32 [[COND]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
+; CHECK-NEXT:[[COND18:%.*]] = sub i32 0, [[TMP1]]
+; CHECK-NEXT:ret i32 [[COND18]]
 ;
   %cmp = icmp sgt i32 %x, -1
   %sub = sub nsw i32 0, %x
@@ -334,9 +334,9 @@ define i32 @nabs_nabs_x01(i32 %x) {
 
 define i32 @nabs_nabs_x02(i32 %x) {
 ; CHECK-LABEL: @nabs_nabs_x02(
-; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
-; CHECK-NEXT:[[COND:%.*]] = sub nsw i32 0, [[TMP1]]
-; CHECK-NEXT:ret i32 [[COND]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
+; CHECK-NEXT:[[COND18:%.*]] = sub i32 0, [[TMP1]]
+; CHECK-NEXT:ret i32 [[COND18]]
 ;
   %cmp = icmp sgt i32 %x, 0
   %sub = sub nsw i32 0, %x
@@ -349,9 +349,9 @@ define i32 @nabs_nabs_x02(i32 %x) {
 
 define i32 @nabs_nabs_x03(i32 %x) {
 ; CHECK-LABEL: @nabs_nabs_x03(
-; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
-; CHECK-NEXT:[[COND:%.*]] = sub nsw i32 0, [[TMP1]]
-; CHECK-NEXT:ret i32 [[COND]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
+; CHECK-NEXT:[[COND18

[llvm-branch-commits] [clang] 374f1d8 - [clang-format] Fix handling of TextProto comments

2020-12-23 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2020-12-23T22:07:13+01:00
New Revision: 374f1d81febf8143e8e633296a42c2311699c5b3

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

LOG: [clang-format] Fix handling of TextProto comments

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

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestTextProto.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 6a240fdec8b9..c5edc670393c 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -789,9 +789,14 @@ BreakableLineCommentSection::BreakableLineCommentSection(
   Prefix[i] = "///< ";
 else if (Prefix[i] == "//!<")
   Prefix[i] = "//!< ";
-else if (Prefix[i] == "#" &&
- Style.Language == FormatStyle::LK_TextProto)
+else if (Prefix[i] == "#")
   Prefix[i] = "# ";
+else if (Prefix[i] == "##")
+  Prefix[i] = "## ";
+else if (Prefix[i] == "###")
+  Prefix[i] = "### ";
+else if (Prefix[i] == "")
+  Prefix[i] = " ";
   }
 
   Tokens[i] = LineTok;

diff  --git a/clang/unittests/Format/FormatTestTextProto.cpp 
b/clang/unittests/Format/FormatTestTextProto.cpp
index 3ae13d172865..1e2594893841 100644
--- a/clang/unittests/Format/FormatTestTextProto.cpp
+++ b/clang/unittests/Format/FormatTestTextProto.cpp
@@ -380,25 +380,29 @@ TEST_F(FormatTestTextProto, KeepsCommentsIndentedInList) {
": 3849");
 }
 
-TEST_F(FormatTestTextProto, UnderstandsHashHashComments) {
+TEST_F(FormatTestTextProto, UnderstandsHashComments) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
   Style.ColumnLimit = 60; // To make writing tests easier.
   EXPECT_EQ("aaa: 100\n"
-"##this is a double-hash comment.\n"
+"## this is a double-hash comment.\n"
 "bb: 100\n"
 "## another double-hash comment.\n"
 "### a triple-hash comment\n"
 "cc: 200\n"
+"### another triple-hash comment\n"
 " a quadriple-hash comment\n"
-"dd: 100\n",
+"dd: 100\n"
+" another quadriple-hash comment\n",
 format("aaa: 100\n"
"##this is a double-hash comment.\n"
"bb: 100\n"
"## another double-hash comment.\n"
-   "### a triple-hash comment\n"
+   "###a triple-hash comment\n"
"cc: 200\n"
-   " a quadriple-hash comment\n"
-   "dd: 100\n",
+   "### another triple-hash comment\n"
+   "a quadriple-hash comment\n"
+   "dd: 100\n"
+   " another quadriple-hash comment\n",
Style));
 }
 



___
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] 47877c9 - [clang-format] Add SpaceBeforeCaseColon option

2020-12-23 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2020-12-23T22:07:14+01:00
New Revision: 47877c9079c27f19a954b660201ea47717c82fec

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

LOG: [clang-format] Add SpaceBeforeCaseColon option

With which you can add a space before the colon of a case or default
statement.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 32942648378b..c58bb1af7ae6 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2839,6 +2839,16 @@ the configuration (without a prefix: ``Auto``).
  int a = 5; vs. int a= 5;
  a += 42;   a+= 42;
 
+**SpaceBeforeCaseColon** (``bool``)
+  If ``false``, spaces will be removed before case colon.
+
+  .. code-block:: c++
+
+true:   false
+switch (x) {vs. switch (x) {
+  case 1 : break; case 1: break;
+}   }
+
 **SpaceBeforeCpp11BracedList** (``bool``)
   If ``true``, a space will be inserted before a C++11 braced list
   used to initialize an object (after the preceding identifier or type).

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dd4de2d2015f..76d4b6bb5acd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -293,6 +293,9 @@ clang-format
 
 - Option ``IndentPragmas`` has been added to allow #pragma to indented with 
the current scope level. This is especially useful when using #pragma to mark 
OpenMP sections of code.
 
+- Option ``SpaceBeforeCaseColon`` has been added to add a space before the
+  colon in a case or default statement.
+
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 9b8309213261..c6a9818a8940 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2438,6 +2438,15 @@ struct FormatStyle {
   /// \endcode
   bool SpaceBeforeAssignmentOperators;
 
+  /// If ``false``, spaces will be removed before case colon.
+  /// \code
+  ///   true:   false
+  ///   switch (x) {vs. switch (x) {
+  /// case 1 : break; case 1: break;
+  ///   }   }
+  /// \endcode
+  bool SpaceBeforeCaseColon;
+
   /// If ``true``, a space will be inserted before a C++11 braced list
   /// used to initialize an object (after the preceding identifier or type).
   /// \code
@@ -2820,6 +2829,7 @@ struct FormatStyle {
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
+   SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 55abc12c61c4..54424ae190e2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -608,6 +608,7 @@ template <> struct MappingTraits {
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
Style.SpaceBeforeAssignmentOperators);
+IO.mapOptional("SpaceBeforeCaseColon", Style.SpaceBeforeCaseColon);
 IO.mapOptional("SpaceBeforeCpp11BracedList",
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
@@ -958,6 +959,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SpaceAfterLogicalNot = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
+  LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index a0cb86cfcebf..1588f7d08184 100755
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -896,7 +896,8 @@ class AnnotatingP

[llvm-branch-commits] [llvm] 45a4f34 - Revert "[IRSim] Adding support for isomorphic predicates"

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

Author: Andrew Litteken
Date: 2020-12-23T15:14:19-06:00
New Revision: 45a4f34bd194acdfe3472406c303a97dc4e2526f

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

LOG: Revert "[IRSim] Adding support for isomorphic predicates"

Reverting due to unit test errors between commits.

This reverts commit 050392660249c70c00e909ae4a7151ba2c766235.

Added: 


Modified: 
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

Removed: 
llvm/test/Transforms/IROutliner/outlining-isomorphic-predicates.ll



diff  --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h 
b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index 99a5fcb3a578..4bc5a17b57e5 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -122,11 +122,6 @@ struct IRInstructionData : ilist_node {
   /// considered similar.
   bool Legal;
 
-  /// This is only relevant if we are wrapping a CmpInst where we needed to
-  /// change the predicate of a compare instruction from a greater than form
-  /// to a less than form.  It is None otherwise.
-  Optional RevisedPredicate;
-
   /// Gather the information that is 
diff icult to gather for an Instruction, or
   /// is changed. i.e. the operands of an Instruction and the Types of those
   /// operands. This extra information allows for similarity matching to make
@@ -134,17 +129,6 @@ struct IRInstructionData : ilist_node {
   /// Instruction performs the same operation.
   IRInstructionData(Instruction &I, bool Legality, IRInstructionDataList &IDL);
 
-  /// Get the predicate that the compare instruction is using for hashing the
-  /// instruction. the IRInstructionData must be wrapping a CmpInst.
-  CmpInst::Predicate getPredicate() const;
-
-  /// A function that swaps the predicates to their less than form if they are
-  /// in a greater than form. Otherwise, the predicate is unchanged.
-  ///
-  /// \param CI - The comparison operation to find a consistent preidcate for.
-  /// \return the consistent comparison predicate. 
-  static CmpInst::Predicate predicateForConsistency(CmpInst *CI);
-
   /// Hashes \p Value based on its opcode, types, and operand types.
   /// Two IRInstructionData instances produce the same hash when they perform
   /// the same operation.
@@ -177,12 +161,6 @@ struct IRInstructionData : ilist_node {
 for (Value *V : ID.OperVals)
   OperTypes.push_back(V->getType());
 
-if (isa(ID.Inst))
-  return llvm::hash_combine(
-  llvm::hash_value(ID.Inst->getOpcode()),
-  llvm::hash_value(ID.Inst->getType()),
-  llvm::hash_value(ID.getPredicate()),
-  llvm::hash_combine_range(OperTypes.begin(), OperTypes.end()));
 return llvm::hash_combine(
 llvm::hash_value(ID.Inst->getOpcode()),
 llvm::hash_value(ID.Inst->getType()),

diff  --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp 
b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index 4ee152450c05..28b0382bba36 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -26,84 +26,15 @@ using namespace IRSimilarity;
 IRInstructionData::IRInstructionData(Instruction &I, bool Legality,
  IRInstructionDataList &IDList)
 : Inst(&I), Legal(Legality), IDL(&IDList) {
-  // We check for whether we have a comparison instruction.  If it is, we
-  // find the "less than" version of the predicate for consistency for
-  // comparison instructions throught the program.
-  if (CmpInst *C = dyn_cast(&I)) {
-CmpInst::Predicate Predicate = predicateForConsistency(C);
-if (Predicate != C->getPredicate())
-  RevisedPredicate = Predicate;
-  }
-
-  // Here we collect the operands and their types for determining whether
-  // the structure of the operand use matches between two 
diff erent candidates.
-  for (Use &OI : I.operands()) {
-if (isa(I) && RevisedPredicate.hasValue()) {
-  // If we have a CmpInst where the predicate is reversed, it means the
-  // operands must be reversed as well.
-  OperVals.insert(OperVals.begin(), OI.get());
-  continue;
-}
-
+  // Here we collect the operands to be used to determine whether two
+  // instructions are similar to one another.
+  for (Use &OI : I.operands())
 OperVals.push_back(OI.get());
-  }
-}
-
-CmpInst::Predicate IRInstructionData::predicateForConsistency(CmpInst *CI) {
-  switch (CI->getPredicate()) {
-  case CmpInst::FCMP_OGT:
-  case CmpInst::FCMP_UGT:
-  case CmpInst::FCMP_OGE:
-  case CmpInst::FCMP_UGE:
-  case CmpInst::ICMP_SGT:
-  case CmpInst::ICMP_UGT:
-  case CmpInst::ICMP_SGE:
-  case CmpInst::ICMP_UGE:
-

[llvm-branch-commits] [clang-tools-extra] 74b3ace - [clangd] Fix case mismatch crash on in CDB on windows after 92dd077af1ff8

2020-12-23 Thread Sam McCall via llvm-branch-commits

Author: Sam McCall
Date: 2020-12-23T22:42:45+01:00
New Revision: 74b3acefc7b6355e89bb9b09dc88a5948f65c342

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

LOG: [clangd] Fix case mismatch crash on in CDB on windows after 92dd077af1ff8

See https://github.com/clangd/clangd/issues/631

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 41b549cefc7c..86375fa11d3b 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -511,11 +511,14 @@ void 
DirectoryBasedGlobalCompilationDatabase::broadcastCDB(
   // Given that we know that CDBs have been moved/generated, don't trust 
caches.
   // (This should be rare, so it's OK to add a little latency).
   constexpr auto IgnoreCache = std::chrono::steady_clock::time_point::max();
-  for (DirectoryCache *Dir : getDirectoryCaches(FileAncestors)) {
+  auto DirectoryCaches = getDirectoryCaches(FileAncestors);
+  assert(DirectoryCaches.size() == FileAncestors.size());
+  for (unsigned I = 0; I < DirectoryCaches.size(); ++I) {
 bool ShouldBroadcast = false;
-if (Dir->get(Opts.TFS, ShouldBroadcast, /*FreshTime=*/IgnoreCache,
- /*FreshTimeMissing=*/IgnoreCache))
-  DirectoryHasCDB.find(Dir->Path)->setValue(true);
+if (DirectoryCaches[I]->get(Opts.TFS, ShouldBroadcast,
+/*FreshTime=*/IgnoreCache,
+/*FreshTimeMissing=*/IgnoreCache))
+  DirectoryHasCDB.find(FileAncestors[I])->setValue(true);
   }
 
   std::vector GovernedFiles;



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


[llvm-branch-commits] [lldb] d97e9f1 - [lldb] Simplify ObjectFile::FindPlugin (NFC)

2020-12-23 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-23T14:06:40-08:00
New Revision: d97e9f1a3d8510de036f8fec68cfd5330c9f050c

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

LOG: [lldb] Simplify ObjectFile::FindPlugin (NFC)

Use early return to reduce the levels of indentation. Extract logic to
find object in container into helper function.

Added: 


Modified: 
lldb/source/Symbol/ObjectFile.cpp

Removed: 




diff  --git a/lldb/source/Symbol/ObjectFile.cpp 
b/lldb/source/Symbol/ObjectFile.cpp
index ffe57121391f..f5dcbc5467f7 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -28,141 +28,121 @@ using namespace lldb_private;
 
 char ObjectFile::ID;
 
+static ObjectFileSP
+CreateObjectFromContainer(const lldb::ModuleSP &module_sp, const FileSpec 
*file,
+  lldb::offset_t file_offset, lldb::offset_t file_size,
+  DataBufferSP &data_sp, lldb::offset_t &data_offset) {
+  ObjectContainerCreateInstance callback;
+  for (uint32_t idx = 0;
+   (callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(
+idx)) != nullptr;
+   ++idx) {
+std::unique_ptr object_container_up(callback(
+module_sp, data_sp, data_offset, file, file_offset, file_size));
+if (object_container_up)
+  return object_container_up->GetObjectFile(file);
+  }
+  return {};
+}
+
 ObjectFileSP
 ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t file_size,
DataBufferSP &data_sp, lldb::offset_t &data_offset) {
-  ObjectFileSP object_file_sp;
-
-  if (module_sp) {
-LLDB_SCOPED_TIMERF(
-"ObjectFile::FindPlugin (module = %s, file = %p, file_offset = "
-"0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")",
-module_sp->GetFileSpec().GetPath().c_str(),
-static_cast(file), static_cast(file_offset),
-static_cast(file_size));
-if (file) {
-  FileSpec archive_file;
-  ObjectContainerCreateInstance create_object_container_callback;
-
-  if (!data_sp) {
-const bool file_exists = FileSystem::Instance().Exists(*file);
-// We have an object name which most likely means we have a .o file in
-// a static archive (.a file). Try and see if we have a cached archive
-// first without reading any data first
-if (file_exists && module_sp->GetObjectName()) {
-  for (uint32_t idx = 0;
-   (create_object_container_callback =
-PluginManager::GetObjectContainerCreateCallbackAtIndex(
-idx)) != nullptr;
-   ++idx) {
-std::unique_ptr object_container_up(
-create_object_container_callback(module_sp, data_sp,
- data_offset, file, 
file_offset,
- file_size));
-
-if (object_container_up)
-  object_file_sp = object_container_up->GetObjectFile(file);
-
-if (object_file_sp.get())
-  return object_file_sp;
-  }
-}
-// Ok, we didn't find any containers that have a named object, now lets
-// read the first 512 bytes from the file so the object file and object
-// container plug-ins can use these bytes to see if they can parse this
-// file.
-if (file_size > 0) {
-  data_sp = FileSystem::Instance().CreateDataBuffer(file->GetPath(),
-512, file_offset);
-  data_offset = 0;
-}
-  }
+  LLDB_SCOPED_TIMERF(
+  "ObjectFile::FindPlugin (module = %s, file = %p, file_offset = "
+  "0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")",
+  module_sp->GetFileSpec().GetPath().c_str(),
+  static_cast(file), static_cast(file_offset),
+  static_cast(file_size));
+
+  if (!module_sp)
+return {};
+
+  if (!file)
+return {};
+
+  if (!data_sp) {
+const bool file_exists = FileSystem::Instance().Exists(*file);
+// We have an object name which most likely means we have a .o file in
+// a static archive (.a file). Try and see if we have a cached archive
+// first without reading any data first
+if (file_exists && module_sp->GetObjectName()) {
+  ObjectFileSP object_file_sp = CreateObjectFromContainer(
+  module_sp, file, file_offset, file_size, data_sp, data_offset);
+  if (object_file_sp)
+return object_file_sp;
+}
+// Ok, we didn't find any containers that have a named object, now lets
+// read the first 512 bytes from the file so the object file and object
+// container plug-ins can use

[llvm-branch-commits] [lldb] 7143923 - Fix lldb test failure due to D93082.

2020-12-23 Thread Sriraman Tallam via llvm-branch-commits

Author: Sriraman Tallam
Date: 2020-12-23T14:16:27-08:00
New Revision: 7143923f86b5d13cb079010b908e55f7f78cb75e

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

LOG: Fix lldb test failure due to D93082.

Rename the basic block symbols in the test to reflect the new names.

Added: 


Modified: 
lldb/test/Shell/Unwind/basic-block-sections.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/basic-block-sections.test 
b/lldb/test/Shell/Unwind/basic-block-sections.test
index 7b24a8675863..8e563b731057 100644
--- a/lldb/test/Shell/Unwind/basic-block-sections.test
+++ b/lldb/test/Shell/Unwind/basic-block-sections.test
@@ -12,22 +12,22 @@
 # RUN: %lldb %t -s %s -o exit | FileCheck  %s --check-prefix=BBSECTIONS
 
 # Reorder basic blocks so that main's basic blocks are discontiguous
-# RUN: echo "main.3" > %t.order
+# RUN: echo "main.__part.3" > %t.order
 # RUN: echo "bar" >> %t.order
 # RUN: echo "main" >> %t.order
-# RUN: echo "main.2" >> %t.order
+# RUN: echo "main.__part.2" >> %t.order
 # RUN: echo "foo" >> %t.order
-# RUN: echo "main.1" >> %t.order
+# RUN: echo "main.__part.1" >> %t.order
 # RUN: %clang_host %p/Inputs/basic-block-sections.c -o %t 
-fbasic-block-sections=all -fuse-ld=lld -Wl,--symbol-ordering-file,%t.order 
-Wl,--warn-symbol-ordering -Wl,--fatal-warnings
 # RUN: %lldb %t -s %s -o exit | FileCheck  %s --check-prefix=BBSECTIONS
 
 # Test the reverse permutation too.
-# RUN: echo "main.1" > %t.order
+# RUN: echo "main.__part.1" > %t.order
 # RUN: echo "foo" >> %t.order
-# RUN: echo "main.2" >> %t.order
+# RUN: echo "main.__part.2" >> %t.order
 # RUN: echo "main" >> %t.order
 # RUN: echo "bar" >> %t.order
-# RUN: echo "main.3" >> %t.order
+# RUN: echo "main.__part.3" >> %t.order
 # RUN: %clang_host %p/Inputs/basic-block-sections.c -o %t 
-fbasic-block-sections=all -fuse-ld=lld -Wl,--symbol-ordering-file,%t.order 
-Wl,--warn-symbol-ordering -Wl,--fatal-warnings
 # RUN: %lldb %t -s %s -o exit | FileCheck  %s --check-prefix=BBSECTIONS
 
@@ -46,4 +46,4 @@ thread backtrace
 
 # BBSECTIONS: frame #0: {{.*}}`bar
 # BBSECTIONS: frame #1: {{.*}}`foo
-# BBSECTIONS: frame #2: {{.*}}`main.1 +
+# BBSECTIONS: frame #2: {{.*}}`main.__part.1 +



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


[llvm-branch-commits] [lld] be89d74 - [lld][test] Relax test assertion of cmake defaults appearing in --version output.

2020-12-23 Thread Jordan Rupprecht via llvm-branch-commits

Author: Jordan Rupprecht
Date: 2020-12-23T14:33:04-08:00
New Revision: be89d7460b63508a6a277050395c14a4fa74b031

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

LOG: [lld][test] Relax test assertion of cmake defaults appearing in --version 
output.

D93491 implemented `--version` for the MachO LLD port, but asserts that the 
string contains something like "LLD N.N". However, this is just the cmake 
default for `LLD_VERSION_STRING`, and downstream users may choose a different 
value, e.g. a rolling distro may print "LLD trunk".

Added: 


Modified: 
lld/test/MachO/driver.test

Removed: 




diff  --git a/lld/test/MachO/driver.test b/lld/test/MachO/driver.test
index 417c71eac561..5a0ccac01c31 100644
--- a/lld/test/MachO/driver.test
+++ b/lld/test/MachO/driver.test
@@ -1,5 +1,5 @@
 # RUN: %lld --version | FileCheck -check-prefix=VERSION %s
-VERSION: {{LLD [0-9]+\.[0-9]+}}
+VERSION: LLD
 
 # RUN: not %lld ---help 2>&1 | FileCheck -check-prefix=SPELLHELP %s
 SPELLHELP: error: unknown argument '---help', did you mean '--help'



___
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] 747f67e - [AMDGPU] Fix adjustWritemask subreg handling

2020-12-23 Thread Stanislav Mekhanoshin via llvm-branch-commits

Author: Stanislav Mekhanoshin
Date: 2020-12-23T14:43:31-08:00
New Revision: 747f67e034a924cf308f4c0f1bb6b1fa46bd9fbe

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

LOG: [AMDGPU] Fix adjustWritemask subreg handling

If we happen to extract a non-dword subreg that breaks the
logic of the function and it may shrink the dmask because
it does not recognize the use of a lane(s).

This bug is next to impossible to trigger with the current
lowering in the BE, but it breaks in one of my future patches.

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

Added: 


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

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 81fdfa0343b3..c7abc585d0d1 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -10862,7 +10862,7 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
 /// Helper function for adjustWritemask
 static unsigned SubIdx2Lane(unsigned Idx) {
   switch (Idx) {
-  default: return 0;
+  default: return ~0u;
   case AMDGPU::sub0: return 0;
   case AMDGPU::sub1: return 1;
   case AMDGPU::sub2: return 2;
@@ -10922,6 +10922,8 @@ SDNode *SITargetLowering::adjustWritemask(MachineSDNode 
*&Node,
 // in OldDmask, so it can be any of X,Y,Z,W; Lane==1 is the second bit
 // set, etc.
 Lane = SubIdx2Lane(I->getConstantOperandVal(1));
+if (Lane == ~0u)
+  return Node;
 
 // Check if the use is for the TFE/LWE generated result at VGPRn+1.
 if (UsesTFC && Lane == TFCLane) {



___
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] 245218b - Basic: Support named pipes natively in SourceManager and FileManager

2020-12-23 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-23T14:57:41-08:00
New Revision: 245218bb355599771ba43a0fe1449d1670f2666c

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

LOG: Basic: Support named pipes natively in SourceManager and FileManager

Handle named pipes natively in SourceManager and FileManager, removing a
call to `SourceManager::overrideFileContents` in
`CompilerInstance::InitializeSourceManager` (removing a blocker for
sinking the content cache to FileManager (which will incidently sink
this new named pipe logic with it)).

SourceManager usually checks if the file entry's size matches the
eventually loaded buffer, but that's now skipped for named pipes since
the `stat` won't reflect the full size.  Since we can't trust
`ContentsEntry->getSize()`, we also need shift the check for files that
are too large until after the buffer is loaded... and load the buffer
immediately in `createFileID` so that no client gets a bad value from
`ContentCache::getSize`. `FileManager::getBufferForFile` also needs to
treat these files as volatile when loading the buffer.

Native support in SourceManager / FileManager means that named pipes can
also be `#include`d, and clang/test/Misc/dev-fd-fs.c was expanded to
check for that.

This is a new version of 3b18a594c7717a328c33b9c1eba675e9f4bd367c, which
was reverted in b34632201987eed369bb7ef4646f341b901c95b8 since it was
missing the `SourceManager` changes.

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

Added: 


Modified: 
clang/lib/Basic/FileManager.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/test/Misc/dev-fd-fs.c

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index c0d3685001ee..f3afe6dd5f48 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -489,7 +489,7 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool 
isVolatile,
   uint64_t FileSize = Entry->getSize();
   // If there's a high enough chance that the file have changed since we
   // got its size, force a stat before opening it.
-  if (isVolatile)
+  if (isVolatile || Entry->isNamedPipe())
 FileSize = -1;
 
   StringRef Filename = Entry->getName();

diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index b71b2be0cc41..d2c0de5006c4 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -115,23 +115,6 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, 
FileManager &FM,
   // return paths.
   IsBufferInvalid = true;
 
-  // Check that the file's size fits in an 'unsigned' (with room for a
-  // past-the-end value). This is deeply regrettable, but various parts of
-  // Clang (including elsewhere in this file!) use 'unsigned' to represent file
-  // offsets, line numbers, string literal lengths, and so on, and fail
-  // miserably on large source files.
-  if ((uint64_t)ContentsEntry->getSize() >=
-  std::numeric_limits::max()) {
-if (Diag.isDiagnosticInFlight())
-  Diag.SetDelayedDiagnostic(diag::err_file_too_large,
-ContentsEntry->getName());
-else
-  Diag.Report(Loc, diag::err_file_too_large)
-<< ContentsEntry->getName();
-
-return None;
-  }
-
   auto BufferOrError = FM.getBufferForFile(ContentsEntry, IsFileVolatile);
 
   // If we were unable to open the file, then we are in an inconsistent
@@ -153,9 +136,31 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, 
FileManager &FM,
 
   Buffer = std::move(*BufferOrError);
 
-  // Check that the file's size is the same as in the file entry (which may
+  // Check that the file's size fits in an 'unsigned' (with room for a
+  // past-the-end value). This is deeply regrettable, but various parts of
+  // Clang (including elsewhere in this file!) use 'unsigned' to represent file
+  // offsets, line numbers, string literal lengths, and so on, and fail
+  // miserably on large source files.
+  //
+  // Note: ContentsEntry could be a named pipe, in which case
+  // ContentsEntry::getSize() could have the wrong size. Use
+  // MemoryBuffer::getBufferSize() instead.
+  if (Buffer->getBufferSize() >= std::numeric_limits::max()) {
+if (Diag.isDiagnosticInFlight())
+  Diag.SetDelayedDiagnostic(diag::err_file_too_large,
+ContentsEntry->getName());
+else
+  Diag.Report(Loc, diag::err_file_too_large)
+<< ContentsEntry->getName();
+
+return None;
+  }
+
+  // Unless this is a named pipe (in which case we can handle a mismatch),
+  // check that the file's size is the same as in the file entry (which may
   // have come from a stat cache).
-  if (Buffer->getBufferSize() != (size_t)ContentsEntry->

[llvm-branch-commits] [clang] 3ee43ad - Basic: Add native support for stdin to SourceManager and FileManager

2020-12-23 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-23T15:18:50-08:00
New Revision: 3ee43adfb20d5dc56b7043b314bd22f457c55483

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

LOG: Basic: Add native support for stdin to SourceManager and FileManager

Add support for stdin to SourceManager and FileManager. Adds
FileManager::getSTDIN, which adds a FileEntryRef for `` and reads
the MemoryBuffer, which is stored as `FileEntry::Content`.

Eventually the other buffers in `ContentCache` will sink to here as well
-- we probably usually want to load/save a MemoryBuffer eagerly -- but
it's happening early for stdin to get rid of
CompilerInstance::InitializeSourceManager's final call to
`SourceManager::overrideFileContents`.

clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp
relies on building a module from stdin; supporting that requires setting
ContentCache::BufferOverridden.

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

Added: 


Modified: 
clang/include/clang/Basic/FileEntry.h
clang/include/clang/Basic/FileManager.h
clang/lib/Basic/FileEntry.cpp
clang/lib/Basic/FileManager.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index aa7bedec44ac..6e91b42e18b7 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -25,6 +25,9 @@
 #include "llvm/Support/FileSystem/UniqueID.h"
 
 namespace llvm {
+
+class MemoryBuffer;
+
 namespace vfs {
 
 class File;
@@ -67,6 +70,7 @@ class FileEntryRef {
   inline unsigned getUID() const;
   inline const llvm::sys::fs::UniqueID &getUniqueID() const;
   inline time_t getModificationTime() const;
+  inline bool isNamedPipe() const;
   inline void closeFile() const;
 
   /// Check if the underlying FileEntry is the same, intentially ignoring
@@ -339,6 +343,9 @@ class FileEntry {
   /// The open file, if it is owned by the \p FileEntry.
   mutable std::unique_ptr File;
 
+  /// The file content, if it is owned by the \p FileEntry.
+  std::unique_ptr Content;
+
   // First access name for this FileEntry.
   //
   // This is Optional only to allow delayed construction (FileEntryRef has no
@@ -390,6 +397,8 @@ time_t FileEntryRef::getModificationTime() const {
   return getFileEntry().getModificationTime();
 }
 
+bool FileEntryRef::isNamedPipe() const { return getFileEntry().isNamedPipe(); }
+
 void FileEntryRef::closeFile() const { getFileEntry().closeFile(); }
 
 } // end namespace clang

diff  --git a/clang/include/clang/Basic/FileManager.h 
b/clang/include/clang/Basic/FileManager.h
index 449aec2b3541..974771a8f8f3 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -99,6 +99,9 @@ class FileManager : public RefCountedBase {
   std::unique_ptr>>
   SeenBypassFileEntries;
 
+  /// The file entry for stdin, if it has been accessed through the 
FileManager.
+  Optional STDIN;
+
   /// The canonical names of files and directories .
   llvm::DenseMap CanonicalNames;
 
@@ -217,6 +220,14 @@ class FileManager : public RefCountedBase {
   bool OpenFile = false,
   bool CacheFailure = true);
 
+  /// Get the FileEntryRef for stdin, returning an error if stdin cannot be
+  /// read.
+  ///
+  /// This reads and caches stdin before returning. Subsequent calls return the
+  /// same file entry, and a reference to the cached input is returned by calls
+  /// to getBufferForFile.
+  llvm::Expected getSTDIN();
+
   /// Get a FileEntryRef if it exists, without doing anything on error.
   llvm::Optional getOptionalFileRef(StringRef Filename,
   bool OpenFile = false,

diff  --git a/clang/lib/Basic/FileEntry.cpp b/clang/lib/Basic/FileEntry.cpp
index 2efdcbbd46aa..5ee9bef9523e 100644
--- a/clang/lib/Basic/FileEntry.cpp
+++ b/clang/lib/Basic/FileEntry.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "clang/Basic/FileEntry.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
 using namespace clang;

diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index f3afe6dd5f48..6e9d5d7fb422 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -338,6 +338,25 @@ FileManager::getFileRef(StringRef Filename, bool openFile, 
bool CacheFailure) {
   return ReturnedRef;
 }
 
+llvm::Expected FileManager::getSTDIN() {
+  // Only read stdin once.
+  if (STDIN)
+return *STDIN;
+
+  std::unique_ptr Content;
+  if (auto ContentOrError = llvm

[llvm-branch-commits] [mlir] ca1ab0c - [mlir] Add tensor passes to passes.md

2020-12-23 Thread Jacques Pienaar via llvm-branch-commits

Author: Jacques Pienaar
Date: 2020-12-23T16:13:03-08:00
New Revision: ca1ab0c66d1c499d4ddcf723dcba692792d531a7

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

LOG: [mlir] Add tensor passes to passes.md

Added: 


Modified: 
mlir/docs/Passes.md

Removed: 




diff  --git a/mlir/docs/Passes.md b/mlir/docs/Passes.md
index c7ac56f84ea9..fdf2893e880a 100644
--- a/mlir/docs/Passes.md
+++ b/mlir/docs/Passes.md
@@ -56,6 +56,10 @@ This document describes the available MLIR passes and their 
contracts.
 
 [include "StandardPasses.md"]
 
+## `tensor` Dialect Passes
+
+[include "TensorPasses.md"]
+
 ## TOSA Dialect Passes
 
 [include "TosaPasses.md"]



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


[llvm-branch-commits] [llvm] d29f93b - [DAGCombiner] Don't create sexts of deleted xors when they were in-visit replaced

2020-12-23 Thread Jordan Rupprecht via llvm-branch-commits

Author: Layton Kifer
Date: 2020-12-23T16:16:26-08:00
New Revision: d29f93bda5114aec596c0cbb1e3ce37b61c6398c

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

LOG: [DAGCombiner] Don't create sexts of deleted xors when they were in-visit 
replaced

Fixes a bug introduced by D91589.

When folding `(sext (not i1 x)) -> (add (zext i1 x), -1)`, we try to replace 
the not first when possible. If we replace the not in-visit, then the now 
invalidated node will be returned, and subsequently we will return an invalid 
sext. In cases where the not is replaced in-visit we can simply return SDValue, 
as the not in the current sext should have already been replaced.

Thanks @jgorbe, for finding the below reproducer.

The following reduced test case crashes clang when built with `clang -O1 
-frounding-math`:

```
template  class a {
  int b() { return c == 0.0 ? 0 : -1; }
  int c;
};
template class a;
```

A debug build of clang produces this "assertion failed" error:
```
clang: 
/home/jgorbe/code/llvm/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:264: void 
{anonymous}::DAGCombiner::AddToWorklist(llvm::
SDNode*): Assertion `N->getOpcode() != ISD::DELETED_NODE && "Deleted Node added 
to Worklist"' failed.
```

Reviewed By: spatel

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/SystemZ/sext-zext.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 74d3e1adcd6c..92b23df9e3af 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -10721,8 +10721,18 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
   (!LegalOperations || (TLI.isOperationLegal(ISD::ZERO_EXTEND, VT) &&
 TLI.isOperationLegal(ISD::ADD, VT {
 // If we can eliminate the 'not', the sext form should be better
-if (SDValue NewXor = visitXOR(N0.getNode()))
-  return DAG.getNode(ISD::SIGN_EXTEND, DL, VT, NewXor);
+if (SDValue NewXor = visitXOR(N0.getNode())) {
+  // Returning N0 is a form of in-visit replacement that may have
+  // invalidated N0.
+  if (NewXor.getNode() == N0.getNode()) {
+// Return SDValue here as the xor should have already been replaced in
+// this sext.
+return SDValue();
+  } else {
+// Return a new sext with the new xor.
+return DAG.getNode(ISD::SIGN_EXTEND, DL, VT, NewXor);
+  }
+}
 
 SDValue Zext = DAG.getNode(ISD::ZERO_EXTEND, DL, VT, N0.getOperand(0));
 return DAG.getNode(ISD::ADD, DL, VT, Zext, DAG.getAllOnesConstant(DL, VT));

diff  --git a/llvm/test/CodeGen/SystemZ/sext-zext.ll 
b/llvm/test/CodeGen/SystemZ/sext-zext.ll
index d48e4ba83588..fbe1c44c1e50 100644
--- a/llvm/test/CodeGen/SystemZ/sext-zext.ll
+++ b/llvm/test/CodeGen/SystemZ/sext-zext.ll
@@ -28,6 +28,25 @@ define i32 @sext_of_not_cmp(i32 %x) {
   ret i32 %sext
 }
 
+;; fold (sext (not (setcc a, b, cc))) -> (sext (setcc a, b, !cc))
+;; make sure we don't crash if the not gets replaced in-visit
+define i32 @sext_of_not_fsetccs(double %x) {
+; CHECK-LABEL: sext_of_not_fsetccs:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:ltdbr %f0, %f0
+; CHECK-NEXT:ipm %r0
+; CHECK-NEXT:afi %r0, 1879048192
+; CHECK-NEXT:srl %r0, 31
+; CHECK-NEXT:lcr %r2, %r0
+; CHECK-NEXT:br %r14
+  %cmp = call i1 @llvm.experimental.constrained.fcmp.f64(double %x, double 
0.00e+00, metadata !"oeq", metadata !"fpexcept.ignore")
+  %xor = xor i1 %cmp, 1
+  %sext = sext i1 %xor to i32
+  ret i32 %sext
+}
+
+declare i1 @llvm.experimental.constrained.fcmp.f64(double, double, metadata, 
metadata)
+
 ;; TODO: fold (add (zext (setcc a, b, cc)), -1) -> (sext (setcc a, b, !cc))
 define i32 @dec_of_zexted_cmp(i32 %x) {
 ; CHECK-LABEL: dec_of_zexted_cmp:



___
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] 69132d1 - [Clang] Reverse test to save on indentation. NFC.

2020-12-23 Thread Alexandre Ganea via llvm-branch-commits

Author: Alexandre Ganea
Date: 2020-12-23T19:24:53-05:00
New Revision: 69132d12deae749a8e4c9def5498ffa354ce1fa6

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

LOG: [Clang] Reverse test to save on indentation. NFC.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenAction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 5b23b6d2b7f5..778d4df3c2e9 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -1078,78 +1078,74 @@ CodeGenAction::loadModule(MemoryBufferRef MBRef) {
 }
 
 void CodeGenAction::ExecuteAction() {
-  // If this is an IR file, we have to treat it specially.
-  if (getCurrentFileKind().getLanguage() == Language::LLVM_IR) {
-BackendAction BA = static_cast(Act);
-CompilerInstance &CI = getCompilerInstance();
-auto &CodeGenOpts = CI.getCodeGenOpts();
-auto &Diagnostics = CI.getDiagnostics();
-std::unique_ptr OS =
-GetOutputStream(CI, getCurrentFile(), BA);
-if (BA != Backend_EmitNothing && !OS)
-  return;
-
-SourceManager &SM = CI.getSourceManager();
-FileID FID = SM.getMainFileID();
-Optional MainFile = SM.getBufferOrNone(FID);
-if (!MainFile)
-  return;
+  if (getCurrentFileKind().getLanguage() != Language::LLVM_IR) {
+this->ASTFrontendAction::ExecuteAction();
+return;
+  }
 
-TheModule = loadModule(*MainFile);
-if (!TheModule)
-  return;
+  // If this is an IR file, we have to treat it specially.
+  BackendAction BA = static_cast(Act);
+  CompilerInstance &CI = getCompilerInstance();
+  auto &CodeGenOpts = CI.getCodeGenOpts();
+  auto &Diagnostics = CI.getDiagnostics();
+  std::unique_ptr OS =
+  GetOutputStream(CI, getCurrentFile(), BA);
+  if (BA != Backend_EmitNothing && !OS)
+return;
 
-const TargetOptions &TargetOpts = CI.getTargetOpts();
-if (TheModule->getTargetTriple() != TargetOpts.Triple) {
-  Diagnostics.Report(SourceLocation(),
- diag::warn_fe_override_module)
-  << TargetOpts.Triple;
-  TheModule->setTargetTriple(TargetOpts.Triple);
-}
+  SourceManager &SM = CI.getSourceManager();
+  FileID FID = SM.getMainFileID();
+  Optional MainFile = SM.getBufferOrNone(FID);
+  if (!MainFile)
+return;
 
-EmbedBitcode(TheModule.get(), CodeGenOpts, *MainFile);
-
-LLVMContext &Ctx = TheModule->getContext();
-Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler,
-  &Diagnostics);
-
-// Set clang diagnostic handler. To do this we need to create a fake
-// BackendConsumer.
-BackendConsumer Result(BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
-   CI.getPreprocessorOpts(), CI.getCodeGenOpts(),
-   CI.getTargetOpts(), CI.getLangOpts(),
-   std::move(LinkModules), *VMContext, nullptr);
-// PR44896: Force DiscardValueNames as false. DiscardValueNames cannot be
-// true here because the valued names are needed for reading textual IR.
-Ctx.setDiscardValueNames(false);
-Ctx.setDiagnosticHandler(
-std::make_unique(CodeGenOpts, &Result));
-
-Expected> OptRecordFileOrErr =
-setupLLVMOptimizationRemarks(
-Ctx, CodeGenOpts.OptRecordFile, CodeGenOpts.OptRecordPasses,
-CodeGenOpts.OptRecordFormat, CodeGenOpts.DiagnosticsWithHotness,
-CodeGenOpts.DiagnosticsHotnessThreshold);
-
-if (Error E = OptRecordFileOrErr.takeError()) {
-  reportOptRecordError(std::move(E), Diagnostics, CodeGenOpts);
-  return;
-}
-std::unique_ptr OptRecordFile =
-std::move(*OptRecordFileOrErr);
+  TheModule = loadModule(*MainFile);
+  if (!TheModule)
+return;
 
-EmitBackendOutput(Diagnostics, CI.getHeaderSearchOpts(), CodeGenOpts,
-  TargetOpts, CI.getLangOpts(),
-  CI.getTarget().getDataLayout(), TheModule.get(), BA,
-  std::move(OS));
+  const TargetOptions &TargetOpts = CI.getTargetOpts();
+  if (TheModule->getTargetTriple() != TargetOpts.Triple) {
+Diagnostics.Report(SourceLocation(), diag::warn_fe_override_module)
+<< TargetOpts.Triple;
+TheModule->setTargetTriple(TargetOpts.Triple);
+  }
 
-if (OptRecordFile)
-  OptRecordFile->keep();
+  EmbedBitcode(TheModule.get(), CodeGenOpts, *MainFile);
+
+  LLVMContext &Ctx = TheModule->getContext();
+  Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler, &Diagnostics);
+
+  // Set clang diagnostic handler. To do this we need to create a fake
+  // BackendConsumer.
+  BackendConsumer Result(BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),
+ CI.getPreprocessorOpt

[llvm-branch-commits] [llvm] 48ad819 - [IRSim] Adding support for isomorphic predicates

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

Author: Andrew Litteken
Date: 2020-12-23T19:42:35-06:00
New Revision: 48ad8194a56f350e84383fff7cb705820ea850bc

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

LOG: [IRSim] Adding support for isomorphic predicates

Some predicates, can be considered the same as long as the operands are
flipped. For example, a > b gives the same result as b > a. This maps
instructions in a greater than form, to their appropriate less than
form, swapping the operands in the IRInstructionData only, allowing for
more flexible matching.

Tests:

llvm/test/Transforms/IROutliner/outlining-isomorphic-predicates.ll
llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

Reviewers: jroelofs, paquette

Recommit of commit 050392660249c70c00e909ae4a7151ba2c766235

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

Added: 
llvm/test/Transforms/IROutliner/outlining-isomorphic-predicates.ll

Modified: 
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h 
b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index 4bc5a17b57e5..99a5fcb3a578 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -122,6 +122,11 @@ struct IRInstructionData : ilist_node {
   /// considered similar.
   bool Legal;
 
+  /// This is only relevant if we are wrapping a CmpInst where we needed to
+  /// change the predicate of a compare instruction from a greater than form
+  /// to a less than form.  It is None otherwise.
+  Optional RevisedPredicate;
+
   /// Gather the information that is 
diff icult to gather for an Instruction, or
   /// is changed. i.e. the operands of an Instruction and the Types of those
   /// operands. This extra information allows for similarity matching to make
@@ -129,6 +134,17 @@ struct IRInstructionData : ilist_node {
   /// Instruction performs the same operation.
   IRInstructionData(Instruction &I, bool Legality, IRInstructionDataList &IDL);
 
+  /// Get the predicate that the compare instruction is using for hashing the
+  /// instruction. the IRInstructionData must be wrapping a CmpInst.
+  CmpInst::Predicate getPredicate() const;
+
+  /// A function that swaps the predicates to their less than form if they are
+  /// in a greater than form. Otherwise, the predicate is unchanged.
+  ///
+  /// \param CI - The comparison operation to find a consistent preidcate for.
+  /// \return the consistent comparison predicate. 
+  static CmpInst::Predicate predicateForConsistency(CmpInst *CI);
+
   /// Hashes \p Value based on its opcode, types, and operand types.
   /// Two IRInstructionData instances produce the same hash when they perform
   /// the same operation.
@@ -161,6 +177,12 @@ struct IRInstructionData : ilist_node {
 for (Value *V : ID.OperVals)
   OperTypes.push_back(V->getType());
 
+if (isa(ID.Inst))
+  return llvm::hash_combine(
+  llvm::hash_value(ID.Inst->getOpcode()),
+  llvm::hash_value(ID.Inst->getType()),
+  llvm::hash_value(ID.getPredicate()),
+  llvm::hash_combine_range(OperTypes.begin(), OperTypes.end()));
 return llvm::hash_combine(
 llvm::hash_value(ID.Inst->getOpcode()),
 llvm::hash_value(ID.Inst->getType()),

diff  --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp 
b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index 28b0382bba36..4ee152450c05 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -26,15 +26,84 @@ using namespace IRSimilarity;
 IRInstructionData::IRInstructionData(Instruction &I, bool Legality,
  IRInstructionDataList &IDList)
 : Inst(&I), Legal(Legality), IDL(&IDList) {
-  // Here we collect the operands to be used to determine whether two
-  // instructions are similar to one another.
-  for (Use &OI : I.operands())
+  // We check for whether we have a comparison instruction.  If it is, we
+  // find the "less than" version of the predicate for consistency for
+  // comparison instructions throught the program.
+  if (CmpInst *C = dyn_cast(&I)) {
+CmpInst::Predicate Predicate = predicateForConsistency(C);
+if (Predicate != C->getPredicate())
+  RevisedPredicate = Predicate;
+  }
+
+  // Here we collect the operands and their types for determining whether
+  // the structure of the operand use matches between two 
diff erent candidates.
+  for (Use &OI : I.operands()) {
+if (isa(I) && RevisedPredicate.hasValue()) {
+  // If we have a CmpInst where the predicate is reversed, it means the
+  // operands must be reverse

[llvm-branch-commits] [llvm] 9939cf5 - [ExecutionEngine, Linker] Use erase_if (NFC)

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

Author: Kazu Hirata
Date: 2020-12-23T21:44:39-08:00
New Revision: 9939cf5a5647729fdeb675264b3c70833e3055cf

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

LOG: [ExecutionEngine, Linker] Use erase_if (NFC)

Added: 


Modified: 
llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
llvm/lib/Linker/IRMover.cpp

Removed: 




diff  --git a/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp 
b/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
index 138b18a1ddcb..6690dd07d99b 100644
--- a/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
@@ -218,11 +218,9 @@ 
SectionMemoryManager::applyMemoryGroupPermissions(MemoryGroup &MemGroup,
   }
 
   // Remove all blocks which are now empty
-  MemGroup.FreeMem.erase(remove_if(MemGroup.FreeMem,
-   [](FreeMemBlock &FreeMB) {
- return FreeMB.Free.allocatedSize() == 0;
-   }),
- MemGroup.FreeMem.end());
+  erase_if(MemGroup.FreeMem, [](FreeMemBlock &FreeMB) {
+return FreeMB.Free.allocatedSize() == 0;
+  });
 
   return std::error_code();
 }

diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index b7a9bb1a..5eeba0c0c3e7 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -905,7 +905,7 @@ IRLinker::linkAppendingVarProto(GlobalVariable *DstGV,
   getArrayElements(SrcGV->getInitializer(), SrcElements);
 
   if (IsNewStructor) {
-auto It = remove_if(SrcElements, [this](Constant *E) {
+erase_if(SrcElements, [this](Constant *E) {
   auto *Key =
   
dyn_cast(E->getAggregateElement(2)->stripPointerCasts());
   if (!Key)
@@ -913,7 +913,6 @@ IRLinker::linkAppendingVarProto(GlobalVariable *DstGV,
   GlobalValue *DGV = getLinkedToGlobal(Key);
   return !shouldLink(DGV, *Key);
 });
-SrcElements.erase(It, SrcElements.end());
   }
   uint64_t NewSize = DstNumElements + SrcElements.size();
   ArrayType *NewType = ArrayType::get(EltTy, NewSize);



___
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] 200b15a - [Analysis] Remove spliceFunction (NFC)

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

Author: Kazu Hirata
Date: 2020-12-23T21:57:25-08:00
New Revision: 200b15af45a6de494ecd0b76c1b1eb661edbdb60

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

LOG: [Analysis] Remove spliceFunction (NFC)

The function was introduced without a user on Jan 3, 2011 in commit
0f87ca77333ef59171749544e8dbdba9009f0dc7.  We still don't have a user
yet.

Added: 


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

Removed: 




diff  --git a/llvm/include/llvm/Analysis/CallGraph.h 
b/llvm/include/llvm/Analysis/CallGraph.h
index 98f9b0683fd4..4da448c9900b 100644
--- a/llvm/include/llvm/Analysis/CallGraph.h
+++ b/llvm/include/llvm/Analysis/CallGraph.h
@@ -87,13 +87,6 @@ class CallGraph {
   /// or calling an external function.
   std::unique_ptr CallsExternalNode;
 
-  /// Replace the function represented by this node by another.
-  ///
-  /// This does not rescan the body of the function, so it is suitable when
-  /// splicing the body of one function to another while also updating all
-  /// callers from the old function to the new.
-  void spliceFunction(const Function *From, const Function *To);
-
 public:
   explicit CallGraph(Module &M);
   CallGraph(CallGraph &&Arg);

diff  --git a/llvm/lib/Analysis/CallGraph.cpp b/llvm/lib/Analysis/CallGraph.cpp
index 19c128b6633c..9b212e564a46 100644
--- a/llvm/lib/Analysis/CallGraph.cpp
+++ b/llvm/lib/Analysis/CallGraph.cpp
@@ -167,20 +167,6 @@ Function 
*CallGraph::removeFunctionFromModule(CallGraphNode *CGN) {
   return F;
 }
 
-/// spliceFunction - Replace the function represented by this node by another.
-/// This does not rescan the body of the function, so it is suitable when
-/// splicing the body of the old function to the new while also updating all
-/// callers from old to new.
-void CallGraph::spliceFunction(const Function *From, const Function *To) {
-  assert(FunctionMap.count(From) && "No CallGraphNode for function!");
-  assert(!FunctionMap.count(To) &&
- "Pointing CallGraphNode at a function that already exists");
-  FunctionMapTy::iterator I = FunctionMap.find(From);
-  I->second->F = const_cast(To);
-  FunctionMap[To] = std::move(I->second);
-  FunctionMap.erase(I);
-}
-
 // getOrInsertFunction - This method is identical to calling operator[], but
 // it will insert a new CallGraphNode for the specified function if one does
 // not already exist.



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