platform/upstream/llvm.git
2 years ago[clang][parse] Move source range into ParsedAttibutesView
Timm Bäder [Tue, 22 Mar 2022 08:27:27 +0000 (09:27 +0100)]
[clang][parse] Move source range into ParsedAttibutesView

Move the SourceRange from the old ParsedAttributesWithRange into
ParsedAttributesView, so we have source range information available
everywhere we use attributes.

This also removes ParsedAttributesWithRange (replaced by simply using
ParsedAttributes) and ParsedAttributesVieWithRange (replaced by using
ParsedAttributesView).

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

2 years ago[ELF] Enable new passmanager plugin support for LTO
Jakob Koschel [Thu, 24 Mar 2022 06:52:16 +0000 (07:52 +0100)]
[ELF] Enable new passmanager plugin support for LTO

Add cli options for new passmanager plugin support to lld.

Currently it is not possible to load dynamic NewPM plugins with lld. This is an
incremental update to D76866. While that patch only added cli options for
llvm-lto2, this adds them for lld as well. This is especially useful for running
dynamic plugins on the linux kernel with LTO.

Reviewed By: MaskRay

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

2 years ago[libc] Use real objects and archives in integration tests.
Siva Chandra Reddy [Thu, 24 Mar 2022 06:58:46 +0000 (06:58 +0000)]
[libc] Use real objects and archives in integration tests.

Previously, we used empty, non-ELF crti.o, crtn.o, libm.a and libc++.a
files. Instead, we now still use dummies but they are real ELF object
files and archives.

2 years ago[mlir][linalg] Create AffineMinOp map in canoncial form.
gysit [Thu, 24 Mar 2022 06:55:43 +0000 (06:55 +0000)]
[mlir][linalg] Create AffineMinOp map in canoncial form.

Create the AffineMinOp used to compute the padding width in canonical form and update the tests.

Reviewed By: springerm

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

2 years ago[NFCI] Fix set-but-unused warning in CGOpenMPRuntime.cpp
Dávid Bolvanský [Thu, 24 Mar 2022 06:49:21 +0000 (07:49 +0100)]
[NFCI] Fix set-but-unused warning in CGOpenMPRuntime.cpp

2 years ago[NFCI] Fix set-but-unused warning in ExprConstant.cpp
Dávid Bolvanský [Thu, 24 Mar 2022 06:47:50 +0000 (07:47 +0100)]
[NFCI] Fix set-but-unused warning in ExprConstant.cpp

2 years agoRevert "[Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators"
Dávid Bolvanský [Thu, 24 Mar 2022 06:43:24 +0000 (07:43 +0100)]
Revert "[Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators"

This reverts commit 460fc440ad8d41ca2e3882987512989b1c188fbe.

2 years ago[flang] Single construct translation from PFT to FIR
Shraiysh Vaishay [Thu, 24 Mar 2022 06:16:09 +0000 (11:46 +0530)]
[flang] Single construct translation from PFT to FIR

This patch adds translation for single construct along with nowait
clause from PFT to FIR.

Allocate clause is added as a TODO as handleAllocateClause is added in
D122302.

Reviewed By: kiranchandramohan

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

2 years ago[CSKY] Enhance asm parser and relocation fixup for some special symbol address instru...
Zi Xuan Wu [Fri, 18 Mar 2022 07:40:14 +0000 (15:40 +0800)]
[CSKY] Enhance asm parser and relocation fixup for some special symbol address instruction

Add processing of parsing and emiting lrw/jsri/jmpi instruction, including related fixup and relocation.
Add relax support about pseudo instructions such as jbr/jbsr.
Add objdump format support like arm in llvm-objdump.

2 years ago[clang][NFC] Fix warning of integer comparison
Kai Luo [Thu, 24 Mar 2022 06:02:27 +0000 (14:02 +0800)]
[clang][NFC] Fix warning of integer comparison

```
warning: comparison of integers of different signs: 'const unsigned long' and 'const int' [-Wsign-compare]
```

Fix https://lab.llvm.org/buildbot/#/builders/57/builds/16220.

2 years ago[mlir][OpenMP][NFC] Remove unnecessary attributes
Shraiysh Vaishay [Thu, 24 Mar 2022 04:38:46 +0000 (10:08 +0530)]
[mlir][OpenMP][NFC] Remove unnecessary attributes

These attributes were added because of oilist required them earlier. It
no longer requires them and so these attributes can be safely removed
from the operations.

Reviewed By: kiranchandramohan

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

