platform/upstream/llvm.git
21 months agoAdd missing include to fix the modules build
Adrian Prantl [Fri, 14 Oct 2022 15:51:34 +0000 (08:51 -0700)]
Add missing include to fix the modules build

21 months ago[flang] Fix a warning
Kazu Hirata [Fri, 14 Oct 2022 15:51:37 +0000 (08:51 -0700)]
[flang] Fix a warning

This patch fixes:

  flang/lib/Lower/ConvertExpr.cpp:2733:14: error: variable
  'callNumResults' set but not used
  [-Werror,-Wunused-but-set-variable]

21 months ago[mlir][memref] Add initial Wide Int Emulation pass and patterns
Jakub Kuderski [Fri, 14 Oct 2022 15:36:47 +0000 (11:36 -0400)]
[mlir][memref] Add initial Wide Int Emulation pass and patterns

Add a new pass and conversions to emulate wide integer operations over memrefs.
The emulation is implemented on top of the existing pass to emulate wide integer arith ops.

Improve naming in the arith pass to avoid potential name clashes.

Reviewed By: antiagainst

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

21 months ago[clang] Fix a warning
Kazu Hirata [Fri, 14 Oct 2022 15:36:59 +0000 (08:36 -0700)]
[clang] Fix a warning

This patch fixes:

  clang/lib/CodeGen/CGCall.cpp:1867:64: error: '&&' within '||'
  [-Werror,-Wlogical-op-parentheses]

21 months ago[AArch64] Make ACLE intrinsics always available part1
Daniel Kiss [Fri, 14 Oct 2022 15:21:17 +0000 (17:21 +0200)]
[AArch64] Make ACLE intrinsics always available part1

A given arch feature might enabled by a pragma or a function attribute so in this cases would be nice to use intrinsics.
Today GCC offers the intrinsics without the march flag[1].
PR[2] for ACLE to clarify the intention and remove the need for -march flag for a given intrinsics.

This is going to be more useful when D127812 lands.

[1] https://godbolt.org/z/bxcMhav3z
[2] https://github.com/ARM-software/acle/pull/214

Reviewed By: dmgreen

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

21 months ago[PowerPC][NFC] Pre-commit case for lowering vector shuffles to xxsplti32dx (64 bit)
Amy Kwan [Fri, 14 Oct 2022 15:15:04 +0000 (10:15 -0500)]
[PowerPC][NFC] Pre-commit case for lowering vector shuffles to xxsplti32dx (64 bit)

This patch adds a test case for lowering vector shuffles to xxsplti32dx in
preparation for D135024. The test case added in this patch only adds the
64-bit CHECKs, as the 32-bit CHECKs cannot be generated (in which D135024
aims to fix).

21 months ago[SaveAndRestore] Upgrade this to support non-copyable types.
Chris Lattner [Fri, 14 Oct 2022 05:01:14 +0000 (22:01 -0700)]
[SaveAndRestore] Upgrade this to support non-copyable types.

This adds a constructor and upgrades the dtor to work with
move-only types.

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

21 months agoRemove redundant option -menable-unsafe-fp-math.
Zahira Ammarguellat [Mon, 3 Oct 2022 19:15:48 +0000 (15:15 -0400)]
Remove redundant option -menable-unsafe-fp-math.

There are currently two options that are used to tell the compiler to perform
unsafe floating-point optimizations:
'-ffast-math' and '-funsafe-math-optimizations'.

'-ffast-math' is enabled by default. It automatically enables the driver option
'-menable-unsafe-fp-math'.
Below is a table illustrating the special operations enabled automatically by
'-ffast-math', '-funsafe-math-optimizations' and '-menable-unsafe-fp-math'
respectively.

Special Operations -ffast-math -funsafe-math-optimizations -menable-unsafe-fp-math
MathErrno        0          1                     1
FiniteMathOnly         1           0                          0
AllowFPReassoc        1           1                          1
NoSignedZero        1                 1                          1
AllowRecip             1                 1                          1
ApproxFunc             1                 1                          1
RoundingMath        0                 0                          0
UnsafeFPMath        1                 0                          1
FPContract        fast          on                     on

'-ffast-math' enables '-fno-math-errno', '-ffinite-math-only',
'-funsafe-math-optimzations' and sets 'FpContract' to 'fast'. The driver option
'-menable-unsafe-fp-math' enables the same special options than
'-funsafe-math-optimizations'. This is redundant.
We propose to remove the driver option '-menable-unsafe-fp-math' and use
instead, the setting of the special operations to set the function attribute
'unsafe-fp-math'. This attribute will be enabled only if those special
operations are enabled and if 'FPContract' is either 'fast' or set to the
default value.

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

21 months ago[cmake] Remove LLVM_INCLUDE_GO_TESTS variable
Nikita Popov [Fri, 14 Oct 2022 14:32:22 +0000 (16:32 +0200)]
[cmake] Remove LLVM_INCLUDE_GO_TESTS variable

As pointed out by thakis in https://reviews.llvm.org/D135436#3858463,
this variable can be dropped now that the Go bindings have been
removed.

