platform/upstream/llvm.git
3 years ago[LoopVectorize] use IR fast-math-flags exclusively (not FP function attributes)
Sanjay Patel [Wed, 27 Jan 2021 19:11:22 +0000 (14:11 -0500)]
[LoopVectorize] use IR fast-math-flags exclusively (not FP function attributes)

I am trying to untangle the fast-math-flags propagation logic
in the vectorizers (see a6f022127 for SLP).

The loop vectorizer has a mix of checking FP function attributes,
IR-level FMF, and just wrong assumptions.

I am trying to avoid regressions while fixing this, and I think
the IR-level logic is good enough for that, but it's hard to say
for sure. This would be the 1st step in the clean-up.

The existing test that I changed to include 'fast' actually shows
a miscompile: the function only had the equivalent of nnan, but we
created new instructions that had fast (all FMF set). This is
similar to the example in https://llvm.org/PR35538

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

3 years ago[libc] Include only the relevant header files in the integration test.
Siva Chandra [Wed, 27 Jan 2021 19:08:31 +0000 (11:08 -0800)]
[libc] Include only the relevant header files in the integration test.

3 years ago[sanitizer][fuchsia] Implement ReleaseMemoryPagesToOS
Marco Vanotti [Mon, 25 Jan 2021 19:08:49 +0000 (11:08 -0800)]
[sanitizer][fuchsia] Implement ReleaseMemoryPagesToOS

The `zx_vmar_op_range` allows us to decommit memory pages without
needing a handle to the underlying vmo, as long as we have a handle to
a vmar that contains this mapping. This allows us to implement the
`ReleaseMemoryPagesToOS` function by decommitting the memory using a
handle to the root vmar.

Reviewed By: mcgrathr

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

3 years ago[lit][NFC] Use enum to represent test order
Julian Lettner [Wed, 27 Jan 2021 19:06:58 +0000 (11:06 -0800)]
[lit][NFC] Use enum to represent test order

Use an enum to more explicitly represent the test execution order.

3 years agoRevert "Suppress non-conforming GNU paste extension in all standard-conforming modes"
Reid Kleckner [Wed, 27 Jan 2021 18:59:28 +0000 (10:59 -0800)]
Revert "Suppress non-conforming GNU paste extension in all standard-conforming modes"

This reverts commit f4537935dcdbf390c863591cf556e76c3abab9c1.
This reverts commit b43c26d036dcbf7a6881f39e4434cf059364022a.

This GNU and MSVC extension turns out to be very popular. Most projects
are not using C++20, so cannot use the new __VA_OPT__ feature to be
standards conformant. The other workaround, using -std=gnu*, enables too
many language extensions and isn't viable.

Until there is a way for users to get the behavior provided by the
`, ## __VA_ARGS__` extension in the -std=c++17 and earlier language
modes, we need to revert this.

3 years ago[gn build] Port 0b50fa99452f
LLVM GN Syncbot [Wed, 27 Jan 2021 18:55:59 +0000 (18:55 +0000)]
[gn build] Port 0b50fa99452f

3 years ago[test] Fix clang/test/CodeGen tests
Fangrui Song [Wed, 27 Jan 2021 18:55:26 +0000 (10:55 -0800)]
[test] Fix clang/test/CodeGen tests

