platform/upstream/llvm.git
3 years agoMachineBasicBlock: add printName method
Nicolai Hähnle [Fri, 24 Jul 2020 16:18:09 +0000 (18:18 +0200)]
MachineBasicBlock: add printName method

Common up some existing MBB name printing logic into a single place.
Note that basic block dumping now prints the same set of attributes as
the MIRPrinter.

Change-Id: I8f022bbd922e831bc96d63143d7472c03282530b

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

3 years ago[AIX] remove -u from the clang when invoke aix as assembler
diggerlin [Fri, 24 Jul 2020 15:28:17 +0000 (11:28 -0400)]
[AIX] remove -u from the clang when invoke aix as assembler

SUMMARY:

since we add .extern directive for external symbol, the -u option for aix as do not need any more.

Reviewers:  Jason liu

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

3 years ago[OPENMP] Fix PR46730: Fix compiler crash on taskloop over constructible loop counters.
Alexey Bataev [Wed, 15 Jul 2020 21:32:02 +0000 (17:32 -0400)]
[OPENMP] Fix PR46730: Fix compiler crash on taskloop over constructible loop counters.

Summary:
If the variable is constrcutible, its copy is created by calling a
constructor. Such variables are duplicated and thus, must be captured.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, cfe-commits, sstefan1, caomhin

Tags: #clang

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

3 years ago[libTooling] Add an `EditGenerator` that applies a rule throughout a bound node.
Yitzhak Mandelbaum [Fri, 24 Jul 2020 13:27:51 +0000 (13:27 +0000)]
[libTooling] Add an `EditGenerator` that applies a rule throughout a bound node.

The new combinator, `rewriteDescendants`, applies a rewrite rule to all
descendants of a specified bound node.  That rewrite rule can refer to nodes
bound by the parent, both in the matcher and in the edits.

Reviewed By: gribozavr2

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

3 years ago[flang] Run non-gtest unit tests with lit.
David Truby [Thu, 16 Jul 2020 13:15:07 +0000 (14:15 +0100)]
[flang] Run non-gtest unit tests with lit.

Summary:
As a corrollary, these tests are now run as part of the check-flang
target.

Reviewers: sscalpone

Subscribers: mgorny, delcypher, llvm-commits

Tags: #llvm

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

3 years ago[AMDGPU][MC] Added support of SP3 syntax for MTBUF format modifier
Dmitry Preobrazhensky [Fri, 24 Jul 2020 13:39:42 +0000 (16:39 +0300)]
[AMDGPU][MC] Added support of SP3 syntax for MTBUF format modifier

Currently supported LLVM MTBUF syntax is shown below. It is not compatible with SP3.

    op     dst, addr, rsrc, FORMAT, soffset

This change adds support for SP3 syntax:

    op     dst, addr, rsrc, soffset SP3FORMAT

In addition to being compatible with SP3, this syntax allows using symbolic names for data, numeric and unified formats. Below is a list of added syntax variants.

format:<expression>
format:[<numeric-format-name>,<data-format-name>]
format:[<data-format-name>,<numeric-format-name>]
format:[<data-format-name>]
format:[<numeric-format-name>]
format:[<unified-format-name>]

The last syntax variant is supported for GFX10 only.

See llvm bug 37738

Reviewers: arsenm, rampitec, vpykhtin

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

3 years ago[openmp] Don't copy exports into the source folder by default.
David Truby [Mon, 20 Jul 2020 11:11:26 +0000 (12:11 +0100)]
[openmp] Don't copy exports into the source folder by default.

Additionally fix the copy if enabled on multi-config targets.

Summary:
This changes the copy command for libomp.so to use the output of the target as
the source of the copy, rather than trying to find it based on
${LIBOMP_LIBRARY_DIR}, which appears to be incorrect in multi-config generator
builds.

Reviewers: jdoerfert

Subscribers: mgorny, yaxunl, guansong, sstefan1, openmp-commits

Tags: #openmp

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

3 years ago[MLIR][SPIRVToLLVM] Conversion of load and store SPIR-V ops
George Mitenkov [Fri, 24 Jul 2020 12:55:07 +0000 (15:55 +0300)]
[MLIR][SPIRVToLLVM] Conversion of load and store SPIR-V ops

This patch introduces conversion pattern for `spv.Store` and `spv.Load`.
Only op with `Function` Storage Class is supported at the moment
because `spv.GlobalVariable` has not been introduced yet. If the op
has memory access attribute, then there are the following cases.
If the access is `Aligned`, add alignment to the op builder. Otherwise
the conversion fails as other cases are not supported yet because they
require additional attributes for `llvm.store`/`llvm.load` ops: e.g.
`volatile` and `nontemporal`.

Reviewed By: antiagainst

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

3 years ago[MLIR][Shape] Fold `shape.mul`
Frederik Gossen [Fri, 24 Jul 2020 13:29:51 +0000 (13:29 +0000)]
[MLIR][Shape] Fold `shape.mul`

Implement constant folding for `shape.mul`.

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

3 years ago[MLIR][Shape] Allow `shape.mul` to operate in indices
Frederik Gossen [Fri, 24 Jul 2020 13:24:23 +0000 (13:24 +0000)]
[MLIR][Shape] Allow `shape.mul` to operate in indices

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

3 years ago[libTooling] Add assorted `EditGenerator` combinators.
Yitzhak Mandelbaum [Tue, 21 Jul 2020 20:09:49 +0000 (20:09 +0000)]
[libTooling] Add assorted `EditGenerator` combinators.

Summary:
This patch adds various combinators that help in constructing `EditGenerator`s:
   * `noEdits`
   * `ifBound`, specialized to `ASTEdit`
   * `flatten` and `flattenVector` which allow for easy construction from a set
     of sub edits.
   * `shrinkTo`, which generates edits to shrink a given range to another that
     it encloses.