2 years ago[mlir][OpenMP] omp.single translation to LLVM IR
Shraiysh Vaishay [Thu, 24 Mar 2022 04:29:34 +0000 (09:59 +0530)]
[mlir][OpenMP] omp.single translation to LLVM IR

This patch adds translation from omp.single to LLVM IR.

Depends on D122288

Reviewed By: ftynse, kiranchandramohan

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

2 years ago[X86][NFC] Fix missing `override` in `isMemUseUpRegs`
Kai Luo [Thu, 24 Mar 2022 04:23:12 +0000 (12:23 +0800)]
[X86][NFC] Fix missing `override` in `isMemUseUpRegs`

Fix warning
```
warning: 'isMemUseUpRegs' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
```

2 years ago[libc] Add implementations of fopen, flose, fread, fwrite and fseek.
Siva Chandra Reddy [Wed, 23 Mar 2022 03:49:26 +0000 (03:49 +0000)]
[libc] Add implementations of fopen, flose, fread, fwrite and fseek.

A follow up patch will add feof and ferror.

Reviewed By: lntue

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

2 years ago[lldb] Test parsing the symtab with indirect symbols from the shared cache
Jonas Devlieghere [Thu, 24 Mar 2022 04:00:57 +0000 (21:00 -0700)]
[lldb] Test parsing the symtab with indirect symbols from the shared cache

This patch adds a test for b0dc2fae6025. That commit fixed a bug where
we could increment the indirect symbol offset every time we parsed the
symbol table.

2 years ago[clang][AVR] Implement standard calling convention for AVR and AVRTiny
Ben Shi [Thu, 24 Mar 2022 03:30:58 +0000 (03:30 +0000)]
[clang][AVR] Implement standard calling convention for AVR and AVRTiny

This patch implements avr-gcc's calling convention:
https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention

Reviewed By: aykevl

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

2 years ago[CUDA][FIX] Fix name conflict in getNVPTXTargetFeatures
Joseph Huber [Thu, 24 Mar 2022 03:07:51 +0000 (23:07 -0400)]
[CUDA][FIX] Fix name conflict in getNVPTXTargetFeatures

Summary:
There was a naming conflict in the getNVPTXTargetFeatures function that
prevented some compilers from correctly disambiguating between the
enumeration and variable of the same name. Rename the variable to avoid
this.

2 years ago[clang-format] Fix invalid code generation with comments in lambda
owenca [Wed, 23 Mar 2022 10:16:19 +0000 (03:16 -0700)]
[clang-format] Fix invalid code generation with comments in lambda

Fixes #51234 and #54496

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

2 years ago[AVR] Reject/Reserve R0~R15 on AVRTiny.
Ben Shi [Mon, 14 Mar 2022 10:35:34 +0000 (10:35 +0000)]
[AVR] Reject/Reserve R0~R15 on AVRTiny.

Reviewed By: aykevl, dylanmckay

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

2 years ago[C++20] [Modules] Make the linkage consistent for template and its
Chuanqi Xu [Wed, 23 Feb 2022 08:23:26 +0000 (16:23 +0800)]
[C++20] [Modules] Make the linkage consistent for template and its
specialization

Before the patch, the compiler would crash for the test due to
inconsistent linkage.

This patch tries to avoid it by make the linkage consistent for template
and its specialization. After the patch, the behavior of compiler would
be partially correct for the case.
The correct one is:

```
export template<class T>
void f() {}

template<>
void f<int>() {}
```

