platform/upstream/llvm.git
2 years ago[lldb/test] Add events listener helper function to lldbtest
Med Ismail Bennani [Wed, 23 Mar 2022 19:29:47 +0000 (12:29 -0700)]
[lldb/test] Add events listener helper function to lldbtest

This patch introduces 2 new lldb utility functions:
- lldbutil.start_listening_from: This can be called in the test setup to
  create a listener and set it up for a specific event mask and add it
  to the user-provided broadcaster's list.
- lldbutil.fetch_next_event: This will use fetch a single event from the
  provided istener and return it if it matches the provided broadcaster.

The motivation behind this is to easily test new kinds of events
(i.e. Swift type-system progress events). However, this patch also
updates `TestProgressReporting.py` and `TestDiagnosticReporting.py`
to make use of these new helper functions.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[InstCombine] Fold abs of known negative operand when source is sub
chenglin.bi [Wed, 23 Mar 2022 19:02:30 +0000 (15:02 -0400)]
[InstCombine] Fold abs of known negative operand when source is sub

When abs source comes from (x - y), check if a "x > y" dominating
condition exists.

Fixes #54132

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

2 years ago[RISCV] Simplify some code in lowering vector int<->fp conversions. NFC
Craig Topper [Wed, 23 Mar 2022 19:02:07 +0000 (12:02 -0700)]
[RISCV] Simplify some code in lowering vector int<->fp conversions. NFC

Don't call EltVT.getSizeInBits() or SrcEltVT.getSizeInBits() a second
time. They are already in EltSize or SrcEltSize variables.

Refactor some comparisons to use multiply instead of division.

2 years ago[InstCombine] Add some initial SimplifyDemandedBits tests for removal of ashr with...
Simon Pilgrim [Wed, 23 Mar 2022 18:27:41 +0000 (18:27 +0000)]
[InstCombine] Add some initial SimplifyDemandedBits tests for removal of ashr with sufficient signbits

We have this in SelectionDAG but it's missing in InstCombine

Based off PR21929 test case

2 years ago[clang][extract-api] Enable processing of multiple headers
Daniel Grumberg [Mon, 21 Mar 2022 19:41:29 +0000 (19:41 +0000)]
[clang][extract-api] Enable processing of multiple headers

Before actually executing the ExtractAPIAction, clear the
CompilationInstance's input list and replace it with a single
synthesized file that just includes (or imports in ObjC) all the inputs.

Depends on D122141

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

2 years ago[mlir][sparse] Adding {pointer,index}OverheadTypeEncoding
wren romano [Mon, 21 Mar 2022 23:49:54 +0000 (16:49 -0700)]
[mlir][sparse] Adding {pointer,index}OverheadTypeEncoding

Work towards: https://github.com/llvm/llvm-project/issues/51652

The new functions fill the gap between `overheadTypeEncoding` and `get{Pointer,Index}OverheadType`.

Reviewed By: aartbik

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

2 years ago[test] Remove the last couple uses of -analyze in llvm/test
Arthur Eubanks [Wed, 23 Mar 2022 18:31:12 +0000 (11:31 -0700)]
[test] Remove the last couple uses of -analyze in llvm/test

2 years ago[test] Set -verify-cfg-preserved=0 in new-pm-defaults.ll
Arthur Eubanks [Wed, 23 Mar 2022 18:09:41 +0000 (11:09 -0700)]
[test] Set -verify-cfg-preserved=0 in new-pm-defaults.ll

Matches other similar tests.

2 years ago[PassManager][Coroutine] Run passes under -O0 conditionally and run GlobalDCE
Arthur Eubanks [Tue, 22 Mar 2022 23:51:36 +0000 (16:51 -0700)]
[PassManager][Coroutine] Run passes under -O0 conditionally and run GlobalDCE

CoroSplit lowers various coroutine intrinsics. It's a CGSCC pass and
CGSCC passes don't run on unreachable functions. Normally GlobalDCE will
come along and delete unreachable functions, but we don't run GlobalDCE
under -O0, so an unreachable function with coroutine intrinsics may
never have CoroSplit run on it.

This patch adds GlobalDCE when coroutines intrinsics are present. It
also now runs all coroutine passes conditional when coroutine intrinsics
are present. This should also solve the -O0 regression reported in
D105877 due to LazyCallGraph construction.

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

Reviewed By: ChuanqiXu

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

2 years agoRevert "Recommit "[SLP] Fix lookahead operand reordering for splat loads." attempt...
Arthur Eubanks [Wed, 23 Mar 2022 17:51:42 +0000 (10:51 -0700)]
Revert "Recommit "[SLP] Fix lookahead operand reordering for splat loads." attempt 2, fixed assertion crash."

This reverts commit 27bd8f94928201f87f6b659fc2228efd539e8245.

Causes crashes, see comments in D121973

2 years ago[lld][Macho][NFC] Encapsulate priorities map in a priority class
Roger Kim [Wed, 23 Mar 2022 17:21:34 +0000 (13:21 -0400)]
[lld][Macho][NFC] Encapsulate priorities map in a priority class

`config->priorities` has been used to hold the intermediate state during the construction of the order in which sections should be laid out. This is not a good place to hold this state since the intermediate state is not a "configuration" for LLD. It should be encapsulated in a class for building a mapping from section to priority (which I created in this diff as the `PriorityBuilder` class).