3 years ago[ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags
Fangrui Song [Wed, 27 Jan 2021 18:43:51 +0000 (10:43 -0800)]
[ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags

Imported functions and variable get the visibility from the module supplying the
definition.  However, non-imported definitions do not get the visibility from
(ELF) the most constraining visibility among all modules (Mach-O) the visibility
of the prevailing definition.

This patch

* adds visibility bits to GlobalValueSummary::GVFlags
* computes the result visibility and propagates it to all definitions

Protected/hidden can imply dso_local which can enable some optimizations (this
is stronger than GVFlags::DSOLocal because the implied dso_local can be
leveraged for ELF -shared while default visibility dso_local has to be cleared
for ELF -shared).

Note: we don't have summaries for declarations, so for ELF if a declaration has
the most constraining visibility, the result visibility may not be that one.

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

3 years ago[FaultsMaps][llvm-objdump] Move FaultMapParser to Object/. Remove CodeGen dependency...
Craig Topper [Wed, 27 Jan 2021 18:21:47 +0000 (10:21 -0800)]
[FaultsMaps][llvm-objdump] Move FaultMapParser to Object/. Remove CodeGen dependency from llvm-objdump

FaultsMapParser lived in CodeGen and was forcing llvm-objdump to
link CodeGen and everything CodeGen depends on.

This was previously attempted in r240364 to fix a link failure.
The CodeGen dependency was independently added to fix the same
link failure, and that ended up being kept.

Removing the dependency seems like the correct layering for
llvm-objdump.

Reviewed By: MaskRay, jhenderson

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

3 years ago[libc] Disable sqrtl_test on non-x86 platforms.
Siva Chandra [Wed, 27 Jan 2021 18:29:30 +0000 (10:29 -0800)]
[libc] Disable sqrtl_test on non-x86 platforms.

The added comment explains why it has been disabled for now. We will
enable back when we fix the problem.

3 years ago[RISCV] Group the legal vector types into lists we can iterator over in the RISCVISel...
Craig Topper [Wed, 27 Jan 2021 17:48:27 +0000 (09:48 -0800)]
[RISCV] Group the legal vector types into lists we can iterator over in the RISCVISelLowering constructor

Remove the RISCVVMVTs namespace because I don't think it provides
a lot of value. If we change the mappings we'd likely have to add
or remove things from the list anyway.

Add a wrapper around addRegisterClass that can determine the
register class from the fixed size of the type.

Reviewed By: frasercrmck, rogfer01

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

3 years ago[flang][openacc] Allow multiple wait clauses
Valentin Clement [Wed, 27 Jan 2021 18:18:27 +0000 (13:18 -0500)]
[flang][openacc] Allow multiple wait clauses

kernels loop and enter data had a too restrictive constraint for the wait clause.
The wait clause is allowed multiple times and not only once. This patch fix this problem.

Reviewed By: SouraVX

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

3 years ago[libc++] Fix extern template test failing on Windows
Louis Dionne [Wed, 27 Jan 2021 18:08:24 +0000 (13:08 -0500)]
[libc++] Fix extern template test failing on Windows

See https://reviews.llvm.org/D94718#2521489 for details.

3 years ago[LoopUtils] Pass SCEVExpander instead SE to addRuntimeChecks.
Florian Hahn [Wed, 27 Jan 2021 17:13:38 +0000 (17:13 +0000)]
[LoopUtils] Pass SCEVExpander instead SE to addRuntimeChecks.

This gives the user control over which expander to use, which in turn
allows the user to decide what to do with the expanded instructions.

Used in D75980.

Reviewed By: lebedev.ri

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

3 years ago[TableGen] [DetailedRecords] Print record name that is null string as ""
Paul C. Anagnostopoulos [Sun, 24 Jan 2021 18:30:31 +0000 (13:30 -0500)]
[TableGen] [DetailedRecords] Print record name that is null string as ""

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

Add a test for the backend.

3 years agoExecutionDomainFix.cpp - use const refs in for-range loops. NFCI.
Simon Pilgrim [Wed, 27 Jan 2021 15:21:26 +0000 (15:21 +0000)]
ExecutionDomainFix.cpp - use const refs in for-range loops. NFCI.

Avoid unnecessary copies. Reported by clang-tidy.

3 years ago[Support] CommandLine.cpp - Fix clang-tidy namespace comment warnings. NFCI.
Simon Pilgrim [Wed, 27 Jan 2021 13:57:43 +0000 (13:57 +0000)]
[Support] CommandLine.cpp - Fix clang-tidy namespace comment warnings. NFCI.

Ensure namespace braces have the correct comment with them

3 years ago[Support] Fix clang-tidy auto warnings. NFCI.
Simon Pilgrim [Wed, 27 Jan 2021 12:02:49 +0000 (12:02 +0000)]
[Support] Fix clang-tidy auto warnings. NFCI.

Use auto pointer/reference to fix llvm-qualified-auto remarks.

3 years ago[CodeGen] SafeStack: preserve DominatorTree if it is avaliable
Roman Lebedev [Wed, 27 Jan 2021 14:13:10 +0000 (17:13 +0300)]
[CodeGen] SafeStack: preserve DominatorTree if it is avaliable

While this is mostly NFC right now, because only ARM happens
to run this pass with DomTree available before it,
and required after it, more backends will be affected once
the SimplifyCFG's switch for domtree preservation is flipped,
and DwarfEHPrepare also preserves the domtree.

3 years ago[NFC] StackProtector: be consistent and to initialize DominatorTreeWrapperPass
Roman Lebedev [Wed, 27 Jan 2021 14:07:43 +0000 (17:07 +0300)]
[NFC] StackProtector: be consistent and to initialize DominatorTreeWrapperPass

We already ask for it, so it might be good to ensure that it is
actually initialized before us. Doesn't seem to matter in practice though.

3 years ago[compiler-rt] Support FreeBSD standalone (boot) environment
Jessica Clarke [Wed, 27 Jan 2021 15:28:59 +0000 (15:28 +0000)]
[compiler-rt] Support FreeBSD standalone (boot) environment

FreeBSD uses -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface to
poison uses of floating point in its standalone environment. It also
deprecates machine/limits.h in favour of sys/limits.h and does not even
provide the former on newer architectures.

This is a cleaner reimplementation of equivalent patches in FreeBSD's
vendored copy of compiler-rt.

Reviewed By: dim

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

3 years ago[libc++] [P0879] constexpr heap and partial_sort algorithms
Arthur O'Dwyer [Thu, 17 Dec 2020 05:26:18 +0000 (00:26 -0500)]
[libc++] [P0879] constexpr heap and partial_sort algorithms

Now the only ones we're still missing from P0879
are `sort` and `nth_element`.

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

3 years ago[mlir] Fold shape.eq %a, %a to true
Tres Popp [Tue, 26 Jan 2021 10:18:24 +0000 (11:18 +0100)]
[mlir] Fold shape.eq %a, %a to true

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

3 years ago[libcxx] Update include/__libcpp_version to match include/__config
Simon Tatham [Wed, 27 Jan 2021 15:01:48 +0000 (15:01 +0000)]
[libcxx] Update include/__libcpp_version to match include/__config

https://reviews.llvm.org/rG5369517d20dd362a178a1b2d6c398d8898ee4620
bumped the version number in __config to 13000, causing a test failure
in libcxx/test/libcxx/libcpp_version.pass.cpp because now the two
don't match.

This is the only part of the post-release TODO in
libcxx/docs/Contributing.rst that wasn't done by that commit.

3 years ago[flang][openacc] Fix clause restriction for exit data directive
Valentin Clement [Wed, 27 Jan 2021 15:07:06 +0000 (10:07 -0500)]
[flang][openacc] Fix clause restriction for exit data directive

Restriction on clauses for the EXIT DATA directive were not fully correct.
This patch fixes the situation. The async, if and finalize clauses are allowed
only once.

Reviewed By: SouraVX

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

3 years ago[flang][openacc] Fix clause restriction for host_data directive
Valentin Clement [Wed, 27 Jan 2021 15:06:18 +0000 (10:06 -0500)]
[flang][openacc] Fix clause restriction for host_data directive

Restriction on clauses for the HOST_DATA directive were not fully correct.
This patch fixes the situation. The if and if_present clauses are allowed
only once.

Reviewed By: SouraVX

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

3 years ago[X86] merge "={eax}" and "~{eax}" into "=&eax" for MSInlineASM
Freddy Ye [Wed, 27 Jan 2021 13:10:33 +0000 (21:10 +0800)]
[X86] merge "={eax}" and "~{eax}" into "=&eax" for MSInlineASM

Reviewed By: pengfei

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

3 years ago[clangd] Treat "null" optional fields as missing
Kadir Cetinkaya [Fri, 22 Jan 2021 14:20:52 +0000 (15:20 +0100)]
[clangd] Treat "null" optional fields as missing

Clangd currently throws away any protocol messages whenever an optional
field has an unexpected type. This patch changes the behaviour to treat
`null` fields as missing.

This enables clangd to be more tolerant against small violations to the
LSP spec.

Fixes https://github.com/clangd/vscode-clangd/issues/134

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

3 years ago[OpenMP][Libomptarget] Fix check-libomptarget
Giorgis Georgakoudis [Mon, 25 Jan 2021 17:48:12 +0000 (09:48 -0800)]
[OpenMP][Libomptarget] Fix check-libomptarget

The check-libomptarget fails when building with LLVM_ENABLE_PROJECTS. This is because test configuration misses the path to libomp.so and libLLVMSupport.so when time profiling is enabled (both libraries have the same path when building). This patch add the path to the configuration.

Reviewed By: vzakhari

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

3 years ago[OpenMP] Fix building using LLVM_ENABLE_RUNTIMES
Giorgis Georgakoudis [Mon, 25 Jan 2021 22:10:50 +0000 (14:10 -0800)]
[OpenMP] Fix building using LLVM_ENABLE_RUNTIMES

Fix when time profiling is enabled.

Related to: D94855

Reviewed By: JonChesterfield

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

3 years ago[clangd] Work around GCC bug 66735
Sam McCall [Wed, 27 Jan 2021 14:32:05 +0000 (15:32 +0100)]
[clangd] Work around GCC bug 66735

3 years agoTry to fix cl-options.c on bots were the default triple is non-x86 non-arm
Nico Weber [Wed, 27 Jan 2021 14:19:25 +0000 (09:19 -0500)]
Try to fix cl-options.c on bots were the default triple is non-x86 non-arm

llvmArchToWindowsSDKArch() returns "" for non-intel non-arm archs.
We're checking for "/fake/lib/" which is followed by the result
of that function -- but if that returns an empty string, then that
trailing slash isn't there. As fix, just explicitly pass a triple
that's intel or arm (I randomly chose aarch64). Since the test runs
with -###, that arch doesn't have to be in LLVM_TARGETS_TO_BUILD.

3 years agoclang-cl: Prefer /vctoolsdir, /winsdkdir over LIB for link invocations
Nico Weber [Wed, 27 Jan 2021 13:52:23 +0000 (08:52 -0500)]
clang-cl: Prefer /vctoolsdir, /winsdkdir over LIB for link invocations

/vctoolsdir and /winsdkdir take precedence over the INCLUDE env var,
so they should also take precedence over LIB. It's not quite as neat
since LIB is still read by the linker and the linker just prefers
the -libpath: paths the driver now passes, but as long as all libraries
are present at /vctoolsdir and /winsdkdir, there's no harm in the linker
also looking at LIB later.

This fixes cl-options.c after a5d85cbe on Windows when LIB is set.
Another way to fix the test would be to prefix the clang-cl
line with `env --unset=LIB`, but I think it's better to fix the
flag to work as expected instead of making the test work around
the surprising behavior that LIB being set causes clang-cl to
not pass -libpath: flags to the linker when /vctoolsdir and
/winsdkdir are used.

3 years ago[clang][cli] Generate HeaderSearch options separately
Jan Svoboda [Wed, 27 Jan 2021 13:50:09 +0000 (14:50 +0100)]
[clang][cli] Generate HeaderSearch options separately

This patch moves parsing of header search options from `generateCC1Options` to separate `GenerateHeaderSearchArgs`.

The round-trip algorithm in D94472 requires this separation to be able to run parsing and generating **only** for the options that need to be tested via round-tripping.

This also moves the `GENERATE_OPTION_WITH_MARSHALLING` to the top of the file, because other kinds of options will be generated in separate functions that will be spread throughout `CompilerInvocation.cpp` to be close to their parsing counterparts.

Reviewed By: dexonsmith

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

3 years ago[clang][cli] Parse HeaderSearch options separately
Jan Svoboda [Wed, 27 Jan 2021 13:34:09 +0000 (14:34 +0100)]
[clang][cli] Parse HeaderSearch options separately

This patch moves parsing of header search options from `parseSimpleArgs` back to `ParseHeaderSearchArgs` where they originally were.

The round-trip algorithm in D94472 requires this separation to be able to run parsing and generating **only** for the options that need to be tested via round-tripping.

Reviewed By: dexonsmith

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

3 years ago[clang][cli] Port OpenMP-related LangOpts to marshalling system
Jan Svoboda [Wed, 27 Jan 2021 09:11:55 +0000 (10:11 +0100)]
[clang][cli] Port OpenMP-related LangOpts to marshalling system

Port some OpenMP-related language options to the marshalling system for automatic command line parsing and generation.

Reviewed By: dexonsmith

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

3 years ago[LoopUnswitch] Add test cases not partially unswitched due to cost.
Florian Hahn [Wed, 27 Jan 2021 12:24:13 +0000 (12:24 +0000)]
[LoopUnswitch] Add test cases not partially unswitched due to cost.

This pre-commits tests for D95468.

3 years ago[mlir:async] Fix deadlock in async runtime await-and-execute functions
Eugene Zhulenev [Wed, 27 Jan 2021 12:27:21 +0000 (04:27 -0800)]
[mlir:async] Fix deadlock in async runtime await-and-execute functions

`emplace???` functions running concurrently can set the ready flag and then pending awaiter will never be executed

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

3 years ago[lldb] Add move_iterator to supported template list
Raphael Isemann [Wed, 27 Jan 2021 12:33:47 +0000 (13:33 +0100)]
[lldb] Add move_iterator to supported template list

Identical to previous commits that just add a standard library template to the
supported template list and test it. Adding this rather obscure class to the
template list is mostly caused by the std::deque test unexpectedly referencing
this type when testing against newer libc++ versions on macOS.

Fixes TestQueueFromStdModule and TestQueueFromStdModule on macOS.
Fixes rdar://73213589

3 years ago[DWARF] Create subprogram's DIE in DISubprogram's unit
Jeremy Morse [Wed, 27 Jan 2021 12:29:12 +0000 (12:29 +0000)]
[DWARF] Create subprogram's DIE in DISubprogram's unit

This is a fix for PR48790. Over in D70350, subprogram DIEs were permitted
to be shared between CUs. However, the creation of a subprogram DIE can be
triggered early, from other CUs. The subprogram definition is then created
in one CU, and when the function is actually emitted children are attached
to the subprogram that expect to be in another CU. This breaks internal CU
references in the children.

Fix this by redirecting the creation of subprogram DIEs in
getOrCreateContextDIE to the CU specified by it's DISubprogram definition.
This ensures that the subprogram DIE is always created in the correct CU.

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

3 years ago[OpenCL][Docs] Moved info from UsersManual into OpenCLSupport.
Anastasia Stulova [Wed, 27 Jan 2021 12:21:22 +0000 (12:21 +0000)]
[OpenCL][Docs] Moved info from UsersManual into OpenCLSupport.

Moved information detailing the implementation from UsersManual
into OpenCLSupport page as it is not relevant to the user's of
clang but primarily needed for the compiler developers.

Tags: #clang

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

3 years ago[analyzer] NFC: Introduce reusable bug category for "C++ move semantics".
Artem Dergachev [Tue, 19 Jan 2021 21:31:14 +0000 (13:31 -0800)]
[analyzer] NFC: Introduce reusable bug category for "C++ move semantics".

Currently only used by MoveChecker but ideally all checkers
should have reusable categories.

3 years agoclang-cl: Add /winsdkdir and /winsdkversion flags
Nico Weber [Tue, 26 Jan 2021 20:21:12 +0000 (15:21 -0500)]
clang-cl: Add /winsdkdir and /winsdkversion flags

These do for the Windows SDK path what D85998 did for
%VCToolsInstallDir% with /vctoolsdir: Offer a way to set them with an
explicit commandline switch.

With this (and /vctoolsdir), it's possible to compile and link
against hermetic vctools and winsdk directories with:

    out/gn/bin/clang-cl win.c -fuse-ld=lld \
        /vctoolsdir path/to/VC/Tools/MSVC/14.26.28801 \
        /winsdkdir path/to/win_sdk

compared to a long list of -imsvc and /link /libpath: flags.

While here:
- Change the case of the "Include" folder inside the windows sdk
  from "include" to "Include" to match on-disk case. Since the
  Windows file system is case-insensitive this isn't a behavior
  change, it's just a bit cleaner.
- Add libpath tests to the /vctoolsdir
- Add a FIXME about reading env vars for win sdk and ucrt sdk
  if these flags aren't present, to match the VCToolsInstallDir
  logic

We should also cache all these computed paths in the driver instead
of computing them every time they're queried, but that's for a future
patch.

It'd also be nice to invent a /winsysroot: flag that sets both
/vctoolsdir: and /winsdkdir: to some well-known subdirectory.
That's for a future patch as well.

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

3 years ago[SCEV] Fix incorrect loop exit count analysis.
Mindong Chen [Tue, 26 Jan 2021 16:10:37 +0000 (00:10 +0800)]
[SCEV] Fix incorrect loop exit count analysis.

In computeLoadConstantCompareExitLimit, the addrec used to compute the
exit count should be from the loop which the exiting block belongs to.

Reviewed by: mkazantsev

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

3 years ago[clang][AST] Encapsulate DeclarationNameLoc, NFCI
Mikhail Maltsev [Wed, 27 Jan 2021 11:21:01 +0000 (11:21 +0000)]
[clang][AST] Encapsulate DeclarationNameLoc, NFCI

This change makes `DeclarationNameLoc` a proper class and refactors its
users to use getter methods instead of accessing the members directly.
The change also makes `DeclarationNameLoc` immutable (i.e., it cannot
be modified once constructed).

Reviewed By: aprantl

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

3 years ago[MachineLICM][MachineSink] Move SinkIntoLoop to MachineSink.
Sjoerd Meijer [Fri, 8 Jan 2021 09:32:52 +0000 (09:32 +0000)]
[MachineLICM][MachineSink] Move SinkIntoLoop to MachineSink.

This moves SinkIntoLoop from MachineLICM to MachineSink. The motivation for
this work is that hoisting is a canonicalisation transformation, but we do not
really have a good story to sink instructions back if that is better, e.g. to
reduce live-ranges, register pressure and spilling. This has been discussed a
few times on the list, the latest thread is:

https://lists.llvm.org/pipermail/llvm-dev/2020-December/147184.html

There it was pointed out that we have the LoopSink IR pass, but that works on
IR, lacks register pressure informatiom, and is focused on profile guided
optimisations, and then we have MachineLICM and MachineSink that both perform
sinking. MachineLICM is more about hoisting and CSE'ing of hoisted
instructions. It also contained a very incomplete and disabled-by-default
SinkIntoLoop feature, which we now move to MachineSink.

Getting loop-sinking to do something useful is going to be at least a 3-step
approach:

1) This is just moving the code and is almost a NFC, but contains a bug fix.
This uses helper function `isLoopInvariant` that was factored out in D94082 and
added to MachineLoop.
2) A first functional change to make loop-sink a little bit less restrictive,
which it really is at the moment, is the change in D94308. This lets it do
more (alias) analysis using functions in MachineSink, making it a bit more
powerful. Nothing changes much: still off by default. But it shows that
MachineSink is a better home for this, and it starts using its functionality
like `hasStoreBetween`, and in the next step we can use `isProfitableToSinkTo`.
3) This is the going to be he interesting step: decision making when and how
many instructions to sink. This will be driven by the register pressure, and
deciding if reducing live-ranges and loop sinking will help in better
performance.
4) Once we are happy with 3), this should be enabled by default, that should be
the end goal of this exercise.

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

