platform/upstream/llvm.git
12 months ago[DAG] Improve carry reconstruction in combineCarryDiamond.
Amaury Séchet [Wed, 5 Jul 2023 17:45:01 +0000 (17:45 +0000)]
[DAG] Improve carry reconstruction in combineCarryDiamond.

The gain is usually suffiscient to go the extra mile and reconstruct a carry in some cases.

Reviewed By: RKSimon

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

12 months ago[InstrProf] Stabilize --show-prof-sym-list dump order
Fangrui Song [Sat, 22 Jul 2023 22:47:44 +0000 (15:47 -0700)]
[InstrProf] Stabilize --show-prof-sym-list dump order

D118181 leverages the iteration order of StringSet, which is not
guaranteed to be deterministic.

12 months ago[CodeGen] Stabilize C2/D2 to C1/D1 replacement order
Fangrui Song [Sat, 22 Jul 2023 22:29:37 +0000 (15:29 -0700)]
[CodeGen] Stabilize C2/D2 to C1/D1 replacement order

The conversion iterates over CodeGenModule::Replacements (a StringMap)
and replaces C2/D2 and moves C1/D1 (
commit 0196a1d98f8a206259a4b5ce93c21807243af92f in 2013, to make the
output look nicer). The iteration order is not guaranteed to be
deterministic, and may cause destructors.cpp to exhibit different
function orders. Use a MapVector instead.

While here, fix an IWYU issue by adding an explicit include, though
MapVector is already used in CodeGenModule.h.

12 months ago[builtins][Mips] Un-break FreeBSD build of __clear_cache
Jessica Clarke [Sat, 22 Jul 2023 22:01:21 +0000 (23:01 +0100)]
[builtins][Mips] Un-break FreeBSD build of __clear_cache

Commit 674a17e9bbe8 ("MIPS/compiler_rt: use synci to flush icache on
r6") completely removed the OS-specific guards under the guise of "For
pre-r6, we can use cacheflush libc function, which is same on Linux and
FreeBSD." However, the code in question had guards for Linux and
OpenBSD, not Linux and FreeBSD, and FreeBSD does not have a cacheflush
libc function as claimed, so this was neither the statement they
intended to make nor was it sufficient justification for making the code
completely unconditional. Whilst the upcoming FreeBSD 14 release has
dropped support for MIPS, FreeBSD 13 has support for it.

Fix this by only calling cacheflush on the OSes where it was previously
called, and not on other OSes where it either definitely isn't available
(FreeBSD) or is unknown (any other OS than the three mentioned in this
commit).

12 months ago[ObjCARC] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 21:41:24 +0000 (22:41 +0100)]
[ObjCARC] Use poison instead of undef as placeholder [NFC]
It's used to specify UB (as ptr argument to store) and to RAUW values when UB occurs.

12 months ago[UnifyLoopExits] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 21:38:10 +0000 (22:38 +0100)]
[UnifyLoopExits] Use poison instead of undef as placeholder [NFC]
This pass creates phi nodes where only one of the incoming values is used.
The remaining ones can be poison.

12 months ago[RewriteStatepointsForGC] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 21:25:41 +0000 (22:25 +0100)]
[RewriteStatepointsForGC] Use poison instead of undef as placeholder [NFC]
This is used in shufflevectors where the placeholder arg is unused.
It's also used when deleting invariant_start

12 months ago[clang-tidy] Support concepts in `bugprone-forwarding-reference-overload`
Evgeny Shulgin [Sat, 22 Jul 2023 19:46:31 +0000 (19:46 +0000)]
[clang-tidy] Support concepts in `bugprone-forwarding-reference-overload`

Ignore constrained perfect forwarding constructors.

Fixes: #58230

Reviewed By: PiotrZSL

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

12 months ago[clang-tidy] Fix checks filter with warnings-as-errors
Piotr Zegar [Sat, 22 Jul 2023 19:28:25 +0000 (19:28 +0000)]
[clang-tidy] Fix checks filter with warnings-as-errors

Since commit 5d12b13b0b26bc58b02ee23c369da8b83240cceb, warnings are
internally classified as errors which skip the check filters.

One use-case is particularly affected: you cannot selectively disable
clang-analyzer-core checks, they are force-enabled because required by others.
So enabling warning as errors will show new (and unwanted) errors !

Co-authored-by: kiwixz <kiwixz@outlook.com>
Fixes: #61969

Reviewed By: carlosgalvezp

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

12 months ago[clang-tidy] Ignore implcit casts in cppcoreguidelines-owning-memory
Piotr Zegar [Sat, 22 Jul 2023 19:24:53 +0000 (19:24 +0000)]
[clang-tidy] Ignore implcit casts in cppcoreguidelines-owning-memory

Add getCheckTraversalKind to the check in order
to ignore some implicit casts when matching
expresions.

Fixes: #63994

Reviewed By: carlosgalvezp

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

12 months ago[clang-tidy][NFC] Fix links in cppcoreguidelines module
Piotr Zegar [Sat, 22 Jul 2023 19:22:21 +0000 (19:22 +0000)]
[clang-tidy][NFC] Fix links in cppcoreguidelines module

Change links in cppcoreguidelines module from github
repository to isocpp.github.io. Unify format.

12 months ago[RISCV] Simplify setOperationAction for f64 ceil/floor/round/trunc/etc. NFC
Craig Topper [Sat, 22 Jul 2023 19:11:13 +0000 (12:11 -0700)]
[RISCV] Simplify setOperationAction for f64 ceil/floor/round/trunc/etc. NFC

We were setting the operations as Legal for Zfa in two places. Use
an else to avoid this.

12 months agoFix test failure on linaro-clang-armv8-quick with
Shubham Sandeep Rastogi [Sat, 22 Jul 2023 18:20:29 +0000 (11:20 -0700)]
Fix test failure on linaro-clang-armv8-quick with
c5a45b2515e6d2c3d29e86ad41c9be5a88f172d4

12 months ago[X86] Fix typo in comment. NFC
Craig Topper [Sat, 22 Jul 2023 18:12:02 +0000 (11:12 -0700)]
[X86] Fix typo in comment. NFC

12 months ago[LegalizeTypes] Use report_fatal_error instead of llvm_unreachable in the default...
Craig Topper [Sat, 22 Jul 2023 18:04:25 +0000 (11:04 -0700)]
[LegalizeTypes] Use report_fatal_error instead of llvm_unreachable in the default case of some type legalization handlers.