21 months ago[C2x] Implement support for nullptr and nullptr_t
Aaron Ballman [Fri, 14 Oct 2022 14:04:34 +0000 (10:04 -0400)]
[C2x] Implement support for nullptr and nullptr_t

This introduces support for nullptr and nullptr_t in C2x mode. The
proposal accepted by WG14 is:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3042.htm

Note, there are quite a few incompatibilities with the C++ feature in
some of the edge cases of this feature. Therefore, there are some FIXME
comments in tests for testing behavior that might change after WG14 has
resolved national body comments (a process we've not yet started). So
this implementation might change slightly depending on the resolution
of comments. This is called out explicitly in the release notes as
well.

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

21 months ago[Libomptarget] Fix missing semicolon in exports
Joseph Huber [Fri, 14 Oct 2022 14:02:42 +0000 (09:02 -0500)]
[Libomptarget] Fix missing semicolon in exports

21 months ago[Libomptarget] Don't use full names for exported plugin symbols
Joseph Huber [Fri, 14 Oct 2022 13:39:04 +0000 (08:39 -0500)]
[Libomptarget] Don't use full names for exported plugin symbols

Summary:
This patch changes the `exports` file to export all `__tgt_rtl`
functions. This is a better option as not each plugin implements all of
these functions, furthermore any new functions added will be
automatically included.

21 months ago[AArch64][SME] Add support for arm_locally_streaming functions.
Sander de Smalen [Fri, 14 Oct 2022 08:51:13 +0000 (08:51 +0000)]
[AArch64][SME] Add support for arm_locally_streaming functions.

Functions with `aarch64_sme_pstatesm_body` will emit a SMSTART at the start
of the function, and a SMSTOP at the end of the function, such that all
operations use the right value for vscale.

Because the placement of these nodes is critically important (i.e. no
vscale-dependent operations should be done before SMSTART has been issued),
we require glueing the CopyFromReg to the Entry node such that we can
insert the SMSTART as part of that glued chain.

More details about the SME attributes and design can be found
in D131562.

Reviewed By: aemerson

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

21 months ago[libc] New version of the mem* framework
Guillaume Chatelet [Fri, 14 Oct 2022 13:46:27 +0000 (13:46 +0000)]
[libc] New version of the mem* framework

    This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

    Codegen can be checked here https://godbolt.org/z/chf1Y6eGM

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

21 months ago[OpenMP] Extend the lit test for uses_allocators in target region
Animesh Kumar [Fri, 14 Oct 2022 11:06:03 +0000 (16:36 +0530)]
[OpenMP] Extend the lit test for uses_allocators in target region

This patch improves the LIT tests on the following :

1. The test on `uses_allocators` clause in the `target` region by
adding the respective CHECK lines. Allocator `omp_thread_mem_alloc`
is also added in the test.
2. The `defaultmap` clause wasn't being tested for the variable-
category `scalar` and the implicit-behavior `tofrom` with respect
to the OpenMP default version.

These improvements are inspired from SOLLVE tests.
SOLLVE repo: https://github.com/SOLLVE/sollve_vv

Reviewed By: jdoerfert

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

21 months ago[AArch64] Select to CCMN when the CCMP's second operator is negative constant
chenglin.bi [Fri, 14 Oct 2022 13:40:55 +0000 (21:40 +0800)]
[AArch64] Select to CCMN when the CCMP's second operator is negative constant

CCMP/CCMN's second operator support const from 0 to 31. When the CCMP's second operator is in the range [-31, -1] we can replace it with CCMN to avoid extra mov.

Fix: #57034

Reviewed By: efriedma

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

21 months agoRevert "[libc] New version of the mem* framework"
Guillaume Chatelet [Fri, 14 Oct 2022 13:21:52 +0000 (13:21 +0000)]
Revert "[libc] New version of the mem* framework"

This reverts commit 9721687835a7df5da0c9482cf684c11b8ba97f75.

21 months agoRevert "[libc] Fix embedded version of bcmp / memcmp"
Guillaume Chatelet [Fri, 14 Oct 2022 13:21:19 +0000 (13:21 +0000)]
Revert "[libc] Fix embedded version of bcmp / memcmp"

This reverts commit 7c9b8fa6d2d921569a1ebeb4816edb7b05a37cdd.

21 months ago[libc] Fix embedded version of bcmp / memcmp
Guillaume Chatelet [Fri, 14 Oct 2022 13:09:28 +0000 (13:09 +0000)]
[libc] Fix embedded version of bcmp / memcmp

21 months ago[lld/ELF] Convert undef-spell-corrector.s test to split-file
Nico Weber [Thu, 13 Oct 2022 14:55:24 +0000 (10:55 -0400)]
[lld/ELF] Convert undef-spell-corrector.s test to split-file

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

21 months agoFix the ExtractAPI tests
Aaron Ballman [Fri, 14 Oct 2022 12:57:01 +0000 (08:57 -0400)]
Fix the ExtractAPI tests

This should address the issues found by:
https://lab.llvm.org/buildbot/#/builders/139/builds/29568
https://lab.llvm.org/buildbot/#/builders/109/builds/48658

21 months agoAdd f16 type support in math.erf op.
Prashant Kumar [Wed, 12 Oct 2022 12:41:16 +0000 (12:41 +0000)]
Add f16 type support in math.erf op.

f16 type support was missing in the math.erf op.

Reviewed By: ezhulenev

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

21 months ago[libc] New version of the mem* framework
Guillaume Chatelet [Fri, 14 Oct 2022 12:42:34 +0000 (12:42 +0000)]
[libc] New version of the mem* framework

This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

Codegen can be checked here https://godbolt.org/z/x19zvE59v

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

21 months ago[clang][Interp] Implement while and do-while loops
Timm Bäder [Fri, 7 Oct 2022 09:37:12 +0000 (11:37 +0200)]
[clang][Interp] Implement while and do-while loops

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

21 months ago[clang][Interp][NFC] Remove unused parameter from emitConst()
Timm Bäder [Fri, 7 Oct 2022 06:12:05 +0000 (08:12 +0200)]
[clang][Interp][NFC] Remove unused parameter from emitConst()

21 months ago[clang][Interp][NFC] Add some tests for invalid array access
Timm Bäder [Mon, 10 Oct 2022 10:58:47 +0000 (12:58 +0200)]
[clang][Interp][NFC] Add some tests for invalid array access

21 months agoSpeculatively fix the lldb test bots
Aaron Ballman [Fri, 14 Oct 2022 12:36:04 +0000 (08:36 -0400)]
Speculatively fix the lldb test bots

This should fix the issue found by:
https://lab.llvm.org/buildbot/#/builders/68/builds/41100

21 months agoRevert "[libc] New version of the mem* framework"
Guillaume Chatelet [Fri, 14 Oct 2022 12:26:38 +0000 (12:26 +0000)]
Revert "[libc] New version of the mem* framework"

This reverts commit 98bf836f3127a346a81da5ae3e27246935298de4.

21 months ago[mlir][llvm] Use tablegen to import atomic ops from LLVM IR.
Tobias Gysi [Fri, 14 Oct 2022 12:00:44 +0000 (15:00 +0300)]
[mlir][llvm] Use tablegen to import atomic ops from LLVM IR.

The revision imports the atomic operations using
tablegen generated builders. Additionally, it moves their tests to
the instructions.ll test file.

Depends on D135880

Reviewed By: ftynse

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

21 months ago[libc] New version of the mem* framework
Guillaume Chatelet [Thu, 13 Oct 2022 14:59:41 +0000 (14:59 +0000)]
[libc] New version of the mem* framework

This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

Codegen can be checked here https://godbolt.org/z/x19zvE59v

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

21 months agoProperly print unnamed TagDecl objects in diagnostics
Aaron Ballman [Fri, 14 Oct 2022 12:17:16 +0000 (08:17 -0400)]
Properly print unnamed TagDecl objects in diagnostics

The diagnostics engine is very smart about being passed a NamedDecl to
print as part of a diagnostic; it gets the "right" form of the name,
quotes it properly, etc. However, the result of using an unnamed tag
declaration was to print '' instead of anything useful.

This patch causes us to print the same information we'd have gotten if
we had printed the type of the declaration rather than the name of it,
as that's the most relevant information we can display.

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

21 months ago[clang][Interp] Implement bitwise Or operations
Timm Bäder [Thu, 6 Oct 2022 13:13:11 +0000 (15:13 +0200)]
[clang][Interp] Implement bitwise Or operations

Analogous to the bitAnd implementation, do the same for bitwise or.

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

21 months ago[clang][Interp] Implement bitwise and operations
Timm Bäder [Fri, 30 Sep 2022 14:59:50 +0000 (16:59 +0200)]
[clang][Interp] Implement bitwise and operations

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

21 months ago[mlir][llvm] Use tablegen to import shufflevector from LLVM IR.
Tobias Gysi [Fri, 14 Oct 2022 11:45:32 +0000 (14:45 +0300)]
[mlir][llvm] Use tablegen to import shufflevector from LLVM IR.

The revision imports the shuffle vector operation using
tablegen generated builders. Additionally, it moves its test to
the instructions.ll test file.

Depends on D135874

Reviewed By: ftynse

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

21 months ago[clang][Interp][NFC] Remove an unnecessary local variable
Timm Bäder [Wed, 5 Oct 2022 04:17:40 +0000 (06:17 +0200)]
[clang][Interp][NFC] Remove an unnecessary local variable

21 months ago[clang][Interp][NFC] Zero-initialize Function::FrameSize
Timm Bäder [Wed, 5 Oct 2022 04:11:57 +0000 (06:11 +0200)]
[clang][Interp][NFC] Zero-initialize Function::FrameSize

It's never going to be used since it's only uninitialized if the
function is invalid, but let's zero it for readbility of
Function::dump().

21 months ago[clang][Interp][NFC] Rename a parameter to be more descriptive
Timm Bäder [Tue, 4 Oct 2022 16:26:25 +0000 (18:26 +0200)]
[clang][Interp][NFC] Rename a parameter to be more descriptive

21 months ago[clang][Interp][NFC] Remove unused function
Timm Bäder [Tue, 4 Oct 2022 15:24:55 +0000 (17:24 +0200)]
[clang][Interp][NFC] Remove unused function

21 months ago[clang][Interp][NFC] Add a failing test case
Timm Bäder [Fri, 30 Sep 2022 10:04:28 +0000 (12:04 +0200)]
[clang][Interp][NFC] Add a failing test case

21 months ago[clang][Interp] Implement ConditionalOperators
Timm Bäder [Wed, 28 Sep 2022 04:51:17 +0000 (06:51 +0200)]
[clang][Interp] Implement ConditionalOperators

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

21 months ago[clang][Interp] Implement div opcode
Timm Bäder [Tue, 27 Sep 2022 16:17:52 +0000 (18:17 +0200)]
[clang][Interp] Implement div opcode

Implement an opcode for division of two integrals.

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

21 months ago[clang][Interp] Implement rem opcode
Timm Bäder [Tue, 27 Sep 2022 15:40:55 +0000 (17:40 +0200)]
[clang][Interp] Implement rem opcode

Implement an opcode to get the remainder of the divison between LHS and
RHS.

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

21 months ago[clang][Interp] Implement bitwise not operations
Timm Bäder [Wed, 28 Sep 2022 12:30:44 +0000 (14:30 +0200)]
[clang][Interp] Implement bitwise not operations

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

21 months ago[mlir][Linalg] Support multi-output fusion in FuseIntoContainingOp
Nicolas Vasilache [Fri, 30 Sep 2022 11:09:37 +0000 (04:09 -0700)]
[mlir][Linalg] Support multi-output fusion in FuseIntoContainingOp

This revision adds the ability to fuse tileable ops with multiple results to
the transform.fuse_into_containing_op.

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

21 months ago[clang][Interp][NFC] Simplify Integral using constexpr if
Timm Bäder [Tue, 27 Sep 2022 15:10:20 +0000 (17:10 +0200)]
[clang][Interp][NFC] Simplify Integral using constexpr if

Just keep one version of the function and differentiate between
std::is_signed() and unsigned using a constexpr if, instead of having
two different versions for the signed and unsigned cases.

21 months ago[clang][Interp][NFC] Use a SourceRange for errors
Timm Bäder [Tue, 27 Sep 2022 10:40:12 +0000 (12:40 +0200)]
[clang][Interp][NFC] Use a SourceRange for errors

This makes the error message generated by bail() a bit more pleasant to
read.

21 months ago[mlir][spirv] GPUToSPIRVPass: support case when `TargetEnv` attribute attached to...
Ivan Butygin [Thu, 13 Oct 2022 19:16:26 +0000 (21:16 +0200)]
[mlir][spirv] GPUToSPIRVPass: support case when `TargetEnv` attribute attached to the `gpu.module`

Previously, only case when `TargetEnv` was attached to the top level `ModuleOp` was supported.

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

21 months ago[clang][Interp] Fix Pointer::toAPValue() LValuePath order
Timm Bäder [Mon, 26 Sep 2022 06:44:09 +0000 (08:44 +0200)]
[clang][Interp] Fix Pointer::toAPValue() LValuePath order

21 months ago[clang][Interp][NFC] Pass Function* pointers around as const
Timm Bäder [Fri, 23 Sep 2022 13:15:09 +0000 (15:15 +0200)]
[clang][Interp][NFC] Pass Function* pointers around as const

21 months ago[ConstraintElim] Add debug message when decomposition fails.
Florian Hahn [Fri, 14 Oct 2022 10:01:53 +0000 (11:01 +0100)]
[ConstraintElim] Add debug message when decomposition fails.

21 months ago[clang][Interp] Fix copy constructors with record array members
Timm Bäder [Fri, 23 Sep 2022 09:29:33 +0000 (11:29 +0200)]
[clang][Interp] Fix copy constructors with record array members

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

21 months ago[clang][Interp][NFC] Explain why tests are disabled
Timm Bäder [Fri, 14 Oct 2022 09:44:23 +0000 (11:44 +0200)]
[clang][Interp][NFC] Explain why tests are disabled

Disabled to make the buildbots happy in
c004d7534dcefcfebc3e07a7fa12f5492be80279. In C++14, the functions here
use a MaterializeTemporaryExpr, which the new constant interpreter
doesn't support yet. Add comments for this and two new RUN lines.

21 months ago[clang][Interp][NFC] Run record tests on i686 as well
Timm Bäder [Fri, 14 Oct 2022 09:19:24 +0000 (11:19 +0200)]
[clang][Interp][NFC] Run record tests on i686 as well

So we have some test coverage on a 32bit arch.

21 months ago[clang][Interp] Classify ArrayInitIndexExpr type
Timm Bäder [Fri, 14 Oct 2022 09:08:57 +0000 (11:08 +0200)]
[clang][Interp] Classify ArrayInitIndexExpr type

We can't just push a uint64 unconditionally here, since on 32bit arches
we later expect a different type, e.g. uint32.

This broke e.g. these builders:
https://lab.llvm.org/buildbot#builders/171/builds/21514
https://lab.llvm.org/buildbot#builders/38/builds/6643

21 months ago[MemorySSA] Add test for select with cross-iteration dependency (NFC)
Nikita Popov [Fri, 14 Oct 2022 09:02:23 +0000 (11:02 +0200)]
[MemorySSA] Add test for select with cross-iteration dependency (NFC)

This is currently miscompiled.

21 months agoRevert "[AArch64] Fix aligning the stack after calling __chkstk"
Martin Storsjö [Fri, 14 Oct 2022 08:27:39 +0000 (11:27 +0300)]
Revert "[AArch64] Fix aligning the stack after calling __chkstk"

This reverts commit 50e0aced4521260af842dba73f1d8c50d36314ea.

This could accidentally start producing invalid code in some
cases (in particular, if compiling with -mstack-alignment=16, which
one could expect to be a no-op for a target where the stack always
is aligned to 16 bytes anyway).

21 months ago[clang][Interp] Disable some RVO tests
Timm Bäder [Fri, 14 Oct 2022 08:44:39 +0000 (10:44 +0200)]
[clang][Interp] Disable some RVO tests

Apparently this breaks a couple of builders:
https://lab.llvm.org/buildbot/#/builders/139/builds/29552
https://lab.llvm.org/buildbot/#/builders/216/builds/11240

21 months ago[Interp] Silence warning in release builds. NFC.
Benjamin Kramer [Fri, 14 Oct 2022 08:35:48 +0000 (10:35 +0200)]
[Interp] Silence warning in release builds. NFC.

21 months agoAdd missing `override`s after aad013de41c0
Benjamin Kramer [Fri, 14 Oct 2022 08:34:17 +0000 (10:34 +0200)]
Add missing `override`s after aad013de41c0

21 months ago[BasicAA] Account for cycles when checking for same select condition
Nikita Popov [Fri, 14 Oct 2022 08:35:36 +0000 (10:35 +0200)]
[BasicAA] Account for cycles when checking for same select condition

If we have translated across a cycle backedge, the same SSA value
for the condition might be referring to two different loop iterations.
Use the isValueEqualInPotentialCycles() helper to avoid assuming
equality in that case.

21 months ago[BasicAA] Add test for select with loop carried dependency (NFC)
Nikita Popov [Fri, 14 Oct 2022 08:31:44 +0000 (10:31 +0200)]
[BasicAA] Add test for select with loop carried dependency (NFC)

21 months ago[mlir] add missing markdown delimiters in SCFOps.td
Oleksandr "Alex" Zinenko [Fri, 14 Oct 2022 08:30:34 +0000 (10:30 +0200)]
[mlir] add missing markdown delimiters in SCFOps.td

21 months ago[clang][Interp] Fix using default copy constructors
Timm Bäder [Wed, 21 Sep 2022 14:05:30 +0000 (16:05 +0200)]
[clang][Interp] Fix using default copy constructors

Implement ArrayInitLoopExprs, which are used in copy constructors to
copy arrays. Also fix problems encountered while doing that.

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

21 months ago[clang][Interp] Implement nested struct initialization
Timm Bäder [Mon, 19 Sep 2022 11:16:47 +0000 (13:16 +0200)]
[clang][Interp] Implement nested struct initialization

Recurse into visitInitializer() if necessary.

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

21 months ago[clang][Interp] Implement This pointer passing to methods
Timm Bäder [Sun, 18 Sep 2022 18:40:27 +0000 (20:40 +0200)]
[clang][Interp] Implement This pointer passing to methods

Implement passing the this pointer to member functions and constructors.
The this pointer is passed via the stack. This changes the functions to
explicitly track whether they have a RVO pointer and a this pointer.

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

21 months ago[clang][Interp] Start implementing record types
Timm Bäder [Fri, 16 Sep 2022 17:11:58 +0000 (19:11 +0200)]
[clang][Interp] Start implementing record types

Implement simple constructors as well as member access expressions.

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

21 months ago[clang][Interp] Don't run functions immediately after compiling them
Timm Bäder [Mon, 10 Oct 2022 11:02:15 +0000 (13:02 +0200)]
[clang][Interp] Don't run functions immediately after compiling them

This doesn't make much sense with functions that expect valid parameters
and/or a certain call stack on the caller side like This/RVO pointers.

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

21 months ago[clang][Interp][NFC] Add more tests for if expressions
Timm Bäder [Fri, 7 Oct 2022 09:54:04 +0000 (11:54 +0200)]
[clang][Interp][NFC] Add more tests for if expressions

Rename the old if_consteval.cpp to just if.cpp and add tests for the
if declaration.

21 months ago[clang][Interp][NFC] Add a TODO comment
Timm Bäder [Fri, 7 Oct 2022 05:49:57 +0000 (07:49 +0200)]
[clang][Interp][NFC] Add a TODO comment

We can ignore casts where FromT and ToT are the same type. But that's a
performance optimization that I'd like to do later. For now, this code
is doing the right thing.

21 months ago[TBAA] Model call accessing immutable type as readnone
Nikita Popov [Thu, 13 Oct 2022 10:31:23 +0000 (12:31 +0200)]
[TBAA] Model call accessing immutable type as readnone

Accesses to constant memory are not observable and should be
reported as readnone, not readonly. This is consistent with what
we do for normal (non-call) instructions: For those, the TBAA
metadata will result in pointsToConstantMemory() returning true,
which will then result in a NoModRef result, not a Ref result.

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

21 months ago[LoongArch] Add codegen support for atomicrmw umin/umax operation on LA64
gonglingqin [Fri, 14 Oct 2022 07:23:51 +0000 (15:23 +0800)]
[LoongArch] Add codegen support for atomicrmw umin/umax operation on LA64

Furthermore, use `beqz $rd, .BB` instead of `beq $rd, $zero, .BB`.

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

21 months ago[mlir][llvm] Use tablegen to import extract/insert ops from LLVM IR.
Tobias Gysi [Fri, 14 Oct 2022 06:32:30 +0000 (09:32 +0300)]
[mlir][llvm] Use tablegen to import extract/insert ops from LLVM IR.

The revision imports the extract and insert value operations using
tablegen generated builders. Additionally, it moves the tests to
the instructions.ll test file.

Reviewed By: ftynse, dcaballe

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

21 months agoAdd f16 nearbyint support.
Leon Clark [Fri, 14 Oct 2022 07:05:10 +0000 (08:05 +0100)]
Add f16 nearbyint support.

Enable lowering of FNEARBYINT for f16 and extend existing tests.

Reviewed By: arsenm

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

21 months agoAMDGPU: Fix failing test with expensive checks
Matt Arsenault [Fri, 14 Oct 2022 06:34:20 +0000 (23:34 -0700)]
AMDGPU: Fix failing test with expensive checks

Fixes failure after d383adec4d3914492e67267462e6f00fdd4934af

21 months agoAtomicExpand: Avoid some operations if the atomic is overaligned
Matt Arsenault [Tue, 20 Sep 2022 21:51:42 +0000 (17:51 -0400)]
AtomicExpand: Avoid some operations if the atomic is overaligned

Let some of the pointer bithacking fold away if we know the LSB are 0.

21 months ago[llvm-profgen] Fix inconsistent loading address issues
wlei [Fri, 14 Oct 2022 03:42:51 +0000 (20:42 -0700)]
[llvm-profgen] Fix inconsistent loading address issues

This is to fix two issues related with loading address:

1) When multiple MMAPs occur and their loading address are different, before it only used the first MMap as base address, all perf address after it used the wrong base address.