The same thing is being done for `config->callGraphProfile`.

Reviewed By: #lld-macho, int3

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

2 years ago[clangd] Fix IncludeFixer test on windows
Sam McCall [Wed, 23 Mar 2022 17:55:56 +0000 (18:55 +0100)]
[clangd] Fix IncludeFixer test on windows

Actual functionality doesn't seem to work with (default)
-fms-compatibility. Not sure why yet...

2 years ago[libc++] Correct outdated documentation about __config_site
Louis Dionne [Wed, 23 Mar 2022 17:40:15 +0000 (13:40 -0400)]
[libc++] Correct outdated documentation about __config_site

The way we handle __config_site changed 1-2 years ago, and the
documentation was never updated -- this commit does that.

2 years ago[flang][Evaluate] Fold DBLE
Roger Ferrer Ibanez [Wed, 23 Mar 2022 05:55:56 +0000 (05:55 +0000)]
[flang][Evaluate] Fold DBLE

We can reuse the folding of REAL.

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

2 years agoChange __auto_type behavior with qualifiers to match GCC behavior
Aaron Ballman [Wed, 23 Mar 2022 17:24:53 +0000 (13:24 -0400)]
Change __auto_type behavior with qualifiers to match GCC behavior

Currently, Clang handles some qualifiers correctly for __auto_type, but
it does not handle the restrict or _Atomic qualifiers in the same way
that GCC does. This patch handles those qualifiers so that they attach
to the deduced type the same as const and volatile already do.

This fixes https://github.com/llvm/llvm-project/issues/53652

2 years ago[libc++][NFC] Change availability macro from macosx to macos
Louis Dionne [Wed, 23 Mar 2022 17:12:55 +0000 (13:12 -0400)]
[libc++][NFC] Change availability macro from macosx to macos

The Clang documentation mentions that macosx is supported for backwards
compatibility, but it's deprecated.

2 years ago[libc++][NFC] Fix include guards and add a missing license header
Louis Dionne [Wed, 23 Mar 2022 17:11:04 +0000 (13:11 -0400)]
[libc++][NFC] Fix include guards and add a missing license header

2 years ago[lldb] Fixup tagged pointers ISAs
Jonas Devlieghere [Wed, 23 Mar 2022 16:46:12 +0000 (09:46 -0700)]
[lldb] Fixup tagged pointers ISAs

This patch upstreams support for tagger pointer ISAs.

2 years ago[SelectionDAG] Don't create entries in ValueMap in ComputePHILiveOutRegInfo
Craig Topper [Wed, 23 Mar 2022 16:28:46 +0000 (09:28 -0700)]
[SelectionDAG] Don't create entries in ValueMap in ComputePHILiveOutRegInfo

Instead of using operator[], use DenseMap::find to prevent default
constructing an entry if it isn't already in the map.

Also simplify a condition to check for 0 instead of a virtual register.
I'm pretty sure we can only get 0 or a virtual register out of the value
map.

2 years ago[flang][NFC] Add module lowering tests
Valentin Clement [Wed, 23 Mar 2022 16:49:40 +0000 (17:49 +0100)]
[flang][NFC] Add module lowering tests

This patch adds test for the lowering of Fortran modules.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[RISCV] Remove check and update test file in D121183
luxufan [Wed, 23 Mar 2022 06:14:12 +0000 (14:14 +0800)]
[RISCV] Remove check and update test file in D121183

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

2 years ago[RISCV] Generate correct ELF EFlags when .ll file has target-abi attribute
luxufan [Tue, 8 Mar 2022 05:55:13 +0000 (13:55 +0800)]
[RISCV] Generate correct ELF EFlags when .ll file has target-abi attribute

In the past, when construct RISCVAsmBackend, MCTargetOptions.ABIName would be passed and stored in RISCVAsmBackend.
But MCTargetOptions.ABIName can only be specified by -target-abi xxx in command line, if the .ll file has target-abi attribute, the codegen module will ignore it. And the generated object file would have incorrect EFlags value.

https://github.com/llvm/llvm-project/issues/50591 also caused by this problem.

This patch override the AsmPrinter::emitFunctionEntryLabel function and use it to set the target abi value that get from .ll file's target-abi attribute. And storing the target-abi in RISCVTargetStreamer instead of RISCVAsmBackend.

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

2 years ago[clang][extract-api] Add struct support
Zixu Wang [Tue, 22 Mar 2022 02:11:29 +0000 (19:11 -0700)]
[clang][extract-api] Add struct support

- Add `StructFieldRecord` and `StructRecord` to store API information
  for structs
- Implement `VisitRecordDecl` in `ExtractAPIVisitor`
- Implement Symbol Graph serialization for struct records.
- Add test case for struct records.

Depends on D121873

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

2 years ago[AArch64] Add tests showing inefficient TBL3/4 generation. NFC
David Green [Wed, 23 Mar 2022 16:43:23 +0000 (16:43 +0000)]
[AArch64] Add tests showing inefficient TBL3/4 generation. NFC

2 years ago[clang][extract-api] Add enum support
Zixu Wang [Thu, 17 Mar 2022 00:49:31 +0000 (17:49 -0700)]
[clang][extract-api] Add enum support

Add support for enum records
- Add `EnumConstantRecord` and `EnumRecord` to store API information for
  enums
