platform/upstream/llvm.git
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

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