3 years ago[AArch64] Add vector saturating add intrinsic costs
David Green [Wed, 27 Jan 2021 10:38:32 +0000 (10:38 +0000)]
[AArch64] Add vector saturating add intrinsic costs

This adds sadd.sat, uadd.sat, ssub.sat and usub.sat costs for AArch64,
similar to how they were recently added for ARM.

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

3 years ago[RISCV] Fix a codegen crash in getSetCCResultType
Fraser Cormack [Tue, 26 Jan 2021 11:36:56 +0000 (11:36 +0000)]
[RISCV] Fix a codegen crash in getSetCCResultType

This patch fixes some crashes coming from
`RISCVISelLowering::getSetCCResultType`, which would occasionally return
an EVT constructed from an invalid MVT, which has a null Type pointer.

The attached test shows this happening currently for some fixed-length
vectors, which hit this issue when the V extension was enabled, even
though they're not legal types under the V extension. The fix was also
pre-emptively extended to scalable vectors which can't be represented as
an MVT, even though a test case couldn't be found for them.

Reviewed By: craig.topper

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

3 years ago[flang][driver] Report prescanning diags during syntax-only parsing
Faris Rehman [Wed, 27 Jan 2021 09:45:56 +0000 (09:45 +0000)]
[flang][driver] Report prescanning diags during syntax-only parsing