- Implement `VisitEnumDecl` in `ExtractAPIVisitor`
- Implement serializatin for enum records and `MemberOf` relationship
- Add test case for enum records
- Few other improvements

Depends on D122160

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

2 years ago[Clang][NeonEmitter] emit ret decl first for -Wdeclaration-after-statement
Nick Desaulniers [Wed, 23 Mar 2022 16:30:50 +0000 (09:30 -0700)]
[Clang][NeonEmitter] emit ret decl first for -Wdeclaration-after-statement

The generated arm_neon.h header isn't -Wdeclaration-after-statement
compliant when targeting -mbig-endian. Update the generator to declare
the return value, if any, first before any other arguments that might
need to be "reversed" from little endian to big.

Another approach would have been to try to ignore this warning in system
headers, though that might not be precise for tokens involved in macro
expansion. See also: https://reviews.llvm.org/D116833#3236209.

Link: https://github.com/ClangBuiltLinux/linux/issues/1603
Fixes: https://github.com/llvm/llvm-project/issues/54062

Reviewed By: DavidSpickett

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

2 years ago[Clang] Fix PR28101
PoYao Chang [Wed, 23 Mar 2022 01:12:05 +0000 (09:12 +0800)]
[Clang] Fix PR28101

Fixes https://github.com/llvm/llvm-project/issues/28475 (PR28101)
by setting identifier for invalid member variables with template parameters,
so that the invalid declarators would not crash clang.

See also: https://github.com/llvm/llvm-project/commit/942c03910a

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

2 years ago[clang][extract-api] Suppprt for the module name property in SymbolGraph
Daniel Grumberg [Wed, 16 Mar 2022 13:38:54 +0000 (13:38 +0000)]
[clang][extract-api] Suppprt for the module name property in SymbolGraph

Adds `--product-name=` flag to the clang driver. This gets forwarded to
cc1 only when we are performing a ExtractAPI Action. This is used to
populate the `name` field of the module object in the generated SymbolGraph.

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

2 years ago[clangd] Add inlay hints for auto-typed parameters with one instantiation.
Sam McCall [Mon, 21 Feb 2022 17:15:53 +0000 (18:15 +0100)]
[clangd] Add inlay hints for auto-typed parameters with one instantiation.

This takes a similar approach as b9b6938183e, and shares some code.
The code sharing is limited as inlay hints wants to deduce the type of the
variable rather than the type of the `auto` per-se.

It drops support (in both places) for multiple instantiations yielding the same
type, as this is pretty rare and hard to build a nice API around.

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

2 years ago[libc][File] Fix a bug under fseek(..., SEEK_CUR).
Siva Chandra Reddy [Wed, 23 Mar 2022 03:55:06 +0000 (03:55 +0000)]
[libc][File] Fix a bug under fseek(..., SEEK_CUR).

Reviewed By: lntue

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

2 years ago[clangd] Support include-fixer inside macro arguments.
Sam McCall [Sat, 26 Feb 2022 17:35:14 +0000 (18:35 +0100)]
[clangd] Support include-fixer inside macro arguments.

Motivating case: EXPECT_EQ(42, missingFunction(bar));

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

2 years ago[AMDGPU] Add missing testcase for SGPR to AGPR copy
hsmahesha [Wed, 23 Mar 2022 15:51:58 +0000 (21:21 +0530)]
[AMDGPU] Add missing testcase for SGPR to AGPR copy

and, also update the function indirectCopyToAGPR() to ensure that it is called only on GFX908 sub-target.

Reviewed By: rampitec

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

2 years ago[flang][NFC] Add nested where lowering test
Valentin Clement [Wed, 23 Mar 2022 16:03:04 +0000 (17:03 +0100)]
[flang][NFC] Add nested where lowering test

this patch adds lowering tests for
netsed where statements

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang][NFC] Add global lowering tests
Valentin Clement [Wed, 23 Mar 2022 16:01:28 +0000 (17:01 +0100)]
[flang][NFC] Add global lowering tests

This patch adds some lowering tests for globals.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoPass split-machine-functions to code generator when flto is used
Junfeng Dong [Wed, 23 Mar 2022 15:54:52 +0000 (08:54 -0700)]
Pass split-machine-functions to code generator when flto is used

-fsplit-machine-functions is an optimization in codegen phase. when -flto is use, clang generate IR bitcode in .o files, and linker will call into these codegen optimization passes. Current clang driver doesn't pass this option to linker when both -fsplit-machine-functions and -flto are used, so the optimization is silently ignored.  My fix generates linker option -plugin-opt=-split-machine-functions for this case. It allows the linker to pass "split-machine-functions" to code generator to turn on that optimization.  It works for both gold and lld.

Reviewed By: hoy, wenlei

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

2 years ago[flang][NFC] Add IO related lowering tests
Valentin Clement [Wed, 23 Mar 2022 15:53:11 +0000 (16:53 +0100)]
[flang][NFC] Add IO related lowering tests

This patch adds lowering tests for IO related use cases.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang][NFC] Add namelist lowering test
Valentin Clement [Wed, 23 Mar 2022 15:51:39 +0000 (16:51 +0100)]
[flang][NFC] Add namelist lowering test