Reviewers: asoffer, gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

3 years ago[MLIR][SPIRVToLLVM] Conversion of SPIR-V variable op
George Mitenkov [Fri, 24 Jul 2020 12:01:08 +0000 (15:01 +0300)]
[MLIR][SPIRVToLLVM] Conversion of SPIR-V variable op

The patch introduces the conversion pattern for function-level
`spv.Variable`. It is modelled as `llvm.alloca` op. If initialized, then
additional store instruction is used. Note that there is no initialization
for arrays and structs since constants of these types are not supported in
LLVM dialect yet. Also, at the moment initialisation is only possible via
`spv.constant` (since `spv.GlobalVariable` conversion is not implemented
yet).

The input code has some scoping is not taken into account and will be
addressed in a different patch.

Reviewed By: ftynse

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

3 years ago[gn build] (manually) port 10b1b4a23 more
Nico Weber [Fri, 24 Jul 2020 12:48:14 +0000 (08:48 -0400)]
[gn build] (manually) port 10b1b4a23 more

3 years ago[gn build] (manually) port 10b1b4a23
Nico Weber [Fri, 24 Jul 2020 12:37:47 +0000 (08:37 -0400)]
[gn build] (manually) port 10b1b4a23

3 years ago[DWARF][EntryValues] Emit GNU extensions in the case of DWARF 4 + SCE
Djordje Todorovic [Fri, 24 Jul 2020 12:32:25 +0000 (14:32 +0200)]
[DWARF][EntryValues] Emit GNU extensions in the case of DWARF 4 + SCE

Emit DWARF 5 call-site symbols even though DWARF 4 is set,
only in the case of LLDB tuning.

This patch addresses PR46643.

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

3 years ago[gn build] (manually) port 228f8d89
Nico Weber [Fri, 24 Jul 2020 12:29:36 +0000 (08:29 -0400)]
[gn build] (manually) port 228f8d89

3 years agoRevert rG5dd566b7c7b78bd- "PassManager.h - remove unnecessary Function.h/Module.h...
Simon Pilgrim [Fri, 24 Jul 2020 12:02:33 +0000 (13:02 +0100)]
Revert rG5dd566b7c7b78bd- "PassManager.h - remove unnecessary Function.h/Module.h includes. NFCI."

This reverts commit 5dd566b7c7b78bd385418c72d63c79895be9ae97.

Causing some buildbot failures that I'm not seeing on MSVC builds.

3 years agoPassManager.h - remove unnecessary Function.h/Module.h includes. NFCI.
Simon Pilgrim [Fri, 24 Jul 2020 11:40:34 +0000 (12:40 +0100)]
PassManager.h - remove unnecessary Function.h/Module.h includes. NFCI.

PassManager.h is one of the top headers in the ClangBuildAnalyzer frontend worst offenders list.

This exposes a large number of implicit dependencies on various forward declarations/includes in other headers that need addressing.

3 years ago[DWARF] Avoid entry_values production for SCE
Djordje Todorovic [Fri, 24 Jul 2020 11:31:36 +0000 (13:31 +0200)]
[DWARF] Avoid entry_values production for SCE

SONY debugger does not prefer debug entry values feature, so
the plan is to avoid production of the entry values
by default when the tuning is SCE debugger.

The feature still can be enabled with the -debug-entry-values
option for the testing/development purposes.

This patch addresses PR46643.

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

3 years ago[obj2yaml][yaml2obj] - Add note-section.yaml tests.
Georgii Rymar [Fri, 24 Jul 2020 11:26:09 +0000 (14:26 +0300)]
[obj2yaml][yaml2obj] - Add note-section.yaml tests.

They were a part of D68983, but were lost in the last
diff and were not committed for unknown reason.

I've renamed (from elf-sht-note.yaml) them and fixed
broken formating a few places. Everything else remained
untouched.

3 years ago[MLIR][Shape] Remove deprecated and unused lowerings
Frederik Gossen [Fri, 24 Jul 2020 11:17:43 +0000 (11:17 +0000)]
[MLIR][Shape] Remove deprecated and unused lowerings

This concerns `from/to_extent_tensor`, `size_to_index`, `index_to_size`, and
`const_size` conversion patterns. The new lowering will work directly on indices
and extent tensors. The shape and size values will allow for error values but
are not yet supported by the dialect conversion.

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

3 years ago[MLIR][Shape] Allow `get_extent` to operate on extent tensors and indices
Frederik Gossen [Fri, 24 Jul 2020 11:12:39 +0000 (11:12 +0000)]
[MLIR][Shape] Allow `get_extent` to operate on extent tensors and indices

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

3 years ago[MLIR][Shape] Allow `shape.any` to operate on extent tensors
Frederik Gossen [Fri, 24 Jul 2020 11:01:23 +0000 (11:01 +0000)]
[MLIR][Shape] Allow `shape.any` to operate on extent tensors

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

3 years ago[MLIR][Shape] Pass Ops instead of Operations in shape lowering
Frederik Gossen [Fri, 24 Jul 2020 10:46:40 +0000 (10:46 +0000)]
[MLIR][Shape] Pass Ops instead of Operations in shape lowering

Shorten builder invocations by using Ops directly instead of `op.getOperation`.

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

3 years ago[MLIR][Shape] Allow `shape.rank` to operate on extent tensors
Frederik Gossen [Fri, 24 Jul 2020 10:26:36 +0000 (10:26 +0000)]
[MLIR][Shape] Allow `shape.rank` to operate on extent tensors

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