Ensure diagnostics from the prescanner are reported when running `flang-new -fsyntax-only` (i.e. only syntax parsing).
This keeps the diagnostics output of flang-new consistent with `f18 -fparse-only` when running the syntax parsing action, ParseSyntaxOnlyAction.

Summary of changes:
- Modify ParseSyntaxOnlyAction::ExecuteAction to report diagnostics

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

3 years agoFix "not all control paths return a value" warning. NFCI.
Simon Pilgrim [Wed, 27 Jan 2021 10:14:54 +0000 (10:14 +0000)]
Fix "not all control paths return a value" warning. NFCI.

3 years ago[AMDGPU] Write "GFX6-GFX9" instead of "GFX6-9" in docs
Jay Foad [Tue, 26 Jan 2021 17:45:41 +0000 (17:45 +0000)]
[AMDGPU] Write "GFX6-GFX9" instead of "GFX6-9" in docs

... and similarly for some other cases. This is for consistency and to
make it easier to search for mentions of a particular architecture.

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

3 years ago[ARM] Add neon FP16 scalar_to_vector patterns.
David Green [Wed, 27 Jan 2021 09:59:15 +0000 (09:59 +0000)]
[ARM] Add neon FP16 scalar_to_vector patterns.

This adds some simple fp16 scalar_to_vector patterns, preventing a
selection failure if this came up.

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