This patch adds a lowering test for the namelist.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years ago[EarlyCSE] Don't eagerly optimize MemoryUses
Nikita Popov [Thu, 10 Mar 2022 15:31:27 +0000 (16:31 +0100)]
[EarlyCSE] Don't eagerly optimize MemoryUses

EarlyCSE currently optimizes all MemoryUses upfront. However,
EarlyCSE only actually queries the clobbering memory access for
a subset of uses, namely those where a CSE candidate has already
been identified. Delaying use optimization to the clobber query
improves compile-time in practice.

This change is not NFC because EarlyCSE has a limit on the number
of clobber queries (EarlyCSEMssaOptCap), in which case it falls
back to the defining access. The defining access for uses will now
no longer coincide with the optimized access.

If there are performance regressions from this change, we should
be able to address them by raising this limit.

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

2 years ago[AArch64] Fallback to DWARF when trying to emit compact unwind info with multiple...
Momchil Velikov [Wed, 23 Mar 2022 14:54:06 +0000 (14:54 +0000)]
[AArch64] Fallback to DWARF when trying to emit compact unwind info with multiple CFA offset adjustments

Instead of asserting, fallback to emitting DWARF unwind info when an
attempt is made to output compact unwind info for a function with
multiple adjustments to the CFA offset.

Multiple adjustments of SP are common and with instruction precise
unwind tables these may translate into multiple `.cfi_def_cfa_offset`
directives.

Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=1302998

Reviewed By: dmgreen

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

2 years ago[Dockerfile] Upgrade debian base image to version 10
Xiaodong Liu [Wed, 23 Mar 2022 15:25:21 +0000 (15:25 +0000)]
[Dockerfile] Upgrade debian base image to version 10

Debian8 is too old to build LLVM project, the version
of GCC, CMake and python are lower than the requirements:
https://llvm.org/docs/GettingStarted.html#software

Debian10 is the earliest release that has software
packages that meet the above requirements.

Reviewed By: sammccall

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

2 years ago[InstCombine] try to narrow shifted bswap-of-zext (2nd try)
Sanjay Patel [Wed, 23 Mar 2022 13:06:47 +0000 (09:06 -0400)]
[InstCombine] try to narrow shifted bswap-of-zext (2nd try)

The first attempt at this missed a validity check.
This version includes a test of the narrow source
type for modulo-16-bits.

Original commit message:

This is the IR counterpart to 370ebc9d9a573d6
which provided a bswap narrowing fix for issue #53867.

Here we can be more general (although I'm not sure yet
what would happen for illegal types in codegen - too
rare to worry about?):
https://alive2.llvm.org/ce/z/3-CPfo

This will be more effective if we have moved the shift
after the bswap as proposed in D122010, but it is
independent of that patch.

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

2 years ago[InstCombine] add test for bogus bswap; NFC
Sanjay Patel [Wed, 23 Mar 2022 11:53:11 +0000 (07:53 -0400)]
[InstCombine] add test for bogus bswap; NFC

This is reduced from a crash caused by D122166.

2 years ago[clang-format] Handle attributes before case label. Relanded.
Marek Kurdej [Wed, 9 Mar 2022 10:05:34 +0000 (11:05 +0100)]
[clang-format] Handle attributes before case label. Relanded.

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

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

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

Relanding as the original patch provoked an infinite loop in JavaScript/TypeScript.
A reproducer test case was added and the issue fixed.

2 years ago[Flang] Lower sin, cos intrinsics
Kiran Chandramohan [Wed, 23 Mar 2022 15:20:22 +0000 (15:20 +0000)]
[Flang] Lower sin, cos intrinsics

The intrinsic computes the sin, cosine values. By default they are lowered
to runtime calls to the pgmath library, for llvm lowering they are
lowered to llvm intrinsics. The generic and llvm lowering does not
lower floating point types with kind greater than 8, the llvm lowering
does not support the complex types.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: clementval

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[Concepts] Fix placeholder constraints when references are involved
Roy Jacobson [Sat, 19 Mar 2022 17:26:02 +0000 (13:26 -0400)]
[Concepts] Fix placeholder constraints when references are involved

Placeholder types were not checked for constraint satisfaction when modified by references or pointers.
The behavior now matches that of GCC and MSVC.

Are there other modifiers we might need to "peel"? I'm not sure my approach to this is the 'right' way to fix this, the loop feels a bit clunky.

GitHub issues [[ https://github.com/llvm/llvm-project/issues/54443 | #54443 ]], [[ https://github.com/llvm/llvm-project/issues/53911 | #53911 ]]

Reviewed By: erichkeane

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

2 years ago[Clang][NFC] Some `const` for `IdentifierInfo *`s feeding `DeclarationName`
Hubert Tong [Wed, 23 Mar 2022 15:03:44 +0000 (11:03 -0400)]
[Clang][NFC] Some `const` for `IdentifierInfo *`s feeding `DeclarationName`

`DeclarationName` already takes `const IdentifierInfo *`. Propagate the
`const` outward to various APIs.

Reviewed By: aaron.ballman

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

2 years ago[LangRef] Allow non-power-of-two assume operand bundle
Nikita Popov [Thu, 10 Feb 2022 08:45:08 +0000 (09:45 +0100)]
[LangRef] Allow non-power-of-two assume operand bundle

There has been a lot of confusion on this in the past (see for
example https://reviews.llvm.org/D110634 and earlier revisions),
so let's try to get some clarity here. This patch specifies that
a) specifying a non-constant assumed alignment is explicitly
allowed and b) an invalid (non-power-of-two) alignment is not UB,
but rather converts it into an assumption that the pointer is null.

This change is done for two reasons:
a) Assume operand bundles are specifically used in cases where the
alignment is not known during frontend codegen (otherwise we'd just
use an align attribute), so rejecting this case doesn't make sense.
b) At least for aligned_alloc the C standard specifies that passing
an invalid alignment results in a null pointer, not undefined
behavior.

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