These can be triggered by in various ways when intrinsics are used wrong or a target doesn't correctly
not support something. Using a fatal error prevents strange behavior
like infinite loops.

We already do this for some of the vector type legalization handles.

12 months ago[RISCV] Remove unnecessary opcode argument to FPUnaryOp_imm template. NFC
Craig Topper [Sat, 22 Jul 2023 17:46:23 +0000 (10:46 -0700)]
[RISCV] Remove unnecessary opcode argument to FPUnaryOp_imm template. NFC

Instead of always passing OPC_OP_FP just hardcode it inside.

12 months agoChange DW_LLE_baseaddr to DW_LLE_baseaddrx in .debug_loclist section
Shubham Sandeep Rastogi [Thu, 20 Jul 2023 18:27:16 +0000 (11:27 -0700)]
Change DW_LLE_baseaddr to DW_LLE_baseaddrx in .debug_loclist section

With https://reviews.llvm.org/D154638, the ability to emit a .debug_addr
section has been added to dsymutil. With this, instead of emitting a
DW_LLE_baseaddr in the .debug_loclist section, a DW_LLE_baseaddrx can be
emitted instead, which will allow for more indirection.

Differetial Revision: https://reviews.llvm.org/D155724

12 months agoDo not emit a .debug_addr section if the DW_AT_addr_base is not set.
Shubham Sandeep Rastogi [Wed, 19 Jul 2023 01:36:30 +0000 (18:36 -0700)]
Do not emit a .debug_addr section if the DW_AT_addr_base is not set.

If the DW_AT_addr_base is not set, dsymutil should not copy any addrx
attributes into the cloned DIE, which will result in no .debug_addr
section being emitted.

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

12 months agoEmit a .debug_addr section with dsymutil
Shubham Sandeep Rastogi [Wed, 28 Jun 2023 22:19:35 +0000 (15:19 -0700)]
Emit a .debug_addr section with dsymutil

DWARF5 has support for DW_FORM_addrx, which can be useful for space
savings, but it needs a .debug_addr section to be used. dsymutil does
not have the ability to emit a debug_addr section currently. This patch
adds support for that.

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

12 months ago[X86] LowerRotate - manually expand rotate by splat constant patterns.
Simon Pilgrim [Sat, 22 Jul 2023 16:54:48 +0000 (17:54 +0100)]
[X86] LowerRotate - manually expand rotate by splat constant patterns.

Fixes issue identified on #63980 where the undef rotate amounts (during widening from v2i32 -> v4i32) were being constant folded to 0 when the shift amounts are created during expansion, losing the splat'd shift amounts.

12 months ago[ORC] Stabilize output stream order
Fangrui Song [Sat, 22 Jul 2023 16:52:14 +0000 (09:52 -0700)]
[ORC] Stabilize output stream order

It currently depends on the StringMap iteration order, which is not
guaranteed to be deterministic. Use MapVector to stabilize the order.

12 months ago[WebAssembly] Stabilize custom section order
Fangrui Song [Sat, 22 Jul 2023 16:37:22 +0000 (09:37 -0700)]
[WebAssembly] Stabilize custom section order

It currently depends on the StringMap iteration order, which is not
guaranteed to be deterministic. Use MapVector to stabilize the order.

12 months ago[clang] Enable C++11-style attributes in all language modes
Nikolas Klauser [Sat, 22 Jul 2023 16:33:55 +0000 (09:33 -0700)]
[clang] Enable C++11-style attributes in all language modes

This also ignores and deprecates the `-fdouble-square-bracket-attributes` command line flag, which seems to not be used anywhere. At least a code search exclusively found mentions of it in documentation: https://sourcegraph.com/search?q=context:global+-fdouble-square-bracket-attributes+-file:clang/*+-file:test/Sema/*+-file:test/Parser/*+-file:test/AST/*+-file:test/Preprocessor/*+-file:test/Misc/*+archived:yes&patternType=standard&sm=0&groupBy=repo

RFC: https://discourse.llvm.org/t/rfc-enable-c-11-c2x-attributes-in-all-standard-modes-as-an-extension-and-remove-fdouble-square-bracket-attributes

This enables `[[]]` attributes in all C and C++ language modes without warning by default. `-Wc++-extensions` does warn. GCC has enabled this extension in all C modes since GCC 10.

Reviewed By: aaron.ballman, MaskRay

Spies: #clang-vendors, beanz, JDevlieghere, Michael137, MaskRay, sstefan1, jplehr, cfe-commits, lldb-commits, dmgreen, jdoerfert, wenlei, wlei

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

12 months ago[clang-tidy][NFC] Fix list.rst generation when adding check
Piotr Zegar [Sat, 22 Jul 2023 15:48:18 +0000 (15:48 +0000)]
[clang-tidy][NFC] Fix list.rst generation when adding check

add_new_check.py does not work properly for checks that
generate fixes in base class. Adding some comments to those
checks in order to fix list.rst generation.

12 months ago[MemCpyOpt] add noalias metadata on lifetime intrinsic test case for stack-move optim...
khei4 [Sat, 22 Jul 2023 14:54:33 +0000 (23:54 +0900)]
[MemCpyOpt] add noalias metadata on lifetime intrinsic test case for stack-move optimization(NFC)

12 months ago[X86] Enable ISD::TRUNCATE support from v2i64 and v4i64 nodes
Simon Pilgrim [Sat, 22 Jul 2023 15:03:50 +0000 (16:03 +0100)]
[X86] Enable ISD::TRUNCATE support from v2i64 and v4i64 nodes

Addresses the last comment from D154592 - ensure we only truncate with PACKSS/PACKUS when it can be cheaply done (and use shuffles otherwise).

12 months ago[NFC][clang] Fixes whitespace.
Mark de Wever [Sat, 22 Jul 2023 14:50:58 +0000 (16:50 +0200)]
[NFC][clang] Fixes whitespace.

These changes cause the Buildkite CI to fail.

12 months ago[libc++][doc] Uses the proper paper number.
Mark de Wever [Sat, 22 Jul 2023 14:44:59 +0000 (16:44 +0200)]
[libc++][doc] Uses the proper paper number.

This was brought to my attention in
https://github.com/llvm/llvm-project/commit/88622aabf10764cc32d546f448076d25b13e94cd#r122279717

12 months ago[gn build] Port 57bd882343f8
LLVM GN Syncbot [Sat, 22 Jul 2023 14:23:37 +0000 (14:23 +0000)]
[gn build] Port 57bd882343f8