3 years ago[Test][AArch64] Use named vregs in overflow legalization tests. NFC
Cassie Jones [Wed, 27 Jan 2021 08:04:18 +0000 (03:04 -0500)]
[Test][AArch64] Use named vregs in overflow legalization tests. NFC

3 years ago[AArch64][GlobalISel] Make G_SADDE and G_SSUBE legal
Cassie Jones [Wed, 27 Jan 2021 09:36:12 +0000 (04:36 -0500)]
[AArch64][GlobalISel] Make G_SADDE and G_SSUBE legal

This makes G_SADDE and G_SSUBE legal in preparation for further work
legalizing overflowing operations. It's fine that they don't have an
instruction selector implementation yet, because G_UADDE and G_USUBE are
already legal on AArch64 without an instruction selector implementation. This
completes the set of G_[SU]{ADD,SUB}[EO] operations on AArch64.

Reviewed By: paquette

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

3 years ago[clang] Fix signedness in vector bitcast evaluation
Sven van Haastregt [Wed, 27 Jan 2021 09:30:26 +0000 (09:30 +0000)]
[clang] Fix signedness in vector bitcast evaluation

The included test case triggered a sign assertion on the result in
`Success()`.  This was caused by the APSInt created for a bitcast
having its signedness bit inverted.  The second APSInt constructor
argument is `isUnsigned`, so invert the result of
`isSignedIntegerType`.

Relanding this patch after reverting.  The test case had to be updated
to be insensitive to 32/64-bit extractelement indices.

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

3 years ago[libc][NFC] Use a end of list marker for cpu feature detection.
Siva Chandra Reddy [Wed, 27 Jan 2021 09:18:58 +0000 (01:18 -0800)]
[libc][NFC] Use a end of list marker for cpu feature detection.

Without this, the array can end up being an empty array leading to
compiler failures.

3 years ago[OpenMP] libomp: fix build by clang-cl with vs2019
AndreyChurbanov [Wed, 27 Jan 2021 09:18:15 +0000 (12:18 +0300)]
[OpenMP] libomp: fix build by clang-cl with vs2019

Problem reported by Joseph Shen <joseph.smeng@gmail.com>.
The patch changes *(&<atomic-var>) to (&<atomic-var>)->load().

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

3 years ago[clang][cli] Port LangOpts to marshalling system, pt.2
Jan Svoboda [Wed, 27 Jan 2021 08:00:16 +0000 (09:00 +0100)]
[clang][cli] Port LangOpts to marshalling system, pt.2

Port some miscellaneous language options to the marshalling system for oautomatic command line parsing and generation.

Reviewed By: dexonsmith

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

3 years ago[mlir] Extend semantic of OffsetSizeAndStrideOpInterface.
Nicolas Vasilache [Wed, 27 Jan 2021 08:06:40 +0000 (08:06 +0000)]
[mlir] Extend semantic of OffsetSizeAndStrideOpInterface.

OffsetSizeAndStrideOpInterface now have the ability to specify only a leading subset of
offset, sizes, strides operands/attributes.
The size of that leading subset must be limited by the corresponding entry in `getArrayAttrMaxRanks` to avoid overflows.
Missing trailing dimensions are assumed to span the whole range (i.e. [0 .. dim)).
This brings more natural semantics to slice-like op on top of subview and is a simplifies to removing all uses of SliceOp in dependent projects.

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

