platform/upstream/llvm.git
2 years ago[flang] Lower function and subroutine calls
Valentin Clement [Wed, 23 Feb 2022 18:48:07 +0000 (19:48 +0100)]
[flang] Lower function and subroutine calls

This patch introduce basic function/subroutine calls.
Because of the state of lowering only simple scalar arguments
can be used in the calls. This will be enhanced in follow up
patches with arrays, allocatable, pointer ans so on.

```
subroutine sub1()
end

subroutine sub2()
  call sub1()
end
```

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years ago[X86] combineX86ShufflesRecursively - pull out repeated getValueType/getSimpleValueTy...
Simon Pilgrim [Wed, 23 Feb 2022 18:45:17 +0000 (18:45 +0000)]
[X86] combineX86ShufflesRecursively - pull out repeated getValueType/getSimpleValueType calls.

2 years agoRevert "[MachineOutliner][AArch64] NFC: Split MBBs into "outlinable ranges""
Jessica Paquette [Wed, 23 Feb 2022 18:35:52 +0000 (10:35 -0800)]
Revert "[MachineOutliner][AArch64] NFC: Split MBBs into "outlinable ranges""

This reverts commit d97f997eb79d91b2872ac13619f49cb3a7120781.

This commit was not NFC.

(See: https://reviews.llvm.org/rGd97f997eb79d91b2872ac13619f49cb3a7120781)

2 years ago[mlir] Async: update condition for dispatching block-aligned compute function
Eugene Zhulenev [Thu, 17 Feb 2022 18:22:18 +0000 (10:22 -0800)]
[mlir] Async: update condition for dispatching block-aligned compute function

+ compare block size with the unrollable inner dimension
+ reduce nesting in the code and simplify a bit IR building

Reviewed By: cota

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

2 years ago[ELF] Check COMMON symbols for PROVIDE and don't redefine COMMON symbols edata/end...
Fangrui Song [Wed, 23 Feb 2022 18:15:42 +0000 (10:15 -0800)]
[ELF] Check COMMON symbols for PROVIDE and don't redefine COMMON symbols edata/end/etext

In GNU ld, the definition precedence is: regular symbol assignment > relocatable object definition > `PROVIDE` symbol assignment.

GNU ld's internal linker scripts define the non-reserved (by C and C++)
edata/end/etext with `PROVIDE` so the relocatable object definition takes
precedence. This makes sense because `int end;` is valid.

We currently redefine such symbols if they are COMMON, but not if they are
regular definitions, so `int end;` with -fcommon is essentially a UB in ld.lld.
Fix this (also improve consistency and match GNU ld) by using the
`isDefined` code path for `isCommon`. In GNU ld, reserved identifiers like
`__ehdr_start` do not use `PROVIDE`, while we treat them all as `PROVIDE`, this
seems fine.

Reviewed By: peter.smith

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

2 years ago[llvm-profgen] Support symbol loading for debug fission
wlei [Tue, 22 Feb 2022 20:09:01 +0000 (12:09 -0800)]
[llvm-profgen] Support symbol loading for debug fission

Support to load debug info from dwarf split file, like .dwo, .dwp files. Leverage the `getNonSkeletonUnitDIE(false)` API to achieve this.

Add test cause to make sure all the ranges is well retrieved by the loader.

Reviewed By: ayermolo, hoy, wenlei

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

2 years ago[clang] Remove getPointerElementType() in EmitVTableTypeCheckedLoad()
Arthur Eubanks [Wed, 23 Feb 2022 17:37:53 +0000 (09:37 -0800)]
[clang] Remove getPointerElementType() in EmitVTableTypeCheckedLoad()

2 years ago[X86] combineX86ShufflesRecursively - don't both widening inputs before calling combi...
Simon Pilgrim [Wed, 23 Feb 2022 17:29:41 +0000 (17:29 +0000)]
[X86] combineX86ShufflesRecursively - don't both widening inputs before calling combineX86ShuffleChain

combineX86ShuffleChain no longer has to assume that the shuffle inputs are the right size, so don't create unnecessary nodes messing up oneuse limits as detailed on Issue #45319

2 years ago[gn build] Port 7c1ee5e95f31
LLVM GN Syncbot [Wed, 23 Feb 2022 17:12:13 +0000 (17:12 +0000)]
[gn build] Port 7c1ee5e95f31

2 years ago[DAG] try to convert multiply to shift via demanded bits
Sanjay Patel [Wed, 23 Feb 2022 16:25:01 +0000 (11:25 -0500)]
[DAG] try to convert multiply to shift via demanded bits

This is a fix for a regression discussed in:
https://github.com/llvm/llvm-project/issues/53829

We cleared more high multiplier bits with 995d400,
but that can lead to worse codegen because we would fail
to recognize the now disguised multiplication by neg-power-of-2
as a shift-left. The problem exists independently of the IR
change in the case that the multiply already had cleared high
bits. We also convert shl+sub into mul+add in instcombine's
negator.

This patch fills in the high-bits to see the shift transform
opportunity. Alive2 attempt to show correctness:
https://alive2.llvm.org/ce/z/GgSKVX

The AArch64, RISCV, and MIPS diffs look like clear wins. The
x86 code requires an extra move register in the minimal examples,
but it's still an improvement to get rid of the multiply on all
CPUs that I am aware of (because multiply is never as fast as a
shift).

There's a potential follow-up noted by the TODO comment. We
should already convert that pattern into shl+add in IR, so
it's probably not common:
https://alive2.llvm.org/ce/z/7QY_Ga

Fixes #53829

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

2 years agoRevert "AttributorAttributes: avoid a crashing on bad alignments"
Arthur Eubanks [Wed, 23 Feb 2022 17:08:03 +0000 (09:08 -0800)]
Revert "AttributorAttributes: avoid a crashing on bad alignments"

This reverts commit 70ff6fbeb9b5acb4995dc42286954b762d0937fd.

Breaks bots, e.g. http://45.33.8.238/linux/69375/step_12.txt.

2 years ago[flang][NFC] Clean up ConvertType
Valentin Clement [Wed, 23 Feb 2022 17:04:15 +0000 (18:04 +0100)]
[flang][NFC] Clean up ConvertType

This patch removes unused or obsolete code in
the ConvertType.h and ConvertType.cpp files. These
files were landed together with the initial flang
upstreaming. This cleanup will help future upstreaming
effort from fir-dev and keep only used code.

Reviewed By: PeteSteinfeld

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

2 years ago[MLIR][Pass] Have PassRegistryEntry own pass strings
Daniel Resnick [Tue, 22 Feb 2022 17:41:48 +0000 (10:41 -0700)]
[MLIR][Pass] Have PassRegistryEntry own pass strings

This eliminates the requirement that pass-related strings outlive pass
instances, which will facilitate future work enabling dynamic passes
written in other languages.

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

2 years ago[flang] Lower complex constant
Valentin Clement [Wed, 23 Feb 2022 17:01:58 +0000 (18:01 +0100)]
[flang] Lower complex constant

Add ability to lower complex constant.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[Pseudo] Token/TokenStream, PP directive parser.
Sam McCall [Mon, 7 Feb 2022 18:11:16 +0000 (19:11 +0100)]
[Pseudo] Token/TokenStream, PP directive parser.

The TokenStream class is the representation of the source code that will
be fed into the GLR parser.

This patch allows a "raw" TokenStream to be built by reading source code.
It also supports scanning a TokenStream to find the directive structure.

Next steps (with placeholders in the code): heuristically choosing a
path through #ifs, preprocessing the code by stripping directives and comments.
These will produce a suitable stream to feed into the parser proper.

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

2 years agoAttributorAttributes: avoid a crashing on bad alignments
Augie Fackler [Fri, 11 Feb 2022 23:32:38 +0000 (18:32 -0500)]
AttributorAttributes: avoid a crashing on bad alignments

Prior to this change, LLVM would attempt to optimize an
aligned_alloc(33, ...) call to the stack. This flunked an assertion when
trying to emit the alloca, which crashed LLVM. Avoid that with extra
checks.

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

2 years ago[SLP] Remove cap on schedule window size
Philip Reames [Wed, 23 Feb 2022 04:00:43 +0000 (20:00 -0800)]
[SLP] Remove cap on schedule window size

This cap was first added in 848c1aa45 (back in 2015).  Per the original commit message, the purpose was to avoid a compile time explosion in long basic blocks.  The algorithmic problem in scheduling has now been fixed in 0539a26d.

In the meantime, the code has rotten fairly badly.  Some intermediate refactoring caused the size to only be incremented if *both* iterators advance in the window search.  This causes the size to be badly undercounted when near one end of a basic block.  We no longer have any test which exercises the logic in an intentional way; there's one test which differs with this change, but the changes appear fairly orthoganol to the purpose of the test file.

Unfortunately, we no longer have the original motivating example, so it's possible that it also hits some other issue.  I tested locally with a large example, but even at it's worst, that one doesn't demonstrate anything too extreme even without the algorithmic fix.  It's clearly faster with, but only by ~20% which doesn't seem in line with the original commit message.   If regressions with this patch are seen, please file a bug and I'll try to fix any other algorithmic problems which fall out.

2 years agoclang-format.el: Make clang-format work in indirect buffers.
Philipp Stephani [Wed, 23 Feb 2022 16:00:04 +0000 (17:00 +0100)]
clang-format.el: Make clang-format work in indirect buffers.

In an indirect buffer, buffer-file-name is nil, so check the base buffer
instead.  This works fine in direct buffers where buffer-base-buffer returns
nil.

Reviewed By: sammccall

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

2 years ago[LAA] Add remarks for unbounded array access
Malhar Jajoo [Wed, 2 Feb 2022 15:52:13 +0000 (15:52 +0000)]
[LAA] Add remarks for  unbounded array access

Adds new optimization remarks when loop vectorization fails due to
the compiler being unable to find bound of an array access inside
a loop

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

2 years ago[X86] combineX86ShuffleChainWithExtract - don't both widening inputs after peeking...
Simon Pilgrim [Wed, 23 Feb 2022 15:43:34 +0000 (15:43 +0000)]
[X86] combineX86ShuffleChainWithExtract - don't both widening inputs after peeking through ISD::EXTRACT_SUBVECTOR nodes

combineX86ShuffleChain no longer has to assume that the shuffle inputs are the right size, so don't create unnecessary nodes messing up oneuse limits as detailed on Issue #45319

Removing widening from combineX86ShufflesRecursively will be the next step, followed by removing combineX86ShuffleChainWithExtract entirely

2 years ago[Bitcode] Store function type IDs rather than function types
Nikita Popov [Wed, 23 Feb 2022 15:32:40 +0000 (16:32 +0100)]
[Bitcode] Store function type IDs rather than function types

This resolves one of the type ID propagation TODOs.

2 years ago[mlir][NFC] Use options struct in ExecutionEngine::create
Emilio Cota [Wed, 23 Feb 2022 03:27:54 +0000 (22:27 -0500)]
[mlir][NFC] Use options struct in ExecutionEngine::create

Its number of optional parameters has grown too large,
which makes adding new optional parameters quite a chore.

Fix this by using an options struct.

Reviewed By: mehdi_amini

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

2 years ago[Clang][OpenMP] Remove use of getPointerElementType()
Nikita Popov [Wed, 23 Feb 2022 15:10:29 +0000 (16:10 +0100)]
[Clang][OpenMP] Remove use of getPointerElementType()

This new pointer element type use snuck in via D118632.

2 years ago[MLIR][Presburger] unittests: use an MLIRContext declared in parsePoly
Arjun P [Wed, 23 Feb 2022 15:00:17 +0000 (15:00 +0000)]
[MLIR][Presburger] unittests: use an MLIRContext declared in parsePoly

Use an `MLIRContext` declared in a single place in the `parsePoly` function that almost all Presburger unit tests use for parsing sets. This function is only used in tests.

This saves us from having to declare and pass a new `MLIRContext` in every test.

Reviewed By: bondhugula, mehdi_amini

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

2 years ago[AMDGPU] Split fp min/max atomics test. NFC.
Jay Foad [Wed, 23 Feb 2022 13:35:34 +0000 (13:35 +0000)]
[AMDGPU] Split fp min/max atomics test. NFC.

Split out f32 buffer, f64 buffer and image atomics. This just makes
it easier to test subtargets that only have some of these
instructions.

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

2 years ago[InstCombine] Support min/max intrinsics in udiv->lshr fold
Nikita Popov [Wed, 23 Feb 2022 14:49:12 +0000 (15:49 +0100)]
[InstCombine] Support min/max intrinsics in udiv->lshr fold

This complements the existing fold for selects. This fold is a bit
more conservative, requiring one-use. The other folds here should
probably also be subjected to a one-use restriction.

https://alive2.llvm.org/ce/z/Q9eCDU
https://alive2.llvm.org/ce/z/8YK2CJ

2 years ago[InstCombine] Add tests for udiv->lshr fold with min/max intrinsics (NFC)
Nikita Popov [Wed, 23 Feb 2022 14:44:37 +0000 (15:44 +0100)]
[InstCombine] Add tests for udiv->lshr fold with min/max intrinsics (NFC)

2 years ago[PowerPC] Add the Power10 LXVKQ instrution.
Stefan Pintilie [Tue, 22 Feb 2022 21:17:18 +0000 (15:17 -0600)]
[PowerPC] Add the Power10 LXVKQ instrution.

Add the Power 10 instruction LXVKQ.

This patch was taken from an original patch by: Yi-Hong Lyu

Reviewed By: lei

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

2 years ago[clang][deps] Return the whole TU command line
Jan Svoboda [Wed, 23 Feb 2022 13:51:40 +0000 (14:51 +0100)]
[clang][deps] Return the whole TU command line

The dependency scanner already generates canonical -cc1 command lines that can be used to compile discovered modular dependencies.

For translation unit command lines, the scanner only generates additional driver arguments the build system is expected to append to the original command line.

While this works most of the time, there are situations where that's not the case. For example with `-Wunused-command-line-argument`, Clang will complain about the `-fmodules-cache-path=` argument that's not being used in explicit modular builds. Combine that with `-Werror` and the build outright fails.

To prevent such failures, this patch changes the dependency scanner to return the full driver command line to compile the original translation unit. This gives us more opportunities to massage the arguments into something reasonable.

Reviewed By: Bigcheese

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

2 years ago[clang][deps] NFC: Update documentation
Jan Svoboda [Wed, 23 Feb 2022 14:18:00 +0000 (15:18 +0100)]
[clang][deps] NFC: Update documentation

In D113473, the dependency scanner stopped emitting "-fmodule-map-file=" arguments. Potential build systems are expected to not add any such arguments on their own. This commit removes mentions of such arguments to avoid confusion.

2 years ago[MC][ELF] Use SHF_SUNW_NODISCARD instead of SHF_GNU_RETAIN on Solaris
Rainer Orth [Wed, 23 Feb 2022 14:43:12 +0000 (15:43 +0100)]
[MC][ELF] Use SHF_SUNW_NODISCARD instead of SHF_GNU_RETAIN on Solaris

As requested in D107955 <https://reviews.llvm.org/D107955>, this patch
splits off the `MC` and `CodeGen` parts and adds a testcase.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

2 years ago[ELF] Use SHF_SUNW_NODISCARD instead of SHF_GNU_RETAIN on Solaris
Rainer Orth [Wed, 23 Feb 2022 14:41:43 +0000 (15:41 +0100)]
[ELF] Use SHF_SUNW_NODISCARD instead of SHF_GNU_RETAIN on Solaris

Instead of the GNU extension `SHF_GNU_RETAIN`, Solaris provides equivalent
functionality with `SHF_SUNW_NODISCARD`. This patch implements the necessary
support.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

2 years ago[InstCombine] Further simplify udiv -> lshr folding
Nikita Popov [Wed, 23 Feb 2022 14:24:44 +0000 (15:24 +0100)]
[InstCombine] Further simplify udiv -> lshr folding

Rather than queuing up actions, have one function that does the
log2() fold in the obvious way, but with a flag that allows us
to check whether the fold will succeed without actually performing
it.

2 years agoSilence some "not all control paths return a value" warnings; NFC
Aaron Ballman [Wed, 23 Feb 2022 14:11:34 +0000 (09:11 -0500)]
Silence some "not all control paths return a value" warnings; NFC

2 years ago[InstSimplify] remove shift that is redundant with part of funnel shift
Sanjay Patel [Wed, 23 Feb 2022 14:06:11 +0000 (09:06 -0500)]
[InstSimplify] remove shift that is redundant with part of funnel shift

In D111530, I suggested that we add some relatively basic pattern-matching
folds for shifts and funnel shifts and avoid a more specialized solution
if possible.

We can start by implementing at least one of these in IR because it's
easier to write the code and verify with Alive2:
https://alive2.llvm.org/ce/z/qHpmNn

This will need to be adapted/extended for SDAG to handle the motivating
bug ( #49541 ) because the patterns only appear later with that example
(added some tests: bb850d422b64)

This can be extended within InstSimplify to handle cases where we 'and'
with a shift too (in that case, kill the funnel shift).
We could also handle patterns where the shift and funnel shift directions
are inverted, but I think it's better to canonicalize that instead to
avoid pattern-match case explosion.

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

2 years agoRemove unused function; NFC
Aaron Ballman [Wed, 23 Feb 2022 14:07:54 +0000 (09:07 -0500)]
Remove unused function; NFC

2 years ago[lld-macho][nfc] Refactor MarkLive
Jez Ng [Wed, 23 Feb 2022 13:57:54 +0000 (08:57 -0500)]
[lld-macho][nfc] Refactor MarkLive

This mirrors the code structure in `lld/ELF`. It also paves the way for
an upcoming diff where I templatize things.

Reviewed By: #lld-macho, thakis

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

2 years ago[lld-macho][nfc] Move ICF-specific logic into ICF.cpp
Jez Ng [Wed, 23 Feb 2022 13:57:52 +0000 (08:57 -0500)]
[lld-macho][nfc] Move ICF-specific logic into ICF.cpp

This mirrors the code organization in `lld/ELF`.

Reviewed By: #lld-macho, thakis

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

2 years agoRevert "Revert "[clang][dataflow] Add support for global storage values""
Stanislav Gatev [Wed, 23 Feb 2022 13:38:51 +0000 (13:38 +0000)]
Revert "Revert "[clang][dataflow] Add support for global storage values""

This reverts commit 169e1aba55bed9f7ffa000f9f170ab2defbc40b2.

It also fixes an incorrect assumption in `initGlobalVars`.

2 years ago[InstCombine] Simplify udiv -> lshr folding
Nikita Popov [Wed, 23 Feb 2022 13:52:56 +0000 (14:52 +0100)]
[InstCombine] Simplify udiv -> lshr folding

What we're really doing here is converting Op0 udiv Op1 into
Op0 lshr log2(Op1), so phrase it in that way. Actually pushing
the lshr into the log2(Op1) expression should be seen as a separate
transform.

2 years agoFix HostProcessWindows for D120321
Pavel Labath [Wed, 23 Feb 2022 13:51:55 +0000 (14:51 +0100)]
Fix HostProcessWindows for D120321

2 years ago[clang][modules] Infer framework modules in explicit builds
Jan Svoboda [Wed, 23 Feb 2022 13:15:47 +0000 (14:15 +0100)]
[clang][modules] Infer framework modules in explicit builds

This patch enables inferring framework modules in explicit builds in all contexts. Until now, inferring framework modules only worked with `-fimplicit-module-maps` due to this block of code:

```
// HeaderSearch::loadFrameworkModule
  case LMM_InvalidModuleMap:
    // Try to infer a module map from the framework directory.
    if (HSOpts->ImplicitModuleMaps)
      ModMap.inferFrameworkModule(Dir, IsSystem, /*Parent=*/nullptr);
    break;
```

Reviewed By: Bigcheese

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

2 years ago[clang][driver][wasm] Fix libstdc++ target-dependent include dir
Timm Bäder [Mon, 21 Feb 2022 15:01:13 +0000 (16:01 +0100)]
[clang][driver][wasm] Fix libstdc++ target-dependent include dir

The triple goes after the gcc version, not before. Also add the
/backward version.

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

2 years agoAdd missing <ctime> include
serge-sans-paille [Wed, 23 Feb 2022 13:28:56 +0000 (14:28 +0100)]
Add missing <ctime> include

As a follow-up to eb4c8608115c1c9af0fc8cb5b1e9f2bc960014ef
Should fix http://45.33.8.238/win/53749/step_4.txt

Related to https://reviews.llvm.org/D120195

2 years ago[lldb] Simplify HostThreadMacOSX
Pavel Labath [Mon, 21 Feb 2022 14:08:23 +0000 (15:08 +0100)]
[lldb] Simplify HostThreadMacOSX

The class is using an incredibly elaborate setup to create and destroy
an NSAutoreleasePool object. We can do it in a much simpler way by
making those calls inside our thread startup function.

The only effect of this patch is that the pool gets released at the end
of the ThreadCreateTrampoline function, instead of slightly later, when
pthreads begin thread-specific cleanup. However, the key destruction
order is unspecified, so nothing should be relying on that.

I didn't find a specific reason for why this would have to be done that
way in git history. It seems that before D5198, this was thread-specific
keys were the only way an os implementation (in Host::ThreadCreated)
could attach some value to a thread.

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

2 years ago[lldb] Modernize ThreadLauncher
Pavel Labath [Mon, 21 Feb 2022 10:07:38 +0000 (11:07 +0100)]
[lldb] Modernize ThreadLauncher

Accept a function object instead of a raw pointer. This avoids a bunch
of boilerplate typically needed to pass arguments to the thread
functions.

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

2 years ago[LAA] Add missing newline in debug print
Thomas Preud'homme [Wed, 23 Feb 2022 13:24:06 +0000 (13:24 +0000)]
[LAA] Add missing newline in debug print

2 years agoAdd myself to the office hours; correct small typo in prose
Aaron Ballman [Wed, 23 Feb 2022 13:13:15 +0000 (08:13 -0500)]
Add myself to the office hours; correct small typo in prose

2 years ago[Libomptarget][NFC} Fix missing newline in error message
Joseph Huber [Wed, 23 Feb 2022 13:09:53 +0000 (08:09 -0500)]
[Libomptarget][NFC} Fix missing newline in error message

2 years ago[MIPS] Recognize DT_MIPS_XHASH dynamic table tag
Simon Atanasyan [Wed, 23 Feb 2022 12:53:41 +0000 (15:53 +0300)]
[MIPS] Recognize DT_MIPS_XHASH dynamic table tag

LLVM tools do not emit `DT_MIPS_XHASH` dynamic table tag. But now
`llvm-objdump` and `llvm-readelf` recognize this tag and print it.

Fixes https://github.com/llvm/llvm-project/issues/53996

2 years agoRevert "[AggressiveInstCombine] Add `phi` nodes support to `TruncInstCombine`"
Anton Afanasyev [Wed, 23 Feb 2022 12:55:06 +0000 (15:55 +0300)]
Revert "[AggressiveInstCombine] Add `phi` nodes support to `TruncInstCombine`"

This reverts commit f84d732f8c1737940afab71824134f41f37a048b.
Breakage of "sanitizer-x86_64-linux-fast"

2 years agoAArch64: clamp UBFX high-bit to 32-bits
Tim Northover [Wed, 23 Feb 2022 11:49:43 +0000 (11:49 +0000)]
AArch64: clamp UBFX high-bit to 32-bits

We were producing invalid instructions like "ubfx w0, w0, #20, #16".

2 years ago[OpenCL] Align subgroup builtin guards
Sven van Haastregt [Wed, 23 Feb 2022 12:22:09 +0000 (12:22 +0000)]
[OpenCL] Align subgroup builtin guards

Until now, subgroup builtins are available with `opencl-c.h` when at
least one of `cl_intel_subgroups`, `cl_khr_subgroups`, or
`__opencl_c_subgroups` is defined.  With `-fdeclare-opencl-builtins`,
subgroup builtins are conditionalized on `cl_khr_subgroups` only.

Align `-fdeclare-opencl-builtins` to `opencl-c.h` by introducing the
internal `__opencl_subgroup_builtins` macro.

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

2 years ago[InstCombine] Remove unused visitUDivOperand() argument (NFC)
Nikita Popov [Wed, 23 Feb 2022 12:16:01 +0000 (13:16 +0100)]
[InstCombine] Remove unused visitUDivOperand() argument (NFC)

This function only works on the RHS operand.

2 years agoRevert "Revert "[analyzer] Fix taint rule of fgets and setproctitle_init""
Balazs Benics [Wed, 23 Feb 2022 11:55:31 +0000 (12:55 +0100)]
Revert "Revert "[analyzer] Fix taint rule of fgets and setproctitle_init""

This reverts commit 2acead35c1289d2b3593a992b0639ca6427e481f.

Let's try `REQUIRES: asserts`.

2 years agoRevert "Revert "[analyzer] Fix taint propagation by remembering to the location context""
Balazs Benics [Wed, 23 Feb 2022 11:53:07 +0000 (12:53 +0100)]
Revert "Revert "[analyzer] Fix taint propagation by remembering to the location context""

This reverts commit d16c5f4192c30d53468a472c6820163a81192825.

Let's try `REQUIRES: asserts`.

2 years ago[NFC][Lexer] Make access to LangOpts more consistent
Dawid Jurczak [Tue, 22 Feb 2022 11:46:56 +0000 (12:46 +0100)]
[NFC][Lexer] Make access to LangOpts more consistent

Before this change without any good reason Lexer::LangOpts is sometimes accessed by getter and another time read directly in Lexer functions.
Since getLangOpts is a bit more verbose prefer direct access to LangOpts member when possible.

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

2 years ago[ValueTracking] Support signed intrinsic clamp
Nikita Popov [Wed, 23 Feb 2022 11:40:31 +0000 (12:40 +0100)]
[ValueTracking] Support signed intrinsic clamp

This is the same special logic we apply for SPF signed clamps
when computing the number of sign bits, just for intrinsics.

This just uses the same logic as the select case, but there's
multiple directions this could be improved in: We could also use
the num sign bits from the clamped value, we could do this during
constant range calculation, and there's probably unsigned analogues
for the constant range case at least.

2 years ago[InstCombine] Add tests for add of clamp pattern (NFC)
Nikita Popov [Wed, 23 Feb 2022 11:21:42 +0000 (12:21 +0100)]
[InstCombine] Add tests for add of clamp pattern (NFC)

Add intrinsic versions of existing SPF tests.

2 years ago[C++20][Modules] Rework testcase to use split file [NFC].
iains [Tue, 22 Feb 2022 20:58:26 +0000 (20:58 +0000)]
[C++20][Modules] Rework testcase to use split file [NFC].

This switches the testcase committed for initial C++20 modules import tracking to
use split-file rather than preprocessor directives.

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

2 years ago[RISCV] Avoid infinite loop between DAGCombiner::visitMUL and RISCVISelLowering:...
Alex Bradbury [Wed, 23 Feb 2022 11:05:46 +0000 (11:05 +0000)]
[RISCV] Avoid infinite loop between DAGCombiner::visitMUL and RISCVISelLowering::transformAddImmMulImm

See https://github.com/llvm/llvm-project/issues/53831 for a full discussion.

The basic issue is that DAGCombiner::visitMUL and
RISCVISelLowering;:transformAddImmMullImm get stuck in a loop, as the
current checks in transformAddImmMulImm aren't sufficient to avoid all
cases where DAGCombiner::isMulAddWithConstProfitable might trigger a
transformation. This patch makes transformAddImmMulImm bail out if C0
(the constant used for multiplication) has more than one use.

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

2 years ago[AggressiveInstCombine] Add `phi` nodes support to `TruncInstCombine`
Anton Afanasyev [Wed, 15 Sep 2021 06:19:53 +0000 (09:19 +0300)]
[AggressiveInstCombine] Add `phi` nodes support to `TruncInstCombine`

Expand `TruncInstCombine` to handle loops by adding `phi` nodes
to expression graph.

Reviewed by: RKSimon, lebedev.ri

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

2 years ago[InstCombine] Fold sub of umin to usub.sat
Nikita Popov [Wed, 23 Feb 2022 10:56:34 +0000 (11:56 +0100)]
[InstCombine] Fold sub of umin to usub.sat

We were handling sub of umax, but not the conjugated umin case.

https://alive2.llvm.org/ce/z/4fdZfy
https://alive2.llvm.org/ce/z/BhUQBM

2 years ago[InstCombine] Add tests for sub of umin intrinsic (NFC)
Nikita Popov [Wed, 23 Feb 2022 10:49:18 +0000 (11:49 +0100)]
[InstCombine] Add tests for sub of umin intrinsic (NFC)

We should be converting these into usub.sat.

2 years ago[ArgPromotion] Regenerate test checks for crash.ll – restored ALL_OLDPM prefix,
Valery Pykhtin [Tue, 22 Feb 2022 07:36:26 +0000 (10:36 +0300)]
[ArgPromotion] Regenerate test checks for crash.ll – restored ALL_OLDPM prefix,
add –allow-unused-prefixes.

This test has two runs that differ in what functions are left after the inliner,
for example: barney exists on OLDPM path but don’t exist on NEWPM path.
I restored prefixes this test had had after automatic checks were introduced
for this test.

For now there are no checks left for ALL_NEWPM path, but the behavior seem to
change over time so I added –allow-unused-prefixes to ease following check updates.

Renamed %tmp => %temp IR values to avoid update warning.

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

2 years agoRevert "[clang][dataflow] Add support for global storage values"
Stanislav Gatev [Wed, 23 Feb 2022 10:32:17 +0000 (10:32 +0000)]
Revert "[clang][dataflow] Add support for global storage values"

This reverts commit 7ea103de140b59a64fc884fa90afd2213619384d.

2 years ago[Modules] Add module structure output to -module-file-info.
Iain Sandoe [Sat, 12 Feb 2022 13:43:32 +0000 (13:43 +0000)]
[Modules] Add module structure output to -module-file-info.

It is useful to be able to visualise the C++20 modules content of a PCM file
both for inspection and for testing.  In particular, when adding more module
types to support C++20 Partitions and Header Units, we would like to be able
to confirm that the output PCM has the intended structure.

The existing scheme for dumping data is restricted to the content of the AST
file control block, which does not include structural data beyond imports.

The change here makes use of the AST unit that is set up by BeginSourceFile
to query for the information on the primary and sub-modules.  We can then
inspect each of these in turn, accounting for Global, Private, Imported and
Exported modules/fragments and then showing the sub-stucture of the main
module(s).

The disadvantage of this mechanism is that it has no easy method to control
the granularity of the output.  Perhaps more detailed inspection would be
better handled by a stand-alone module inspection tool.

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

2 years ago[gn build] Port 25d7b4fb446b
LLVM GN Syncbot [Wed, 23 Feb 2022 10:12:15 +0000 (10:12 +0000)]
[gn build] Port 25d7b4fb446b

2 years ago[clang] CIndex.cpp - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim [Wed, 23 Feb 2022 10:09:40 +0000 (10:09 +0000)]
[clang] CIndex.cpp - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointers are used immediately, so assert the cast is correct instead of returning nullptr

2 years ago[flang][driver] Make `flang-new` always generate run-time type info
Andrzej Warzynski [Thu, 17 Feb 2022 13:32:32 +0000 (13:32 +0000)]
[flang][driver] Make `flang-new` always generate run-time type info

Currently, the driver generates the tables with "run-time type
information for derived types" only when specific actions are run.
However, the corresponding data might be required by the subsequent
compilation stages (e.g. lowering, code-gen) and should be generated
unconditionally. Note that this is only possible once the semantic
checks have been run.

Note that when generating these tables, extra semantic errors might be
generated. The driver will always report these and in most cases such
semantic errors will cause the driver to exit immediately. The only
exception are actions inheriting from `PrescanAndSemaDebugAction`.
Currently, there's only one such action: `DebugDumpAllAction`
(corresponds to `-fdebug-dump-all` command-line flag). I've updated the
comments for this action to clarify this.

This change will mostly affect lowering, which currently is only
available for most basic examples (e.g. empty programs). I wasn't able
to find a working case that would demonstrate the new behaviour. I
hope that this change is straightforward enough and am submitting it
without a test.

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

2 years ago[objcopy][NFC] Rename files to avoid clashing of archive members.
Alexey Lapshin [Tue, 22 Feb 2022 19:56:22 +0000 (22:56 +0300)]
[objcopy][NFC] Rename files to avoid clashing of archive members.

libtool uses file names to name members of an static library.
Files, located in different directories and having matching name,
would have the same name inside an archive. This is not a problem
for ld, but may be a problem for ar. This patch renames files
from ObjCopy library to avoid names clashing.

See https://reviews.llvm.org/D88827#3335814

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

2 years ago[mlir][Bazel] Fix wrong dependency for GPUBaseIncGen.
Adrian Kuegel [Wed, 23 Feb 2022 09:52:24 +0000 (10:52 +0100)]
[mlir][Bazel] Fix wrong dependency for GPUBaseIncGen.

2 years ago[Test][AggressiveInstCombine] Add test for `phi` instruction
Anton Afanasyev [Wed, 15 Sep 2021 06:18:51 +0000 (09:18 +0300)]
[Test][AggressiveInstCombine] Add test for `phi` instruction

2 years agoRevert "Revert "[analyzer] Add failing test case demonstrating buggy taint propagation""
Balazs Benics [Wed, 23 Feb 2022 09:37:03 +0000 (10:37 +0100)]
Revert "Revert "[analyzer] Add failing test case demonstrating buggy taint propagation""

This reverts commit b8ae323cca61dc1edcd36e9ae18c7e4c3d76d52e.

Let's try `REQUIRES: asserts`.

2 years ago[VE][NFC] Move functions to VVP module
Simon Moll [Wed, 23 Feb 2022 09:07:50 +0000 (10:07 +0100)]
[VE][NFC] Move functions to VVP module

Separate vector isel functions to the module they belong to. Keep scalar
stuff and calls into vector isel in the VEISelLowering.

2 years agoCleanup llvm/DebugInfo/PDB headers
serge-sans-paille [Sat, 19 Feb 2022 23:03:20 +0000 (00:03 +0100)]
Cleanup llvm/DebugInfo/PDB headers

accumulated preprocessed size:
before: 1065515095
after: 1065629059

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D120195

2 years ago[NFC] Add #include for constants
Bill Wendling [Wed, 23 Feb 2022 09:26:53 +0000 (01:26 -0800)]
[NFC] Add #include for constants

2 years ago[NFC] Add #include for constants
Bill Wendling [Wed, 23 Feb 2022 09:23:21 +0000 (01:23 -0800)]
[NFC] Add #include for constants

2 years ago[compiler-rt][builtins] Fix CMake builtin target flag
Tobias Hieta [Tue, 22 Feb 2022 08:52:09 +0000 (09:52 +0100)]
[compiler-rt][builtins] Fix CMake builtin target flag

clang-cl doesn't support -target <target>, instead it only supports
--target=<target> so building a RUNTIME configuration for clang-cl
ended up in never building builtins. Which in turn lead to clang-cl
not being able to find the runtime libraries because we depend
on the compiler_rt.builtins.lib being in the runtime dir for the
Driver to add it as a candidate.

I don't think this should have any downsides since most the code
these days are using --target=<target> instead of the old syntax.

Reviewed By: mstorsjo

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

2 years ago[NFC] Remove unnecessary "#include"s from header files
Bill Wendling [Wed, 23 Feb 2022 09:20:48 +0000 (01:20 -0800)]
[NFC] Remove unnecessary "#include"s from header files

2 years ago[ARM] Recognize SSAT and USAT from SMIN/SMAX
David Green [Wed, 23 Feb 2022 08:55:54 +0000 (08:55 +0000)]
[ARM] Recognize SSAT and USAT from SMIN/SMAX

We have some recognition of SSAT and USAT from SELECT_CC at the moment.
This extends the matching to SMIN/SMAX which can help catch more cases,
either from min/max being the canonical form in instcombine or from some
expanded nodes like fp_to_si_sat.

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

2 years ago[InstCombine] Remove one-use limitation from X-Y==0 fold
Nikita Popov [Tue, 22 Feb 2022 16:53:14 +0000 (17:53 +0100)]
[InstCombine] Remove one-use limitation from X-Y==0 fold

This one-use limitation is artificial, we do not increase
instruction count if we perform the fold with multiple uses. The
motivating case is shown in @sub_eq_zero_select, where the one-use
limitation causes us to miss a subsequent select fold.

I believe the backend is pretty good about reusing flag-producing
subs for cmps with same operands, so I think doing this is fine.

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

2 years ago[clang-tidy][NFC] Remove Tristate from CachedGlobList
Nathan James [Wed, 23 Feb 2022 08:35:30 +0000 (08:35 +0000)]
[clang-tidy][NFC] Remove Tristate from CachedGlobList

The tristate is a little redundant as we can determine if the item was already in the cache based on the return from try_emplace.

Reviewed By: salman-javed-nz

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

2 years ago[ASTMatchers] Expand isInline matcher to VarDecl
Nathan James [Wed, 23 Feb 2022 08:33:58 +0000 (08:33 +0000)]
[ASTMatchers] Expand isInline matcher to VarDecl

Add support to the `isInline` matcher for C++17's inline variables.

Reviewed By: aaron.ballman

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

2 years ago[NFC] Add unittest for Decl::isInExportDeclContext
Chuanqi Xu [Wed, 23 Feb 2022 08:22:55 +0000 (16:22 +0800)]
[NFC] Add unittest for Decl::isInExportDeclContext

2 years ago[clang][dataflow] Add support for global storage values
Stanislav Gatev [Fri, 18 Feb 2022 18:51:42 +0000 (18:51 +0000)]
[clang][dataflow] Add support for global storage values

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D120149

2 years ago[gn build] Port a2fab82f33bb
LLVM GN Syncbot [Wed, 23 Feb 2022 08:21:48 +0000 (08:21 +0000)]
[gn build] Port a2fab82f33bb

2 years ago[pseudo] Implement LRTable.
Haojian Wu [Fri, 11 Feb 2022 13:09:15 +0000 (14:09 +0100)]
[pseudo] Implement LRTable.

This patch introduces a dense implementation of the LR parsing table, which is
used by LR parsers.

We build a SLR(1) parsing table from the LR(0) graph.

Statistics of the LR parsing table on the C++ spec grammar:
  - number of states: 1449
  - number of actions: 83069
  - size of the table (bytes): 334928

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

2 years ago[RISCV] Add more test for GORCI aliaes in Zbp extension
Lian Wang [Wed, 23 Feb 2022 08:01:51 +0000 (08:01 +0000)]
[RISCV] Add more test for GORCI aliaes in Zbp extension

Supplement tests for some aliaes of gorci.

RV32:
add orc4.h/orc2.h in rv32zbp.ll
add orc.h/orc16/orc8/orc4/orc2/orc in rv32zbp-intrinsic.ll

RV64:
add orc4.h/orc2.h in rv64zbp.ll
add orc.h/orc32/orc16/orc8/orc4/orc2/orc/orc16.w/orc8.w/
    orc4.w/orc2.w/orc.w in rv64zbp-intrinsic.ll

Reviewed By: craig.topper

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

2 years ago[flang] Lower real constant
Valentin Clement [Wed, 23 Feb 2022 07:27:10 +0000 (08:27 +0100)]
[flang] Lower real constant

This patch handles lowering of real constant.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[RISCV] Supplement more tests for GREVI aliaes in Zbp extension
Lian Wang [Wed, 23 Feb 2022 06:14:58 +0000 (06:14 +0000)]
[RISCV] Supplement more tests for GREVI aliaes in Zbp extension

Supplement tests for some aliaes of grevi.

RV32:
add rev4.h/rev2.h in rv32zbp.ll
add rev/rev2/rev4/rev8/rev16 in rv32zbp-intrinsic.ll

RV64:
add rev4.h/rev2.h in rv64zbp.ll
add rev.h/rev/rev2/rev4/rev8/rev16/rev32/rev.w/rev2.w/
    rev4.w/rev8.w/rev16.w in rv64zbp-intrinsic.ll

Reviewed By: craig.topper

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

2 years ago[SampleProfile] Handle the case when the option `MaxNumPromotions` is zero.
minglotus-6 [Tue, 22 Feb 2022 03:17:06 +0000 (19:17 -0800)]
[SampleProfile] Handle the case when the option `MaxNumPromotions` is zero.

In places where `MaxNumPromotions` is used to allocated an array, bail out early to prevent allocating an array of length 0.

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

2 years ago[ELF][test] Fix CU address_size in some gdb-index tests
Fangrui Song [Wed, 23 Feb 2022 05:42:15 +0000 (21:42 -0800)]
[ELF][test] Fix CU address_size in some gdb-index tests

Revert 251640ab575634256de6d6fde5c5359fe21efe91 which fixed the wrong thing.

While here, add `2>&1 | count 0` to assert no warning from lib/DebugInfo/DWARF.

2 years ago[ProfileData] Remove unused and racy FunctionSamples::Format after D51643
Fangrui Song [Wed, 23 Feb 2022 04:29:08 +0000 (20:29 -0800)]
[ProfileData] Remove unused and racy FunctionSamples::Format after D51643

The write may be racy if ThinLTO creates multiple `InProcessThinBackend` instances.

2 years ago[compiler-rt][builtins] build the macOS compiler-rt built-ins with Mac Catalyst support
Alex Lorenz [Mon, 14 Feb 2022 22:20:28 +0000 (14:20 -0800)]
[compiler-rt][builtins] build the macOS compiler-rt built-ins with Mac Catalyst support

This patch extends compiler-rt's cmake config to build macOS builtins with both macOS and Mac Catalyst support.
This is done by telling the compiler to emit macho files with two build version load commands.

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

2 years ago[ELF][test] Terminate .debug_info with a null entry to fix warnings
Fangrui Song [Wed, 23 Feb 2022 03:20:55 +0000 (19:20 -0800)]
[ELF][test] Terminate .debug_info with a null entry to fix warnings

2 years ago[clang] Remove Address::deprecated() calls in CodeGenFunction.cpp
Arthur Eubanks [Wed, 23 Feb 2022 02:28:32 +0000 (18:28 -0800)]
[clang] Remove Address::deprecated() calls in CodeGenFunction.cpp

2 years ago[OpenMP] Remove static allocator in linker wrapper
Joseph Huber [Wed, 23 Feb 2022 02:21:33 +0000 (21:21 -0500)]
[OpenMP] Remove static allocator in linker wrapper

Summary:
We don't need this static allocator to survive the entire file, the
strings stored have a defined lifetime.

2 years ago[OpenMP] Unrecognized objects should not be considered failure
Joseph Huber [Wed, 23 Feb 2022 02:13:03 +0000 (21:13 -0500)]
[OpenMP] Unrecognized objects should not be considered failure

Summary:
This patch removes the error we recieve when attempting to extract
offloading sections. We shouldn't consider this a failure because
extracting bitcode isn't necessarily required.

2 years agoRemove redundant word word in AsmParser DIFlag parsing
David Blaikie [Wed, 23 Feb 2022 01:49:38 +0000 (17:49 -0800)]
Remove redundant word word in AsmParser DIFlag parsing