In this case, the linkage for both declaration should be external (the
wording I get by consulting in WG21 is "the linkage for name f should be
external").

And for the case:
```
template<class T>
void f() {}

export template<>
void f<int>() {}
```

Compiler should reject it. This isn't done now. After all, this patch would
stop a crash.

Reviewed By: iains, aaron.ballman, dblaikie

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

2 years ago[AVR][MC] Emit some aliases for GPRs and IO registers
Ben Shi [Wed, 23 Mar 2022 06:37:32 +0000 (06:37 +0000)]
[AVR][MC] Emit some aliases for GPRs and IO registers

Emit the following aliases (if available):

.set __tmp_reg__, [0|16]
.set __zero_reg__, [1|17]
.set __SREG__, 63
.set __SP_H__, 62
.set __SP_L__, 61
.set __EIND__, 60
.set __RAMPZ__, 59

Reviewed By: aykevl

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

2 years ago[clang][AVR] Implement standard calling convention for AVR and AVRTiny
Ben Shi [Tue, 1 Mar 2022 08:44:49 +0000 (08:44 +0000)]
[clang][AVR] Implement standard calling convention for AVR and AVRTiny

This patch implements avr-gcc's calling convention:
https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention

Reviewed By: aykevl

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

2 years ago[Flang][NFC] Rearrange intrinsic generator functions
Kiran Chandramohan [Thu, 24 Mar 2022 01:50:59 +0000 (01:50 +0000)]
[Flang][NFC] Rearrange intrinsic generator functions

This patch rearranges the generator functions for various intrinsics.
The rearrangement will help to identify any missing functionality.

Reviewed By: PeteSteinfeld

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

2 years ago[gn build] Port 64902d335c21
LLVM GN Syncbot [Thu, 24 Mar 2022 01:49:33 +0000 (01:49 +0000)]
[gn build] Port 64902d335c21

2 years ago[Inline asm] Fix mangle problem when variable used in inline asm.
Xiang1 Zhang [Thu, 24 Mar 2022 01:24:15 +0000 (09:24 +0800)]
[Inline asm] Fix mangle problem when variable used in inline asm.
(Correct 'Mem symbol + IntelExpr' output in PIC model)

Reviewed By: skan

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

2 years ago[InlineAsm] Fix mangle problem when global variable used in inline asm
Xiang1 Zhang [Thu, 24 Mar 2022 00:48:35 +0000 (08:48 +0800)]
[InlineAsm] Fix mangle problem when global variable used in inline asm
(Add modifier P for ARR[BaseReg+IndexReg+..])

Reviewed By: skan

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

2 years ago[Inline asm] Fix mangle problem when variable used in inline asm.
Xiang1 Zhang [Thu, 24 Mar 2022 00:46:15 +0000 (08:46 +0800)]
[Inline asm] Fix mangle problem when variable used in inline asm.
(Connect InlineAsm Memory Operand with its real value not just name)
Revert 2 history bugfix patch:

Revert "[X86][MS-InlineAsm] Make the constraint *m to be simple place holder"
This patch revert https://reviews.llvm.org/D115225 which mainly
fix problems intrduced by https://reviews.llvm.org/D113096

This reverts commit d7c07f60b35f901f5bd9153b11807124a9bdde60.

Revert "Reland "[X86][MS-InlineAsm] Use exact conditions to recognize MS global variables""
This patch revert https://reviews.llvm.org/D116090 which fix problem
intrduced by https://reviews.llvm.org/D115225

This reverts commit 24c68ea1eb4fc0d0e782424ddb02da9e8c53ddf5.

Reviewed By: skan

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

2 years agoReland "Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO"
Julian Lettner [Thu, 24 Mar 2022 00:37:07 +0000 (17:37 -0700)]
Reland "Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO"

For MachO, lower `@llvm.global_dtors` into `@llvm_global_ctors` with
`__cxa_atexit` calls to avoid emitting the deprecated `__mod_term_func`.

Reuse the existing `WebAssemblyLowerGlobalDtors.cpp` to accomplish this.

Enable fallback to the old behavior via Clang driver flag
(`-fregister-global-dtors-with-atexit`) or llc / code generation flag
(`-lower-global-dtors-via-cxa-atexit`).  This escape hatch will be
removed in the future.

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

2 years agoRecommit "[SLP] Fix lookahead operand reordering for splat loads." attempt 3, fixed...
Vasileios Porpodas [Thu, 24 Mar 2022 00:32:46 +0000 (17:32 -0700)]
Recommit "[SLP] Fix lookahead operand reordering for splat loads." attempt 3, fixed assertion crash.

Original review: https://reviews.llvm.org/D121354

This reverts commit e6ead19b774718113007ecb1a4449d7af0cbcfeb.

2 years ago[MLIR][Presburger] Matrix::insertColumns: add doc, fix lint issue, and early exit...
Arjun P [Mon, 21 Mar 2022 14:13:21 +0000 (14:13 +0000)]
[MLIR][Presburger] Matrix::insertColumns: add doc, fix lint issue, and early exit when possible

Reviewed By: Groverkss

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

2 years ago[MLIR][Presburger] PWMAFunction::valueAt: support local ids
Arjun P [Wed, 23 Mar 2022 23:11:28 +0000 (23:11 +0000)]
[MLIR][Presburger] PWMAFunction::valueAt: support local ids

Add a baseline implementation of support for local ids for `PWMAFunction::valueAt`. This can be made more efficient later if needed by handling locals with known div representations separately.

Reviewed By: Groverkss

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

2 years ago[MLIR][Presburger] LexSimplex::addEquality: add equalities as fixed columns
Arjun P [Wed, 23 Mar 2022 23:04:13 +0000 (23:04 +0000)]
[MLIR][Presburger] LexSimplex::addEquality: add equalities as fixed columns

In LexSimplex, instead of adding equalities as a pair of inequalities,
add them as a single row, move them into the basis, and keep them there.

There will always be a valid basis involving all non-redundant equalities. Such
equalities will then be ignored in some other operations, such as when looking
for pivot columns. This speeds them up a little bit.

More importantly, this is an important precursor patch to adding support for
symbolic integer lexmin, as this heuristic can sometimes make a big difference there.

Reviewed By: Groverkss

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

2 years ago[MLIR][Presburger] Introduce SimplexRollbackScopeExit to rollback on scope exit
Arjun P [Mon, 21 Mar 2022 19:59:17 +0000 (19:59 +0000)]
[MLIR][Presburger] Introduce SimplexRollbackScopeExit to rollback on scope exit

This simplifies many places where we just want to do something in a "transient context"
and return some value.

Reviewed By: Groverkss

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

2 years ago[MLIR][Presburger] IntegerRelation: implement partial rollback support
Arjun P [Wed, 23 Mar 2022 23:40:20 +0000 (23:40 +0000)]
[MLIR][Presburger] IntegerRelation: implement partial rollback support

It is often necessary to "rollback" IntegerRelations to an earlier state. Although providing full rollback support is non-trivial, we really only need to support the case where the only changes made are to append ids or append constraints, and then rollback these additions. This patch adds support to rollback in such situations by recording the number of ids and constraints of each kind and providing support to truncate the IntegerRelation to those counts by removing appended ids and constraints. This already simplifies subtraction a little bit and will also be useful in the implementation of symbolic integer lexmin.

Reviewed By: Groverkss

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

2 years agoLoad dyld manually with 'main bin spec' userland corefiles
Jason Molenda [Thu, 24 Mar 2022 00:08:02 +0000 (17:08 -0700)]
Load dyld manually with 'main bin spec' userland corefiles

In ProcessMachCore::DoLoadCore when we have a standalone
binary and a 'main bin spec' LC_NOTE detailing the UUID and
load address, ProcessMachCore will do a (potentially slow)
lookup to try to find the binary and/or dSYM.  For kernel and
userland corefile using 'main bin spec', we would follow the
normal schemes of locating them.  DynamicLoaderDarwinKernel would
use the same (possibly expensive) calls to find the correct
binary.  dyld by default would use the in-core-file binary image,
and so if the corefile didn't include the entire address space,
the LINKEDIT for dyld could be missing.  This means we can't find
the dyld4::dyld_all_image_infos struct, which tells us where the
other binaries are loaded in memory.

Treat userland 'bin main spec' like we do standalone firmewares;
try the expensive checks to find the best dyld we can, before
falling back to using a memory module out of the corefile.

Also add a little TODO for myself in this load_standalone_binary
function that we should handle the case of a binary in the shared
cache correctly, creating a memory module in the corefile and
using the segment load addresses from that to set our segment
load addresses for the final binary.

rdar://89717101

2 years ago[PowerPC] The BL8_NOTOC_RM instruction needs to produce a notoc relocation.
Stefan Pintilie [Wed, 23 Mar 2022 18:46:57 +0000 (13:46 -0500)]
[PowerPC] The BL8_NOTOC_RM instruction needs to produce a notoc relocation.

The BL8_NOTOC_RM instruction was incorrectly producing a relocation that reqired
a TOC restore after the call. This patch fixes that issue and the notoc
relocation is now used.

Reviewed By: jsji

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

2 years ago[libc][obvious] add aligned_alloc as entrypoint
Michael Jones [Wed, 23 Mar 2022 23:31:52 +0000 (16:31 -0700)]
[libc][obvious] add aligned_alloc as entrypoint

This patch adds aligned_alloc as an entrypoint. Previously it was being
included implicitly.

Reviewed By: sivachandra

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

2 years ago[lldb] Don't persist the LINKEDIT slide in the indirect symbol offset
Jonas Devlieghere [Wed, 23 Mar 2022 23:24:15 +0000 (16:24 -0700)]
[lldb] Don't persist the LINKEDIT slide in the indirect symbol offset

The current code increment the indirect symbol offset with the LINKEDIT
slide every time ObjectFileMachO::ParseSymtab is called.

This resulted in a crash when calling add-dsym which causes us to
potentially re-parse the original binary's symbol table. There's a
separate question about whether we should re-parse the symbol table at
all which was fixed by D114288. Regardless, copying the load command is
cheap enough that this is still the right thing to do.

rdar://72337717

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

2 years ago[libc] Link the SCUDO integration tests to a special entrypoint collection.
Siva Chandra Reddy [Wed, 23 Mar 2022 23:17:56 +0000 (23:17 +0000)]
[libc] Link the SCUDO integration tests to a special entrypoint collection.

We were previously linking to libllvmlibc.a. But, with libllvmlibc.a now
including functions which depend on the loader, we will have to use the
LLVM libc loader as well. To avoid this, we will link to a special
library which is just a collection of SCUDO allocator entrypoints.

Reviewed By: michaelrj

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

2 years ago[lldb] Remove lldbassert from CommandInterpreter::PrintCommandOutput
Jonas Devlieghere [Wed, 23 Mar 2022 21:13:58 +0000 (14:13 -0700)]
[lldb] Remove lldbassert from CommandInterpreter::PrintCommandOutput

The assertion checks that the command output doesn't contain any null
bytes. I'm not sure if the intention was to make sure the string wasn't
shorter than the reported length or if this was a way to catch us
accidentally writing an (unformatted) null byte.

The consensus is that we don't want to have embedded nulls in the
command output, but that this isn't the right place to enforce that.

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

2 years ago[lldb] Support class_ro_t pointer authentication
Jonas Devlieghere [Wed, 23 Mar 2022 17:15:20 +0000 (10:15 -0700)]
[lldb] Support class_ro_t pointer authentication

Upstream support for signed class_ro_t pointers.

2 years agoRevert "[gn build] Port 9c542a5a4e1b"
Zequan Wu [Wed, 23 Mar 2022 22:41:03 +0000 (15:41 -0700)]
Revert "[gn build] Port 9c542a5a4e1b"

This reverts commit e28ace8a97583cacadd92180bda9fa3e49554c51.

2 years agoRevert "Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO"
Zequan Wu [Wed, 23 Mar 2022 22:40:52 +0000 (15:40 -0700)]
Revert "Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO"

This reverts commit 22570bac694396514fff18dec926558951643fa6.

2 years ago[flang][NFC] Add forall lowering test
Valentin Clement [Wed, 23 Mar 2022 23:09:22 +0000 (00:09 +0100)]
[flang][NFC] Add forall lowering test

Add test for forall lowering use case.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang][NFC] Add more lowering tests
Valentin Clement [Wed, 23 Mar 2022 23:08:02 +0000 (00:08 +0100)]
[flang][NFC] Add more lowering tests

