platform/upstream/llvm.git
3 years ago[NFC] Replace loop by idiomatic llvm::find_if
serge-sans-paille [Tue, 16 Mar 2021 11:48:25 +0000 (12:48 +0100)]
[NFC] Replace loop by idiomatic llvm::find_if

3 years ago[CodeCompletion] Avoid spurious signature help for init-list args
Sam McCall [Fri, 12 Mar 2021 11:00:54 +0000 (12:00 +0100)]
[CodeCompletion] Avoid spurious signature help for init-list args

Somewhat surprisingly, signature help is emitted as a side-effect of
computing the expected type of a function argument.
The reason is that both actions require enumerating the possible
function signatures and running partial overload resolution, and doing
this twice would be wasteful and complicated.

Change #1: document this, it's subtle :-)

However, sometimes we need to compute the expected type without having
reached the code completion cursor yet - in particular to allow
completion of designators.
eb4ab3358cd4dc834a761191b5531b38114f7b13 did this but introduced a
regression - it emits signature help in the wrong location as a side-effect.

Change #2: only emit signature help if the code completion cursor was reached.

Currently there is PP.isCodeCompletionReached(), but we can't use it
because it's set *after* running code completion.
It'd be nice to set this implicitly when the completion token is lexed,
but ConsumeCodeCompletionToken() makes this complicated.

Change #3: call cutOffParsing() *first* when seeing a completion token.

After this, the fact that the Sema::Produce*SignatureHelp() functions
are even more confusing, as they only sometimes do that.
I don't want to rename them in this patch as it's another large
mechanical change, but we should soon.

Change #4: prepare to rename ProduceSignatureHelp() to GuessArgumentType() etc.

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

3 years ago[TableGen/GlobalISel] Emit MI_predicate custom code for PatFrags (not only PatFrag)
Bjorn Pettersson [Fri, 12 Mar 2021 11:24:43 +0000 (12:24 +0100)]
[TableGen/GlobalISel] Emit MI_predicate custom code for PatFrags (not only PatFrag)

When GlobalISelEmitter::emitCxxPredicateFns emitted code for MI
predicates it used "PatFrag" when searching for definitions. With
this patch it will search for all "PatFrags" instead. Since PatFrag
derives from PatFrags the difference is that we now include all
definitions using PatFrags directly as well. Thus making it possible
to use GISelPredicateCode together with a PatFrags definition.

It might be noted that the matcher code was emitted also for PatFrags
in the past. But then one ended up with errors since the custom code
in testMIPredicate_MI was missing.

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

3 years ago[SLP] improve readability in reduction logic; NFC
Sanjay Patel [Tue, 16 Mar 2021 10:53:08 +0000 (06:53 -0400)]
[SLP] improve readability in reduction logic; NFC

We had 2 different and ambiguously-named 'I' variables.

3 years ago[clangd] Add `limit` extension on completion and workspace-symbols
Sam McCall [Tue, 2 Mar 2021 21:16:29 +0000 (22:16 +0100)]
[clangd] Add `limit` extension on completion and workspace-symbols

This overrides the --limit-results command-line flag, and is not constrained
by it.
See https://github.com/clangd/clangd/issues/707

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

3 years ago[clangd] Turn off implicit cancellation based on client capabilities
Sam McCall [Thu, 11 Mar 2021 12:43:59 +0000 (13:43 +0100)]
[clangd] Turn off implicit cancellation based on client capabilities

Capability is in upcoming 3.17: https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/

(This is also useful for C++ embedders)

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

3 years ago[test] Make sure the test program in GetErrcMessages.cmake exits normally.
Markus Böck [Tue, 16 Mar 2021 11:13:31 +0000 (12:13 +0100)]
[test] Make sure the test program in GetErrcMessages.cmake exits normally.

If for some reason the test program does not exit normally it'd currently lead to a false positive and it's stdout output being assigned to the output variable.

Instead, check the test program exited normally before assigning the process output to the out variable.

Follow up on rGaf2796c76d2ff4b73165ed47959afd35a769beee
Fixes an issue discovered post commit in https://reviews.llvm.org/D98278

3 years ago[clangd] Reject renames to non-identifier characters
Sam McCall [Thu, 11 Mar 2021 12:56:24 +0000 (13:56 +0100)]
[clangd] Reject renames to non-identifier characters

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

3 years ago[CodeCompletion] Don't track preferred types if code completion is disabled.
Sam McCall [Thu, 11 Mar 2021 23:01:25 +0000 (00:01 +0100)]
[CodeCompletion] Don't track preferred types if code completion is disabled.

Some of this work isn't quite trivial.

(As requested in D96058)

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

3 years ago[sanitizer][NFC] Don't inherit InternalMmapVector
Vitaly Buka [Tue, 16 Mar 2021 10:55:29 +0000 (03:55 -0700)]
[sanitizer][NFC] Don't inherit InternalMmapVector

3 years ago[AMDGPU][MC] Disabled lds_direct for GFX90a
Dmitry Preobrazhensky [Tue, 16 Mar 2021 10:51:03 +0000 (13:51 +0300)]
[AMDGPU][MC] Disabled lds_direct for GFX90a

Fixed bug 49382.

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

3 years ago[test][NFC] Minor formatting and comment adjustments in GetErrcMessages.cmake
Markus Böck [Tue, 16 Mar 2021 10:05:48 +0000 (11:05 +0100)]
[test][NFC] Minor formatting and comment adjustments in GetErrcMessages.cmake

These changes address post-commit review comments discussed in https://reviews.llvm.org/D98278

3 years ago[mlir]: Add canonicalization for dim of 1D alloc of size rank.
Adrian Kuegel [Wed, 3 Mar 2021 08:47:24 +0000 (09:47 +0100)]
[mlir]: Add canonicalization for dim of 1D alloc of size rank.

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

3 years ago[flang] Save AllocateObject and PointerObject analyzed expression
Jean Perier [Tue, 16 Mar 2021 08:47:35 +0000 (09:47 +0100)]
[flang] Save AllocateObject and PointerObject analyzed expression

`parser::AllocateObject` and `parser::PointerObject` can be represented
as typed expressions once analyzed. This simplifies the work for parse-tree
consumers that work with typed expressions to deal with allocatable and
pointer objects such as lowering.

This change also makes it easier to add typedExpr in the future by
automatically handling nodes that have this member when possible.

Changes:

- Add a `mutable TypedExpr typedExpr` field to `parser::PointerObject` and `parser::AllocateObject`.
- Add a `parser::HasTypedExpr<T>` helper to better share code relating to typedExpr in the parse tree.
- Add hooks in `semantics::ExprChecker` for AllocateObject and PointerObject nodes, and use
  ExprOrVariable on it to analyze and set the tyedExpr field during
  expression analysis. This required adding overloads for `AssumedTypeDummy`.
- Update check-nullify.cpp and check-deallocate.cpp to not re-analyze the StructureComponent but to
  use the typedExpr field instead.
- Update dump/unparse to use HasTypedExpr and use the typedExpr when there is one.

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

3 years ago[lit] Sort test start times based on prior test timing data
David Zarzycki [Wed, 10 Mar 2021 15:19:15 +0000 (10:19 -0500)]
[lit] Sort test start times based on prior test timing data

Lit as it exists today has three hacks that allow users to run tests earlier:

1) An entire test suite can set the `is_early` boolean.
2) A very recently introduced "early_tests" feature.
3) The `--incremental` flag forces failing tests to run first.

All of these approaches have problems.

1) The `is_early` feature was until very recently undocumented. Nevertheless it still lacks testing and is a imprecise way of optimizing test starting times.
2) The `early_tests` feature requires manual updates and doesn't scale.
3) `--incremental` is undocumented, untested, and it requires modifying the *source* file system by "touching" the file. This "touch" based approach is arguably a hack because it confuses editors (because it looks like the test was modified behind the back of the editor) and "touching" the test source file doesn't work if the test suite is read only from the perspective of `lit` (via advanced filesystem/build tricks).

This patch attempts to simplify and address all of the above problems.

This patch formalizes, documents, tests, and defaults lit to recording the execution time of tests and then reordering all tests during the next execution. By reordering the tests, high core count machines run faster, sometimes significantly so.

This patch also always runs failing tests first, which is a positive user experience win for those that didn't know about the hidden `--incremental` flag.

Finally, if users want, they can _optionally_ commit the test timing data (or a subset thereof) back to the repository to accelerate bots and first-time runs of the test suite.

Reviewed By: jhenderson, yln

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

3 years ago[NFC] Wisely nest dyn_cast in FunctionLoweringInfo
serge-sans-paille [Tue, 16 Mar 2021 09:11:57 +0000 (10:11 +0100)]
[NFC] Wisely nest dyn_cast in FunctionLoweringInfo

Take advantage of the inheritance tree to avoid a few comparison.

3 years ago[SVE][LoopVectorize] Add support for scalable vectorization of loops with vector...
Caroline Concatto [Tue, 19 Jan 2021 11:30:50 +0000 (11:30 +0000)]
[SVE][LoopVectorize] Add support for scalable vectorization of loops with vector reverse

This patch adds support for reverse loop vectorization.
It is possible to vectorize the following loop:
```
  for (int i = n-1; i >= 0; --i)
    a[i] = b[i] + 1.0;
```
with fixed or scalable vector.
The loop-vectorizer will use 'reverse' on the loads/stores to make
sure the lanes themselves are also handled in the right order.
This patch adds support for scalable vector on IRBuilder interface to
create a reverse vector. The IR function
CreateVectorReverse lowers to experimental.vector.reverse for scalable vector
and keedp the original behavior for fixed vector using shuffle reverse.

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

3 years agoscf::ForOp: Fold away iterator arguments with no use and for which the corresponding...
Lorenzo Chelini [Tue, 16 Mar 2021 06:46:10 +0000 (06:46 +0000)]
scf::ForOp: Fold away iterator arguments with no use and for which the corresponding input is yielded

Enhance 'ForOpIterArgsFolder' to remove unused iteration arguments in a
scf::ForOp. If the block argument corresponding to the given iterator has no
use and the yielded value equals the input, we fold it away.

Reviewed By: nicolasvasilache

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

3 years ago[RISCV] Don't emit #undef BUILTIN from RISCVVEmitter.cpp
Jim Lin [Tue, 16 Mar 2021 06:57:45 +0000 (14:57 +0800)]
[RISCV] Don't emit #undef BUILTIN from RISCVVEmitter.cpp

In BuiltinsRISCV.def, other extension 's intrinsics need to be defined by using macro BUILTIN.
So, it shouldn't undefine macro BUILTIN in the end of declaration for V intrinsics.

Reviewed By: craig.topper

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

3 years ago[AArch64][GlobalISel] Fix crash on lowering <1 x half> types.
Amara Emerson [Tue, 16 Mar 2021 06:27:10 +0000 (23:27 -0700)]
[AArch64][GlobalISel] Fix crash on lowering <1 x half> types.

3 years ago[AArch64][ASAN] Disable fgets_fputs.cpp test.
Yvan Roux [Tue, 16 Mar 2021 06:00:19 +0000 (07:00 +0100)]
[AArch64][ASAN] Disable fgets_fputs.cpp test.

This test is failing for long a time on AArch64 bots, disable it for now
to keep the bots green while investigating it.