2) For pseudo probe profile, the address is always based on preferred loading address. If the base address is not equal to the preferred loading address, the pseudo probe address query will be wrong.

Solution: Instead of converting the address to offset lazily, right now all the address after parsing are converted on the fly based on preferred loading address in the parsing time. There is no "offset" used in profile generator any more.

Reviewed By: hoy, wenlei

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

21 months ago[BOLT] Section-handling refactoring/overhaul
Maksim Panchenko [Thu, 22 Sep 2022 19:05:12 +0000 (12:05 -0700)]
[BOLT] Section-handling refactoring/overhaul

Simplify the logic of handling sections in BOLT. This change brings more
direct and predictable mapping of BinarySection instances to sections in
the input and output files.

* Only sections from the input binary will have a non-null SectionRef.
  When a new section is created as a copy of the input section,
  its SectionRef is reset to null.

* RewriteInstance::getOutputSectionName() is removed as the section name
  in the output file is now defined by BinarySection::getOutputName().

* Querying BinaryContext for sections by name uses their original name.
  E.g., getUniqueSectionByName(".rodata") will return the original
  section even if the new .rodata section was created.

* Input file sections (with relocations applied) are emitted via MC with
  ".bolt.org" prefix. However, their name in the output binary is
  unchanged unless a new section with the same name is created.