This patch adds more lowering tests from the PFT to FIR.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[libc] Change FEnv to use MXCSR as source of truth
Michael Jones [Wed, 16 Mar 2022 19:08:25 +0000 (12:08 -0700)]
[libc] Change FEnv to use MXCSR as source of truth

This patch primarily fixes the fenv implementation on Windows, since
Windows uses the MXCSR in place of the x87 status registers for storing
information about the floating point environment. This allows FEnv to
work correctly on Windows, and successfully build.

Reviewed By: lntue

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

2 years ago[NFCI] Fix set-but-unused warning in asan_fake_stack.cpp
Mitch Phillips [Wed, 23 Mar 2022 22:45:09 +0000 (15:45 -0700)]
[NFCI] Fix set-but-unused warning in asan_fake_stack.cpp

2 years ago[CGSCC] Use make_early_inc_range. NFC
Fangrui Song [Wed, 23 Mar 2022 22:31:09 +0000 (15:31 -0700)]
[CGSCC] Use make_early_inc_range. NFC

2 years agoRevert "Expose GetAddressingBits() in the Process API."
Adrian Prantl [Wed, 23 Mar 2022 22:27:38 +0000 (15:27 -0700)]
Revert "Expose GetAddressingBits() in the Process API."

This reverts commit 7504dd5e00f514628614db8ee07514c73220e597.

