platform/upstream/llvm.git
4 years ago[flang] This adds the lowering stubs for Open MP.
Eric Schweitz [Wed, 27 May 2020 21:18:40 +0000 (14:18 -0700)]
[flang] This adds the lowering stubs for Open MP.

The lowering bridge will call these lowering hooks to process the Open
MP directives that it iterates over in the PFT.  This is a mock
interface without an implementation in this patch.

Reviewed By: kiranchandramohan

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

4 years agoUpdate some names in test. NFC.
Stanislav Mekhanoshin [Mon, 1 Jun 2020 16:07:17 +0000 (09:07 -0700)]
Update some names in test. NFC.

There seems to be some instability with IR nameing between
platforms. Attempted to fix it with replacing dot-numbered
names.

4 years ago[Object] Add DF_1_PIE
Fangrui Song [Mon, 1 Jun 2020 15:50:21 +0000 (08:50 -0700)]
[Object] Add DF_1_PIE

This flag (and the whole field DT_FLAGS_1) originated from Solaris. I intend to use it in an LLD patch D80872.

Reviewed By: jhenderson

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

4 years ago[InstCombine] add test for select-of-shuffle; NFC
Sanjay Patel [Mon, 1 Jun 2020 15:50:43 +0000 (11:50 -0400)]
[InstCombine] add test for select-of-shuffle; NFC

This is based on an example in D80658

4 years agoProcess gep (phi ptr1, ptr2) in SROA
Stanislav Mekhanoshin [Fri, 29 May 2020 21:00:51 +0000 (14:00 -0700)]
Process gep (phi ptr1, ptr2) in SROA

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

4 years ago[libc] Add implementations of ceil[f], floor[f] and trunc[f] from math.h.
Siva Chandra Reddy [Mon, 18 May 2020 22:06:01 +0000 (15:06 -0700)]
[libc] Add implementations of ceil[f], floor[f] and trunc[f] from math.h.

Reviewers: abrachet

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

4 years ago[WebAssembly] Update test expectations
Sam Clegg [Mon, 1 Jun 2020 15:12:53 +0000 (08:12 -0700)]
[WebAssembly] Update test expectations

simd-2.C now compiles thanks to:
  https://github.com/WebAssembly/wasi-libc/pull/183

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

4 years ago[InstNamer] use 'i' for Instructions, not 'tmp'
Sanjay Patel [Mon, 1 Jun 2020 14:56:27 +0000 (10:56 -0400)]
[InstNamer] use 'i' for Instructions, not 'tmp'

As discussed in https://bugs.llvm.org/show_bug.cgi?id=45951 and
D80584, the name 'tmp' is almost always a bad choice, but we have
a legacy of regression tests with that name because it was baked
into utils/update_test_checks.py.

This change makes -instnamer more consistent (already using "arg"
and "bb", the common LLVM shorthand). And it avoids the conflict
in telling users of the FileCheck script to run "-instnamer" to
create a better regression test and having that cause a warn/fail
in update_test_checks.py.

4 years ago[openmp] Fixed taskloop recursive splitting so that taskloop tasks have
AndreyChurbanov [Mon, 1 Jun 2020 14:51:02 +0000 (17:51 +0300)]
[openmp] Fixed taskloop recursive splitting so that taskloop tasks have
same parent tasks.

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

4 years agoSupport GCC [[gnu::attributes]] in C2x mode
Aaron Ballman [Mon, 1 Jun 2020 14:39:38 +0000 (10:39 -0400)]
Support GCC [[gnu::attributes]] in C2x mode

GCC 10.1 introduced support for the [[]] style spelling of attributes in C
mode. Similar to how GCC supports __attribute__((foo)) as [[gnu::foo]] in
C++ mode, it now supports the same spelling in C mode as well. This patch
makes a change in Clang so that when you use the GCC attribute spelling,
the attribute is automatically available in all three spellings by default.
However, like Clang, GCC has some attributes it only recognizes in C++ mode
(specifically, abi_tag and init_priority), which this patch also honors.

4 years ago[StructurizeCFG] Fix an incorrect comment, NFC.
Ehud Katz [Mon, 1 Jun 2020 14:42:09 +0000 (17:42 +0300)]
[StructurizeCFG] Fix an incorrect comment, NFC.

4 years ago[CodeGen] remove instnamer dependency from test file; NFC
Sanjay Patel [Mon, 1 Jun 2020 14:14:47 +0000 (10:14 -0400)]
[CodeGen] remove instnamer dependency from test file; NFC

This file was originally added without instnamer at:
rL283716 / fe2b9b4fbf860e3dc7da7705f548bc8d7b6ab9c1

But that was reverted and the test file reappeared with instnamer at:
rL285688 / 62f516f5906f967179610a73e4cc1d852b908bbd

I'm not seeing any difference locally from checking nameless values,
so trying to remove a layering violation and see if that can
survive the build bots.

4 years ago[Support] Add more context to DataExtractor getLEB128 errors
James Henderson [Fri, 22 May 2020 12:53:47 +0000 (13:53 +0100)]
[Support] Add more context to DataExtractor getLEB128 errors

Reviewed by: clayborg, dblaikie, labath

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

4 years agoRevert "[lldb] Pass -fPIC flag even when DYLIB_ONLY is set"
Raphael Isemann [Mon, 1 Jun 2020 12:41:08 +0000 (14:41 +0200)]
Revert "[lldb] Pass -fPIC flag even when DYLIB_ONLY is set"

This reverts commit fd0ab3b3eb88de3fe4792c34b50084595e22d68d.

The fix here is incorrect and the actual fault was an incorrect test Makefile.