* New sections are emitted internally with ".bolt.new" prefix if there's
  a name conflict with an input file section. Their original name is
  preserved in the output file.

* Section header string table is properly populated with section names
  that are actually used. Previously we used to include discarded
  section names as well.

* Fix the problem when dynamic relocations were propagated to a new
  section with a name that matched a section in the input binary.
  E.g., the new .rodata with jump tables had dynamic relocations from
  the original .rodata.

Reviewed By: rafauler

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

21 months ago[BranchRelaxation] Fall through only if block has no unconditional branches
Anshil Gandhi [Fri, 14 Oct 2022 04:47:28 +0000 (22:47 -0600)]
[BranchRelaxation] Fall through only if block has no unconditional branches

Prior to inserting an unconditional branch from X to its
fall through basic block, check if X has any terminators to
avoid inserting additional branches.

Reviewed By: arsenm

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

21 months agoAMDGPU: Add __builtin_amdgcn_permlane64
Matt Arsenault [Wed, 28 Sep 2022 21:55:30 +0000 (17:55 -0400)]
AMDGPU: Add __builtin_amdgcn_permlane64

21 months agoAsmPrinter: Remove pointless code in inline asm emission
Matt Arsenault [Thu, 13 Oct 2022 17:02:34 +0000 (10:02 -0700)]
AsmPrinter: Remove pointless code in inline asm emission