2 years ago[Flang] Lower atan, sinh, cosh intrinsics
Kiran Chandramohan [Wed, 23 Mar 2022 14:39:11 +0000 (14:39 +0000)]
[Flang] Lower atan, sinh, cosh intrinsics

The intrinsic computes the tan and hyperbolic sin, cosine values. By
default they are lowered to runtime calls to the math library. Not all
types are supported currently. The generic and llvm lowering does not
lower floating point types with kind greater than 8, the llvm lowering
does not support the complex types.

Note: tanh is not present in fir-dev hence ignoring for now. We can add
support after upstreaming is complete. sin and cos will come in separate
patches since they have llvm intrinsic lowering.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: William Moses <gh@wsmoses.com>
2 years ago[clang][deps] NFC: De-duplicate clang-cl tests
Jan Svoboda [Wed, 23 Mar 2022 14:29:49 +0000 (15:29 +0100)]
[clang][deps] NFC: De-duplicate clang-cl tests

In D92191, a bunch of test cases were added to check `clang-scan-deps` works in `clang-cl` mode as well.

We don't need to duplicate all test cases, though. Testing the few special cases we have in `clang-scan-deps` for `clang-cl` should be good enough:

1. Deducing output path (and therefore target name in our make output).
2. Ignoring `-Xclang` arguments in step 1.
3. Deducing resource directory by invoking the compiler executuable.

This test de-duplicates the extra clang-cl test cases.

Reviewed By: dexonsmith, saudi

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

2 years ago[clang][deps] Create lit substitution for deps-to-rsp
Jan Svoboda [Wed, 23 Mar 2022 13:59:03 +0000 (14:59 +0100)]
[clang][deps] Create lit substitution for deps-to-rsp

This patch gets rid of the ridiculous relative path we use to invoke the `module-deps-to-rsp.py` script and creates proper lit substitution, cleaning up the tests.

Reviewed By: dexonsmith

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

2 years ago[FuncSpec][NFC] Clang-format the source code and fix debug typo.
Alexandros Lamprineas [Wed, 23 Mar 2022 14:23:17 +0000 (14:23 +0000)]
[FuncSpec][NFC] Clang-format the source code and fix debug typo.

2 years ago[CGExpr] Perform bitcast unconditionally
Nikita Popov [Wed, 23 Mar 2022 14:32:36 +0000 (15:32 +0100)]
[CGExpr] Perform bitcast unconditionally

The way the check is written is not compatible with opaque
pointers -- while we don't need to change the IR pointer type,
we do need to change the element type stored in the Address.

2 years ago[Bitcode] Check for live uses of llvm.cmdline/embedded.module
Nikita Popov [Wed, 23 Mar 2022 14:19:29 +0000 (15:19 +0100)]
[Bitcode] Check for live uses of llvm.cmdline/embedded.module

The one use check here is very misleading: At this point we should
actually have no uses, because the only possible use in llvm.used
was already dropped. But because the use in llvm.used is generally
bitcasted, we end up still having one dead use here.

What we actually want to check is that there are no live uses, for
which a helper has recently been added.

2 years ago[InstrProfiling] Account for missing bitcast/GEP
Nikita Popov [Wed, 23 Mar 2022 13:58:24 +0000 (14:58 +0100)]
[InstrProfiling] Account for missing bitcast/GEP

This code is supposed to clean up a constexpr bitcast/GEP, but
with opaque pointers this ends up dropping references to the
global.

2 years ago[CGObjCMac] Check global value type instead of poitner type
Nikita Popov [Wed, 23 Mar 2022 13:27:32 +0000 (14:27 +0100)]
[CGObjCMac] Check global value type instead of poitner type

As we're going to reassign the initializer, we actually need the
value types to match, not just the pointer types. This is only
relevant with opaque pointers.

2 years ago[CGBlocks] Don't assume presence of bitcast
Nikita Popov [Wed, 23 Mar 2022 13:15:06 +0000 (14:15 +0100)]
[CGBlocks] Don't assume presence of bitcast

With opaque pointers, the bitcast constexpr will not be present.

2 years ago[Clang][NFC] Cleanup dcl.constexpr/p3 tests
Corentin Jabot [Tue, 22 Mar 2022 22:47:51 +0000 (23:47 +0100)]
[Clang][NFC] Cleanup dcl.constexpr/p3 tests

* Check for warnings instead of using -Werror, to avoid masking the
type of diagnostic emitted

* use different -verify labels instead of using conditional
compilation of diagnostic checks

Reviewed By: aaron.ballman

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

2 years ago[compiler-rt] Remove forgotten mention of SVN modules, LLVM now uses Git.
Frederic Cambus [Wed, 23 Mar 2022 14:28:46 +0000 (15:28 +0100)]
[compiler-rt] Remove forgotten mention of SVN modules, LLVM now uses Git.