To give some more background:

The original test for D80798 compiled three source files into either one
executable or one executable + 2 shared libraries, each being one different
test setup. If both the monolithic executable and the shared libraries
where compiled in the same directory, then Make would overwrite the .o files
of one test setup with the other. This caused that while -fPIC was passed
correctly to the test setup with the shared libraries, the compiler invocations
for the monolithic executable would later overwrite these object files (and
as only the test setup with the shared library used -fPIC, it appeared as if
the shared library object files didn't receive the -fPIC flag).

Thanks to Pavel for figuring this out.

4 years ago[DebugInfo] Add use of truncating data extractor to debug line parsing
James Henderson [Wed, 20 May 2020 14:53:44 +0000 (15:53 +0100)]
[DebugInfo] Add use of truncating data extractor to debug line parsing

This will ensure that nothing can ever start parsing data from a future
sequence and part-read data will be returned as 0 instead.

Reviewed by: aprantl, labath

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

4 years ago[lldb][NFC] Make ClangExpressionSourceCode's wrapping logic more consistent
Raphael Isemann [Mon, 1 Jun 2020 08:28:22 +0000 (10:28 +0200)]
[lldb][NFC] Make ClangExpressionSourceCode's wrapping logic more consistent

Summary:
ClangExpressionSourceCode has different ways to wrap the user expression based on
which context the expression is executed in. For example, if we're in a C++ member
function we put the expression inside a fake member function of a fake class to make the
evaluation possible. Similar things are done for Objective-C instance/static methods.
There is also a default wrapping where we put the expression in a normal function
just to make it possible to execute it.

The way we currently define which kind of wrapping the expression needs is based on
the `wrapping_language` we keep passing to the ClangExpressionSourceCode
instance. We repurposed the language type enum for that variable to distinguish the
cases above with the following mapping:
* language = C_plus_plus -> member function wrapping
* language = ObjC -> instance/static method wrapping (`is_static` distinguished between those two).
* language = C -> normal function wrapping
* all other cases like C_plus_plus11, Haskell etc. make our class a no-op that does mostly nothing.

That mapping is currently not documented and just confusing as the `language`
is unrelated to the expression language (and in the ClangUserExpression we even pretend
that it *is* the actual language, but luckily never used it for anything). Some of the code
in ClangExpressionSourceCode is also obviously thinking that this is the actual language of
the expression as it checks for non-existent cases such as `ObjC_plus_plus` which is
not part of the mapping.

This patch makes a new enum to describe the four cases above (with instance/static Objective-C
methods now being their own case). It also make that enum just a member of
ClangExpressionSourceCode instead of having to pass the same value to the class repeatedly.
This gets also rid of all the switch-case-checks for 'unknown' language such as C_plus_plus11 as this
is no longer necessary.

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: abidh

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

4 years ago[utils] change default nameless value to "TMP"
Sanjay Patel [Mon, 1 Jun 2020 10:49:07 +0000 (06:49 -0400)]
[utils] change default nameless value to "TMP"

This is effectively reverting rGbfdc2552664d to avoid test churn
while we figure out a better way forward.

We at least salvage the warning on name conflict from that patch
though.

If we change the default string again, we may want to mass update
tests at the same time. Alternatively, we could live with the poor
naming if we change -instnamer.

This also adds a test to LLVM as suggested in the post-commit
review. There's a clang test that is also affected. That seems
like a layering violation, but I have not looked at fixing that yet.

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

4 years ago[llvm-dwarfdump][test] Use verbose output to check expected opcodes
James Henderson [Wed, 20 May 2020 14:29:55 +0000 (15:29 +0100)]
[llvm-dwarfdump][test] Use verbose output to check expected opcodes

The debug_line_invalid.test test case was previously using the
interpreted line table dumping to identify which opcodes have been
parsed. This change moves to looking for the expected opcodes
explicitly. This is probably a little clearer and also allows for
testing some cases that wouldn't be easily identifiable from the
interpreted table.

Reviewed by: MaskRay

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

4 years agoARMFrameLowering.h - remove unnecessary includes. NFC.
Simon Pilgrim [Mon, 1 Jun 2020 10:39:56 +0000 (11:39 +0100)]
ARMFrameLowering.h - remove unnecessary includes. NFC.

They are implicitly included in TargetFrameLowering.h and only ever used in TargetFrameLowering override methods.

4 years agoMIPatternMatch.h - remove unused APFloat/APInt includes. NFC.
Simon Pilgrim [Mon, 1 Jun 2020 10:36:27 +0000 (11:36 +0100)]
MIPatternMatch.h - remove unused APFloat/APInt includes. NFC.

4 years ago[DebugInfo] Separate fields with commas in headers of type units (3/3).
Igor Kudrin [Mon, 1 Jun 2020 08:57:23 +0000 (15:57 +0700)]
[DebugInfo] Separate fields with commas in headers of type units (3/3).

For most tables, we already use commas in headers. This set of patches
unifies dumping the remaining ones.

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

4 years ago[DebugInfo] Separate fields with commas in headers of compile units (2/3).
Igor Kudrin [Mon, 1 Jun 2020 08:56:28 +0000 (15:56 +0700)]
[DebugInfo] Separate fields with commas in headers of compile units (2/3).

For most tables, we already use commas in headers. This set of patches
unifies dumping the remaining ones.

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

4 years ago[DebugInfo] Separate fields with commas in headers of .debug_pub* tables (1/3).
Igor Kudrin [Mon, 1 Jun 2020 08:35:33 +0000 (15:35 +0700)]
[DebugInfo] Separate fields with commas in headers of .debug_pub* tables (1/3).

For most tables, we already use commas in headers. This set of patches
unifies dumping the remaining ones.

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

4 years ago[llvm-readelf] - Add explicit braces again. NFC.
Georgii Rymar [Mon, 1 Jun 2020 10:10:16 +0000 (13:10 +0300)]
[llvm-readelf] - Add explicit braces again. NFC.

Partially reverts feee98645dde4be31a70cc6660d2fc4d4b9d32d8.

Add explicit braces to a different place to fix
"error: add explicit braces to avoid dangling else [-Werror,-Wdangling-else]"

4 years ago[llvm-readelf] - Add explicit braces. NFC.
Georgii Rymar [Mon, 1 Jun 2020 09:53:50 +0000 (12:53 +0300)]
[llvm-readelf] - Add explicit braces. NFC.

Should fix the BB (http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/3907/steps/build%20stage%201/logs/stdio):

llvm-readobj/ELFDumper.cpp:4708:5: error: add explicit braces to avoid dangling else [-Werror,-Wdangling-else]
    else
    ^

4 years ago[StructurizeCFG] Fix region nodes ordering
Ehud Katz [Mon, 1 Jun 2020 09:50:35 +0000 (12:50 +0300)]
[StructurizeCFG] Fix region nodes ordering

This is a reimplementation of the `orderNodes` function, as the old
implementation didn't take into account all cases.
The new implementation uses SCCs instead of Loops to take account of
irreducible loops.

Fix PR41509

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

4 years ago[llvm-readobj] - Improve error reporting for hash tables.
Georgii Rymar [Thu, 21 May 2020 10:57:41 +0000 (13:57 +0300)]
[llvm-readobj] - Improve error reporting for hash tables.

This improves the next points for broken hash tables:

1) Use reportUniqueWarning to prevent duplication when
   --hash-table and --elf-hash-histogram are used together.