This was scanning through def operands looking for the
symbol operand. This is pointless because the symbol is always
the first operand as enforced by the verifier, and all operands
are implicit.

21 months ago[AArch64][BuildErrorFix] Add compatible classifyGlobalFunctionReference
Xiang1 Zhang [Fri, 14 Oct 2022 03:23:20 +0000 (11:23 +0800)]
[AArch64][BuildErrorFix] Add compatible classifyGlobalFunctionReference

21 months ago[AArch64] add tests for ccmp with negative constant op1; NFC
chenglin.bi [Fri, 14 Oct 2022 04:07:43 +0000 (12:07 +0800)]
[AArch64] add tests for ccmp with negative constant op1; NFC

21 months ago[flang] Add a semantics test for atomic_ref
Katherine Rasmussen [Thu, 13 Oct 2022 01:10:53 +0000 (18:10 -0700)]
[flang] Add a semantics test for atomic_ref

Reviewed By: rouson

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

21 months ago[clang][PowerPC][NFC] Add base test case for PPC64 VAArg aggregate smaller than a...
Ting Wang [Fri, 14 Oct 2022 02:57:40 +0000 (22:57 -0400)]
[clang][PowerPC][NFC] Add base test case for PPC64 VAArg aggregate smaller than a slot

Reviewed By: shchenz

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