In newer review feedback it was pointed out that there is a better API for this in Process::GetCodeAddressMask().

2 years ago[OpenMP] Do not create offloading entries for internal or hidden symbols
Joseph Huber [Wed, 23 Mar 2022 21:05:43 +0000 (17:05 -0400)]
[OpenMP] Do not create offloading entries for internal or hidden symbols

Currently we create offloading entries to register device variables with
the host. When we register a variable we will look up the symbol in the
device image and map the device address to the host address. This is a
problem when the symbol is declared with hidden visibility or internal
linkage. This means the symbol is not accessible externally and we
cannot get its address. We should still allow static variables to be
declared on the device, but ew should not create an offloading entry for
them so they exist independently on the host and device.

Fixes #54309

Reviewed By: jdoerfert

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

2 years agoreland: [AArch64] Add support for -march=native for Apple M1 CPU
Keith Smiley [Wed, 23 Mar 2022 21:28:54 +0000 (14:28 -0700)]
reland: [AArch64] Add support for -march=native for Apple M1 CPU

This reverts commit fc3cdd0b295a04c38f01b391ae414553963e33b9.

The issue was imports being scoped to specific architectures for Apple
platforms.

2 years ago[mlir] Make OpBuilder::createOperation to accept raw inputs
Chia-hung Duan [Wed, 23 Mar 2022 21:37:26 +0000 (21:37 +0000)]
[mlir] Make OpBuilder::createOperation to accept raw inputs