2) Dump nbuckets and nchain fields. It is often possible
   to dump them even when the table itself goes past the EOF etc.

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

4 years agoAArch64: materialize large stack offset into xzr correctly.
Tim Northover [Wed, 22 Apr 2020 13:02:48 +0000 (14:02 +0100)]
AArch64: materialize large stack offset into xzr correctly.

When a stack offset was too big to materialize in a single instruction, we were
trying to do it in stages:

    adds xD, sp, #imm
    adds xD, xD, #imm

Unfortunately, if xD is xzr then the second instruction doesn't exist and
wouldn't do what was needed if it did. Instead we can use a temporary register
for all but the last addition.

4 years ago[DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'
Djordje Todorovic [Wed, 27 May 2020 11:58:21 +0000 (13:58 +0200)]
[DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

After the D70350, the retainedTypes: isn't being used for the purpose
of call site debug info for extern calls, so it is safe to delete it
from IR representation.
We are also adding a test to ensure the subprogram isn't stored within
the retainedTypes: from corresponding DICompileUnit.

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

4 years ago[ASTMatchers] Force c++ unittests to specify correct language standard
Nathan James [Mon, 1 Jun 2020 06:52:01 +0000 (07:52 +0100)]
[ASTMatchers] Force c++ unittests to specify correct language standard

Force the unittests on c++ code for matchers to specify the correct standard.

Reviewed By: gribozavr2

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

4 years agoImprove SmallPtrSetImpl::count implementation
serge-sans-paille [Mon, 1 Jun 2020 05:49:19 +0000 (07:49 +0200)]
Improve SmallPtrSetImpl::count implementation

Relying on the find method implies a roundtrip to the iterator world, which is
not costless because iterator creation involves a few check to ensure the
iterator is in a valid position (through the SmallPtrSetIteratorImpl::AdvanceIfNotValid
method). It turns out that the result of SmallPtrSetImpl::find_imp is either
valid or the EndPointer, so there's no need to go through that abstraction,
and the compiler cannot guess it.

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

4 years agoFix strict aliasing warning in msan.cpp
serge-sans-paille [Thu, 28 May 2020 15:50:31 +0000 (17:50 +0200)]
Fix strict aliasing warning in msan.cpp

Use internal_memcpy instead.

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

4 years ago[MachineCombine] add a hook for resource length limit
Chen Zheng [Wed, 27 May 2020 02:39:37 +0000 (22:39 -0400)]
[MachineCombine] add a hook for resource length limit

4 years ago[PowerPC] Exploit vabsd on P9
Li Rong Yi [Mon, 1 Jun 2020 02:29:18 +0000 (02:29 +0000)]
[PowerPC] Exploit vabsd on P9

Summary: Exploit vabsd* for for absolute difference of vectors on P9,
for example:
void foo (char *restrict p, char *restrict q, char *restrict t)
{
  for (int i = 0; i < 16; i++)
     t[i] = abs (p[i] - q[i]);
}
this case should be matched to the HW instruction vabsdub.

Reviewed By: steven.zhang

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

4 years ago[gn build] (semi-manually) port a8ca0ec2670
Nico Weber [Mon, 1 Jun 2020 02:04:35 +0000 (22:04 -0400)]
[gn build] (semi-manually) port a8ca0ec2670

4 years agoAMDGPU/GlobalISel: Add stub reg-bank aware combiner pass
Matt Arsenault [Sun, 31 May 2020 23:58:55 +0000 (19:58 -0400)]
AMDGPU/GlobalISel: Add stub reg-bank aware combiner pass

4 years ago[Driver] Simplify Linux::addProfileRTLibs
Fangrui Song [Mon, 1 Jun 2020 00:15:14 +0000 (17:15 -0700)]
[Driver] Simplify Linux::addProfileRTLibs

4 years ago[analyzer] Add dumps to CheckerRegistry
Kirstóf Umann [Sun, 31 May 2020 19:22:35 +0000 (21:22 +0200)]
[analyzer] Add dumps to CheckerRegistry

4 years ago[Driver] NFC: Use Twine temp to replace std::string local
Hubert Tong [Sun, 31 May 2020 20:38:10 +0000 (16:38 -0400)]
[Driver] NFC: Use Twine temp to replace std::string local

This patch replaces a `std::string` local used for a concatentation with
a `Twine` where the string was being passed into call.

4 years ago[test][compiler-rt] Avoid LD_PRELOAD for "outer" dynamic linkers
Hubert Tong [Sun, 31 May 2020 20:33:42 +0000 (16:33 -0400)]
[test][compiler-rt] Avoid LD_PRELOAD for "outer" dynamic linkers

Summary:
This patch moves the setting of `LD_PRELOAD` "inwards" to avoid issues
where the built library needs to be loaded with the dynamic linker that
was configured with the build (and cannot, for example, be loaded by the
dynamic linker associated with the `env` utility).

Reviewed By: vitalybuka, nemanjai, jsji

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

4 years ago[X86] Rewrite how X86PartialReduction finds candidates to consider optimizing.
Craig Topper [Sun, 31 May 2020 19:39:14 +0000 (12:39 -0700)]
[X86] Rewrite how X86PartialReduction finds candidates to consider optimizing.

Previously we walked the users of any vector binop looking for
more binops with the same opcode or phis that eventually ended up
in a reduction. While this is simple it also means visiting the
same nodes many times since we'll do a forward walk for each
BinaryOperator in the chain. It was also far more general than what
we have tests for or expect to see.

This patch replaces the algorithm with a new method that starts at
extract elements looking for a horizontal reduction. Once we find
a reduction we walk through backwards through phis and adds to
collect leaves that we can consider for rewriting.

We only consider single use adds and phis. Except for a special
case if the Add is used by a phi that forms a loop back to the
Add. Including other single use Adds to support unrolled loops.

Ultimately, I want to narrow the Adds, Phis, and final reduction
based on the partial reduction we're doing. I still haven't
figured out exactly what that looks like yet. But restricting
the types of graphs we expect to handle seemed like a good first
step. As does having all the leaves and the reduction at once.

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

4 years ago[X86][AVX] Reduce unary target shuffles width if the upper elements aren't demanded.
Simon Pilgrim [Sun, 31 May 2020 19:19:24 +0000 (20:19 +0100)]
[X86][AVX] Reduce unary target shuffles width if the upper elements aren't demanded.

4 years ago[X86][AVX] combineX86ShufflesRecursively - peekThroughOneUseBitcasts subvector before...
Simon Pilgrim [Sun, 31 May 2020 18:58:15 +0000 (19:58 +0100)]
[X86][AVX] combineX86ShufflesRecursively - peekThroughOneUseBitcasts subvector before widening.

This matches what we do for the full sized vector ops at the start of combineX86ShufflesRecursively, and helps getFauxShuffleMask extract more INSERT_SUBVECTOR patterns.

4 years agoChange some extraneous /// comments to // comments inside methods. NFC.
Chris Lattner [Sun, 31 May 2020 18:43:54 +0000 (11:43 -0700)]
Change some extraneous /// comments to // comments inside methods. NFC.

4 years agoclang-tidy and clang-query wont crash with invalid command line options
Nathan James [Sun, 31 May 2020 16:41:29 +0000 (17:41 +0100)]
clang-tidy and clang-query wont crash with invalid command line options

Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=46141 | clang-tidy crashed for unknown command line argument. ]]