3 years ago[NFC][GVN] Clean loadpre-missed-opportunity.ll test some more
Roman Lebedev [Fri, 24 Jul 2020 09:37:02 +0000 (12:37 +0300)]
[NFC][GVN] Clean loadpre-missed-opportunity.ll test some more

3 years ago[IPSCCP] Add another test case with argmemonly callsite attributes.
Florian Hahn [Fri, 24 Jul 2020 08:59:03 +0000 (09:59 +0100)]
[IPSCCP] Add another test case with argmemonly callsite attributes.

3 years ago[MLIR][Shape] Clean up shape to standard lowering
Frederik Gossen [Fri, 24 Jul 2020 08:53:54 +0000 (08:53 +0000)]
[MLIR][Shape] Clean up shape to standard lowering

Put only class declarations in anonymous namespaces.

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

3 years ago[DWARFYAML] Replace 'Format', 'Version', etc with 'FormParams'. NFC.
Xing GUO [Fri, 24 Jul 2020 08:54:31 +0000 (16:54 +0800)]
[DWARFYAML] Replace 'Format', 'Version', etc with 'FormParams'. NFC.

This patch replaces 'Format', 'Version' fields, etc with 'FormParams' to
simplify codes.

Reviewed By: labath

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

3 years ago[MLIR][Shape] Simplify shape lowering
Frederik Gossen [Fri, 24 Jul 2020 08:43:43 +0000 (08:43 +0000)]
[MLIR][Shape] Simplify shape lowering

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

3 years ago[MLIR][Shape] Allow for `shape_of` to return extent tensors
Frederik Gossen [Fri, 24 Jul 2020 08:39:56 +0000 (08:39 +0000)]
[MLIR][Shape] Allow for `shape_of` to return extent tensors

The operation `shape.shape_of` now returns an extent tensor `tensor<?xindex>` in
cases when no error are possible. All consuming operation will eventually accept
both, shapes and extent tensors.

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

3 years ago[LLD][ELF] - Linkerscript: report location for the "unclosed comment in a linker...
Georgii Rymar [Wed, 22 Jul 2020 09:48:16 +0000 (12:48 +0300)]
[LLD][ELF] - Linkerscript: report location for the "unclosed comment in a linker script" error.

Currently we print "error: unclosed comment in a linker script", which doesn't
provide information about the real error location.

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

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

3 years ago[MLIR][Shape] Allow `shape.get_extent` to operate on extent tensors
Frederik Gossen [Fri, 24 Jul 2020 08:34:00 +0000 (08:34 +0000)]
[MLIR][Shape] Allow `shape.get_extent` to operate on extent tensors

`shape.get_extent` now accepts extent tensors `tensor<?xindex>` as an argument.

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

3 years ago[MLIR][Standard] Add default lowering for `assert`
Frederik Gossen [Fri, 24 Jul 2020 08:09:12 +0000 (08:09 +0000)]
[MLIR][Standard] Add default lowering for `assert`

The default lowering of `assert` calls `abort` in case the assertion is
violated. The failure message is ignored but should be used by custom lowerings
that can assume more about their environment.

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

3 years ago[SystemZ] Implement __builtin_eh_return_data_regno
Ulrich Weigand [Fri, 24 Jul 2020 08:28:06 +0000 (10:28 +0200)]
[SystemZ] Implement __builtin_eh_return_data_regno

Implement __builtin_eh_return_data_regno for SystemZ.
Match behavior of GCC.

Author: slavek-kucera

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

3 years agoAMDGPU/GlobalISel: Select set.inactive intrinsic
Petar Avramovic [Fri, 24 Jul 2020 08:13:43 +0000 (10:13 +0200)]
AMDGPU/GlobalISel: Select set.inactive intrinsic

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

3 years ago[MLIR][Shape] Generalze `shape.const_shape` to extent tensors
Frederik Gossen [Fri, 24 Jul 2020 08:05:26 +0000 (08:05 +0000)]
[MLIR][Shape] Generalze `shape.const_shape` to extent tensors

The operation `shape.const_shape` was used for constants of type shape only.
We can now also use it to create constant extent tensors.

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

3 years ago[libFuzzer] Instrument bcmp
Fangrui Song [Fri, 24 Jul 2020 07:23:46 +0000 (00:23 -0700)]
[libFuzzer] Instrument bcmp

If we define memcmp in an archive, bcmp should be defined as well (many libc
define bcmp/memcmp in one object file).  Otherwise if the application calls bcmp
or strcmp which gets optimized to bcmp (SimplifyLibCalls), the undefined
reference may pull in an optimized bcmp/strcmp implementation (libc replacement)
later on the linker command line.  If both libFuzzer's memcmp and the optimized
memcmp are strong => there will be a multiple definition error.

3 years ago[MLIR][LLVMDialect] Added branch weights attribute to CondBrOp
George Mitenkov [Fri, 24 Jul 2020 06:41:22 +0000 (09:41 +0300)]
[MLIR][LLVMDialect] Added branch weights attribute to CondBrOp

This patch introduces branch weights metadata to `llvm.cond_br` op in
LLVM Dialect. It is modelled as optional `ElementsAttr`, for example:
```
llvm.cond_br %cond weights(dense<[1, 3]> : vector<2xi32>), ^bb1, ^bb2
```
When exporting to proper LLVM, this attribute is transformed into metadata
node. The test for metadata creation is added to `../Target/llvmir.mlir`.

Reviewed By: ftynse

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

3 years ago[X86] Make the X86ProcFamilyEnum private to X86Subtarget. Removed unneeded 'protected...
Craig Topper [Fri, 24 Jul 2020 06:06:46 +0000 (23:06 -0700)]
[X86] Make the X86ProcFamilyEnum private to X86Subtarget. Removed unneeded 'protected' from X86Subtarget. NFC