This provides a way to create an operation without manipulating
OperationState directly. This is useful for creating unregistered ops.

Reviewed By: rriddle, mehdi_amini

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

2 years ago[flang][NFC] Add lowering tests for interfaces
Valentin Clement [Wed, 23 Mar 2022 22:00:42 +0000 (23:00 +0100)]
[flang][NFC] Add lowering tests for interfaces

This patch adds lowering tests for Fortran
interfaces.

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

Reviewed By: PeteSteinfeld

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

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

Add more use cases of lowering of derived types.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years ago[llvm-profdata] Unify default cutoffs for detailed summary printing
Wenlei He [Tue, 22 Mar 2022 06:31:58 +0000 (23:31 -0700)]
[llvm-profdata] Unify default cutoffs for detailed summary printing

Use `ProfileSummaryBuilder::DefaultCutoffs` for llvm-profdata detailed summary printing for Instr profile.

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

2 years ago[mlir] Add simple fuzzer for textual format
Jacques Pienaar [Wed, 23 Mar 2022 21:33:50 +0000 (14:33 -0700)]
[mlir] Add simple fuzzer for textual format

Only use this on generic parser for now by not registering any dialect. For flushing out some parser bugs. The textual format is not meant to be load bearing in production runs, but still useful to remove edge cases/failures.

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

2 years ago[clang] Improve diagnostic for reopened inline namespace
Fabian Wolff [Wed, 23 Mar 2022 21:27:35 +0000 (22:27 +0100)]
[clang] Improve diagnostic for reopened inline namespace

Reviewed By: cor3ntin, aaron.ballman

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

2 years agoRevert "[AArch64] Add support for -march=native for Apple M1 CPU"
Keith Smiley [Wed, 23 Mar 2022 21:26:52 +0000 (14:26 -0700)]
Revert "[AArch64] Add support for -march=native for Apple M1 CPU"

This reverts commit fcca10c69aaab539962d10fcc59a5f074b73b0de.

2 years agoExpose GetAddressingBits() in the Process API.
Adrian Prantl [Wed, 23 Mar 2022 21:06:18 +0000 (14:06 -0700)]
Expose GetAddressingBits() in the Process API.

This is needed by the Swift Plugin.

See also  https://github.com/apple/llvm-project/pull/4110.

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

2 years ago[llvm-profgen] Decoding pseudo probe for profiled function only.
Hongtao Yu [Wed, 23 Mar 2022 19:36:44 +0000 (12:36 -0700)]
[llvm-profgen] Decoding pseudo probe for profiled function only.

Complete pseudo probes decoding can result in large memory usage. In practice only a small porting of the decoded probes are used in profile generation. I'm changing the full decoding mode to be decoding for profiled functions only, though we still do a full scan of the .pseudoprobe section due to a missing table-of-content but we don't have to build the in-memory data structure for functions not sampled.

To build the in-memory data structure for profiled functions only, I'm rewriting the previous non-recursive probe decoding logic to be recursive. This is easy to read and maintain.

I also have to change the previous representation of unsymbolized context from probe-based stack to address-based stack since the profiled functions are unknown yet by the time of virtual unwinding. The address-based stack will be converted to probe-based stack after virtual unwinding and on-demand probe decoding.

I'm seeing 20GB memory is saved for one of our internal large service.

Reviewed By: wenlei

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

2 years ago[Clang] Added testcases for -Wunused-but-set-parameter
Dávid Bolvanský [Wed, 23 Mar 2022 21:14:27 +0000 (22:14 +0100)]
[Clang] Added testcases for -Wunused-but-set-parameter