Reviewed By: aaron.ballman, thakis

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

4 years agoRevert "clang-tidy and clang-query wont crash with invalid command line options"
Nathan James [Sun, 31 May 2020 15:40:09 +0000 (16:40 +0100)]
Revert "clang-tidy and clang-query wont crash with invalid command line options"

This reverts commit f23ddbe3c3ae5f40b99ba272afc3d16b800ba8b9.

4 years ago[utils] update expected strings in tests; NFC
Sanjay Patel [Sun, 31 May 2020 15:06:32 +0000 (11:06 -0400)]
[utils] update expected strings in tests; NFC

The script was changes with:
https://github.com/llvm/llvm-project/commit/bfdc2552664d6f0bb332a9c6a115877020f3c1df

4 years agoclang-tidy and clang-query wont crash with invalid command line options
Nathan James [Sat, 30 May 2020 21:03:50 +0000 (22:03 +0100)]
clang-tidy and clang-query wont crash with invalid command line options

Summary: Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=46141 | clang-tidy crashed for unknown command line argument. ]]

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

4 years agoAArch64/GlobalISel: Fix incorrect ptrmask usage for alignment
Matt Arsenault [Sat, 30 May 2020 20:03:16 +0000 (16:03 -0400)]
AArch64/GlobalISel: Fix incorrect ptrmask usage for alignment

I inverted the mask when I ported to the new form of G_PTRMASK in
8bc03d2168241f7b12265e9cd7e4eb7655709f34.

I don't think this really broke anything, since G_VASTART isn't
handled for types with an alignment higher than the stack alignment.

4 years ago[utils] change update_test_checks.py use of 'TMP' value names
Sanjay Patel [Sun, 31 May 2020 14:46:11 +0000 (10:46 -0400)]
[utils] change update_test_checks.py use of 'TMP' value names

As discussed in PR45951:
https://bugs.llvm.org/show_bug.cgi?id=45951

There's a potential name collision between update_test_checks.py and -instnamer
and/or manually-generated IR test files because all of them try to use the
variable name that should never be used: "tmp".