3 years ago[OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn
Pushpinder Singh [Tue, 16 Mar 2021 04:54:21 +0000 (04:54 +0000)]
[OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

Remove emit-llvm-bc from addClangTargetOptions as it conflicts with -E for save-temps.

AMDGCN does not yet support linking object files so backend and assemble actions are
skipped, leaving LLVM IR as the output format.

Reviewed By: JonChesterfield, ronlieb

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

3 years ago[CSSPGO][llvm-profgen] Fix getCanonicalFnName usage in llvm-profgen
wlei [Thu, 4 Mar 2021 04:37:19 +0000 (20:37 -0800)]
[CSSPGO][llvm-profgen] Fix getCanonicalFnName usage in llvm-profgen

Previously we didn't support to keep the unique linkage name(-funique-internal-linkage-name) in llvm-profgen. As discussed in https://reviews.llvm.org/D96932, we choose to do canonicalization for it.

Now since "selected" is set as the default parameter of getCanonicalFnName in `D96932`, we don't need to add any attribute here for the previous usage and only fix the missing usage in the pseudo probe decoding.

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

3 years ago[OpenMP][FIX] Repair accidental replacement of _shfl_sync with _shfl
Johannes Doerfert [Tue, 16 Mar 2021 02:52:38 +0000 (21:52 -0500)]
[OpenMP][FIX] Repair accidental replacement of _shfl_sync with _shfl

This was broken accidentally in D95752.

Reviewed By: ye-luo

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

3 years ago[NVPTX] CUDA does provide malloc/free since compute capability 2.X
Johannes Doerfert [Sun, 14 Mar 2021 17:27:42 +0000 (12:27 -0500)]
[NVPTX] CUDA does provide malloc/free since compute capability 2.X

https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#dynamic-global-memory-allocation-and-operations

Reviewed By: tra

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

3 years ago[OCaml][test] Fix Bindings/OCaml/executionengine.ml test
Josh Berdine [Sat, 13 Mar 2021 23:29:36 +0000 (23:29 +0000)]
[OCaml][test] Fix Bindings/OCaml/executionengine.ml test

It seems that at some point it became necessary to pass `-thread` to
the ocaml compiler for this test.

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

3 years ago[gn build] Port 4f198b0c27b0
LLVM GN Syncbot [Tue, 16 Mar 2021 02:41:16 +0000 (02:41 +0000)]
[gn build] Port 4f198b0c27b0

3 years ago[X86] Pass to transform amx intrinsics to scalar operation.
Bing1 Yu [Tue, 16 Mar 2021 01:44:42 +0000 (09:44 +0800)]
[X86] Pass to transform amx intrinsics to scalar operation.

This pass runs in any situations but we skip it when it is not O0 and the
function doesn't have optnone attribute. With -O0, the def of shape to amx
intrinsics is near the amx intrinsics code. We are not able to find a
point which post-dominate all the shape and dominate all amx intrinsics.
To decouple the dependency of the shape, we transform amx intrinsics
to scalar operation, so that compiling doesn't fail. In long term, we
 should improve fast register allocation to allocate amx register.

Reviewed By: pengfei

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

3 years agoSkip path separators to make the test portable across Win/Linux
David Blaikie [Tue, 16 Mar 2021 00:08:37 +0000 (17:08 -0700)]
Skip path separators to make the test portable across Win/Linux

3 years ago[mlir][amx] Add Intel AMX dialect (architectural-specific vector dialect)
Aart Bik [Mon, 15 Mar 2021 22:32:57 +0000 (15:32 -0700)]
[mlir][amx] Add Intel AMX dialect (architectural-specific vector dialect)

The Intel Advanced Matrix Extensions (AMX) provides a tile matrix
multiply unit (TMUL), a tile control register (TILECFG), and eight
tile registers TMM0 through TMM7 (TILEDATA). This new MLIR dialect
provides a bridge between MLIR concepts like vectors and memrefs
and the lower level LLVM IR details of AMX.

Reviewed By: nicolasvasilache

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

3 years agoFix 34885bffdf43920c0f011e17a65fd678100240dd
Walter Erquinigo [Mon, 15 Mar 2021 23:35:49 +0000 (16:35 -0700)]
Fix 34885bffdf43920c0f011e17a65fd678100240dd

It failed https://lab.llvm.org/buildbot/#/builders/17/builds/5262 and
the fix is simply to relax a regex expression in a test.

3 years ago[CMake] Clean up unnecessary dependency
Petr Hosek [Mon, 15 Mar 2021 23:26:18 +0000 (16:26 -0700)]
[CMake] Clean up unnecessary dependency

The LINK_COMPONENTS dependency between DebugInfoCodeView and
DebugInfoMSF is unnecessary. Breaking them would allow a more
fine-controlled distribution.

Patch By: dangyi

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

3 years ago[libomptarget] Build amdgcn devicertl by default
Jon Chesterfield [Mon, 15 Mar 2021 23:17:49 +0000 (23:17 +0000)]
[libomptarget] Build amdgcn devicertl by default

[libomptarget] Build amdgcn devicertl by default

The cmake for this looks for an llvm install and does the right thing when
building as part of enable_runtimes. It will probably do the right thing
in other settings - at least, it won't try to build this with gcc.

Reviewed By: jdoerfert

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

3 years ago[gn build] Port ecf6466f01c5
LLVM GN Syncbot [Mon, 15 Mar 2021 23:01:19 +0000 (23:01 +0000)]
[gn build] Port ecf6466f01c5

3 years ago[JITLink][MachO][x86-64] Introduce generic x86-64 support.
Lang Hames [Mon, 15 Mar 2021 21:56:29 +0000 (14:56 -0700)]
[JITLink][MachO][x86-64] Introduce generic x86-64 support.

This patch introduces generic x86-64 edge kinds, and refactors the MachO/x86-64
backend to use these edge kinds. This simplifies the implementation of the
MachO/x86-64 backend and makes it possible to write generic x86-64 passes and
utilities.

The new edge kinds are different from the original set used in the MachO/x86-64
backend. Several edge kinds that were not meaningfully distinguished in that
backend (e.g. the PCRelMinusN edges) have been merged into single edge kinds in
the new scheme (these edge kinds can be reintroduced later if we find a use for
them). At the same time, new edge kinds have been introduced to convey extra
information about the state of the graph. E.g. The Request*AndTransformTo**
edges represent GOT/TLVP relocations prior to synthesis of the GOT/TLVP
entries, and the 'Relaxable' suffix distinguishes edges that are candidates for
optimization from edges which should be left as-is (e.g. to enable runtime
redirection).

ELF/x86-64 will be refactored to use these generic edges at some point in the
future, and I anticipate a similar refactor to create a generic arm64 support
header too.

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

3 years ago[flang] Create intrinsics modules directory (contd.)
Tim Keith [Mon, 15 Mar 2021 22:36:12 +0000 (15:36 -0700)]
[flang] Create intrinsics modules directory (contd.)

Use -module-dir rather than WORKING_DIRECTORY because we are potentially
creating the working directory in this custom command.

3 years agoEmit inline implementation of __builtin__wmemchr on MSVCRT platforms.
Amy Huang [Thu, 11 Mar 2021 00:36:07 +0000 (16:36 -0800)]
Emit inline implementation of __builtin__wmemchr on MSVCRT platforms.

The MSVC runtime library doesn't have a definition for wmemchr,
so provide an inline implementation.

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

3 years ago[gn build] merge af2796c76d2f a bit more
Nico Weber [Mon, 15 Mar 2021 22:20:15 +0000 (18:20 -0400)]
[gn build] merge af2796c76d2f a bit more

The default is fine on non-Win, but on Win this needs an explicit
setting now that lit no longer has the right default.

3 years ago[flang] Create intrinsics modules directory
Tim Keith [Mon, 15 Mar 2021 22:17:35 +0000 (15:17 -0700)]
[flang] Create intrinsics modules directory

A clean build fails using make because the intrinsics modules directory
doesn't exist. For some reason it works fine with ninja.

3 years ago[lldb-vscode] Handle request_evaluate's context attribute
Walter Erquinigo [Mon, 15 Mar 2021 18:58:19 +0000 (11:58 -0700)]
[lldb-vscode] Handle request_evaluate's context attribute

Summary:
The request "evaluate" supports a "context" attribute, which is sent by VSCode. The attribute is defined here https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Evaluate

The "clipboard" context is not yet supported by lldb-vscode, so we can forget about it for now. The 'repl' (i.e. Debug Console) and 'watch' (i.e. Watch Expression) contexts must use the expression parser in case the frame's variable path is not enough, as the user expects these expressions to never fail. On the other hand, the 'hover' expression is invoked whenever the user hovers on any keyword on the UI and the user is fine with the expression not being fully resolved, as they know that the 'repl' case is the fallback they can rely on.

Given that the 'hover' expression is invoked many many times without the user noticing it due to it being triggered by the mouse, I'm making it use only the frame's variable path functionality and not the expression parser. This should speed up tremendously the responsiveness of a debug session when the user only sets source breakpoints and inspect local variables, as the entire debug info is not needed to be parsed.

Regarding tests, I've tried to be as comprehensive as possible considering a multi-file project. Fortunately, the results from the "hover" case are enough most of the times.

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

3 years ago[OpenMP] Remove unused cpu_stackoffset member
Peyton, Jonathan L [Mon, 15 Mar 2021 21:48:22 +0000 (16:48 -0500)]
[OpenMP] Remove unused cpu_stackoffset member

3 years ago[DWARF] Check for AddrOffsetSectionBase to work with DWO Units.
Alexander Yermolovich [Mon, 15 Mar 2021 20:46:41 +0000 (13:46 -0700)]
[DWARF] Check for AddrOffsetSectionBase to work with DWO Units.

Context: https://lists.llvm.org/pipermail/llvm-dev/2021-February/148521.html

A fix for llvm-symbolizer, and other tools like BOLT, that allows retrieving address when built with -gsplit-dwarf=single mode.

Reviewed By: dblaikie

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

3 years ago[AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff...
diggerlin [Mon, 15 Mar 2021 21:32:03 +0000 (17:32 -0400)]
[AIX][XCOFF] Fixed the test case which failed at aix OS because enable -mignore-xcoff-visibility by default.

Summary:

because we enable -mignore-xcoff-visibility by default when there is no -fvisibility option in the clang in AIX OS
it will cause some test case fail at aix os. in order to let the -mignore-xcoff-visibility to be disable, we need to add the -fvisibility=default for those test case.

Reviewers: hubert.reinterpretcast daltenty
Differential Revision: https://reviews.llvm.org/D98660

3 years ago[NVPTX] Avoid temp copy of byval kernel parameters.
Artem Belevich [Fri, 5 Mar 2021 02:34:39 +0000 (18:34 -0800)]
[NVPTX] Avoid temp copy of byval kernel parameters.

Avoid making a temporary copy of byval argument if all accesses are loads and
therefore the pointer to the parameter can not escape.

This avoids excessive global memory accesses when each kernel makes its own
copy.

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

3 years agoNFC: Formatting changes.
Nick Lewycky [Mon, 15 Mar 2021 21:26:39 +0000 (14:26 -0700)]
NFC: Formatting changes.

Run clang-format over these files.

Capitalize some variable names per clang-tidy's request.

Pulled out to simplify review of D98302.

3 years ago[flang] Runtime: implement INDEX intrinsic function
peter klausler [Fri, 12 Mar 2021 21:40:31 +0000 (13:40 -0800)]
[flang] Runtime: implement INDEX intrinsic function

Implement INDEX in the runtime, reusing some infrastructure
(with generalization and renaming as needed) put into place
for its cousins SCAN and VERIFY.

I did not implement full Boyer-Moore substring searching
for the forward case, but did accelerate some advancement on
mismatches.

I (re)implemented unit testing for INDEX in the new gtest
framework, combining it with the tests that have recently
been ported to gtest for SCAN and VERIFY.

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

3 years ago[AMDGPU] Fix copyPhysReg to not produce unalined vgpr access
Stanislav Mekhanoshin [Fri, 12 Mar 2021 19:33:19 +0000 (11:33 -0800)]
[AMDGPU] Fix copyPhysReg to not produce unalined vgpr access

RA can insert something like a sub1_sub2 COPY of a wide VGPR
tuple which results in the unaligned acces with v_pk_mov_b32
after the copy is expanded. This is regression after D97316.

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

3 years ago[AnnotationRemarks] Remove unneeded Function.h include (NFC).
Florian Hahn [Mon, 15 Mar 2021 21:08:47 +0000 (21:08 +0000)]
[AnnotationRemarks] Remove unneeded Function.h include (NFC).

3 years ago[gn build] merge 9bcf0eff99
Nico Weber [Mon, 15 Mar 2021 21:04:50 +0000 (17:04 -0400)]
[gn build] merge 9bcf0eff99

3 years ago[SystemZ] Test for isinf and isfinite in testFPKind().
Jonas Paulsson [Thu, 4 Mar 2021 01:52:05 +0000 (02:52 +0100)]
[SystemZ] Test for isinf and isfinite in testFPKind().

Recognize BI__builtin_isinf and BI__builtin_isfinite (and a few other opcodes
for finite) in testFPKind() and handle with TDC.

Review: Ulrich Weigand.

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

3 years ago[gn build] kind of merge af2796c76d2f
Nico Weber [Mon, 15 Mar 2021 21:00:09 +0000 (17:00 -0400)]
[gn build] kind of merge af2796c76d2f

Good enough for now. If we need more, we'll do the usual
platform-dependent hardcoding that in practice works for everything else
too.

3 years ago[AMDGPU] Fixed msan failure with uninitialized value
Stanislav Mekhanoshin [Mon, 15 Mar 2021 20:54:33 +0000 (13:54 -0700)]
[AMDGPU] Fixed msan failure with uninitialized value

3 years ago[libomptarget][nfc][amdgcn] Use precise triple for devicertl build
Jon Chesterfield [Mon, 15 Mar 2021 20:23:52 +0000 (20:23 +0000)]
[libomptarget][nfc][amdgcn] Use precise triple for devicertl build

3 years ago[PowerPC] Add __PCREL__ when PC Relative is enabled.
Stefan Pintilie [Mon, 15 Mar 2021 17:33:49 +0000 (12:33 -0500)]
[PowerPC] Add __PCREL__ when PC Relative is enabled.

This patch adds the `__PCREL__` define when PC Relative addressing is enabled.

Reviewed By: nemanjai, #powerpc

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

3 years ago[libomptarget][nfc] Drop unused DEVICE macro
Jon Chesterfield [Mon, 15 Mar 2021 20:12:49 +0000 (20:12 +0000)]
[libomptarget][nfc] Drop unused DEVICE macro

[libomptarget][nfc] Drop unused DEVICE macro

Reviewed By: jdoerfert

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

3 years ago[libomptarget] Build amdgpu plugin by default
Jon Chesterfield [Mon, 15 Mar 2021 20:12:01 +0000 (20:12 +0000)]
[libomptarget] Build amdgpu plugin by default

[libomptarget] Build amdgpu plugin by default

This will build the amdgpu plugin if cmake is able to find the hsa
runtime library, which will be the case if rocm is installed or if
the hsa library has been installed somewhere cmake looks.

Reviewed By: tianshilei1992

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

3 years ago[clangd] Optionally add reflection for clangd-index-server
Kirill Bobyrev [Mon, 15 Mar 2021 20:02:24 +0000 (21:02 +0100)]
[clangd] Optionally add reflection for clangd-index-server

This was originally landed without the optional part and reverted later:

https://github.com/llvm/llvm-project/commit/8080ea4c4b8c456c72c617587cc32f174b3105c1

Reviewed By: kadircet

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

3 years agoRevert line accidentally included in af2796c76d2ff4b73165ed47959afd35a769beee
Markus Böck [Mon, 15 Mar 2021 20:03:27 +0000 (21:03 +0100)]
Revert line accidentally included in af2796c76d2ff4b73165ed47959afd35a769beee

3 years ago[SLP] update stale test comments; NFC
Sanjay Patel [Mon, 15 Mar 2021 20:01:52 +0000 (16:01 -0400)]
[SLP] update stale test comments; NFC

These bugs were fixed with 0a8e7ca402eb

3 years ago[AMDGPU] Use single cache policy operand
Stanislav Mekhanoshin [Tue, 9 Feb 2021 00:36:10 +0000 (16:36 -0800)]
[AMDGPU] Use single cache policy operand

Replace individual operands GLC, SLC, and DLC with a single cache_policy
bitmask operand. This will reduce the number of operands in MIR and I hope
the amount of code. These operands are mostly 0 anyway.

Additional advantage that parser will accept these flags in any order unlike
now.

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

3 years ago[test] Add ability to get error messages from CMake for errc substitution
Markus Böck [Mon, 15 Mar 2021 19:56:08 +0000 (20:56 +0100)]
[test] Add ability to get error messages from CMake for errc substitution

Visual Studios implementation of the C++ Standard Library does not use strerror to produce a message for std::error_code unlike other standard libraries such as libstdc++ or libc++ that might be used.

This patch adds a cmake script that through running a C++ program gets the error messages for the POSIX error codes and passes them onto lit through an optional config parameter.

If the config parameter is not set, or getting the messages failed, due to say a cross compiling configuration without an emulator, it will fall back to using pythons strerror functions.

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

3 years ago[libomptarget] Fix devicertl build
Jon Chesterfield [Mon, 15 Mar 2021 19:50:21 +0000 (19:50 +0000)]
[libomptarget] Fix devicertl build

[libomptarget] Fix devicertl build

The target specific functions in target_interface are extern C, but the
implementations for nvptx were mostly C++ mangling. That worked out as
a quirk of DEVICE macro expanding to nothing, except for shuffle.h which
only forward declared the functions with C++ linkage.

Also implements GetWarpSize, as used by shuffle, and includes target_interface
in nvptx target_impl.cu to help catch future divergence between interface and
implementation.

Reviewed By: jdoerfert

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

3 years ago[Polly] Fix deprecation warning. NFC.
Michael Kruse [Mon, 15 Mar 2021 19:27:48 +0000 (14:27 -0500)]
[Polly] Fix deprecation warning. NFC.

IRBuilder::CreateLoad without type parameter was deprecated in 6312c538
to prepare for opaque pointers.

3 years ago[CSSPGO] Load context profile for external functions in PreLink and populate ThinLTO...
Wenlei He [Sat, 13 Mar 2021 21:55:28 +0000 (13:55 -0800)]
[CSSPGO] Load context profile for external functions in PreLink and populate ThinLTO import list

For ThinLTO's prelink compilation, we need to put external inline candidates into an import list attached to function's entry count metadata. This enables ThinLink to treat such cross module callee as hot in summary index, and later helps postlink to import them for profile guided cross module inlining.

For AutoFDO, the import list is retrieved by traversing the nested inlinee functions. For CSSPGO, since profile is flatterned, a few things need to happen for it to work:

 - When loading input profile in extended binary format, we need to load all child context profile whose parent is in current module, so context trie for current module includes potential cross module inlinee.
 - In order to make the above happen, we need to know whether input profile is CSSPGO profile before start reading function profile, hence a flag for profile summary section is added.
 - When searching for cross module inline candidate, we need to walk through the context trie instead of nested inlinee profile (callsite sample of AutoFDO profile).
 - Now that we have more accurate counts with CSSPGO, we swtiched to use entry count instead of total count to decided if an external callee is potentially beneficial to inline. This make it consistent with how we determine whether call tagert is potential inline candidate.

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

3 years ago[dfsan] Updated check_custom_wrappers.sh to dedup function names
Jianzhou Zhao [Mon, 15 Mar 2021 19:10:34 +0000 (19:10 +0000)]
[dfsan] Updated check_custom_wrappers.sh to dedup function names

The origin wrappers added by https://reviews.llvm.org/D98359 reuse
those __dfsw_ functions.

3 years agoChange void getNoop(MCInst &NopInst) to MCInst getNop()
Fangrui Song [Mon, 15 Mar 2021 19:05:33 +0000 (12:05 -0700)]
Change void getNoop(MCInst &NopInst) to MCInst getNop()

Prefer (self-documenting) return values to output parameters (which are
liable to be used).
While here, rename Noop to Nop which is more widely used and improves
consistency with hasEmitNops/setEmitNops/emitNop/etc.

3 years ago[lld-macho] Place LC_FUNCTION_STARTS data at the right position
Jez Ng [Mon, 15 Mar 2021 18:54:18 +0000 (14:54 -0400)]
[lld-macho] Place LC_FUNCTION_STARTS data at the right position

This pleases the codesign

(Otherwise it complains about "function starts data out of place")

Reviewed By: #lld-macho, smeenai

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

3 years ago[dfsan] Do not check dfsan_get_origin by check_custom_wrappers.sh
Jianzhou Zhao [Mon, 15 Mar 2021 18:54:16 +0000 (18:54 +0000)]
[dfsan] Do not check dfsan_get_origin by check_custom_wrappers.sh

It is implemented like dfsan_get_label, and does not any code
in dfsan_custome.cpp.

3 years ago[RISCV] Add RISCVISD::BR_CC similar to RISCVISD::SELECT_CC.
Craig Topper [Mon, 15 Mar 2021 18:44:59 +0000 (11:44 -0700)]
[RISCV] Add RISCVISD::BR_CC similar to RISCVISD::SELECT_CC.

This allows me to introduce similar combines for branches as
we have recently added for SELECT_CC. Some of them are less
useful for standalone setccs and only help branch instructions.
By having a BR_CC node its easier to only affect branches.

I'm using CondCodeSDNode to make isel patterns easier to
write so we can refer to the codes by name. SELECT_CC uses a
constant instead.

I've translated the condition code just like SELECT_CC so
we need less patterns for the swapped conditions. This
includes special cases for X < 1 and X > -1 that get translated
to blez and bgez by using a 0 constant.

computeKnownBitsForTargetNode support for SELECT_CC is added
to allow MaskedValueIsZero to work for cases where the true
and false values of the SELECT_CC are setccs and the
result of the SELECT_CC is used by a BR_CC. This was needed
to avoid regressions in some of the overflow tests.

Reviewed By: luismarques

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

3 years ago[libomptarget] Drop assert.h, use freestanding for amdgcn devicertl
Jon Chesterfield [Mon, 15 Mar 2021 18:50:09 +0000 (18:50 +0000)]
[libomptarget] Drop assert.h, use freestanding for amdgcn devicertl

[libomptarget] Drop assert.h, use freestanding for amdgcn devicertl

Promotes the runtime assert to a link time error for the unimplemented
fallback functions. Enables amdgcn to build with only clang provided
headers, which makes it less likely to break other builds when enabled.

Reviewed By: jdoerfert

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

3 years ago[RISCV] Add isel-patterns to optimize (a < 1) into blez (a <= 0)
Philipp Tomsich [Mon, 15 Mar 2021 18:31:05 +0000 (11:31 -0700)]
[RISCV] Add isel-patterns to optimize (a < 1) into blez (a <= 0)

The following code-sequence showed up in a testcase (isolated from
SPEC2017) for if-conversion and vectorization when searching for the
maximum in an array:
        addi    a2, zero, 1
        blt     a1, a2, .LBB0_5
which can be expressed as `bge zero,a1,.LBB0_5`/`blez a1,/LBB0_5`.

More generally, we want to express (a < 1) as (a <= 0).

This adds the required isel-pattern and updates the testcases.

Reviewed By: craig.topper

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

3 years ago[Polly][Optimizer] Apply user-directed unrolling.
Michael Kruse [Mon, 15 Mar 2021 17:13:21 +0000 (12:13 -0500)]
[Polly][Optimizer] Apply user-directed unrolling.

Make Polly look for unrolling metadata (https://llvm.org/docs/TransformMetadata.html#loop-unrolling) that is usually only interpreted by the LoopUnroll pass and apply it to the SCoP's schedule.

While not that useful by itself (there already is an unroll pass), it introduces mechanism to apply arbitrary loop transformation directives in arbitrary order to the schedule. Transformations are applied until no more directives are found. Since ISL's rescheduling would discard the manual transformations and it is assumed that when the user specifies the sequence of transformations, they do not want any other transformations to apply. Applying user-directed transformations can be controlled using the `-polly-pragma-based-opts` switch and is enabled by default.

This does not influence the SCoP detection heuristic. As a consequence, loop that do not fulfill SCoP requirements or the initial profitability heuristic will be ignored. `-polly-process-unprofitable` can be used to disable the latter.

Other than manually editing the IR, there is currently no way for the user to add loop transformations in an order other than the order in the default pipeline, or transformations other than the one supported by clang's LoopHint. See the `unroll_double.ll` test as example that clang currently is unable to emit. My own extension of `#pragma clang loop` allowing an arbitrary order and additional transformations is available here: https://github.com/meinersbur/llvm-project/tree/pragma-clang-loop. An effort to upstream this functionality as `#pragma clang transform` (because `#pragma clang loop` has an implicit transformation order defined by the loop pipeline) is D69088.

Additional transformations from my downstream pragma-clang-loop branch are tiling, interchange, reversal, unroll-and-jam, thread-parallelization and array packing. Unroll was chosen because it uses already-defined metadata and does not require correctness checks.

Reviewed By: sebastiankreutzer

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

3 years ago[AArch64] Implement __rndr, __rndrrs intrinsics
Stelios Ioannou [Tue, 9 Mar 2021 14:56:49 +0000 (14:56 +0000)]
[AArch64] Implement __rndr, __rndrrs intrinsics

This patch implements the __rndr and __rndrrs intrinsics to provide access to the random
number instructions introduced in Armv8.5-A. They are only defined for the AArch64
execution state and are available when __ARM_FEATURE_RNG is defined.

These intrinsics store the random number in their pointer argument and return a status
code if the generation succeeded. The difference between __rndr __rndrrs, is that the latter
intrinsic reseeds the random number generator.

The instructions write the NZCV flags indicating the success of the operation that we can
then read with a CSET.

[1] https://developer.arm.com/docs/101028/latest/data-processing-intrinsics
[2] https://bugs.llvm.org/show_bug.cgi?id=47838

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

Change-Id: I8f92e7bf5b450e5da3e59943b53482edf0df6efc

3 years ago[mlir] fix SPIR-V CPU and Vulkan runners after e2310704d890ad252aeb1ca28b4b84d29514b1d1
Alex Zinenko [Mon, 15 Mar 2021 17:35:40 +0000 (18:35 +0100)]
[mlir] fix SPIR-V CPU and Vulkan runners after e2310704d890ad252aeb1ca28b4b84d29514b1d1

The commit in question changed the syntax but did not update the runner
tests. This also required registering the MemRef dialect for custom
parser to work correctly.

3 years agoAllow __ieee128 as an alias to __float128 on ppc
serge-sans-paille [Wed, 3 Mar 2021 08:58:31 +0000 (09:58 +0100)]
Allow __ieee128 as an alias to __float128 on ppc

This matches gcc behavior.

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

3 years ago[NFC] Use higher level constructs to check for whitespace/newlines in the lexer
serge-sans-paille [Mon, 15 Mar 2021 17:18:55 +0000 (18:18 +0100)]
[NFC] Use higher level constructs to check for whitespace/newlines in the lexer

It turns out that according to valgrind and perf, it's also slightly faster.

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

3 years ago[OpenCL] Respect calling convention for builtin
Luke Drummond [Wed, 10 Mar 2021 18:14:42 +0000 (18:14 +0000)]
[OpenCL] Respect calling convention for builtin

`__translate_sampler_initializer` has a calling convention of
`spir_func`, but clang generated calls to it using the default CC.

Instruction Combining was lowering these mismatching calling conventions
to `store i1* undef` which itself was subsequently lowered to a trap
instruction by simplifyCFG resulting in runtime `SIGILL`

There are arguably two bugs here: but whether there's any wisdom in
converting an obviously invalid call into a runtime crash over aborting
with a sensible error message will require further discussion. So for
now it's enough to set the right calling convention on the runtime
helper.

Reviewed By: svenh, bader

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

3 years ago[flang][docs] Fix the time for the new Flang driver call
Andrzej Warzynski [Mon, 15 Mar 2021 17:24:35 +0000 (17:24 +0000)]
[flang][docs] Fix the time for the new Flang driver call

3 years ago[libcxx] [test] Fix the temp_directory_path test for windows
Martin Storsjö [Fri, 26 Feb 2021 13:15:36 +0000 (15:15 +0200)]
[libcxx] [test] Fix the temp_directory_path test for windows

Check a different set of env vars, don't check the exact value
of the fallback path. (GetTempPath falls back to returning the Windows
folder if nothing better is available in env vars.)

The test still fails one check on windows (due to relying on perms::none),
which will be addressed separately.

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

3 years ago[AssumeBundles] Add nonnull/align to op bundle if noundef exists
Juneyoung Lee [Tue, 16 Mar 2021 00:20:49 +0000 (09:20 +0900)]
[AssumeBundles] Add nonnull/align to op bundle if noundef exists

This is a patch to add nonnull and align to assume's operand bundle
only if noundef exists.
Since nonnull and align in fn attr have poison semantics, they should be
paired with noundef or noundef-implying attributes to be immediate UB.

Reviewed By: jdoerfert, Tyker

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

3 years ago[CodeGen] Fix issues with scalable-vector INSERT/EXTRACT_SUBVECTORs
Fraser Cormack [Fri, 12 Mar 2021 11:22:29 +0000 (11:22 +0000)]
[CodeGen] Fix issues with scalable-vector INSERT/EXTRACT_SUBVECTORs

This patch addresses a few issues when dealing with scalable-vector
INSERT_SUBVECTOR and EXTRACT_SUBVECTOR nodes.

When legalizing in DAGTypeLegalizer::SplitVecRes_INSERT_SUBVECTOR, we
store the low and high halves to the stack separately. The offset for
the high half was calculated incorrectly.

Additionally, we can optimize this process when we can detect that the
subvector is contained entirely within the low/high split vector type.
While this optimization is valid on scalable vectors, when performing
the 'high' optimization, the subvector must also be a scalable vector.
Note that the 'low' optimization is still conservative: it may be
possible to insert v2i32 into the low half of a split nxv1i32/nxv1i32,
but we can't guarantee it. It is always possible to insert v2i32 into
nxv2i32 or v2i32 into nxv4i32+2 as we know vscale is at least 1.

Lastly, in SelectionDAG::isSplatValue, we early-exit on the extracted subvector value
type being a scalable vector, forgetting that we can also extract a
fixed-length vector from a scalable one.

Reviewed By: craig.topper

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

3 years ago[Polly] Refactoring astScheduleDimIsParallel to take the C++ wrapper object. NFC
Kevin Zhou [Mon, 15 Mar 2021 13:15:02 +0000 (08:15 -0500)]
[Polly] Refactoring astScheduleDimIsParallel to take the C++ wrapper object. NFC

Polly currently needs to be slowly refactor to use the C++ wrapper objects to handle the reference counters automatically.
I took the function of astScheduleDimIsParallel and refactored it so that it uses the C++ wrapper function as much as possible.

There are some problems with the IsParallel since it expects the C objects, so the C++ wrapper functions must be .release() and .get() first before they are able to be used with IsParallel.

When checking the ReductionDependencies Parallelism with the Build's Schedule, I opted to keep the union map as a C object rather than a C++ object. Eventually, changes will need to be made to IsParallel to refactor it to the C++ wrappers. When this is done, this function will also need to be slightly refactored to not use the C object.

Reviewed By: Meinersbur

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

3 years ago[libomptarget][amdgcn] Drop use of inttypes.h, moving closer to freestanding
Jon Chesterfield [Mon, 15 Mar 2021 16:54:56 +0000 (16:54 +0000)]
[libomptarget][amdgcn] Drop use of inttypes.h, moving closer to freestanding

[libomptarget][amdgcn] Drop use of inttypes.h, moving closer to freestanding

The glibc headers are a periodic source of problems compiling the devicertl.
This patch resolves the following error run into while building llvm on a slightly
different linux system.
```
In file included from .../lib/clang/13.0.0/include/inttypes.h:21:
In file included from /usr/include/inttypes.h:25:
/usr/include/features.h:461:12: fatal error: 'sys/cdefs.h' file not found
#  include <sys/cdefs.h>
           ^~~~~~~~~~~~~
```
As a second patch, removing assert.h from shuffle will let amdgcn build as
-ffreestanding, at which point only the headers that clang itself provides are
used and interactions with the host glibc are eliminated. Doing the same for
nvptx is complicated by printf handling but also seems worthwhile.

Reviewed By: tianshilei1992

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

3 years ago[libcxx] [test] Fix the get_temp_file_name() function for mingw
Martin Storsjö [Thu, 25 Feb 2021 10:43:36 +0000 (12:43 +0200)]
[libcxx] [test] Fix the get_temp_file_name() function for mingw

Add the missing includes for getting the defines and functions used
in the mingw version of get_temp_file_name().

This fixes 31 tests when built in a mingw configuration.

Also remove a redundant ifdef; _WIN32 is defined in mingw targets too.

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

3 years ago[libcxx] [test] Disable some allocation checks in class.path tests on windows
Martin Storsjö [Thu, 25 Feb 2021 21:06:18 +0000 (23:06 +0200)]
[libcxx] [test] Disable some allocation checks in class.path tests on windows

On windows, the path internal representation is wchar_t, and
input/output often goes through utf8 inbetween, which causes extra
allocations.

MS STL also fails a number of strict allocation checks, so this
shouldn't be a standards compliance issue.

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

3 years ago[gn build] (semi-manually) port b136a74efc54
Nico Weber [Mon, 15 Mar 2021 16:50:45 +0000 (12:50 -0400)]
[gn build] (semi-manually) port b136a74efc54

3 years ago[CMake] Require python 3.6 if enabling LLVM test targets
Christopher Tetreault [Mon, 15 Mar 2021 16:33:31 +0000 (09:33 -0700)]
[CMake] Require python 3.6 if enabling LLVM test targets

The lit test suite uses python 3.6 features. Rather than a strange
python syntax error upon running the lit tests, we will require the
correct version in CMake.

Reviewed By: serge-sans-paille, yln

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

3 years ago[RISCV] Improve legalization of i32 UADDO/USUBO on RV64.
Craig Topper [Mon, 15 Mar 2021 16:20:26 +0000 (09:20 -0700)]
[RISCV] Improve legalization of i32 UADDO/USUBO on RV64.

The default legalization uses zero extends that require pair of shifts
on RISCV. Instead we can take advantage of the fact that unsigned
compares work equally well on sign extended inputs. This allows
us to use addw/subw and sext.w.

Reviewed By: luismarques

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

3 years ago[X86][SSE] isHorizontalBinOp - ensure we clear any unused source operands to improve...
Simon Pilgrim [Mon, 15 Mar 2021 16:15:05 +0000 (16:15 +0000)]
[X86][SSE] isHorizontalBinOp - ensure we clear any unused source operands to improve HADD/SUB matching

Our shuffle matching for HADD/SUB patterns wasn't clearing repeated ops in 'fake unary' style shuffle masks (unpack(x,x) etc.), preventing matching of add(fakeunary(),fakeunary()) style patterns.

3 years ago[mlir] make memref.cast implement ViewLikeOpInterface
Alex Zinenko [Mon, 15 Mar 2021 16:19:37 +0000 (17:19 +0100)]
[mlir] make memref.cast implement ViewLikeOpInterface

This was seemingly dropped in e2310704d890ad252aeb1ca28b4b84d29514b1d1,
potentially due to a misrebase. The absence of this trait makes aliasing
analysis incorrect, leading to, e.g., buffer deallocation pass inserting
deallocations too early.

3 years ago[dfsan] Add origin ABI wrappers for thread/signal/fork
Jianzhou Zhao [Wed, 10 Mar 2021 06:31:56 +0000 (06:31 +0000)]
[dfsan] Add origin ABI wrappers for thread/signal/fork

This is a part of https://reviews.llvm.org/D95835.

See https://github.com/llvm/llvm-project/commit/bb91e02efd00eda04296069a83228c8d9db105b7 about the similar issue of fork in MSan's origin tracking.

Reviewed By: morehouse

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

3 years ago[NFC] Fix "unused parameter" error revealed in the Linux self-build.
Zahira Ammarguellat [Mon, 15 Mar 2021 16:15:34 +0000 (12:15 -0400)]
[NFC] Fix "unused parameter" error revealed in the Linux self-build.

3 years ago[clang][patch] Solve PR49479, File scope fp pragma should propagate to functions...
Melanie Blower [Mon, 15 Mar 2021 14:06:33 +0000 (10:06 -0400)]
[clang][patch] Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions

Previously, the CurFPFeatures state was set to command line settings before
semantic analysis of the nested member functions and initialization
expressions, that's not correct, it should use the pragma state which
is in effect at the lexical position.

Reviewed By: Erich Keane, Aaron Ballman

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

3 years ago[InstSimplify] ctlz({signbit} >>u x) --> x
Sanjay Patel [Mon, 15 Mar 2021 15:44:53 +0000 (11:44 -0400)]
[InstSimplify] ctlz({signbit} >>u x) --> x

The motivating pattern was handled in 0a2d69480d ,
but we should have this for symmetry.

But this really highlights that we could generalize for
any shifted constant if we match this in instcombine.

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

3 years ago[InstSimplify] add tests for ctlz of shifted constant; NFC
Sanjay Patel [Mon, 15 Mar 2021 15:20:27 +0000 (11:20 -0400)]
[InstSimplify] add tests for ctlz of shifted constant; NFC

3 years ago[RISCV][compiler-rt] Add support for save-restore
Edward Jones [Thu, 12 Nov 2020 16:33:03 +0000 (16:33 +0000)]
[RISCV][compiler-rt] Add support for save-restore

This adds the compiler-rt entry points required by the
-msave-restore option.

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

3 years agoStop traping on sNaN in __builtin_isinf
Thomas Preud'homme [Wed, 9 Dec 2020 22:18:32 +0000 (22:18 +0000)]
Stop traping on sNaN in __builtin_isinf

__builtin_isinf currently generates a floating-point compare operation
which triggers a trap when faced with a signaling NaN in StrictFP mode.
This commit uses integer operations instead to not generate any trap in
such a case.

Reviewed By: mibintc

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

3 years ago[libcxx] [docs] Update docs about how to build for Windows
Martin Storsjö [Sun, 21 Feb 2021 23:20:28 +0000 (01:20 +0200)]
[libcxx] [docs] Update docs about how to build for Windows

Refresh the existing paragraphs on building in MSVC configurations,
add a sample of one working configuration for MinGW, and add more
details on what's necessary to run the tests these days.

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

3 years ago[gn build] Port 13e49dcee48f
LLVM GN Syncbot [Mon, 15 Mar 2021 15:24:41 +0000 (15:24 +0000)]
[gn build] Port 13e49dcee48f

3 years ago[amdgpu] Implement lower function LDS pass
Jon Chesterfield [Mon, 15 Mar 2021 15:24:00 +0000 (15:24 +0000)]
[amdgpu] Implement lower function LDS pass

[amdgpu] Implement lower function LDS pass

Local variables are allocated at kernel launch. This pass collects global
variables that are used from non-kernel functions, moves them into a new struct
type, and allocates an instance of that type in every kernel. Uses are then
replaced with a constantexpr offset.

Prior to this pass, accesses from a function are compiled to trap. With this
pass, most such accesses are removed before reaching codegen. The trap logic
is left unchanged by this pass. It is still reachable for the cases this pass
misses, notably the extern shared construct from hip and variables marked
constant which survive the optimizer.

This is of interest to the openmp project because the deviceRTL runtime library
uses cuda shared variables from functions that cannot be inlined. Trunk llvm
therefore cannot compile some openmp kernels for amdgpu. In addition to the
unit tests attached, this patch applied to ROCm llvm with fixed-abi enabled
and the function pointer hashing scheme deleted passes the openmp suite.

This lowering will use more LDS than strictly necessary. It is intended to be
a functionally correct fallback for cases that are difficult to target from
future optimisation passes.

Reviewed By: arsenm

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