21 months ago[InlineAsm][bugfix] Correct function addressing in inline asm
Xiang1 Zhang [Tue, 13 Sep 2022 06:48:12 +0000 (14:48 +0800)]
[InlineAsm][bugfix] Correct function addressing in inline asm
In Linux PIC model, there are 4 cases about value/label addressing:
Case 1: Function call or Label jmp inside the module.
Case 2: Data access (such as global variable, static variable) inside the module.
Case 3: Function call or Label jmp outside the module.
Case 4: Data access (such as global variable) outside the module.

Due to current llvm inline asm architecture designed to not "recognize" the asm
code, there are quite troubles for us to treat mem addressing differently for
same value/adress used in different instuctions.
For example, in pic model, call a func may in plt way or direclty pc-related,
but lea/mov a function adress may use got.

This patch fix/refine the case 1 and case 2 in inline asm.
Due to currently inline asm didn't support jmp the outsider lable, this patch
mainly focus on fix the function call addressing bugs in inline asm.

Reviewed By: Pengfei, RKSimon

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

21 months ago[mlir][bufferize] Treat certain aliasing-only uses like memory reads
Matthias Springer [Fri, 14 Oct 2022 01:39:50 +0000 (10:39 +0900)]
[mlir][bufferize] Treat certain aliasing-only uses like memory reads