This patch proposes to reduce the odds of collision and adds a warning if we
detect the problem. This will cause regression test churn when regenerating
CHECK lines on existing files.

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

4 years ago[PhaseOrdering] add test for hoisting/CSE (PR46115); NFC
Sanjay Patel [Sun, 31 May 2020 14:10:28 +0000 (10:10 -0400)]
[PhaseOrdering] add test for hoisting/CSE (PR46115); NFC

4 years ago[X86][AVX] Add SimplifyMultipleUseDemandedBits VBROADCAST handling to SimplifyDemande...
Simon Pilgrim [Sun, 31 May 2020 13:20:00 +0000 (14:20 +0100)]
[X86][AVX] Add SimplifyMultipleUseDemandedBits VBROADCAST handling to SimplifyDemandedVectorElts.

As suggested on D79987.

4 years ago[VectorCombine] add tests for scalarizing binop-with-constant; NFC
Sanjay Patel [Sun, 31 May 2020 13:05:48 +0000 (09:05 -0400)]
[VectorCombine] add tests for scalarizing binop-with-constant; NFC

Goes with proposal in D80885.

This is adapted from the InstCombine tests that were added for
D50992

But these should be adjusted further to provide more interesting
scenarios for x86-specific codegen. Eg, vector types/sizes will
have different costs depending on ISA attributes.

We also need to add tests that include a load of the scalar
variable and add tests that include extra uses of the insert
to further exercise the cost model.

4 years ago[X86] getFauxShuffleMask/getTargetShuffleInputs - make SelectionDAG const (PR45974).
Simon Pilgrim [Sun, 31 May 2020 12:50:40 +0000 (13:50 +0100)]
[X86] getFauxShuffleMask/getTargetShuffleInputs - make SelectionDAG const (PR45974).

Try to prevent future node creation issues (as detailed in PR45974) by making the SelectionDAG reference const, so it can still be used for analysis, but not node creation.

4 years ago[X86][AVX] Add test case described in D79987
Simon Pilgrim [Sun, 31 May 2020 12:46:46 +0000 (13:46 +0100)]
[X86][AVX] Add test case described in D79987

4 years ago[PhaseOrdering] add scalarization test for PR42174; NFC
Sanjay Patel [Sun, 31 May 2020 12:41:09 +0000 (08:41 -0400)]
[PhaseOrdering] add scalarization test for PR42174; NFC

Motivating test for vector-combine enhancement in D80885.
Make sure that vectorization and canonicalization are
working together as expected.

4 years ago[X86][AVX] getFauxShuffleMask - don't widen shuffle inputs from INSERT_SUBVECTOR...
Simon Pilgrim [Sun, 31 May 2020 12:19:18 +0000 (13:19 +0100)]
[X86][AVX] getFauxShuffleMask - don't widen shuffle inputs from INSERT_SUBVECTOR(X,SHUFFLE(Y,Z))

Don't create nodes on the fly when decoding INSERT_SUBVECTOR as faux shuffles.

4 years ago[X86][AVX] Pad small shuffle inputs in combineX86ShufflesRecursively
Simon Pilgrim [Sun, 31 May 2020 10:43:27 +0000 (11:43 +0100)]
[X86][AVX] Pad small shuffle inputs in combineX86ShufflesRecursively

As detailed on PR45974 and D79987, getFauxShuffleMask is creating nodes on the fly to create shuffles with inputs the same size as the result, causing problems for hasOneUse() checks in later simplification stages.

Currently only combineX86ShufflesRecursively benefits from these widened inputs so I've begun moving the functionality there, and out of getFauxShuffleMask. This allows us to remove the widening from VBROADCAST and *EXTEND* faux shuffle cases.

This just leaves the INSERT_SUBVECTOR case in getFauxShuffleMask still creating nodes, which will require more extensive refactoring.

4 years ago[ScheduleDAG] Avoid unnecessary recomputation of topological order.
Florian Hahn [Sun, 31 May 2020 10:04:35 +0000 (11:04 +0100)]
[ScheduleDAG] Avoid unnecessary recomputation of topological order.

In some cases ScheduleDAGRRList has to add new nodes to resolve problems
with interfering physical registers. When new nodes are added, it
completely re-computes the topological order, which can take a long
time, but is unnecessary. We only add nodes one by one, and initially
they do not have any predecessors. So we can just insert them at the end
of the vector. Later we add predecessors, but the helper function
properly updates the topological order much more efficiently. With this
change, the compile time for the program below drops from 300s to 30s on
my machine.

    define i11129 @test1() {
      %L1 = load i11129, i11129* undef
      %B30 = ashr i11129 %L1, %L1
      store i11129 %B30, i11129* undef
      ret i11129 %L1
    }

This should be generally beneficial, as we can skip a large amount of
work. Theoretically there are some scenarios where we might not safe
much, e.g. when we add a dependency between the first and last node.
Then we would have to shift all nodes. But we still do not have to spend
the time re-computing the initial order.

Reviewers: MatzeB, atrick, efriedma, niravd, paquette

Reviewed By: paquette

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

4 years agoRevert "[NFC][PowerPC] Add a new case to test phi-node-elimination pass"
Kang Zhang [Sun, 31 May 2020 09:24:21 +0000 (09:24 +0000)]
Revert "[NFC][PowerPC] Add a new case to test phi-node-elimination pass"
This case wll be failed on some machines which enable expensive-checks.

This reverts commit af3abbf7bd2213003a133c361c212ac6efb1bd2b.