3 years ago[MLIR][SPIRV] Updated documentation for variableOp
George Mitenkov [Fri, 24 Jul 2020 06:37:00 +0000 (09:37 +0300)]
[MLIR][SPIRV] Updated documentation for variableOp

This is an update of the documentation for `spv.Variable`.
Removed `bind` and `built_in` that are now used with `spv.globalVariable`
instead.

Reviewed By: antiagainst

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

3 years ago[CMake] Simplify CMake handling for zlib
Petr Hosek [Thu, 30 Apr 2020 20:07:13 +0000 (13:07 -0700)]
[CMake] Simplify CMake handling for zlib

Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

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

3 years ago[llvm][NFC] Don't use llvm/Config/config.h in .h files
Mircea Trofin [Fri, 24 Jul 2020 05:27:38 +0000 (22:27 -0700)]
[llvm][NFC] Don't use llvm/Config/config.h in .h files

 config.h is excluded from installs, llvm-config.h isn't

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

3 years ago[MLIR] Missing line breaks in MLIR Language Reference
H.-S. Zheng [Fri, 24 Jul 2020 05:06:01 +0000 (05:06 +0000)]
[MLIR] Missing line breaks in MLIR Language Reference

 Missing line breaks in the example under `Codegen of Unranked Memref` section.

Reviewed By: mehdi_amini

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

3 years ago[AST][FPEnv] Keep FP options in trailing storage of CallExpr
Serge Pavlov [Fri, 24 Jul 2020 05:04:19 +0000 (12:04 +0700)]
[AST][FPEnv] Keep FP options in trailing storage of CallExpr

This change allow a CallExpr to have optional FPOptionsOverride object,
stored in trailing storage. The implementaion is made similar to the way
used in BinaryOperator.

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

3 years ago[DWARFYAML] Use writeDWARFOffset() to simplify emitting offsets. NFC.
Xing GUO [Fri, 24 Jul 2020 04:10:21 +0000 (12:10 +0800)]
[DWARFYAML] Use writeDWARFOffset() to simplify emitting offsets. NFC.

This patch uses writeDWARFOffset() to simplify some codes. NFC.

3 years ago[mlir][DialectConversion] Enable deeper integration of type conversions
River Riddle [Fri, 24 Jul 2020 02:38:30 +0000 (19:38 -0700)]
[mlir][DialectConversion] Enable deeper integration of type conversions

This revision adds support for much deeper type conversion integration into the conversion process, and enables auto-generating cast operations when necessary. Type conversions are now largely automatically managed by the conversion infra when using a ConversionPattern with a provided TypeConverter. This removes the need for patterns to do type cast wrapping themselves and moves the burden to the infra. This makes it much easier to perform partial lowerings when type conversions are involved, as any lingering type conversions will be automatically resolved/legalized by the conversion infra.

To support this new integration, a few changes have been made to the type materialization API on TypeConverter. Materialization has been split into three separate categories:
* Argument Materialization: This type of materialization is used when converting the type of block arguments when calling `convertRegionTypes`. This is useful for contextually inserting additional conversion operations when converting a block argument type, such as when converting the types of a function signature.
* Source Materialization: This type of materialization is used to convert a legal type of the converter into a non-legal type, generally a source type. This may be called when uses of a non-legal type persist after the conversion process has finished.
* Target Materialization: This type of materialization is used to convert a non-legal, or source, type into a legal, or target, type. This type of materialization is used when applying a pattern on an operation, but the types of the operands have not yet been converted.

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

3 years ago[gn build] (manually) merge d054c7ee2e9
Nico Weber [Fri, 24 Jul 2020 02:28:00 +0000 (22:28 -0400)]
[gn build] (manually) merge d054c7ee2e9

3 years agoAdd test utility 'extract'
Fangrui Song [Fri, 24 Jul 2020 02:13:16 +0000 (19:13 -0700)]
Add test utility 'extract'

See https://lists.llvm.org/pipermail/llvm-dev/2020-July/143373.html
"[llvm-dev] Multiple documents in one test file" for some discussions.

`extract part filename` splits the input file into multiple parts separated by
regex `^(.|//)--- ` and extract the specified part to stdout or the
output file (if specified).

Use case A (organizing input of different formats (e.g. linker
script+assembly) in one file).

```
// RUN: extract lds %s -o %t.lds
// RUN: extract asm %s -o %t.s
// RUN: llvm-mc %t.s -o %t.o
// RUN: ld.lld -T %t.lds %t.o -o %t
This is sometimes better than the %S/Inputs/ approach because the user
can see the auxiliary files immediately and don't have to open another file.
```

Use case B (for utilities which don't have built-in input splitting
feature):

```
// RUN: extract case1 %s | llc | FileCheck %s --check-prefix=CASE1
// RUN: extract case2 %s | llc | FileCheck %s --check-prefix=CASE2
Combing tests prudently can improve readability.
This is sometimes better than having multiple test files.
```

Since this is a new utility, there is no git history concerns for
UpperCase variable names. I use lowerCase variable names like mlir/lld.

Reviewed By: jhenderson

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

3 years ago[LegalizeTypes] Teach DAGTypeLegalizer::GenWidenVectorLoads to pad with undef if...
Craig Topper [Fri, 24 Jul 2020 01:43:40 +0000 (18:43 -0700)]
[LegalizeTypes] Teach DAGTypeLegalizer::GenWidenVectorLoads to pad with undef if needed when concatenating small or loads to match a larger load