3 years agoFix an error about implicit fallthrough during self build - new tag for ittapi.
Alexey Bader [Wed, 27 Jan 2021 05:53:38 +0000 (08:53 +0300)]
Fix an error about implicit fallthrough during self build - new tag for ittapi.

A fix has been implemented in the ittap repo to fix an error about implicit fallthrough in a switch that was occurring during self build.
A new tag has been created for that fix. This is to update the tag.

Reviewed By: bader

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

Patch by Zahira Ammarguellat.

3 years ago[clang-format] Avoid considering include directive as a template closer.
Marek Kurdej [Wed, 27 Jan 2021 08:14:22 +0000 (09:14 +0100)]
[clang-format] Avoid considering include directive as a template closer.

This fixes a bug [[ http://llvm.org/PR48891 | PR48891 ]] introduced in D93839 where:
```
#include <stdint.h>
namespace rep {}
```
got formatted as
```
#include <stdint.h>
namespace rep {
}
```

Reviewed By: MyDeveloperDay, leonardchan

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

3 years ago[clang][cli] Port LangOpts to marshalling system, pt.1
Jan Svoboda [Wed, 27 Jan 2021 07:47:54 +0000 (08:47 +0100)]
[clang][cli] Port LangOpts to marshalling system, pt.1

Port some miscellaneous language options to the marshalling system for oautomatic command line parsing and generation.

Reviewed By: dexonsmith

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

3 years ago[mlir][Linalg] Add canonicalization for init_tensor -> subtensor op.
MaheshRavishankar [Wed, 27 Jan 2021 07:21:33 +0000 (23:21 -0800)]
[mlir][Linalg] Add canonicalization for init_tensor -> subtensor op.

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

3 years ago[llvm-objdump] Use append_range (NFC)
Kazu Hirata [Wed, 27 Jan 2021 04:00:19 +0000 (20:00 -0800)]
[llvm-objdump] Use append_range (NFC)

3 years ago[MemorySSA] Use ListSeparator (NFC)
Kazu Hirata [Wed, 27 Jan 2021 04:00:17 +0000 (20:00 -0800)]
[MemorySSA] Use ListSeparator (NFC)

3 years ago[AMDGPU] Forward-declare TargetRegisterClass (NFC)
Kazu Hirata [Wed, 27 Jan 2021 04:00:16 +0000 (20:00 -0800)]
[AMDGPU] Forward-declare TargetRegisterClass (NFC)

AMDGPUInstructionSelector.h needs TargetRegisterClass but relies on a
forward declaration of TargetRegisterClass in InstructionSelector.h.
This patch adds a forward declaration right in
AMDGPUInstructionSelector.h.

While we are at it, this patch removes the one in
InstructionSelector.h, where it is unnecessary.

3 years ago[TableGen] Add isContradictoryImpl implementation to CheckCondCodeMatcher and CheckCh...
Craig Topper [Wed, 27 Jan 2021 03:41:52 +0000 (19:41 -0800)]
[TableGen] Add isContradictoryImpl implementation to CheckCondCodeMatcher and CheckChild2CondCodeMatcher.

This enables better pattern factoring in the RISCV ISel table.

3 years agoBump the trunk major version to 13 llvmorg-13-init
Tom Stellard [Wed, 27 Jan 2021 03:37:08 +0000 (19:37 -0800)]
Bump the trunk major version to 13

and clear the release notes.

3 years agoFrontend: Use early returns in CompilerInstance::clearOutputFiles, NFC
Duncan P. N. Exon Smith [Wed, 27 Jan 2021 03:27:32 +0000 (19:27 -0800)]
Frontend: Use early returns in CompilerInstance::clearOutputFiles, NFC

Use early returns in `CompilerInstance::clearOutputFiles` to clarify the
logic, and rename `ec` to `EC` as a drive-by.

No functionality change.

3 years agoRename clang/test/Frontend/output-{failures,paths}.c, NFC
Duncan P. N. Exon Smith [Wed, 27 Jan 2021 03:26:24 +0000 (19:26 -0800)]
Rename clang/test/Frontend/output-{failures,paths}.c, NFC

A follow up patch will add a few success cases here; rename it to
`output-paths.c` instead of `output-failures.c`.

3 years ago[gn build] Port bb9eb1982980
LLVM GN Syncbot [Wed, 27 Jan 2021 01:23:23 +0000 (01:23 +0000)]
[gn build] Port bb9eb1982980

3 years ago[OpenMP][NVPTX] Drop dependence on CUDA to build NVPTX `deviceRTLs`
Shilei Tian [Wed, 27 Jan 2021 01:21:27 +0000 (20:21 -0500)]
[OpenMP][NVPTX] Drop dependence on CUDA to build NVPTX `deviceRTLs`

With D94745, we no longer use CUDA SDK to compile `deviceRTLs`. Therefore,
many CMake code in the project is useless. This patch cleans up unnecessary code
and also drops the requirement to build NVPTX `deviceRTLs`. CUDA detection is
still being used however to determine whether we need to involve the tests. Auto
detection of compute capability is enabled by default and can be disabled by
setting CMake variable `LIBOMPTARGET_NVPTX_AUTODETECT_COMPUTE_CAPABILITY=OFF`.
If auto detection is enabled, and CUDA is also valid, it will only build the
bitcode library for the detected version; otherwise, all variants supported will
be generated. One drawback of this patch is, we now generate 96 variants of
bitcode library, and totally 1485 files to be built with a clean build on a
non-CUDA system. `LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=""` can be used to
disable building NVPTX `deviceRTLs`.

Reviewed By: JonChesterfield

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

3 years ago[RISCV] Add rv64 run lines to rv32 MC layer tests for B extension
Craig Topper [Wed, 27 Jan 2021 01:03:21 +0000 (17:03 -0800)]
[RISCV] Add rv64 run lines to rv32 MC layer tests for B extension

Remove common instructions from rv64 tests since they are now
covered by the rv64 run lines in the rv32 tests.

Add rv32-only* tests for a few cases that aren't common between
r32 and rv64.

Addresses review feedback from D95150.

Reviewed By: frasercrmck

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

3 years agoSupport for instrumenting only selected files or functions
Petr Hosek [Fri, 15 Jan 2021 09:14:37 +0000 (01:14 -0800)]
Support for instrumenting only selected files or functions

This change implements support for applying profile instrumentation
only to selected files or functions. The implementation uses the
sanitizer special case list format to select which files and functions
to instrument, and relies on the new noprofile IR attribute to exclude
functions from instrumentation.

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

3 years ago[libc++] Give `MoveOnly` all six comparison operators, not just == and <.
Arthur O'Dwyer [Mon, 25 Jan 2021 22:00:14 +0000 (17:00 -0500)]
[libc++] Give `MoveOnly` all six comparison operators, not just == and <.

Split out of D93512.

3 years ago[OpenMP] Modify OMP_ALLOCATOR environment variable
Nawrin Sultana [Mon, 2 Nov 2020 22:17:37 +0000 (16:17 -0600)]
[OpenMP] Modify OMP_ALLOCATOR environment variable

This patch sets the def-allocator-var ICV based on the environment variables
provided in OMP_ALLOCATOR. Previously, only allowed value for OMP_ALLOCATOR
was a predefined memory allocator. OpenMP 5.1 specification allows predefined
memory allocator, predefined mem space, or predefined mem space with traits in
OMP_ALLOCATOR. If an allocator can not be created using the provided environment
variables, the def-allocator-var is set to omp_default_mem_alloc.

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

3 years ago[libomptarget][cuda] Handle missing _v2 symbols gracefully
Jon Chesterfield [Wed, 27 Jan 2021 00:22:28 +0000 (00:22 +0000)]
[libomptarget][cuda] Handle missing _v2 symbols gracefully

[libomptarget][cuda] Handle missing _v2 symbols gracefully

Follow on from D95367. Dlsym the _v2 symbols if present, otherwise use the
unsuffixed version. Builds a hashtable for the check, can revise for zero
heap allocations later if necessary.

Reviewed By: jdoerfert

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

3 years ago[gn build] fix get.py change
Nico Weber [Wed, 27 Jan 2021 00:20:23 +0000 (19:20 -0500)]
[gn build] fix get.py change

3 years ago[gn build] restore build command removed in 9595a7ff55b6 for platforms without prebuilts
Nico Weber [Wed, 27 Jan 2021 00:19:19 +0000 (19:19 -0500)]
[gn build] restore build command removed in 9595a7ff55b6 for platforms without prebuilts

3 years agoDisable rosegment for old Android versions.
Dan Albert [Wed, 27 Jan 2021 00:04:56 +0000 (16:04 -0800)]
Disable rosegment for old Android versions.

The unwinder used by the crash handler on versions of Android prior to
API 29 did not correctly handle binaries built with rosegment, which is
enabled by default for LLD. Android only supports LLD, so it's not an
issue that this flag is not accepted by other linkers.

Reviewed By: srhines

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

3 years agollvm-lib: Pull error printing code out of two functions
Nico Weber [Wed, 27 Jan 2021 00:11:56 +0000 (19:11 -0500)]
llvm-lib: Pull error printing code out of two functions

Slightly changes the output in error code, but no behavior change in
normal use. This is for preparation for using these two functions
elsewhere.

3 years ago[libomptarget][NFC] Avoid gcc 5/6 issue with lambda captures.
Vyacheslav Zakharin [Tue, 26 Jan 2021 22:45:40 +0000 (14:45 -0800)]
[libomptarget][NFC] Avoid gcc 5/6 issue with lambda captures.

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

3 years agoFrontend: Fix layering between create{,Default}OutputFile, NFC
Duncan P. N. Exon Smith [Sat, 21 Nov 2020 02:04:32 +0000 (18:04 -0800)]
Frontend: Fix layering between create{,Default}OutputFile, NFC

Fix layering between `CompilerInstance::createDefaultOutputFile` and the
two versions of `createOutputFile`.

- Add missing configuration flags to `createDefaultOutputFile` so that
  GeneratePCHAction and GenerateModuleFromModuleMapAction can use it.
  They previously promised that temporary files were turned on; now
  `createDefaultOutputFile` handles that logic.
- Lift the logic handling `InFile` and `Extension` to
  `createDefaultOutputFile`, since it's only the callers of that
  function that are using it.
- Rename the deeper of the two `createOutputFile`s to
  `createOutputFileImpl` and make it private to `CompilerInstance` (to
  prove that no one else is using it).
- Sink the logic for adding to `CompilerInstance::OutputFiles` down to
  `createOutputFileImpl`, allowing two "optional" (but always used)
  `std::string*` out parameters to be removed.
- Instead of passing a `std::error_code` out parameter into
  `createOutputFileImpl`, have it return `Expected<>`.
- As a drive-by, inline `CompilerInstance::addOutputFile` into its only
  caller, `createOutputFileImpl`.

Clean layering makes it easier for a future commit to extract
`createOutputFileImpl` out of `CompilerInstance`.

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

3 years ago[llc] Add reportError helper and canonicalize error messages
Fangrui Song [Tue, 26 Jan 2021 23:33:37 +0000 (15:33 -0800)]
[llc] Add reportError helper and canonicalize error messages

3 years agoFrontend: Simplify handling of non-seeking streams in CompilerInstance, NFC
Duncan P. N. Exon Smith [Tue, 15 Dec 2020 01:46:11 +0000 (17:46 -0800)]
Frontend: Simplify handling of non-seeking streams in CompilerInstance, NFC

Add a new `raw_pwrite_ostream` variant, `buffer_unique_ostream`, which
is like `buffer_ostream` but with unique ownership of the stream it's
wrapping. Use this in CompilerInstance to simplify the ownership of
non-seeking output streams, avoiding logic sprawled around to deal with
them specially.

This also simplifies future work to encapsulate output files in a
different class.

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

3 years ago[GlobalISel] Implement computeKnownBits for G_SEXT_INREG
Jessica Paquette [Tue, 26 Jan 2021 22:39:39 +0000 (14:39 -0800)]
[GlobalISel] Implement computeKnownBits for G_SEXT_INREG

Just use the existing `Known.sextInReg` implementation.

- Update KnownBitsTest.cpp.
- Update combine-redundant-and.mir for a more concrete example.

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

3 years agoSalvage debug info for function arguments in coro-split funclets.
Adrian Prantl [Tue, 26 Jan 2021 22:30:10 +0000 (14:30 -0800)]
Salvage debug info for function arguments in coro-split funclets.

This patch improves the availability for variables stored in the
coroutine frame by emitting an alloca to hold the pointer to the frame
object and rewriting dbg.declare intrinsics to point inside the frame
object using salvaged DIExpressions. Finally, a new alloca is created
in the funclet to hold the FramePtr pointer to ensure that it is
available throughout the entire function at -O0.

This path also effectively reverts D90772. The testcase updates
highlight nicely how every removed CHECK for a dbg.value is preceded
by a new CHECK for a dbg.declare.

Thanks to JunMa, Yifeng, and Bruno for their thoughtful reviews!

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

rdar://71866936

3 years agoFrontend: Fix memory leak in CompilerInstance::setVerboseOutputStream
Duncan P. N. Exon Smith [Sat, 21 Nov 2020 03:13:19 +0000 (19:13 -0800)]
Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream

Found this memory leak in `CompilerInstance::setVerboseOutputStream` by
inspection; it looks like this wasn't previously exercised, since it was
never called twice.

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

3 years ago[ARM] Fix STRT/STRHT/STRBT input/output operands.
Zhuojia Shen [Tue, 26 Jan 2021 22:00:58 +0000 (14:00 -0800)]
[ARM] Fix STRT/STRHT/STRBT input/output operands.

STRT, STRHT, and STRBT are store instructions and their source register
$Rt should be treated as an input operand instead of an output operand.
This should fix things (e.g., liveness tracking in LivePhysRegs) if
these instructions were used in CodeGen.

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

3 years ago[NewPM] Add ExtraVectorizerPasses support
Bjorn Pettersson [Fri, 22 Jan 2021 23:54:04 +0000 (00:54 +0100)]
[NewPM] Add ExtraVectorizerPasses support

As it looks like NewPM generally is using SimpleLoopUnswitch
instead of LoopUnswitch, this patch also use SimpleLoopUnswitch
in the ExtraVectorizerPasses sequence (compared with LegacyPM
which use the LoopUnswitch pass).

Reviewed By: aeubanks

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

3 years ago[libomptarget][NFC] Use portable printf format specifiers.
Vyacheslav Zakharin [Tue, 26 Jan 2021 21:52:53 +0000 (13:52 -0800)]
[libomptarget][NFC] Use portable printf format specifiers.

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

3 years ago[InstCombine] Preserve FMF for powi simplifications.
Valery N Dmitriev [Tue, 26 Jan 2021 19:05:16 +0000 (11:05 -0800)]
[InstCombine] Preserve FMF for powi simplifications.

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

3 years ago[NFC] Show instcombine powi simplifications drop FMF
Valery N Dmitriev [Tue, 26 Jan 2021 18:59:27 +0000 (10:59 -0800)]
[NFC] Show instcombine powi simplifications drop FMF

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

3 years ago[X86] In shrinkAndImmediate, place the new constant into the topological sort.
Craig Topper [Tue, 26 Jan 2021 19:28:25 +0000 (11:28 -0800)]
[X86] In shrinkAndImmediate, place the new constant into the topological sort.

Revert the change to use APInt::isSignedIntN from
5ff5cf8e057782e3e648ecf5ccf1d9990b53ee90.

Its clear that the games we were playing to avoid the topological
sort aren't working. So just fix it once and for all.

Fixes PR48888.

3 years ago[NFC][lit] Cleanup code using string interpolation
Julian Lettner [Tue, 26 Jan 2021 18:54:16 +0000 (10:54 -0800)]
[NFC][lit] Cleanup code using string interpolation

LLVM now requires Python 3.6, so we can use string interpolation to make
code more readable.

3 years ago[GlobalISel][IRTranslator] Ignore the llvm.experimental.noalias.scope.decl intrinsic.
Amara Emerson [Tue, 26 Jan 2021 20:54:41 +0000 (12:54 -0800)]
[GlobalISel][IRTranslator] Ignore the llvm.experimental.noalias.scope.decl intrinsic.

These don't generate any code.

3 years ago[OpenMP][Libomptarget] Fix cmake error on remote plugin
Atmn Patel [Tue, 26 Jan 2021 20:56:48 +0000 (15:56 -0500)]
[OpenMP][Libomptarget] Fix cmake error on remote plugin

Requiring 3.15 causes a build breakage, I'm sure none of the contents actually require
3.15 or above.

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

3 years ago[gn build] Port 1e634f3952aa
LLVM GN Syncbot [Tue, 26 Jan 2021 20:48:31 +0000 (20:48 +0000)]
[gn build] Port 1e634f3952aa

3 years ago[llvm-elfabi] Fix test after D95140
Fangrui Song [Tue, 26 Jan 2021 20:45:45 +0000 (12:45 -0800)]
[llvm-elfabi] Fix test after D95140

3 years ago[libomptarget][cuda] Gracefully handle missing cuda library
Jon Chesterfield [Tue, 26 Jan 2021 20:43:06 +0000 (20:43 +0000)]
[libomptarget][cuda] Gracefully handle missing cuda library

[libomptarget][cuda] Gracefully handle missing cuda library

If using dynamic cuda, and it failed to load, it is not safe to call
cuGetErrorString.

Reviewed By: jdoerfert

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