4 years ago[NFC][PowerPC] Add a new case to test phi-node-elimination pass
Kang Zhang [Sun, 31 May 2020 08:05:27 +0000 (08:05 +0000)]
[NFC][PowerPC] Add a new case to test phi-node-elimination pass

4 years ago[AMDGPU] Propagate fast-math flags when lowering FSIN and FCOS
Jay Foad [Fri, 29 May 2020 16:02:13 +0000 (17:02 +0100)]
[AMDGPU] Propagate fast-math flags when lowering FSIN and FCOS

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

4 years ago[AMDGPU] Precommit tests for D80813
Jay Foad [Fri, 29 May 2020 15:52:43 +0000 (16:52 +0100)]
[AMDGPU] Precommit tests for D80813

4 years agoAMDGPU: Add setTruncStoreAction for vector i64 types made legal recently
Changpeng Fang [Sun, 31 May 2020 03:45:27 +0000 (20:45 -0700)]
AMDGPU: Add setTruncStoreAction for vector i64 types made legal recently

Reviewers:
  rampitec, arsenm

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

4 years ago[X86] Remove unneeded bitconverts from isel patterns. NFC
Craig Topper [Sun, 31 May 2020 03:24:51 +0000 (20:24 -0700)]
[X86] Remove unneeded bitconverts from isel patterns. NFC

The types already match so TableGen is removing the bitconvert.

4 years ago[X86] Add DAG combine to turn (v2i64 (scalar_to_vector (i64 (bitconvert (mmx))))...
Craig Topper [Sun, 31 May 2020 01:51:20 +0000 (18:51 -0700)]
[X86] Add DAG combine to turn (v2i64 (scalar_to_vector (i64 (bitconvert (mmx))))) to MOVQ2DQ. Remove unneeded isel patterns.

We already had a DAG combine for (mmx (bitconvert (i64 (extractelement v2i64))))
to MOVDQ2Q.

Remove patterns for MMX_MOVQ2DQrr/MMX_MOVDQ2Qrr that use
scalar_to_vector/extractelement involving i64 scalar type with
v2i64 and x86mmx.

4 years ago[DAGCombiner] Move debug message and statistic update into CommitTargetLoweringOpt.
Craig Topper [Sun, 31 May 2020 01:40:17 +0000 (18:40 -0700)]
[DAGCombiner] Move debug message and statistic update into CommitTargetLoweringOpt.

This code was repeated in two callers of CommitTargetLoweringOpt.
But CommitTargetLoweringOpt is also called from TargetLowering.
We should print a message for those calls to. So sink the
repeated code into CommitTargetLoweringOpt to catch those calls.

4 years ago[X86] Teach computeKnownBitsForTargetNode that the upper half of X86ISD::MOVQ2DQ...
Craig Topper [Sun, 31 May 2020 00:04:56 +0000 (17:04 -0700)]
[X86] Teach computeKnownBitsForTargetNode that the upper half of X86ISD::MOVQ2DQ is all zero.

4 years ago[X86] Fix a place where we created MOVQ2DQ with a DstVT other than v2i64.
Craig Topper [Sun, 31 May 2020 00:03:53 +0000 (17:03 -0700)]
[X86] Fix a place where we created MOVQ2DQ with a DstVT other than v2i64.

The type profile and isel pattern have this type declared as
being MVT::v2i64. But isel skips the explicit type check due to
the type profile.

4 years ago[X86] Autogenerate complete checks. NFC
Craig Topper [Sat, 30 May 2020 23:27:26 +0000 (16:27 -0700)]
[X86] Autogenerate complete checks. NFC

4 years ago[X86] Move MMX_SET0 pattern into the instruction definition. NFC
Craig Topper [Sat, 30 May 2020 23:12:44 +0000 (16:12 -0700)]
[X86] Move MMX_SET0 pattern into the instruction definition. NFC

4 years ago[ELF][docs] Update supported targets
Fangrui Song [Sun, 31 May 2020 02:33:50 +0000 (19:33 -0700)]
[ELF][docs] Update supported targets

PowerPC, PowerPC64 and x86-32 have production quality.
Mention Hexagon, RISC-V and SPARC V9.

4 years ago[llvm-objdump] Delete unneeeded namespace llvm {}
Fangrui Song [Sun, 31 May 2020 01:03:43 +0000 (18:03 -0700)]
[llvm-objdump] Delete unneeeded namespace llvm {}

4 years ago[llvm-objdump] Move llvm:: to llvm::objdump:: and qualifying definitions with objdump::
Fangrui Song [Sun, 31 May 2020 01:00:14 +0000 (18:00 -0700)]
[llvm-objdump] Move llvm:: to llvm::objdump:: and qualifying definitions with objdump::

Or adding `static`.

Qualifying definitions with `objdump::` comforms to the coding standards
https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions

4 years ago[llvm-objdump] Simplify reportError() and prepend outs().flush()
Fangrui Song [Sun, 31 May 2020 00:25:18 +0000 (17:25 -0700)]
[llvm-objdump] Simplify reportError() and prepend outs().flush()

As noticed by dblaikie.

I don't know what code paths using reportError can cause stdout output
to be interleaved with stderr, so no test is added now.

Also drop an unneeded use of errs().fflush() in reportWarning().
I requested this in D64165.

4 years ago[X86] Add pseudo instructions to use MULX with a single destination when the low...
Craig Topper [Sat, 30 May 2020 22:51:56 +0000 (15:51 -0700)]
[X86] Add pseudo instructions to use MULX with a single destination when the low result isn't used.

The instruction is defined to only produce high result if both
destinations are the same. We can exploit this to avoid
unnecessarily clobbering a register.

In order to hide this from register allocation we use a pseudo
instruction and expand the result during MCInst creation.

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

4 years ago[Driver] Fix BooleanFFlag identifiers to use 'f' 'fno_' prefixes instead of suffixes
Fangrui Song [Sat, 30 May 2020 22:41:09 +0000 (15:41 -0700)]
[Driver] Fix BooleanFFlag identifiers to use 'f' 'fno_' prefixes instead of suffixes

4 years agoRemove some non-determinism from the `Darwin/duplicate_os_log_reports.cpp` test.
Dan Liew [Sat, 30 May 2020 22:17:41 +0000 (15:17 -0700)]
Remove some non-determinism from the `Darwin/duplicate_os_log_reports.cpp` test.

The test read from an uninitialized buffer which could cause the output
to be unpredictable.

The test is currently disabled so this won't actually change anything
until the test is re-enabled.

4 years ago[X86] Minor cleanups to addShuffleComments in X86MCInstPrinter.cpp. NFCI
Craig Topper [Sat, 30 May 2020 19:53:56 +0000 (12:53 -0700)]
[X86] Minor cleanups to addShuffleComments in X86MCInstPrinter.cpp. NFCI

-Replace some ifs that should be impossible with asserts.
-Use X86::AddrDisp and X86::AddrNumOperands to make code more readable
-Use X86II::isKMasked/isKMergeMasked to do some operand skipping to remove or simplify switches

4 years ago[X86] Factor constant pool comment printing out of the switch in X86AsmPrinter::emitI...
Craig Topper [Sat, 30 May 2020 07:31:21 +0000 (00:31 -0700)]
[X86] Factor constant pool comment printing out of the switch in X86AsmPrinter::emitInstruction. NFC

Pull the verbose asm check out of the cases and move it up to
the call of the new function.

4 years ago[LoopUnroll] Add a test case for rG7873376bb36b.
Whitney Tsang [Sat, 30 May 2020 20:24:10 +0000 (20:24 +0000)]
[LoopUnroll] Add a test case for rG7873376bb36b.

rG7873376bb36b fixes a build failure for allyesconfig.

The problem happened when the single exiting block doesn't dominate the
loop latch, then the immediate dominator of the exit block should not be
the exiting block after unrolling. As the exiting block of
different unrolled iteration can branch to the exit block, and the ith
exiting block doesn't dominate (i+1)th exiting block, the immediate
dominator of the exit block should not the nearest common dominator of
the exiting block and the loop latch of the same iteration.

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

4 years ago[Tests] Convert last statepoint lowering tests to bundle format
Philip Reames [Sat, 30 May 2020 19:58:41 +0000 (12:58 -0700)]
[Tests] Convert last statepoint lowering tests to bundle format

4 years ago[clang-tidy] RenamerClangTidyChecks ignore builtin and command line macros
Nathan James [Wed, 27 May 2020 14:01:17 +0000 (15:01 +0100)]
[clang-tidy] RenamerClangTidyChecks ignore builtin and command line macros

Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42635 | readability-identifier-naming option MacroDefinitionCase should ignore macros passed as parameters. ]]