12 months ago[gn] port 822c31a0fe827a6 (HAVE_BUILTIN_THREAD_POINTER)
Nico Weber [Sat, 22 Jul 2023 14:22:32 +0000 (10:22 -0400)]
[gn] port 822c31a0fe827a6 (HAVE_BUILTIN_THREAD_POINTER)

Should maybe be 1 on linux, at least if is_clang. But just disabling
it everywhere is good enough for now.

12 months ago[gn] port b0bb68fd3cb7bfba (LLVM_ENABLE_REVERSE_ITERATION in clang/test)
Nico Weber [Sat, 22 Jul 2023 14:14:09 +0000 (10:14 -0400)]
[gn] port b0bb68fd3cb7bfba (LLVM_ENABLE_REVERSE_ITERATION in clang/test)

12 months ago[gn] port 9996e71f2d (LLVM_ENABLE_REVERSE_ITERATION in llvm/test)
Nico Weber [Sat, 22 Jul 2023 14:12:01 +0000 (10:12 -0400)]
[gn] port 9996e71f2d (LLVM_ENABLE_REVERSE_ITERATION in llvm/test)

12 months ago[mlir][LLVM] Introduce reduction intrinsics for minimum/maximum
Daniil Dudkin [Sat, 22 Jul 2023 13:25:26 +0000 (16:25 +0300)]
[mlir][LLVM] Introduce reduction intrinsics for minimum/maximum

This patch adds supports for the reduction intrinsic
for floating point minimum and maximum that have
been added to LLVM by https://reviews.llvm.org/D152370.

Related to: #63969

Reviewed By: dcaballe

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

12 months ago[Inline] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 12:23:32 +0000 (13:23 +0100)]
[Inline] Use poison instead of undef as placeholder [NFC]

12 months ago[StructurizeCFG] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 12:19:42 +0000 (13:19 +0100)]
[StructurizeCFG] Use poison instead of undef as placeholder [NFC]
These are used to create branch instructions. The condition is patched later

12 months ago[X86][BF16] Customize INSERT_VECTOR_ELT for bf16 when feature BF16 is on
Phoebe Wang [Sat, 22 Jul 2023 12:25:44 +0000 (20:25 +0800)]
[X86][BF16] Customize INSERT_VECTOR_ELT for bf16 when feature BF16 is on

Fixes root cause of #63017.
The reason is similar to BUILD_VECTOR. We have legal vector type but
still soft promote for scalar type. So we need to customize these scalar
to vector nodes.

Reviewed By: RKSimon

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

12 months agoPartially revert "clang/HIP: Remove __llvm_amdgcn_* wrapper hacks"
Matt Arsenault [Fri, 21 Jul 2023 16:33:35 +0000 (12:33 -0400)]
Partially revert "clang/HIP: Remove __llvm_amdgcn_* wrapper hacks"

Revert part of f407a7399575a6821940973c54754d42e72dd9ce.

Some of the HIP headers were using the f16 rcp inline, such that it
breaks compiling code against non-top-of-tree headers. Need to wait
for a few HIP releases to expire to fully remove these.

Fixes #63981

12 months agoAMDGPU: Silence a gcc warning
Matt Arsenault [Sat, 22 Jul 2023 11:45:18 +0000 (07:45 -0400)]
AMDGPU: Silence a gcc warning

12 months agoConstantFolding: Fix canonicalize folding for dynamic mode denormal inputs
Matt Arsenault [Sat, 22 Jul 2023 11:35:04 +0000 (07:35 -0400)]
ConstantFolding: Fix canonicalize folding for dynamic mode denormal inputs

We have to assume the input could be positive-zero. Makes alive2
happy.

12 months ago[CoroSplit] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 11:56:03 +0000 (12:56 +0100)]
[CoroSplit] Use poison instead of undef as placeholder [NFC]
Used to construct full structs/vectors
also, covert freeze undef -> freeze poison (same semantics)

12 months ago[SimplifyCFG] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sat, 22 Jul 2023 11:44:03 +0000 (12:44 +0100)]
[SimplifyCFG] Use poison instead of undef as placeholder [NFC]
This is used in a phi node that is created for which only 1 value is accessed (the non-poison)

12 months ago[mlir][rocdl] Change the translation of `GridDim*Op` to `__ockl_get_num_groups`
Fabian Mora [Sat, 22 Jul 2023 11:32:42 +0000 (11:32 +0000)]
[mlir][rocdl] Change the translation of `GridDim*Op` to `__ockl_get_num_groups`

Currently, `ROCDL::GridDim*Op` is being translated to `__ockl_get_global_size`, however
to match the meaning of `gpu.grid_dim` it should instead be translated to
`__ockl_get_num_groups`. This change would also make it agree with the meaning
of `gridDimx.*` in HIP, see:
https://github.com/ROCm-Developer-Tools/hipamd/blob/develop/include/hip/amd_detail/amd_hip_runtime.h#L257

Difference between the functions:
```
__ockl_get_global_size =  blockDim * numBlocks
__ockl_get_num_groups = numBlocks
```

Reviewed By: krzysz00

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

12 months ago[bazel] Add missing dependency for b2d76a063dd7fb681c98a10d8e7f54fd6d25dd27
Benjamin Kramer [Sat, 22 Jul 2023 11:21:51 +0000 (13:21 +0200)]
[bazel] Add missing dependency for b2d76a063dd7fb681c98a10d8e7f54fd6d25dd27

12 months ago[X86][BF16] Do not scalarize masked load for BF16 when we have AVX512BF16
Phoebe Wang [Sat, 22 Jul 2023 10:13:58 +0000 (18:13 +0800)]
[X86][BF16] Do not scalarize masked load for BF16 when we have AVX512BF16

Fixes #63017

Reviewed By: RKSimon

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

12 months ago[libc++][print] Adds stdout functions.
Mark de Wever [Wed, 12 Jul 2023 06:20:26 +0000 (08:20 +0200)]
[libc++][print] Adds stdout functions.

Implements parts of
- P2093R14 Formatted output
- P2539R4  Should the output of std::print to a terminal be
           synchronized with the underlying stream?

Depends on D150044

Reviewed By: #libc, ldionne

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

12 months ago[VirtualFileSystem] Use std::map::emplace
Fangrui Song [Sat, 22 Jul 2023 07:00:57 +0000 (00:00 -0700)]
[VirtualFileSystem] Use std::map::emplace