This fixes an issue in One-Shot Bufferize that could lead to missing buffer copies in the future. This bug can currently not be triggered because of the order in which ops are analyzed (always bottom-to-top). However, if we consider different traversal orders for the analysis in the future, this bug can cause subtle issues that are difficult to debug.

Example:
```
%0 = ...
%1 = tensor.insert ... into %0
%2 = tensor.extract_slice %0
tensor.extract %2[...]
```

In case of a top-to-bottom analysis of the above IR, the `tensor.insert` is analyzed before the `tensor.extract_slice`. In that case, the `tensor.insert` will bufferize in-place because %2 is not yet known to become an alias of %0 (and therefore causing a conflict).

With this change, the `tensor.insert` will bufferize out-of-place, regardless of the traversal order.

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

21 months ago[mlir] Update CallInterfaceCallable to use the new casting infra.
Nick Kreeger [Fri, 14 Oct 2022 01:33:24 +0000 (20:33 -0500)]
[mlir] Update CallInterfaceCallable to use the new casting infra.

This enables casting LLVM style for mlir::CallInterfaceCallable usage.

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

21 months ago[PowerPC] Change CRNOT to a code gen single operand instruction
Nemanja Ivanovic [Fri, 14 Oct 2022 01:09:23 +0000 (20:09 -0500)]
[PowerPC] Change CRNOT to a code gen single operand instruction

Inputs to crnor can come from operands with chains so
if it is being used simply to negate such an operand,
the repeated input cannot be CSE'd. This patch just
adds a code-gen only instruction for this that takes
a single input and duplicates it in the encoding of
the underlying crnor.

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

21 months agoImprove dynamic loader support in DynamicLoaderPOSIXDYLD when using core files.
Greg Clayton [Wed, 28 Sep 2022 23:50:38 +0000 (16:50 -0700)]
Improve dynamic loader support in DynamicLoaderPOSIXDYLD when using core files.

Prior to this fix, no shared libraries would be loaded for a core file, even if they exist on the current machine. The issue was the DYLDRendezvous would read a DYLDRendezvous::Rendezvous from memory of the process in DYLDRendezvous::Resolve() which would read some ld.so structures as they existed in the middle of a process' lifetime. In core files we see, the DYLDRendezvous::Rendezvous::state would be set to eAdd for running processes. When ProcessELFCore.cpp would load the core file, it would call DynamicLoaderPOSIXDYLD::DidAttach(), which would call the above Rendezvous functions. The issue came when during the DidAttach function it call DYLDRendezvous::GetAction() which would return eNoAction if the DYLDRendezvous::m_current.state was read from memory as eAdd. This caused no shared libraries to be loaded for any ELF core files. We now detect if we have a core file and after reading the DYLDRendezvous::m_current.state from memory we set it to eConsistent, which causes DYLDRendezvous::GetAction() to return the correct action of eTakeSnapshot and shared libraries get loaded.

We also improve the DynamicLoaderPOSIXDYLD class to not try and set any breakpoints to catch shared library loads/unloads when we have a core file, which saves a bit of time.

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