Reviewers: aaron.ballman, alexfh, gribozavr2, hokein

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

4 years ago[LoopUnroll] Fix build failure for allyesconfig.
Whitney Tsang [Sat, 30 May 2020 18:20:23 +0000 (18:20 +0000)]
[LoopUnroll] Fix build failure for allyesconfig.

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

4 years ago[DSE] Remove noop stores in MSSA.
zoecarver [Sat, 30 May 2020 16:56:04 +0000 (09:56 -0700)]
[DSE] Remove noop stores in MSSA.

Adds a simple fast-path check for the pattern:
v = load ptr
store v to ptr

I took the tests from the bugzilla post, I can add more if needed (but I think these should be sufficent).

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

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

4 years ago[lldb] Pass -fPIC flag even when DYLIB_ONLY is set
Raphael Isemann [Fri, 29 May 2020 15:08:28 +0000 (17:08 +0200)]
[lldb] Pass -fPIC flag even when DYLIB_ONLY is set

Summary:
It seems that when we rewrite a few rules to only build a dylib (i.e., when DYLIB_ONLY is set),
the rule for setting the CFLAGS for the dylib's object file compilation will no longer work. From what I can
see this is because in DYLIB_ONLY mode we pretend to compile the main executable so
the DYLIB_OBJECTS scope is actually never used.

This patch makes `-fPIC` unstopped if DYLIB_ONLY is set so that -fPIC actually ends up in the
CFLAGS for the dylib object file compilation.

The test for this is D80798 which only compiles on Linux with this patch.

Reviewers: friss, labath

Reviewed By: friss

Subscribers: JDevlieghere

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

4 years ago[BasicAA] Use known lower bounds for index values for size based check.
Florian Hahn [Sat, 30 May 2020 15:20:42 +0000 (16:20 +0100)]
[BasicAA] Use known lower bounds for index values for size based check.

Currently, BasicAA does not exploit information about value ranges of
indexes. For example, consider the 2 pointers %a = %base and
%b = %base + %stride below, assuming they are used to access 4 elements.

If we know that %stride >= 4, we know the accesses do not alias. If
%stride is a constant, BasicAA currently gets that. But if the >= 4
constraint is encoded using an assume, it misses the NoAlias.

This patch extends DecomposedGEP to include an additional MinOtherOffset
field, which tracks the constant offset similar to the existing
OtherOffset, which the difference that it also includes non-negative
lower bounds on the range of the index value. When checking if the
distance between 2 accesses exceeds the access size, we can use this
improved bound.