Clang now emits warnings for them after D122271 (shared logic with -Wunused-but-set-variable)

2 years ago[AArch64] Add support for -march=native for Apple M1 CPU
Keith Smiley [Mon, 14 Feb 2022 19:27:43 +0000 (11:27 -0800)]
[AArch64] Add support for -march=native for Apple M1 CPU

This improves the getHostCPUName check for Apple M1 CPUs, which
previously would always be considered cyclone instead. This also enables
`-march=native` support when building on M1 CPUs which would previously
fail. This isn't as sophisticated as the X86 CPU feature checking which
consults the CPU via getHostCPUFeatures, but this is still better than
before. This CPU selection could also be invalid if this was run on an
iOS device instead, ideally we can improve those cases as they come up.

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

2 years ago[Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators
Dávid Bolvanský [Wed, 23 Mar 2022 21:03:57 +0000 (22:03 +0100)]
[Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators

Clang fails to diagnose:
```
void test() {
    int j = 0;
    for (int i = 0; i < 1000; i++)
            j++;
    return;
}
```

Reason: Missing support for UnaryOperator.

We should not warn with volatile variables... so add check for it.

Reviewed By: efriedma

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

2 years ago[libc] Add a new rule add_integration_test.
Siva Chandra Reddy [Tue, 22 Mar 2022 06:53:33 +0000 (06:53 +0000)]
[libc] Add a new rule add_integration_test.

All existing loader tests are switched to an integration test added with
the new rule. Also, the getenv test is now enabled as an integration test.

All loader tests have been moved to test/integration. Also, the simple
checker library for the previous loader tests has been moved to a
separate directory of its own.

A follow up change will perform more cleanup of the loader CMake rules
to eliminate now redundent options.

Reviewed By: lntue, michaelrj

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

2 years ago[AMDGPU] Add s_nop WaitStates between neighboring mfma
Austin Kerbow [Fri, 4 Mar 2022 08:33:21 +0000 (00:33 -0800)]
[AMDGPU] Add s_nop WaitStates between neighboring mfma

In some cases padding bubbles between sequential MFMA instructions may
lead to increased inter-wave performance. Add option to request to pad
some portion of these stall cycles with s_nops.

Fixes: SWDEV-326925

Reviewed By: rampitec

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

2 years ago[Attributor][FIX] Avoid endless recursion, simple case
Johannes Doerfert [Wed, 23 Mar 2022 18:47:06 +0000 (13:47 -0500)]
[Attributor][FIX] Avoid endless recursion, simple case

There is potential for endless recursion if we try to determine the
underlying objects of a load, just to end up with the load as underlying
object. A proper solution will require us to pass a visited set around.
This will happen as we cleanup genericValueTraversal soon.

2 years ago[gn build] Change python run lines to python3
Nico Weber [Wed, 23 Mar 2022 19:42:22 +0000 (15:42 -0400)]
[gn build] Change python run lines to python3

macOS 12.3 no longer ships non-3 python.

Almost all of these scripts were launched by ninja, and the GN files
already told it to run them under python3, so this is a fairly small
change.  The main effect is that if you run them manually, you now
get the same behavior.

(A small set of scripts, gn.py, gen.py, sync_source_lists_from_cmake.py,
are for manual running.  For these, it is an actual change.)

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

2 years ago[libc] Rename libc-integration-test to libc-api-test.
Siva Chandra Reddy [Tue, 22 Mar 2022 23:42:01 +0000 (23:42 +0000)]
[libc] Rename libc-integration-test to libc-api-test.

Reviewed By: jeffbailey, michaelrj

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

2 years ago[mlir] Fix emitting an error at EOF
Mogball [Wed, 23 Mar 2022 08:00:46 +0000 (08:00 +0000)]
[mlir] Fix emitting an error at EOF

Emitting at error at EOF will emit the diagnostic past the end of the file. When emitting an error during parsing at EOF, emit it at the previous character.

Reviewed By: jpienaar

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

2 years agoInstall symlink "otool" if LLVM_INSTALL_CCTOOLS_SYMLINKS is set
Nico Weber [Wed, 23 Mar 2022 13:42:31 +0000 (09:42 -0400)]
Install symlink "otool" if LLVM_INSTALL_CCTOOLS_SYMLINKS is set

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

2 years ago[LV] Extend checks in debugloc.ll.
Florian Hahn [Wed, 23 Mar 2022 20:21:57 +0000 (20:21 +0000)]
[LV] Extend checks in debugloc.ll.

2 years ago[gn build] add llvm_install_cctools_symlinks arg
Nico Weber [Wed, 23 Mar 2022 13:32:49 +0000 (09:32 -0400)]
[gn build] add llvm_install_cctools_symlinks arg

It behaves (mostly) like the LLVM_INSTALL_CCTOOLS_SYMLINKS option
in cmake.

The minor difference is that the llvm-objcopy symlinks bitcode_strip
and install_name_tool symlink to llvm-objcopy directly in the GN build,
while it's a bitcode_strip -> llvm-bitcode-strip -> objcopy chain
in the CMake build (and analogous for install_name_tool).

The implementation is very similar to the implementation of the
existing llvm_install_binutils_symlinks arg.

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

2 years ago[gn build] (manually) port b0fd9497af6
Nico Weber [Wed, 23 Mar 2022 20:16:53 +0000 (16:16 -0400)]
[gn build] (manually) port b0fd9497af6

2 years ago[NFC] Replace a not-null-check && isa with isa_and_nonnull
Erich Keane [Wed, 23 Mar 2022 19:55:47 +0000 (12:55 -0700)]
[NFC] Replace a not-null-check && isa with isa_and_nonnull

2 years ago[ProfSampleLoader] When disable-sample-loader-inlining is true, merge profiles of...
minglotus-6 [Wed, 16 Mar 2022 21:48:26 +0000 (14:48 -0700)]
[ProfSampleLoader] When disable-sample-loader-inlining is true, merge profiles of inlined instances to outlining versions.

When --disable-sample-loader-inlining is true, skip inline transformation, but merge profiles of inlined instances to outlining versions.

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

2 years ago[mlir][MemRef] Fix warning on unsigned comparison
Nathaniel McVicar [Wed, 23 Mar 2022 19:45:45 +0000 (12:45 -0700)]
[mlir][MemRef] Fix warning on unsigned comparison

Fix warning in clang introduced in D121766.

Reviewed By: mehdi_amini

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

2 years ago[gn build] (manually) port b0fd9497af6d
Nico Weber [Wed, 23 Mar 2022 19:46:42 +0000 (15:46 -0400)]
[gn build] (manually) port b0fd9497af6d

2 years ago[libc++] Add a lightweight overridable assertion handler
Louis Dionne [Thu, 3 Mar 2022 22:37:03 +0000 (17:37 -0500)]
[libc++] Add a lightweight overridable assertion handler

This patch adds a lightweight assertion handler mechanism that can be
overriden at link-time in a fashion similar to `operator new`.

This is a third take on https://llvm.org/D121123 (which allowed customizing
the assertion handler at compile-time), and https://llvm.org/D119969
(which allowed customizing the assertion handler at runtime only).

This approach is, I think, the best of all three explored approaches.
Indeed, replacing the assertion handler in user code is ergonomic,
yet we retain the ability to provide a custom assertion handler when
deploying to older platforms that don't have a default handler in
the dylib.

As-is, this patch provides a pretty good amount of backwards compatibility
with the previous debug mode:

- Code that used to set _LIBCPP_DEBUG=0 in order to get basic assertions
  in their code will still get basic assertions out of the box, but
  those assertions will be using the new assertion handler support.
- Code that was previously compiled with references to __libcpp_debug_function
  and friends will work out-of-the-box, no changes required. This is
  because we provide the same symbols in the dylib as we used to.
- Code that used to set a custom __libcpp_debug_function will stop
  compiling, because we don't provide that declaration anymore. Users
  will have to migrate to the new way of setting a custom assertion
  handler, which is extremely easy. I suspect that pool of users is
  very limited, so breaking them at compile-time is probably acceptable.

The main downside of this approach is that code being compiled with
assertions enabled but deploying to an older platform where the assertion
handler didn't exist yet will fail to compile. However users can easily
fix the problem by providing a custom assertion handler and defining
the _LIBCPP_AVAILABILITY_CUSTOM_ASSERTION_HANDLER_PROVIDED macro to
let the library know about the custom handler. In a way, this is
actually a feature because it avoids a load-time error that one would
otherwise get when trying to run the code on the older target.

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

2 years ago[InstCombine] add tests for nsw propagation; NFC
Sanjay Patel [Wed, 23 Mar 2022 19:29:30 +0000 (15:29 -0400)]
[InstCombine] add tests for nsw propagation; NFC

These are based on tests that were included in the abandoned D122299.
Comments indicate what should or should not happen if we change
behavior in Negator.

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