21 months ago[gn build] port 1fda6f6859aa (lld driver_executable)
Nico Weber [Thu, 13 Oct 2022 23:56:37 +0000 (19:56 -0400)]
[gn build] port 1fda6f6859aa (lld driver_executable)

21 months ago[SPIRV] Fix formatting of function tests
Michal Paszkowski [Mon, 10 Oct 2022 22:17:11 +0000 (00:17 +0200)]
[SPIRV] Fix formatting of function tests

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

21 months ago[scudo] Support partial page releasing
Chia-hung Duan [Thu, 13 Oct 2022 22:52:04 +0000 (22:52 +0000)]
[scudo] Support partial page releasing

Block grouping enables us doing partial page releasing so that we can
release the pages in a finer granularity. Which means we don't need to
visit all blocks to determine which pages are unused. Besides, this
means we can do incremental page releasing depends on the number fo free
blocks.

Reviewed By: cryptoad, cferris

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

21 months ago[scudo] Manage free blocks in BatchGroup.
Chia-hung Duan [Thu, 13 Oct 2022 22:51:17 +0000 (22:51 +0000)]
[scudo] Manage free blocks in BatchGroup.

Scudo is supposed to allocate any blocks across the entired mapped
pages and each page is equally likely to be selected. Which means Scudo
is leaning to touch as many pages as possible. This brings better
security but it also sacrifices the chance of releasing dirty pages.

To alleviate the unmanagable footprint growing, this CL introduces the
BatchGroup concept. Each blocks will be classified into a BatchGroup
according to its address. While allocation, we are leaning to allocate
blocks in the same group first. Note that the blocks selected from a
group is still random over several pages. At the same time, we have
better prediction of dirty page growing speed. Besides, we are able to
do partial page releasing by examing part of BatchGroups.

Reviewed By: cryptoad, cferris

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

21 months ago[scudo] Add PageReleaseContext to convey page usage status.
Chia-hung Duan [Thu, 13 Oct 2022 22:33:35 +0000 (22:33 +0000)]
[scudo] Add PageReleaseContext to convey page usage status.

PageReleaseContext contains all the information needed for determing if
a page can be released. Splitting out the context increases the flexibility
of heterogenous free lists in the future. Also rename PackedCounterArray to
PageMap.

Reviewed By: cryptoad, cferris

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

21 months agoUse u16 to store Count/MaxCount
Chia-hung Duan [Thu, 13 Oct 2022 22:03:06 +0000 (22:03 +0000)]
Use u16 to store Count/MaxCount

The Count/MaxCount used in TransferBatch and PerClass can be fit in u16 in
current configurations and it's also reasonable to have a u16 limit. The
spare 16 bits will be used for additional status like pages mapping
status in a TransferBatch.

Reviewed By: cryptoad, cferris, vitalybuka

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

21 months agoPlatformDarwinKernel calls the ctor directly, not setting no-jit
Jason Molenda [Thu, 13 Oct 2022 23:28:18 +0000 (16:28 -0700)]
PlatformDarwinKernel calls the ctor directly, not setting no-jit

Fix a small thinko in https://reviews.llvm.org/D133534 .  Normally
DynamicLoaderDarwinKernels are created via the CreateInstance plugin
method, and that plugin method sets the Process CanJIT to false.
In the above patch, I added a new code path that can call the
DynamicLoaderDarwinKernel ctor directly, without going through
CreateInstance, and CanJIT was not being correctly set for the
process.

rdar://101148552

21 months agoDriver: Change default Android linker to lld.
Peter Collingbourne [Fri, 7 Oct 2022 04:13:05 +0000 (21:13 -0700)]
Driver: Change default Android linker to lld.

The clang distributed with the Android NDK has defaulted to lld since r22,
so let's update the driver to match.

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

21 months ago[NFC][FuncSpec] Add a test to show redundant function cloning.
Alexandros Lamprineas [Fri, 7 Oct 2022 16:40:41 +0000 (17:40 +0100)]
[NFC][FuncSpec] Add a test to show redundant function cloning.

Happens when we find identical specializations.

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

21 months ago[PGO] Do not create block count annotations when all weights are 0,
Wolfgang Pieb [Fri, 16 Sep 2022 16:40:14 +0000 (09:40 -0700)]
[PGO] Do not create block count annotations when all weights are 0,
avoiding an assertion.

A BB with a nonzero count, whose successor blocks all have 0 counts, could
cause an assertion. Don't create any branch weights in this case.

Reviewed By: xur

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

21 months ago[lld][WebAssembly] Add symbols marking start/end of stack region
Sam Clegg [Thu, 13 Oct 2022 16:53:12 +0000 (09:53 -0700)]
[lld][WebAssembly] Add symbols marking start/end of stack region

Currently emscripten is make assumptions about that memory layout,
assuming the stack is between `__data_end` and `__heap_base`:

https://github.com/emscripten-core/emscripten/blob/af961ad5c4c278ec510f0b7f7d522a95ee5a90f8/system/lib/compiler-rt/stack_limits.S#L42-L61

With this change we can be more precise:

https://github.com/emscripten-core/emscripten/pull/18057

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