For now this is limited to using non-negative lower bounds for indices,
as this conveniently skips cases where we do not have a useful lower
bound (because it is not constrained). We potential miss out in cases
where the lower bound is constrained but negative, but that can be
exploited in the future.

Reviewers: sanjoy, hfinkel, reames, asbirlea

Reviewed By: asbirlea

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

4 years agoSafeStackColoring.h - reduce Instructions.h include to forward declaration. NFC.
Simon Pilgrim [Sat, 30 May 2020 13:38:02 +0000 (14:38 +0100)]
SafeStackColoring.h - reduce Instructions.h include to forward declaration. NFC.

SafeStackColoring.cpp - remove includes directly defined in SafeStackColoring.h header. NFC.

4 years agoCriticalAntiDepBreaker.cpp - remove includes directly defined in CriticalAntiDepBreak...
Simon Pilgrim [Sat, 30 May 2020 13:32:36 +0000 (14:32 +0100)]
CriticalAntiDepBreaker.cpp - remove includes directly defined in CriticalAntiDepBreaker.h header. NFC.

4 years agoSafeStackLayout.cpp - remove includes directly defined in SafeStackLayout.h module...
Simon Pilgrim [Sat, 30 May 2020 13:30:19 +0000 (14:30 +0100)]
SafeStackLayout.cpp - remove includes directly defined in SafeStackLayout.h module header. NFC.

4 years ago[TargetLowering] SimplifyDemandedBits - remove shift amount clamps from getValidShift...
Simon Pilgrim [Sat, 30 May 2020 13:04:55 +0000 (14:04 +0100)]
[TargetLowering] SimplifyDemandedBits - remove shift amount clamps from getValidShiftAmountConstant calls. NFC.

getValidShiftAmountConstant only returns a value if the shift amount is in range, so we don't need to check it again.

4 years ago[SelectionDAG] ComputeNumSignBits - use Valid Min/Max shift amount helpers directly...
Simon Pilgrim [Sat, 30 May 2020 13:02:14 +0000 (14:02 +0100)]
[SelectionDAG] ComputeNumSignBits - use Valid Min/Max shift amount helpers directly. NFCI.

We are calling getValidShiftAmountConstant first followed by getValidMinimumShiftAmountConstant/getValidMaximumShiftAmountConstant if that failed. But both are used in the same way in ComputeNumSignBits and the Min/Max variants call getValidShiftAmountConstant internally anyhow.

4 years agoPackedVersion.h - reduce includes to forward declarations. NFC.
Simon Pilgrim [Sat, 30 May 2020 12:17:19 +0000 (13:17 +0100)]
PackedVersion.h - reduce includes to forward declarations. NFC.

4 years ago[clang-format] [PR46130] When editing a file with unbalance {} the namespace comment...
mydeveloperday [Sat, 30 May 2020 12:00:35 +0000 (13:00 +0100)]
[clang-format] [PR46130] When editing a file with unbalance {} the namespace comment fixer can incorrectly comment the wrong closing brace

Summary:
https://bugs.llvm.org/show_bug.cgi?id=46130   from Twitter https://twitter.com/ikautak/status/1265998988232159232

I have seen this myself many times.. if you have format on save and you work in an editor where you are constantly saving (:w muscle memory)

If you are in the middle of editing and somehow you've missed a { or } in your code, somewhere, often way below where you are at the bottom of your file the namespace comment fixer will have put the namespace on the previous closing brace.

This leads to you having to fix up the bottom of the file.

This revision prevents that happening by performing an initial pass of the tokens and simply counting the number of `{` and `}`  and ensuring they balance.

If they don't balance we don't do any namespace fixing as it will likely be unstable and incorrect.

Reviewed By: curdeius

Subscribers: cfe-commits

Tags: #clang, #clang-format

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

4 years agoTBEHandler.h - remove unnecessary VersionTuple forward declaration. NFC.
Simon Pilgrim [Sat, 30 May 2020 12:07:57 +0000 (13:07 +0100)]
TBEHandler.h - remove unnecessary VersionTuple forward declaration. NFC.

We already have to include VersionTuple.h

4 years agoArchitectureSet.h - add missing <tuple> include.
Simon Pilgrim [Sat, 30 May 2020 11:48:46 +0000 (12:48 +0100)]
ArchitectureSet.h - add missing <tuple> include.

MSVC seems to implicitly include this from <utility> but other toolchains don't

4 years agoArchitectureSet.h - reduce raw_ostream.h include to forward declaration. NFC.
Simon Pilgrim [Sat, 30 May 2020 11:36:16 +0000 (12:36 +0100)]
ArchitectureSet.h - reduce raw_ostream.h include to forward declaration. NFC.

Move raw_ostream.h include to ArchitectureSet.cpp.

4 years agoArchitecture.h - reduce includes to forward declarations. NFC.
Simon Pilgrim [Sat, 30 May 2020 11:17:13 +0000 (12:17 +0100)]
Architecture.h - reduce includes to forward declarations. NFC.

Move includes to Architecture.cpp.

4 years agoIPDBRawSymbol.h - remove already declared forward declarations. NFC.
Simon Pilgrim [Sat, 30 May 2020 11:00:17 +0000 (12:00 +0100)]
IPDBRawSymbol.h - remove already declared forward declarations. NFC.

PDBTypes.h holds most PDB forward declarations already, move IPDBSession in there as well.

4 years agoIPDBRawSymbol.h - reduce StringRef.h include to forward declaration. NFC.
Simon Pilgrim [Sat, 30 May 2020 10:29:17 +0000 (11:29 +0100)]
IPDBRawSymbol.h - reduce StringRef.h include to forward declaration. NFC.