12 months ago[mlir][Transforms] GreedyPatternRewriteDriver: Fix `changed` parameter
Matthias Springer [Sat, 22 Jul 2023 06:30:40 +0000 (08:30 +0200)]
[mlir][Transforms] GreedyPatternRewriteDriver: Fix `changed` parameter

`changed` was not updated correctly when it was already set to "true" before calling `applyPatternsAndFoldGreedily`.

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

12 months ago[mlir][transform] Add `transform.apply_dce` op
Matthias Springer [Sat, 22 Jul 2023 06:23:48 +0000 (08:23 +0200)]
[mlir][transform] Add `transform.apply_dce` op

Add a transform that eliminates dead operations. This is useful after certain transforms (such as fusion) that create/clone new IR but leave the original IR in place.

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

12 months ago[VirtualFileSystem] Make gcc<7.5 happy after 75d71800aa384ee58663d892c325572f5588df2a
Fangrui Song [Sat, 22 Jul 2023 06:23:32 +0000 (23:23 -0700)]
[VirtualFileSystem] Make gcc<7.5 happy after 75d71800aa384ee58663d892c325572f5588df2a

There is a libstdc++ stl_map.h bug that is only back ported to 7.5.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78595#c13

```
/tmp/opt/gcc-7.3.0/include/c++/7.3.0/bits/stl_tree.h:2091:28: error: no matching function for call to ‘std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::unique_ptr<llvm::vfs::detail::InMemoryNode> >, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::unique_ptr<llvm::vfs::detail::InMemoryNode> > >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::unique_ptr<llvm::vfs::detail::InMemoryNode> > > >::_M_get_insert_unique_pos(std::pair<llvm::StringRef, std::unique_ptr<llvm::vfs::detail::InMemoryNode> >::first_type&)’
  = _M_get_insert_unique_pos(_KeyOfValue()(__v));
    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
```

Just construct a std::string from StringRef to work around it.

12 months agoFix crash in ODS backend for Type/Attr when an incorrect construct is used for Type...
Mehdi Amini [Sat, 22 Jul 2023 04:47:33 +0000 (21:47 -0700)]
Fix crash in ODS backend for Type/Attr when an incorrect construct is used for Type/Attr

Instead of crashing, try to print a useful error message.

12 months ago[flang][openacc] Fix hasDynamicShape logic
Valentin Clement [Sat, 22 Jul 2023 04:46:20 +0000 (21:46 -0700)]
[flang][openacc] Fix hasDynamicShape logic

Reviewed By: razvanlupusoru

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

12 months agoRevert "Reapply: [MemCpyOpt] implement single BB stack-move optimization which unify...
khei4 [Sat, 22 Jul 2023 04:08:12 +0000 (13:08 +0900)]
Revert "Reapply: [MemCpyOpt] implement single BB stack-move optimization which unify the static unescaped allocas"
revert because crash on chrome windows https://reviews.llvm.org/D153453#4524256

This reverts commit 569769b64858fd38f41267db41b461d3163aa754.

12 months ago[clang] Add serialization support for the DynamicAllocLValue variant of APValue:...
Nathan Ridge [Fri, 21 Jul 2023 08:05:14 +0000 (04:05 -0400)]
[clang] Add serialization support for the DynamicAllocLValue variant of APValue::LValueBase::Ptr

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

12 months ago[CodeGen] Support bitcode input containing multiple modules
Fangrui Song [Sat, 22 Jul 2023 03:05:35 +0000 (20:05 -0700)]
[CodeGen] Support bitcode input containing multiple modules

When using -fsplit-lto-unit (explicitly specified or due to using
-fsanitize=cfi/-fwhole-program-vtables), the emitted LLVM IR contains a module
flag metadata `"EnableSplitLTOUnit"`. If a module contains both type metadata
and `"EnableSplitLTOUnit"`, `ThinLTOBitcodeWriter.cpp` will write two modules
into the bitcode file. Compiling the bitcode (not ThinLTO backend compilation)
will lead to an error due to `parseIR` requiring a single module.

```
% clang -flto=thin a.cc -c -o a.bc
% clang -c a.bc
% clang -fsplit-lto-unit -flto=thin a.cc -c -o a.bc
% clang -c a.bc
error: Expected a single module
1 error generated.
```

There are multiple ways to have just one module in a bitcode file
output: `-Xclang -fno-lto-unit`, not using features like `-fsanitize=cfi`,
using `-fsanitize=cfi` with `-fno-split-lto-unit`. I think whether a
bitcode input file contains 2 modules (internal implementation strategy)
should not be a criterion to require an additional driver option when
the user seek for a non-LTO compile action.

Let's place the extra module (if present) into CodeGenOptions::LinkBitcodeFiles
(originally for -cc1 -mlink-bitcode-file). Linker::linkModules will link the two
modules together. This patch makes the following commands work:

```
clang -S -emit-llvm a.bc
clang -S a.bc
clang -c a.bc
```

Reviewed By: ormris

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

12 months agoOptimize emission of `dynamic_cast` to final classes.
Richard Smith [Sat, 22 Jul 2023 00:37:55 +0000 (17:37 -0700)]
Optimize emission of `dynamic_cast` to final classes.

- When the destination is a final class type that does not derive from
  the source type, the cast always fails and is now emitted as a null
  pointer or call to __cxa_bad_cast.

- When the destination is a final class type that does derive from the
  source type, emit a direct comparison against the corresponding base
  class vptr value(s). There may be more than one such value in the case
  of multiple inheritance; check them all.

For now, this is supported only for the Itanium ABI. I expect the same thing is
possible for the MS ABI too, but I don't know what guarantees are made about
vfptr uniqueness.

Reviewed By: rjmccall

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

12 months ago[lldb] Convert script native types to StructuredData counterpart
Med Ismail Bennani [Fri, 21 Jul 2023 23:43:24 +0000 (16:43 -0700)]
[lldb] Convert script native types to StructuredData counterpart

This patch adds the ability to pass native types from the script
interpreter to methods that use a {SB,}StructuredData argument.

To do so, this patch changes the `ScriptedObject` struture that holds
the pointer to the script object as well as the originating script
interpreter language. It also exposes that to the SB API via a new class
called `SBScriptObject`.

This structure allows the debugger to parse the script object and
convert it to a StructuredData object. If the type is not compatible
with the StructuredData types, we will store its pointer in a
`StructuredData::Generic` object.