2 years ago[flang][NFC] Add character lowering tests
Valentin Clement [Wed, 23 Mar 2022 14:27:36 +0000 (15:27 +0100)]
[flang][NFC] Add character lowering tests

This patch some lowering tests for characters related operations.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years ago[flang][NFC] Add call lowering tests
Valentin Clement [Wed, 23 Mar 2022 14:25:59 +0000 (15:25 +0100)]
[flang][NFC] Add call lowering tests

This patch adds various lowering test
for calls.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Mats Petersson <mats.petersson@arm.com>
2 years ago[flang][NFC] Add misc lowering tests
Valentin Clement [Wed, 23 Mar 2022 14:24:00 +0000 (15:24 +0100)]
[flang][NFC] Add misc lowering tests

This patch adds some lowering tests.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang] Add lowering C interoperability test
Valentin Clement [Wed, 23 Mar 2022 14:22:08 +0000 (15:22 +0100)]
[flang] Add lowering C interoperability test

This patch adds a lowering test for the C
interoperability.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[clang][AArc64][SVE] Implement vector-scalar operators
David Truby [Wed, 16 Mar 2022 14:23:57 +0000 (14:23 +0000)]
[clang][AArc64][SVE] Implement vector-scalar operators

This patch extends the support for C/C++ operators for SVE
types to allow one of the arguments to be a scalar, in which
case a vector splat is performed.

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

2 years agoFix LLVM sphinx build
Aaron Ballman [Wed, 23 Mar 2022 14:17:01 +0000 (10:17 -0400)]
Fix LLVM sphinx build

This amends a749e3295df4aee18a0ad723875a6501f30ac744 to fix a few
missed targets in the contributor documentation.

2 years agoCleanup include: Add missing header
serge-sans-paille [Wed, 23 Mar 2022 14:15:07 +0000 (15:15 +0100)]
Cleanup include: Add missing header

Should fix https://lab.llvm.org/buildbot#builders/57/builds/16192 introduced by
02c28970b26b3888543d0a4c343a569fbf8fe16b

2 years agoReplace links to archived mailing lists by links to Discourse forums
Danny Mösch [Wed, 23 Mar 2022 14:10:20 +0000 (10:10 -0400)]
Replace links to archived mailing lists by links to Discourse forums

2 years ago[clang][lex] Fix failures with Microsoft header search rules
Jan Svoboda [Tue, 22 Mar 2022 16:03:58 +0000 (17:03 +0100)]
[clang][lex] Fix failures with Microsoft header search rules

`HeaderSearch` currently assumes `LookupFileCache` is eventually populated in `LookupFile`. However, that's not always the case with `-fms-compatibility` and its early returns.

This patch adds a defensive check that the iterator pulled out of the cache is actually valid before using it.

(This bug was introduced in D119721. Before that, the cache was initialized to `0` - essentially the `search_dir_begin()` iterator.)

Reviewed By: dexonsmith, erichkeane

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

2 years agoUnbreak the build after 02c28970b2
Benjamin Kramer [Wed, 23 Mar 2022 13:38:13 +0000 (14:38 +0100)]
Unbreak the build after 02c28970b2

2 years ago[analyzer] Fix crash in RangedConstraintManager.cpp
Vince Bridgers [Wed, 23 Mar 2022 00:33:19 +0000 (19:33 -0500)]
[analyzer] Fix crash in RangedConstraintManager.cpp

This change fixes a crash in RangedConstraintManager.cpp:assumeSym due to an
unhandled BO_Div case.