In the included test case the align 16 allowed the v23f32 load to handled as load v16f32, load v4f32, and load v4f32(one element not used). These loads all need to be concatenated together into a final vector. In this case we tried to concatenate the two v4f32 loads to match the type of the v16f32 load so we could do a second concat_vectors, but those loads alone only add up to v8f32. So we need to two v4f32 undefs to pad it.

It appears we've tried to hack around a similar issue in this code before by adding undef padding to loads in one of the earlier loops in this function. Originally in r147964 by padding all loads narrower than previous loads to the same size. Later modifed to only the last load in r293088. This patch removes that earlier code and just handles it on demand where we know we need it.

Fixes PR46820

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

3 years agoGlobalISel: Add scalarSameSizeAs LegalizeRule
Matt Arsenault [Wed, 22 Jul 2020 13:22:45 +0000 (09:22 -0400)]
GlobalISel: Add scalarSameSizeAs LegalizeRule

Widen or narrow a type to a type with the same scalar size as
another. This can be used to force G_PTR_ADD/G_PTRMASK's scalar
operand to match the bitwidth of the pointer type. Use this to
disallow narrower types for G_PTRMASK.

3 years agoGlobalISel: Drop original type pointeriness in minScalarSameAs
Matt Arsenault [Wed, 22 Jul 2020 13:52:49 +0000 (09:52 -0400)]
GlobalISel: Drop original type pointeriness in minScalarSameAs

It is not useful to report WidenScalar for a pointer value, so always
report a scalar value with the target size. This allows using this to
clamp the scalar operand to the pointer size in operations like
G_PTR_ADD or G_PTRMASK.

3 years agoGlobalISel: Fix maxScalarIf predicate check
Matt Arsenault [Wed, 22 Jul 2020 13:26:11 +0000 (09:26 -0400)]
GlobalISel: Fix maxScalarIf predicate check

The std::function itself was tested, not the result of the actual
query. It seems like there should be a warning for this. Inline the
check to avoid this.

3 years agoRevert D84264 "[SCCP] Directly remove non-feasible edges" & 5db5b4bc4394ca247c9eb665e...
Fangrui Song [Fri, 24 Jul 2020 00:51:48 +0000 (17:51 -0700)]
Revert D84264 "[SCCP] Directly remove non-feasible edges" & 5db5b4bc4394ca247c9eb665e03b851848aa2fbf

It breaks stage-2 build. Clang crashed when compiling
llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp

llvm/Support/GenericDomTree.h eraseNode: Node is not a leaf node

3 years ago[flang] Implicitly convert result of statement function
Tim Keith [Fri, 24 Jul 2020 00:15:33 +0000 (17:15 -0700)]
[flang] Implicitly convert result of statement function

The result of a statement function may require an implicit conversion
to match its result type. Add that to the expression that represents
the statement function body in SubprogramDetails.

Extract the analysis of that expression into a separate function.

Dump the statement function expression as part of the dump of
SubprogramDetails.

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

3 years agoRevert "[libFuzzer] Expose fuzzer::FuzzerDriver()"
Mitch Phillips [Fri, 24 Jul 2020 00:07:55 +0000 (17:07 -0700)]
Revert "[libFuzzer] Expose fuzzer::FuzzerDriver()"

This reverts commit 22a376e73bc218137738ee4ac8af44e223576475.

3 years ago[libFuzzer] Add a missing include_directories.
Dokyung Song [Thu, 23 Jul 2020 23:03:13 +0000 (23:03 +0000)]
[libFuzzer] Add a missing include_directories.

Summary: FuzzerInterceptors.cpp includes <sanitizer/common_interface_defs.h>, and this patch adds a missing include_directories to make sure the included file is found.

Reviewers: morehouse, hctim, dmajor

Subscribers: mgorny, #sanitizers

Tags: #sanitizers

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

3 years ago[AArch64][SVE] Teach copyPhysReg to copy ZPR2/3/4.
Eli Friedman [Thu, 23 Jul 2020 00:06:47 +0000 (17:06 -0700)]
[AArch64][SVE] Teach copyPhysReg to copy ZPR2/3/4.

It's sort of tricky to hit this in practice, but not impossible. I have
a synthetic C testcase if anyone is interested.

The implementation is identical to the equivalent NEON register copies.

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

3 years ago[ORC] Enable use of TargetProcessControl::getMemMgr with ObjectLinkingLayer.
Lang Hames [Thu, 23 Jul 2020 23:03:45 +0000 (16:03 -0700)]
[ORC] Enable use of TargetProcessControl::getMemMgr with ObjectLinkingLayer.

This patch makes ownership of the JITLinkMemoryManager by ObjectLinkingLayer
optional: the layer can still own the memory manager but no longer has to.

Evevntually we want to move to a state where ObjectLinkingLayer never owns its
memory manager. For now allowing optional ownership makes it easier to develop
classes that can dynamically use either RTDyldObjectLinkingLayer, which owns
its memory managers, or ObjectLinkingLayer (e.g. LLJIT).

3 years ago[bugpoint] Fix typo in assertion message. NFC
Craig Topper [Thu, 23 Jul 2020 23:06:25 +0000 (16:06 -0700)]
[bugpoint] Fix typo in assertion message. NFC

3 years ago[WebAssembly] Fix store_unfolded_offset tests in simd-offset.ll
Thomas Lively [Thu, 23 Jul 2020 23:05:19 +0000 (16:05 -0700)]
[WebAssembly] Fix store_unfolded_offset tests in simd-offset.ll

These tests were previously duplicates of the
unfolded_gep_negative_offset tests, and this change updates them to
test what they were meant to test.

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

3 years ago[NFC][GVN] Add a (horrible) test for D84181 demonstrating non-NFC'ness
Roman Lebedev [Thu, 23 Jul 2020 22:25:25 +0000 (01:25 +0300)]
[NFC][GVN] Add a (horrible) test for D84181 demonstrating non-NFC'ness