This patch also adds some SWIG typemaps that checks the input argument to
ensure it's either an SBStructuredData object, in which case it just
passes it throught, or a python object that is NOT another SB type, to
provide some guardrails for the user.

rdar://111467140

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
12 months agoSet default C++ level for PlayStation(r) to C++17.
Sunil Srivastava [Sat, 22 Jul 2023 01:18:21 +0000 (18:18 -0700)]
Set default C++ level for PlayStation(r) to C++17.

12 months ago[include-cleaner] allow spelling strategies to customize verbatim/system headers
Sam McCall [Wed, 19 Jul 2023 02:49:54 +0000 (04:49 +0200)]
[include-cleaner] allow spelling strategies to customize verbatim/system headers

Our use case is wanting to apply a spelling strategy to rewrite the spellings
written in IWYU pragma private directives.

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

12 months ago[lldb] Consider OP_addrx in DWARFExpression::Update_DW_OP_addr
Felipe de Azevedo Piovezan [Fri, 21 Jul 2023 23:39:31 +0000 (16:39 -0700)]
[lldb] Consider OP_addrx in DWARFExpression::Update_DW_OP_addr

This rewrites DW_OP_addrx inside DWARFExpression as an DW_OP_addr so
that we can update addresses that are originally located in the
debug_addr section.

The full discussion behind this can be found in
https://discourse.llvm.org/t/dwarfexpression-and-dw-op-addrx/71627/12, but a
summary follows.

When SymbolFileDWARF::ParseVariableDIE creates DWARFExpressions for
variables whose location is an OP_addr, it knows how to remap
addresses appropriately in the DebugMap case. It then calls
DWARFExpression::Update_DW_OP_addr, which updates the value associated
with OP_addr.

However, when we have an OP_addrx, the update function does
nothing. This makes sense, as the DWARFExpression does not have a
mutable view of the debug_addr section. In non-DebugMap flows this is
not an issue, as the debug_addr contains the correct addresses of
variables. In DebugMap flows, this is problematic because the work
done by RelinkOSOAddress is lost. By updating the OP to OP_addr, we
can also update the address as required,

We also explored the alternative of relinking the debug_addr section
when we are initializing OSOs (InitOSO). However, this creates an
inconsistent story for users of
DWARFExpression::GetLocation_DW_OP_addr. This function returns an
address without telling callers whether that address came from an
OP_addr or an OP_addrx. If we preemptively relink OP_addrx results
without doing the same for OP_addr results, then callers can’t know
whether the address they got was an executable address or an object
file address. In other words, they can’t know whether they need to
call LinkOSOFileAddress on those results or not.

This patch addresses the majority of test failures when enabling DWARF
5 for MachO (over 200 test failures).

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

12 months ago[mlir][tosa][fix] Add proper type checking trait for tosa mul
TatWai Chong [Fri, 21 Jul 2023 23:28:45 +0000 (16:28 -0700)]
[mlir][tosa][fix] Add proper type checking trait for tosa mul

when operating integer type tensors, tosa elementwise multiplication
requires the element type of result to be a 32-bit integer rather
than the same type as inputs.

Change-Id: Ifd3d7ebd879be5c6b2c8e23aa6d7ef41f39c6d41

Reviewed By: mgehre-amd

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

12 months ago[NFC] Remove extra semicolons in clang/lib/APINotes/APINotesFormat.h
Evan Wilde [Fri, 21 Jul 2023 23:17:16 +0000 (16:17 -0700)]
[NFC] Remove extra semicolons in clang/lib/APINotes/APINotesFormat.h

There are some trailing semicolons on namespaces in
clang/lib/APINotes/APINotesFormat.h. These result in warnings while
building and don't need to be there.

Reviewed By: compnerd

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

12 months ago[AMDGPU] Fix an unused variable warning
Kazu Hirata [Fri, 21 Jul 2023 23:14:41 +0000 (16:14 -0700)]
[AMDGPU] Fix an unused variable warning

This patch fixes:

  llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:1006:9: error:
  unused variable 'Ty' [-Werror,-Wunused-variable]

12 months agoEnable compact unwind in all darwin simulators
Jon Roelofs [Fri, 21 Jul 2023 19:51:39 +0000 (12:51 -0700)]
Enable compact unwind in all darwin simulators

... since they've always supported it.

rdar://104359594

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

12 months agoRevert "[RISCV] Add test which shows alignment of constant pools and the functions...
Philip Reames [Fri, 21 Jul 2023 23:02:33 +0000 (16:02 -0700)]
Revert "[RISCV] Add test which shows alignment of constant pools and the functions which followed"

This reverts commit cbf2a6ce197e8176c01316fe25400aae0b7390c4.  This was a precommited test for a change which is being abandoned.

12 months agoRevert "Reapply [IR] Mark and constant expressions as undesirable"
Nathan Chancellor [Fri, 21 Jul 2023 22:23:08 +0000 (15:23 -0700)]
Revert "Reapply [IR] Mark and constant expressions as undesirable"

This reverts commit 086ee99564afbb11449c08ea2e094f7f49fadde5.

This patch causes an infinite loop when building arch/mips/mm/c-r4k.c in
the Linux kernel. See the comment in Phabricator for a reduced
reproducer: https://reviews.llvm.org/rG086ee99564afbb11449c08ea2e094f7f49fadde5

12 months agoAMDGPU: Fix variables only used in asserts
Matt Arsenault [Fri, 21 Jul 2023 22:52:50 +0000 (18:52 -0400)]
AMDGPU: Fix variables only used in asserts

12 months agoAMDGPU: Implement new 2ulp fdiv lowering
Matt Arsenault [Sun, 16 Jul 2023 12:32:08 +0000 (08:32 -0400)]
AMDGPU: Implement new 2ulp fdiv lowering

Extends the new frexp scaled reciprocal to the general case. The
reciprocal case is just the same thing when frexp of 1 is constant
folded. Could probably clean up the code to rely on that constant
folding.

Improves results for the IEEE path for the default OpenCL division. We
used to only emit the fdiv.fast intrinsic with a 2.5 ulp accuracy
threshold with DAZ, which uses explicit range checks. This gives us a
better fast option with the default IEEE behavior.

12 months agoAMDGPU: Refactor AMDGPUCodeGenPrepare fdiv handling
Matt Arsenault [Wed, 19 Jul 2023 14:11:53 +0000 (10:11 -0400)]
AMDGPU: Refactor AMDGPUCodeGenPrepare fdiv handling