clang: <root>clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp:51:
  virtual clang::ento::ProgramStateRef
  clang::ento::RangedConstraintManager::assumeSym(clang::ento::ProgramStateRef,
    clang::ento::SymbolRef, bool):
  Assertion `BinaryOperator::isComparisonOp(Op)' failed.

Reviewed By: NoQ

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

2 years ago[analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)
Vince Bridgers [Fri, 18 Feb 2022 16:20:05 +0000 (10:20 -0600)]
[analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)

This is a NFC refactoring to change makeIntValWithPtrWidth
and remove getZeroWithPtrWidth to use types when forming values to match
pointer widths. Some targets may have different pointer widths depending
upon address space, so this needs to be comprehended.

Reviewed By: steakhal

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

2 years ago[dsymutil] Update vector of section starts with size of current section
Augusto Noronha [Tue, 22 Mar 2022 17:11:32 +0000 (14:11 -0300)]
[dsymutil] Update vector of section starts with size of current section

Take into account the contributions of the sections from different
object files when calculating the address where relocations should be
applied.

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

2 years agoCleanup include: codegen second round
serge-sans-paille [Mon, 21 Mar 2022 20:51:43 +0000 (21:51 +0100)]
Cleanup include: codegen second round

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

2 years ago[clang-format] [doc] Add script to automatically update help output in ClangFormat...
Marek Kurdej [Thu, 17 Mar 2022 15:13:32 +0000 (16:13 +0100)]
[clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.

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

Reviewed By: MyDeveloperDay

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

2 years agoRe-land c3460689288abc98c91d8d6bffa74be9eb16c74d with fixes
Marcus Johnson [Wed, 23 Mar 2022 12:12:14 +0000 (08:12 -0400)]
Re-land c3460689288abc98c91d8d6bffa74be9eb16c74d with fixes

It was previously reverted in a6beb18b845ca8548319d08df9eea46c87e1e533
due to test failures.

2 years ago[mlir][bufferize] Do not run the buffer deallocation pass if no allocs escape block...
Matthias Springer [Wed, 23 Mar 2022 11:07:23 +0000 (20:07 +0900)]
[mlir][bufferize] Do not run the buffer deallocation pass if no allocs escape block boundaries

This fixes a bufferization issue with ops that are not supported by the buffer deallocation pass when `allow-return-allocs=0`.

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

2 years agoUpdate the C and C++ status pages now that Clang 14 is out
Aaron Ballman [Wed, 23 Mar 2022 11:59:18 +0000 (07:59 -0400)]
Update the C and C++ status pages now that Clang 14 is out

2 years ago[LLVMContext] Respect default value of -opaque-pointers option (NFC)
Nikita Popov [Wed, 23 Mar 2022 11:57:30 +0000 (12:57 +0100)]
[LLVMContext] Respect default value of -opaque-pointers option (NFC)

If the option is edited to use true as the default, we should
respect that, rather than hardcoding false here.

2 years agoRevert "[clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocata...
Zahira Ammarguellat [Wed, 23 Mar 2022 11:51:08 +0000 (04:51 -0700)]
Revert "[clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable""."

This reverts commit 56d46b36fc231a0beb518602503035bba92043e0.

The LIT test SemaCXX/attr-trivial-abi.cpp is failing with 32bit build on
Windows. All the lines with the ifdef WIN32 are asserting but they are
not expected to. It looks like the LIT test was not tested on a 32bit
build of the compiler.

2 years ago[InstCombine] add tests for shuffle of mismatched binops; NFC
Sanjay Patel [Tue, 22 Mar 2022 20:36:16 +0000 (16:36 -0400)]
[InstCombine] add tests for shuffle of mismatched binops; NFC

2 years agoReland "[llvm][AArch64] Insert "bti j" after call to setjmp"
David Spickett [Wed, 23 Mar 2022 10:51:08 +0000 (10:51 +0000)]
Reland "[llvm][AArch64] Insert "bti j" after call to setjmp"

This reverts commit edb7ba714acba1d18a20d9f4986d2e38aee1d109.

This changes BLR_BTI to take variable_ops meaning that we can accept
a register or a label. The pattern still expects one argument so we'll
never get more than one. Then later we can check the type of the operand
to choose BL or BLR to emit.

(this is what BLR_RVMARKER does but I missed this detail of it first time around)

Also require NoSLSBLRMitigation which I missed in the first version.

2 years ago[CGOpenMPRuntime] Remove uses of deprecated Address constructor
Nikita Popov [Wed, 23 Mar 2022 11:14:39 +0000 (12:14 +0100)]
[CGOpenMPRuntime] Remove uses of deprecated Address constructor

And as these are the last remaining uses, also remove the
constructor itself.

2 years agoForgot to add a release note for WG14 N2412.
Aaron Ballman [Wed, 23 Mar 2022 11:39:53 +0000 (07:39 -0400)]
Forgot to add a release note for WG14 N2412.

This support was completed in bf7d9970ba0ac5ecfa1a469086f5789de5c94e3f

2 years ago[mlir][OpenMP] Add omp.single
Shraiysh Vaishay [Wed, 23 Mar 2022 10:11:09 +0000 (15:41 +0530)]
[mlir][OpenMP] Add omp.single

This patch adds omp.single according to Section 2.8.2 of OpenMP 5.0.

Also added tests for the same.

Reviewed By: peixin

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

Co-authored-by: Kiran Kumar T P <kirankumar.tp@amd.com>
2 years ago[OpenCL] opencl-c.h: remove arg names for vload/vstore builtins
Sven van Haastregt [Wed, 23 Mar 2022 11:12:50 +0000 (11:12 +0000)]
[OpenCL] opencl-c.h: remove arg names for vload/vstore builtins

This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the identifiers "data" and
"offset".

Continues the direction set out in D119560.

2 years ago[MLIR][Presburger] support IntegerRelation::convertIdKind
Arjun P [Wed, 23 Mar 2022 11:10:48 +0000 (11:10 +0000)]
[MLIR][Presburger] support IntegerRelation::convertIdKind

Reviewed By: Groverkss

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

2 years agoReapply [CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()
Nikita Popov [Fri, 18 Mar 2022 12:06:42 +0000 (13:06 +0100)]
Reapply [CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()

This requires some adjustment in caller code, because there was
a confusion regarding the meaning of the PtrTy argument: This
argument is the type of the pointer being loaded, not the addresses
being loaded from.

Reapply after fixing the specified pointer type for one call in
47eb4f7dcd845878b16a53dadd765195b9c24b6e, where the used type is
important for determining alignment.

2 years ago[CodeGen][OpenMP] Add alignment to test (NFC)
Nikita Popov [Wed, 23 Mar 2022 10:59:15 +0000 (11:59 +0100)]
[CodeGen][OpenMP] Add alignment to test (NFC)

Check which alignments are generated for loads/stores.

2 years ago[MLIR][Presburger] add Simplex:addDivisionVariable
Arjun P [Tue, 22 Mar 2022 13:21:20 +0000 (13:21 +0000)]
[MLIR][Presburger] add Simplex:addDivisionVariable

This is a convenience function for adding new divisions to the Simplex given the numerator and denominator.

This will be needed for symbolic integer lexmin support.

Reviewed By: Groverkss

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

2 years ago[CGOpenMPRuntime] Specify correct type in EmitLoadOfPointerLValue()
Nikita Popov [Wed, 23 Mar 2022 10:35:32 +0000 (11:35 +0100)]
[CGOpenMPRuntime] Specify correct type in EmitLoadOfPointerLValue()

Perform a bitcast first, so we can specify the correct pointer type
inf EmitLoadOfPointerLValue(), rather than using a dummy void pointer.

2 years agoRevert "[llvm][AArch64] Insert "bti j" after call to setjmp"
David Spickett [Wed, 23 Mar 2022 10:43:20 +0000 (10:43 +0000)]
Revert "[llvm][AArch64] Insert "bti j" after call to setjmp"

This reverts commit eb5ecbbcbb6ce38e29237ab5d17156fcb2e96e74
due to failures on buildbots with expensive checks enabled.

2 years ago[CGOpenMPRuntime] Reuse getDepobjElements() (NFC)
Nikita Popov [Wed, 23 Mar 2022 10:21:46 +0000 (11:21 +0100)]
[CGOpenMPRuntime] Reuse getDepobjElements() (NFC)

There were two more places repeating this code, reuse the helper.
This requires moving the static functions into the class.

2 years agoCleanup includes: Transforms/Instrumentation & Transforms/Vectorize
serge-sans-paille [Mon, 21 Mar 2022 20:52:21 +0000 (21:52 +0100)]
Cleanup includes: Transforms/Instrumentation & Transforms/Vectorize

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

2 years ago[bazel] Make extract_api compatible with bazel
Benjamin Kramer [Wed, 23 Mar 2022 10:00:35 +0000 (11:00 +0100)]
[bazel] Make extract_api compatible with bazel

2 years agoFix link to Rationale document from doc on tuple.
Ingo Müller [Wed, 23 Mar 2022 09:53:22 +0000 (09:53 +0000)]
Fix link to Rationale document from doc on tuple.

This also replaces the absolute link to the same document with a
relative one in the same file.

Reviewed By: rriddle

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

2 years ago[llvm][AArch64] Insert "bti j" after call to setjmp
David Spickett [Mon, 14 Mar 2022 10:24:45 +0000 (10:24 +0000)]
[llvm][AArch64] Insert "bti j" after call to setjmp

Some implementations of setjmp will end with a br instead of a ret.
This means that the next instruction after a call to setjmp must be
a "bti j" (j for jump) to make this work when branch target identification
is enabled.

The BTI extension was added in armv8.5-a but the bti instruction is in the
hint space. This means we can emit it for any architecture version as long
as branch target enforcement flags are passed.

The starting point for the hint number is 32 then call adds 2, jump adds 4.
Hence "hint #36" for a "bti j" (and "hint #34" for the "bti c" you see
at the start of functions).

The existing Arm command line option -mno-bti-at-return-twice has been
applied to AArch64 as well.

Support is added to SelectionDAG Isel and GlobalIsel. FastIsel will
defer to SelectionDAG.

Based on the change done for M profile Arm in https://reviews.llvm.org/D112427

Fixes #48888

Reviewed By: danielkiss

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

2 years ago[CodeGen][OpenMP] Add alignment to test (NFC)
Nikita Popov [Wed, 23 Mar 2022 09:28:04 +0000 (10:28 +0100)]
[CodeGen][OpenMP] Add alignment to test (NFC)

Check which alignments are generated for loads and stores.

2 years agoRevert "[CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()"
Nikita Popov [Wed, 23 Mar 2022 09:22:14 +0000 (10:22 +0100)]
Revert "[CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()"

This reverts commit 767ec883e37510a247ea5695921876ef67cf5b3f.

This results in a some incorrect alignments which are not covered
by existing tests.

2 years ago[NFC] Remove trailing whitespaces in clang/Driver/Options.td
Tobias Hieta [Wed, 23 Mar 2022 09:21:04 +0000 (10:21 +0100)]
[NFC] Remove trailing whitespaces in clang/Driver/Options.td

2 years ago[WebAssembly] Fix error location for parsed symbol/label operands
Alex Bradbury [Wed, 23 Mar 2022 08:53:05 +0000 (08:53 +0000)]
[WebAssembly] Fix error location for parsed symbol/label operands

The previous code didn't take account for the fact that parseExpression
my lex additional tokens - because of this, it's necessary to record the
location of the current token ahead of the call. This patch additionally
makes use of the fact parseExpression will set its End parameter to the
end of the expression.

Although this fix could be added independently of D122127, I've opted to
make it a child patch in order to ensure the change has some test
coverage.

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

2 years ago[WebAssembly] Use location of operand for operand-based type check errors
Alex Bradbury [Wed, 23 Mar 2022 08:51:15 +0000 (08:51 +0000)]
[WebAssembly] Use location of operand for operand-based type check errors

This addresses a series of FIXMEs introduced in D122020.

A follow-up patch (D122128) addresses the bug that is exposed by this
change (an issue with source location information when lexing
identifiers).

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