3 years ago[PowerPC] Implement low-order Vector Multiply, Modulus and Divide Instructions
Amy Kwan [Thu, 23 Jul 2020 18:12:45 +0000 (13:12 -0500)]
[PowerPC] Implement low-order Vector Multiply, Modulus and Divide Instructions

This patch aims to implement the low order vector multiply, divide and modulo
instructions available on Power10.

The patch involves legalizing the ISD nodes MUL, UDIV, SDIV, UREM and SREM for
v2i64 and v4i32 vector types in order to utilize the following instructions:
- Vector Multiply Low Doubleword: vmulld
- Vector Modulus Word/Doubleword: vmodsw, vmoduw, vmodsd, vmodud
- Vector Divide Word/Doubleword: vdivsw, vdivsd, vdivuw, vdivud

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

3 years agoRevert "[CMake] Simplify CMake handling for zlib"
Petr Hosek [Thu, 23 Jul 2020 22:12:42 +0000 (15:12 -0700)]
Revert "[CMake] Simplify CMake handling for zlib"

This reverts commit 1d09ecf36175f7910ffedd6d497c07b5c74c22fb since
it breaks sanitizer bots.

3 years agoscudo: Interleave odd and even tags for adjacent blocks.
Peter Collingbourne [Wed, 22 Jul 2020 20:45:14 +0000 (13:45 -0700)]
scudo: Interleave odd and even tags for adjacent blocks.

This guarantees that we will detect a buffer overflow or underflow
that overwrites an adjacent block. This spatial guarantee is similar
to the temporal guarantee that we provide for immediate use-after-free.

Enabling odd/even tags involves a tradeoff between use-after-free
detection and buffer overflow detection. Odd/even tags make it more
likely for buffer overflows to be detected by increasing the size of
the guaranteed "red zone" around the allocation, but on the other
hand use-after-free is less likely to be detected because the tag
space for any particular chunk is cut in half. Therefore we introduce
a tuning setting to control whether odd/even tags are enabled.

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

3 years agoUse llvm::size rather than an empty loop to get the number of top
Eric Christopher [Thu, 23 Jul 2020 21:53:18 +0000 (14:53 -0700)]
Use llvm::size rather than an empty loop to get the number of top
level loops.

3 years ago[CMake] Simplify CMake handling for zlib
Petr Hosek [Thu, 30 Apr 2020 20:07:13 +0000 (13:07 -0700)]
[CMake] Simplify CMake handling for zlib

Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

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

3 years agoReland "[DFSan] Handle fast16labels for all API functions."
Matt Morehouse [Thu, 23 Jul 2020 20:53:46 +0000 (20:53 +0000)]
Reland "[DFSan] Handle fast16labels for all API functions."

Support fast16labels in `dfsan_has_label`, and print an error for all
other API functions.  For `dfsan_dump_labels` we return silently rather
than crashing since it is also called from the atexit handler where it
is undefined behavior to call exit() again.

Reviewed By: kcc

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

3 years ago[GlobalISel] Use existing MIR builder instead of creating one in combiner.
Amara Emerson [Thu, 23 Jul 2020 21:15:58 +0000 (14:15 -0700)]
[GlobalISel] Use existing MIR builder instead of creating one in combiner.

3 years ago[clang] Fix libdl linking for libclang in standalone mode
Tobias Hieta [Thu, 23 Jul 2020 21:10:22 +0000 (00:10 +0300)]
[clang] Fix libdl linking for libclang in standalone mode

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