NFC-ish. Does trigger some reordering of the fdiv scalarization. Also
skips scalarizing in more cases where nothing was going to happen. We
can still scalarize in some no-op edge cases.

https://reviews.llvm.org/D155740

12 months agoTrack the RequestingModule in the HeaderSearch LookupFile cache.
Richard Smith [Fri, 21 Jul 2023 21:53:36 +0000 (14:53 -0700)]
Track the RequestingModule in the HeaderSearch LookupFile cache.

Different requesting modules can have different lookup results, so don't
cache results across modules.

Fixes a regression introduced in reviews.llvm.org/D132779.

Test case based on one provided by Jan Svoboda.

Reviewed By: jansvoboda11

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

12 months ago[flang] Fix portability warning that was incorrectly an "else if"
Peter Klausler [Thu, 20 Jul 2023 19:37:25 +0000 (12:37 -0700)]
[flang] Fix portability warning that was incorrectly an "else if"

A semantics check for an assumed-length dummy procedure pointer was
inappropriately part of an "else" clause for a preceding check,
causing it to not be applied in all situations.

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

12 months ago[mlir][arith] Add canon pattern for chained `arith.muli`
Jakub Kuderski [Fri, 21 Jul 2023 22:17:39 +0000 (18:17 -0400)]
[mlir][arith] Add canon pattern for chained `arith.muli`

@benvanik reported this as missing.

Reviewed By: Mogball

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

12 months ago[HWASAN][LSAN] Replace cstdint with stdint.h
Kirill Stoimenov [Fri, 21 Jul 2023 21:17:50 +0000 (21:17 +0000)]
[HWASAN][LSAN] Replace cstdint with stdint.h

Reviewed By: brooksmoses, MaskRay

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

12 months ago[flang] Emit just one warning for a bad format edit descriptor
Peter Klausler [Thu, 20 Jul 2023 21:44:46 +0000 (14:44 -0700)]
[flang] Emit just one warning for a bad format edit descriptor

An attempt to use an edit descriptor (other than A or L) in a FORMAT
statement without arequired 'w' width will elicit warnings from both
the parser and the I/O checker in semantics.  Remove the warning from
the parser.

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

12 months agoTOSA-to-Linalg lowering for element-wise ops
Rafael Ubal Tena [Fri, 21 Jul 2023 21:48:11 +0000 (14:48 -0700)]
TOSA-to-Linalg lowering for element-wise ops

- Wrote complete documentation for the `Broadcastable` op trait. This is mostly meant as a thorough description of its previous behavior, with the exception of minor feature updates.

- Restricted legality criteria for a `Broadcastable` op in order to simplify current and future lowering passes and increase efficiency of code generated by those passes. New restriction are: 1) A dynamic dimension in an inferred result is not compatible with a static dimension in the actual result. 2) Broadcast semantics are restricted to input operands and not supported between inferred and actual result shapes.

- Implemented TOSA-to-Linalg lowering support for unary, binary, tertiary element-wise ops. This support is complete for all legal cases described in the `Broadcastable` trait documentation.

- Added unit tests for `tosa.abs`, `tosa.add`, and `tosa.select` as examples of unary, binary, and tertiary ops.

Reviewed By: eric-k256

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

12 months ago[RISCV] Add test which shows alignment of constant pools and the functions which...
Philip Reames [Fri, 21 Jul 2023 19:39:45 +0000 (12:39 -0700)]
[RISCV] Add test which shows alignment of constant pools and the functions which followed

12 months ago[flang][runtime] Fix NORM2([negative, ...])
Peter Klausler [Thu, 20 Jul 2023 20:50:10 +0000 (13:50 -0700)]
[flang][runtime] Fix NORM2([negative, ...])

NORM2 is broken for arrays that start with a negative number
because it sets the initial running max_ value to that number
rather than to its absolute value.

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

12 months ago[mlir] Move attr -> properties to not require Operation
Jacques Pienaar [Fri, 21 Jul 2023 21:54:43 +0000 (14:54 -0700)]
[mlir] Move attr -> properties to not require Operation

This allows for converting before/without an Operation is created.

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

12 months ago[flang] Strengthen procedure compatibility checking
Peter Klausler [Thu, 20 Jul 2023 18:46:31 +0000 (11:46 -0700)]
[flang] Strengthen procedure compatibility checking

Add more checks to procedure compatibility testing for procedure pointer
assignments, actual procedure arguments, &c.  Specifically, don't
allow corresponding dummy data objects to differ in their use
of polymorphism, assumed size arrays, or assumed shape arrays.

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

12 months ago[NVPTX] Add initial support for '.alias' in PTX
Joseph Huber [Wed, 12 Jul 2023 18:35:01 +0000 (13:35 -0500)]
[NVPTX] Add initial support for '.alias' in PTX

This patch adds initial support for using aliases when targeting PTX. We
perform a pretty strict conversion from the globals referenced to the
expected output. as described in the PTX documentation at
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#kernel-and-function-directives-alias

These cannot currently be used due to a bug in the `nvlink`
implementation that causes aliases to pruned functions to crash the
linker.

Reviewed By: tra

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

12 months ago[flang] Portability warning and documentation for an obscure extension
Peter Klausler [Thu, 20 Jul 2023 17:39:04 +0000 (10:39 -0700)]
[flang] Portability warning and documentation for an obscure extension

A quotation mark can appear in a Fortran character literal by doubling
it; for example, PRINT *, "'""'" prints '"'.  When those doubled
quotation marks are split by a free form line continuation, the
continuation line should have an ampersand before the second quotation
mark.  But most compilers, including this one, allow the second
quotation mark to appear as the first character on the continuation
line, too.

So this works:

  print *, "'"&
"'"

but it really should be written as:

  print *, "'"&
&"'"

Emit a portability warning and document that we support this near-universal
extension.

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

12 months ago[clangd] Allow indexing of __reserved_names outside system headers
Sam McCall [Sat, 15 Jul 2023 20:21:25 +0000 (22:21 +0200)]
[clangd] Allow indexing of __reserved_names outside system headers

The special handling for these names was added in
https://github.com/llvm/llvm-project/commit/055d8090d1d5137dab88533995e0c5d9b5390c28
and the motivation was the C++ standard library.

It turns out some projects like using these names anyway, in particular the
linux kernel. D153946 proposed making this a config option, but there are
some implementation issues with the config system.

As an alternative, this patch tweaks the heuristic so we only drop these symbols
in system headers. This does the right thing for linux and the C++ standard
library, at least.

Fixes https://github.com/clangd/clangd/issues/1680
Fixes https://github.com/llvm/llvm-project/issues/63862

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

12 months ago[Headers][doc] Add SHA1/SHA256 intrinsic descriptions
Paul Robinson [Thu, 20 Jul 2023 16:44:18 +0000 (09:44 -0700)]
[Headers][doc] Add SHA1/SHA256 intrinsic descriptions

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

12 months ago[flang] Rename new test file
Peter Klausler [Fri, 21 Jul 2023 21:16:56 +0000 (14:16 -0700)]
[flang] Rename new test file

A recent patch added a new test file whose name conflicts with an existing
test on case-insensitive filesystems.  Rename it.

12 months ago[flang] Ensure that NULL(without MOLD=) not passed to dummy argument with assumed...
Peter Klausler [Wed, 19 Jul 2023 22:02:32 +0000 (15:02 -0700)]
[flang] Ensure that NULL(without MOLD=) not passed to dummy argument with assumed type parameters

A dummy argument with an assumed (*) character length or derived type parameter
value specification needs to be associated with an actual argument that can
supply a value for it, so make sure that a NULL without a MOLD= is not being
passed.

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

12 months ago[clangd] Use index for go-to-type
Sam McCall [Thu, 20 Jul 2023 22:23:35 +0000 (00:23 +0200)]
[clangd] Use index for go-to-type

This ensures it finds the definition even if not visible.

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

12 months ago[clangd] Add BlockEnd comments for control flow statements
Sam McCall [Mon, 17 Jul 2023 06:02:40 +0000 (08:02 +0200)]
[clangd] Add BlockEnd comments for control flow statements

These mark the end of CompoundStmts bodies of if/while/for/switch.
To identify which statement is being ended, we include abbreviated
text of the condition/loop variable.

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

12 months ago[flang] Disallow ASYNCHRONOUS for subroutine
Peter Klausler [Wed, 19 Jul 2023 20:56:32 +0000 (13:56 -0700)]
[flang] Disallow ASYNCHRONOUS for subroutine

The check for inappropriate usage of the ASYNCHRONOUS attribute
needed to be moved in declaration checking so that it can catch
attempts to use it on a subroutine.

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

12 months ago[flang] Enforce F'2023 C7125
Peter Klausler [Wed, 19 Jul 2023 20:23:53 +0000 (13:23 -0700)]
[flang] Enforce F'2023 C7125

An item whose declared type is ABSTRACT may not appear in an
array constructor.

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

12 months ago[libc] Remove test RPC opcodes from the exported header
Joseph Huber [Mon, 10 Jul 2023 14:38:37 +0000 (09:38 -0500)]
[libc] Remove test RPC opcodes from the exported header

This patch does the noisy work of removing the test opcodes from the
exported interface to an interface that is only visible in `libc`. The
benefit of this is that we both test the exported RPC registration more
directly, and we do not need to give this interface to users.

I have decided to export any opcode that is not a "core" libc feature as
having its MSB set in the opcode. We can think of these as non-libc
"extensions".

Reviewed By: JonChesterfield

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

12 months agoAMDGPU: Overhaul and improve rcp and rsq f32 formation
Matt Arsenault [Mon, 3 Jul 2023 14:22:24 +0000 (10:22 -0400)]
AMDGPU: Overhaul and improve rcp and rsq f32 formation

The highlight change is a new denormal safe 1ulp lowering which uses
rcp after using frexp to perform input scaling. This saves 2
instructions compared to other implementations which performed an
explicit denormal range change. This improves the OpenCL default, and
requires a flag for HIP. I don't believe there's any flag wired up for
OpenMP to emit the necessary fpmath metadata.

This provides several improvements and changes that were hard to
separate without regressing one case or another. Disturbingly the
OpenCL conformance test seems to have the reciprocal test commented
out. I locally hacked it back in to test this.

Starts introducing f32 rsq intrinsics in AMDGPUCodeGenPrepare. Like
the rcp case, we could do this in codegen if !fpmath were preserved
(although we would lose some computeKnownFPClass tricks). Start
requiring contract flags to form rsq. The rsq fusion actually improves
the result from ~2ulp to ~1ulp. We have some older fusion in codegen
which only keys off unsafe math which should be refined.

Expand rsq patterns by checking for denormal inputs and pre/post
multiplying like the current library code does. We also take advantage
of computeKnownFPClass to avoid the scaling when we can statically
prove the input cannot be a denormal. We could do the same for the rcp
case, but unlike rsq a large input can underflow to denormal. We need
additional upper bound exponent checks on the input in order to do the
same for rcp.

This rsq handling also now starts handling the negated case. We
introduce rsq with an fneg. In the case the fneg doesn't fold into its
user, it's a neutral change but provides improvement if it is foldable
as a source modifier.

Also starts respecting the arcp attribute properly, and more strictly
interprets afn. We were previously interpreting afn as implying you
could do the reciprocal expansion of an fdiv. The codegen handling of
these also needs to be revisited.

This also effectively introduces the optimization
combineRepeatedFPDivisors enables, just done in the IR instead (and
only for f32).

This is almost across the board better. The one minor regression is
for gfx6/buggy frexp case where for multiple reciprocals, we could
previously reuse rematerialized constants per instance (it's neutral
for a single rcp).

The fdiv.fast and sqrt handling need to be revisited next.

https://reviews.llvm.org/D155593

12 months ago[MLIR][ANALYSIS] Add liveness analysis utility
Srishti Srivastava [Fri, 21 Jul 2023 20:28:57 +0000 (13:28 -0700)]
[MLIR][ANALYSIS] Add liveness analysis utility

This commit adds a utility to implement liveness analysis using the
sparse backward data-flow analysis framework. Theoretically, liveness
analysis assigns liveness to each (value, program point) pair in the
program and it is thus a dense analysis. However, since values are
immutable in MLIR, a sparse analysis, which will assign liveness to
each value in the program, suffices here.

Liveness analysis has many applications. It can be used to avoid the
computation of extraneous operations that have no effect on the memory
or the final output of a program. It can also be used to optimize
register allocation. Both of these applications help achieve one very
important goal: reducing runtime.

A value is considered "live" iff it:
  (1) has memory effects OR
  (2) is returned by a public function OR
  (3) is used to compute a value of type (1) or (2).