3 years ago[Loop Fusion] Integrate Loop Peeling into Loop Fusion (re-land after fixing ASAN...
Sidharth Baveja [Thu, 23 Jul 2020 21:02:04 +0000 (21:02 +0000)]
[Loop Fusion] Integrate Loop Peeling into Loop Fusion (re-land after fixing ASAN build failures)

This patch adds the ability to peel off iterations of the first loop in loop
fusion. This can allow for both loops to have the same trip count, making it
legal for them to be fused together.

Here is a simple scenario peeling can be used in loop fusion:

for (i = 0; i < 10; ++i)
  a[i] = a[i] + 3;
for (j = 1; j < 10; ++j)
  b[j] = b[j] + 5;

Here is we can make use of peeling, and then fuse the two loops together. We
can peel off the 0th iteration of the loop i, and then combine loop i and j for
i = 1 to 10.

a[0] = a[0] +3;
for (i = 1; i < 10; ++i) {
  a[i] = a[i] + 3;
  b[i] = b[i] + 5;
}

Currently peeling with loop fusion is only supported for loops with constant
trip counts and a single exit point. Both unguarded and guarded loops are
supported.

Reviewed By: bmahjour (Bardia Mahjour), MaskRay (Fangrui Song)

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

3 years ago[ARM] Add predicated mla reduction patterns
David Green [Thu, 23 Jul 2020 20:47:59 +0000 (21:47 +0100)]
[ARM] Add predicated mla reduction patterns

Similar to 8fa824d7a3 but this time for MLA patterns, this selects
predicated vmlav/vmlava/vmlalv/vmlava instructions from
vecreduce.add(select(p, mul(x, y), 0)) nodes.

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

3 years ago[lldb] Remove the user-defined copy-ctor in ConstString
Jonas Devlieghere [Thu, 23 Jul 2020 20:06:51 +0000 (13:06 -0700)]
[lldb] Remove the user-defined copy-ctor in ConstString

ConstString is essentially trivially copyable yet it has a user defined
copy constructor that copies its one member pointer. Remove it so it
qualifies as trivial in the eyes of the compiler.

This also fixes two unused variable warnings now that the compiler knows
that the constructor has no side-effects.

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

3 years ago[Bitcode] Avoid duplicating linker option when upgrading
Steven Wu [Thu, 23 Jul 2020 20:04:57 +0000 (13:04 -0700)]
[Bitcode] Avoid duplicating linker option when upgrading

Summary:
The upgrading path from old ModuleFlag based linker options to the new
NamedMetadata based linker option in in materializeMetadata() which gets
called once for the module and once for every GV. The linker options are
getting dup'ed every time and it can create massive amount of the linker
options in the object file that gets created from old bitcode. Fix the
problem by checking if the new option exists or not before upgrade
again.

rdar://64543389

Reviewers: pcc, t.p.northover, dexonsmith, arphaman

Reviewed By: arphaman

Subscribers: hiraditya, jkorous, ributzka, llvm-commits

Tags: #llvm

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

3 years ago[SCCP] Add another switch+phi test (NFC)
Nikita Popov [Thu, 23 Jul 2020 19:50:47 +0000 (21:50 +0200)]
[SCCP] Add another switch+phi test (NFC)

3 years agoAdd new function properties to FunctionPropertiesAnalysis
Tarindu Jayatilaka [Thu, 23 Jul 2020 19:46:47 +0000 (12:46 -0700)]
Add new function properties to FunctionPropertiesAnalysis

 Added  LoadInstCount, StoreInstCount, MaxLoopDepth, LoopCount

Reviewed By: jdoerfert, mtrofin

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

3 years agoAMDGPU: Fix failures from overflowing uint8_t number of operands
Matt Arsenault [Wed, 22 Jul 2020 23:22:34 +0000 (19:22 -0400)]
AMDGPU: Fix failures from overflowing uint8_t number of operands

If the operand index exceeded the limit of unsigned char, it wrapped
and would point to the wrong operand. Increase the size of the operand
index field to avoid this, and also don't bother trying to fold into
implicit operands.

3 years ago[libc] Remove unused #include <vector> in fmin_test, fminf_test, and fminl_test.
Tue Ly [Thu, 23 Jul 2020 19:26:05 +0000 (15:26 -0400)]
[libc] Remove unused #include <vector> in fmin_test, fminf_test, and fminl_test.

3 years ago[libc] Add implementations of fmax, fmaxf, and fmaxl.
Tue Ly [Thu, 23 Jul 2020 06:04:33 +0000 (02:04 -0400)]
[libc] Add implementations of fmax, fmaxf, and fmaxl.

Summary: Add implementations of fmax, fmaxf, and fmaxl.

Reviewers: sivachandra

Subscribers: mgorny, tschuett, libc-commits, ecnelises

Tags: #libc-project

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

3 years agoscudo: Remove some boilerplate from the combined allocator tests. NFCI.
Peter Collingbourne [Thu, 23 Jul 2020 18:31:32 +0000 (11:31 -0700)]
scudo: Remove some boilerplate from the combined allocator tests. NFCI.

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

3 years ago[libFuzzer] Expose fuzzer::FuzzerDriver()
Mitch Phillips [Thu, 23 Jul 2020 19:00:50 +0000 (12:00 -0700)]
[libFuzzer] Expose fuzzer::FuzzerDriver()

Summary:
Allows other-language libFuzzer derivatives to invoke the driver.

Patch By: Ian Eldred Pudney <ipudney@google.com>

Reviewers: morehouse, kcc

Reviewed By: morehouse

Subscribers: #sanitizers

Tags: #sanitizers

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

3 years ago[AArch64][GlobalISel] Add post-legalize combine for sext(trunc(sextload)) -> trunc...
Amara Emerson [Wed, 17 Jun 2020 18:55:53 +0000 (11:55 -0700)]
[AArch64][GlobalISel] Add post-legalize combine for sext(trunc(sextload)) -> trunc/copy

On AArch64 we generate redundant G_SEXTs or G_SEXT_INREGs because of this.

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

3 years ago[SCCP] Add missing change reporting
Nikita Popov [Thu, 23 Jul 2020 18:58:03 +0000 (20:58 +0200)]
[SCCP] Add missing change reporting

Forgot to actually use the return value of the function.

3 years agoAdd a Printer to the FunctionPropertiesAnalysis
Tarindu Jayatilaka [Thu, 23 Jul 2020 18:56:56 +0000 (11:56 -0700)]
Add a Printer to the FunctionPropertiesAnalysis

 A printer pass and a lit test case was added.

Reviewed By: mtrofin

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

3 years ago[IR] Add min/max/abs intrinsics
Nikita Popov [Sun, 19 Jul 2020 15:06:17 +0000 (17:06 +0200)]
[IR] Add min/max/abs intrinsics

This adds the llvm.abs(), llvm.umin(), llvm.umax(), llvm.smin(),
and llvm.smax() intrinsics specified in D81829. For SelectionDAG,
the ISD opcodes and all the legalization and lowering already exist,
so this just wires them up to the intrinsic in the SDAG builder and
adds rudimentary tests. For GlobalISel only the min/max intrinsics
are wired up, as llvm.abs() will require the addition of a G_ABS op,
and corresponding legalization support.

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

3 years ago[LangRef] Add integer min/max/abs intrinsics
Roman Lebedev [Thu, 23 Jul 2020 18:45:50 +0000 (20:45 +0200)]
[LangRef] Add integer min/max/abs intrinsics

Add LangRef specification for the llvm.abs, llvm.umin, llvm.umax,
llvm.smin, and llvm.smax integer intrinsics.

Link to RFC:
https://lists.llvm.org/pipermail/llvm-dev/2020-June/142257.html

Proposed alive2 implementation:
https://github.com/AliveToolkit/alive2/pull/353

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

3 years agoRefactor FunctionPropertiesAnalysis
Tarindu Jayatilaka [Thu, 23 Jul 2020 18:49:10 +0000 (11:49 -0700)]
Refactor FunctionPropertiesAnalysis

 this separates  `analyze` logic from  `FunctionPropertiesAnalysis`

Reviewed By: mtrofin

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

3 years agoAMDGPU/GlobalISel: Add some tests for stack passed pointers
Matt Arsenault [Wed, 8 Jul 2020 15:32:24 +0000 (11:32 -0400)]
AMDGPU/GlobalISel: Add some tests for stack passed pointers

3 years ago[SCCP] Directly remove non-feasible edges
Nikita Popov [Tue, 21 Jul 2020 19:26:30 +0000 (21:26 +0200)]
[SCCP] Directly remove non-feasible edges

Non-feasible control-flow edges are currently removed by replacing
the branch condition with a constant and then calling
ConstantFoldTerminator. This happens in a rather roundabout manner,
by inspecting the users (effectively: predecessors) of unreachable
blocks, and further complicated by the need to explicitly materialize
the condition for "forced" edges. I would like to extend SCCP to
discard switch conditions that are non-feasible based on range
information, but this is incompatible with the current approach
(as there is no single constant we could use.)

Instead, this patch explicitly removes non-feasible edges. It
currently only needs to handle the case where there is a single
feasible edge. The llvm_unreachable() branch will need to be
implemented for the aforementioned switch improvement.

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

3 years agoAMDGPU/GlobalISel: Handle call return values
Matt Arsenault [Sun, 5 Jul 2020 20:15:36 +0000 (16:15 -0400)]
AMDGPU/GlobalISel: Handle call return values

The only case that I know doesn't work is the implicit sret case when
the return type doesn't fit in the return registers.

3 years ago[flang][openacc] Add missing comment in header
clementval [Thu, 23 Jul 2020 18:10:00 +0000 (14:10 -0400)]
[flang][openacc] Add missing comment in header

3 years ago[mlir][Linalg] Fixing bug in subview size computation in Linalg tiling.
MaheshRavishankar [Thu, 23 Jul 2020 17:20:54 +0000 (10:20 -0700)]
[mlir][Linalg] Fixing bug in subview size computation in Linalg tiling.

The `makeTiledViews` did not use the sizes of the tiled views based on
the result of the loop bound inference computation. This manifested as
an error in computing tile sizes with convolution where not all the
result expression of concatenated affine maps are simple
AffineDimExpr.

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

3 years ago[libc++] Build the dylib with -faligned-allocation
Louis Dionne [Thu, 23 Jul 2020 15:05:47 +0000 (11:05 -0400)]
[libc++] Build the dylib with -faligned-allocation

This avoids issues when building the dylib for deployment targets that
don't support aligned allocation, where Clang normally triggers an
error to warn users their code would break at runtime when back-deployed.
Since we're building the dylib itself, which contains the aligned
allocation functions, we don't want to trigger that error.

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

3 years agoRevert "[DFSan] Handle fast16labels for all API functions."
Matt Morehouse [Thu, 23 Jul 2020 17:48:10 +0000 (17:48 +0000)]
Revert "[DFSan] Handle fast16labels for all API functions."

This reverts commit 19d9c0397e61f2fb59a22d7c699436133a409aea due to
buildbot failure.

3 years ago[PredicateInfo][SCCP] Remove assertion (PR46814)
Nikita Popov [Thu, 23 Jul 2020 17:12:20 +0000 (19:12 +0200)]
[PredicateInfo][SCCP] Remove assertion (PR46814)

As long as RenamedOp is not guaranteed to be accurate, we cannot
assert here and should just return false. This was already done
for the other conditions in this function.

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

3 years ago[X86][SSE] Add additional (f)add(shuffle(x,y),shuffle(x,y)) tests for D83789
Simon Pilgrim [Thu, 23 Jul 2020 17:22:07 +0000 (18:22 +0100)]
[X86][SSE] Add additional (f)add(shuffle(x,y),shuffle(x,y)) tests for D83789

3 years ago[libFuzzer] Disable interceptor tests on non-Linux platforms.
Dokyung Song [Thu, 23 Jul 2020 16:31:12 +0000 (16:31 +0000)]
[libFuzzer] Disable interceptor tests on non-Linux platforms.

Summary: libFuzzer's interceptor support added in 831ae45e3dc609e43ba561af07670a8fe47461ef currently only works on Linux. This patch disables the test cases added as part of that commit on non-Linux platforms.

Reviewers: morehouse, hctim

Subscribers: #sanitizers

Tags: #sanitizers

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

3 years ago[MSAN] Allow emitting checks for struct types
Gui Andrade [Thu, 23 Jul 2020 16:50:42 +0000 (16:50 +0000)]
[MSAN] Allow emitting checks for struct types

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

3 years agoRegionInfo.cpp - remove duplicate includes that already exist in RegionInfo.h. NFC.
Simon Pilgrim [Thu, 23 Jul 2020 16:50:00 +0000 (17:50 +0100)]
RegionInfo.cpp - remove duplicate includes that already exist in RegionInfo.h. NFC.

Also remove some unnecessary forward declarations in RegionInfo.h.

3 years ago[MSAN] Never allow checking calls to __sanitizer_unaligned_{load,store}
Gui Andrade [Thu, 23 Jul 2020 16:36:19 +0000 (16:36 +0000)]
[MSAN] Never allow checking calls to __sanitizer_unaligned_{load,store}

These functions expect the caller to always pass shadows over TLS.

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