It is also to be noted that a value could be of multiple types (1/2/3) at
the same time.

A value "has memory effects" iff it:
  (1.a) is an operand of an op with memory effects OR
  (1.b) is a non-forwarded branch operand and a block where its op could
  take the control has an op with memory effects.

A value `A` is said to be "used to compute" value `B` iff `B` cannot be
computed in the absence of `A`. Thus, in this implementation, we say that
value `A` is used to compute value `B` iff:
  (3.a) `B` is a result of an op with operand `A` OR
  (3.b) `A` is used to compute some value `C` and `C` is used to compute
  `B`.

---

It is important to note that there already exists an MLIR liveness
utility here: llvm-project/mlir/include/mlir/Analysis/Liveness.h. So,
what is the need for this new liveness analysis utility being added by
this commit? That need is explained as follows:-

The similarities between these two utilities is that both use the
fixpoint iteration method to converge to the final result of liveness.
And, both have the same theoretical understanding of liveness as well.

However, the main difference between (a) the existing utility and (b)
the added utility is the "scope of the analysis". (a) is restricted to
analysing each block independently while (b) analyses blocks together,
i.e., it looks at how the control flows from one block to the other,
how a caller calls a callee, etc. The restriction in the former implies
that some potentially non-live values could be marked live and thus the
full potential of liveness analysis will not be realised.

This can be understood using the example below:

```
1 func.func private @private_dead_return_value_removal_0() -> (i32, i32) {
2   %0 = arith.constant 0 : i32
3   %1 = arith.addi %0, %0 : i32
4   return %0, %1 : i32, i32
5 }
6 func.func @public_dead_return_value_removal_0() -> (i32) {
7   %0:2 = func.call @private_dead_return_value_removal_0() : () -> (i32, i32)
8   return %0#0 : i32
9 }
```

Here, if we just restrict our analysis to a per-block basis like (a), we
will say that the %1 on line 3 is live because it is computed and then
returned outside its block by the function. But, if we perform a
backward data-flow analysis like (b) does, we will say that %0#1 of line
7 is not live because it isn't returned by the public function and thus,
%1 of line 3 is also not live. So, while (a) will be unable to suggest
any IR optimizations, (b) can enable this IR to convert to:-

```
1 func.func private @private_dead_return_value_removal_0() -> i32 {
2   %0 = arith.constant 0 : i32
3   return %0 : i32
4 }
5 func.func @public_dead_return_value_removal_0() -> i32 {
6   %0 = call @private_dead_return_value_removal_0() : () -> i32
7   return %0 : i32
8 }
```

One operation was removed and one unnecessary return value of the
function was removed and the function signature was modified. This is an
optimization that (b) can enable but (a) cannot. Such optimizations can
help remove a lot of extraneous computations that are currently being
done.

Signed-off-by: Srishti Srivastava <srishtisrivastava.ai@gmail.com>
Reviewed By: matthiaskramm, jcai19

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

12 months ago[flang] Catch case of character array constructor with indeterminable length
Peter Klausler [Wed, 19 Jul 2023 19:06:31 +0000 (12:06 -0700)]
[flang] Catch case of character array constructor with indeterminable length

F'2023 7.8 para 5 requires that an implied DO loop with no iterations
in a character array constructor should have items whose lengths are
constant expressions independent of the value of the implied DO loop
index.

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

12 months ago[AArch64] Move branch relaxation after bbsection assignment
Daniel Hoekwater [Tue, 27 Jun 2023 01:30:27 +0000 (01:30 +0000)]
[AArch64] Move branch relaxation after bbsection assignment

Because branch relaxation needs to factor in if branches target
a block in the same section or a different one, it needs to run
after the Basic Block Sections / Machine Function Splitting passes.

Because Jump table compression relies on block offsets remaining
fixed after the table is compressed, we must also move the JT
compression pass.

The only tests affected are ones enforcing just the ordering and
the a few that have basic block ids changed because RenumberBlocks
hasn't run yet.

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

12 months ago[SLP][NFC]Add a test with strided loads, NFC.
Alexey Bataev [Fri, 21 Jul 2023 20:13:01 +0000 (13:13 -0700)]
[SLP][NFC]Add a test with strided loads, NFC.

12 months ago[flang][runtime] Detect NEWUNIT= without FILE= or STATUS='SCRATCH'
Peter Klausler [Wed, 19 Jul 2023 00:05:47 +0000 (17:05 -0700)]
[flang][runtime] Detect NEWUNIT= without FILE= or STATUS='SCRATCH'

It is an error to open a new unit with OPEN(NEWUNIT=) and have
neither a file name nor a scratch status.  Catch it, and report a
new error code.

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

12 months ago[LV] Replace use of getMaxSafeDepDist with isSafeForAnyVector (NFC)
Florian Hahn [Fri, 21 Jul 2023 20:05:50 +0000 (22:05 +0200)]
[LV] Replace use of getMaxSafeDepDist with isSafeForAnyVector (NFC)

Replace the use of getMaxSafeDepDistBytes with the more direct
isSafeForAnyVector. This removes the need to define getMaxSafeDepDistBytes.

12 months agoValueTracking: Implement computeKnownFPClass for frexp
Matt Arsenault [Wed, 3 May 2023 13:52:53 +0000 (09:52 -0400)]
ValueTracking: Implement computeKnownFPClass for frexp

Work around the lack of proper multiple return values by looking
at the extractvalue.

https://reviews.llvm.org/D150982

12 months agoValueTracking: Add baseline tests for frexp handling in computeKnownFPClass
Matt Arsenault [Wed, 3 May 2023 11:37:16 +0000 (07:37 -0400)]
ValueTracking: Add baseline tests for frexp handling in computeKnownFPClass

12 months agoAMDGPU: Add baseline test for fdiv combine
Matt Arsenault [Sun, 2 Jul 2023 00:21:28 +0000 (20:21 -0400)]
AMDGPU: Add baseline test for fdiv combine

12 months ago[flang] Preserve errors from generic matching
Peter Klausler [Tue, 18 Jul 2023 23:14:49 +0000 (16:14 -0700)]
[flang] Preserve errors from generic matching

When searching for a matching specific procedure for a set of actual
arguments in a type-bound generic interface for a defined operator,
don't discard any error messages that may have been produced for
the specific that was found.  Tweak the code to preserve those
messages and add them to the context's messages, and add a test.

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