platform/upstream/llvm.git
20 months agoRevert "Harmonize cmake_policy() across standalone builds of all projects"
Michał Górny [Thu, 27 Oct 2022 12:30:02 +0000 (14:30 +0200)]
Revert "Harmonize cmake_policy() across standalone builds of all projects"

This reverts commit 88d7508dc479210f07abccb17f0194b66264b125.
It's reported to break builds when symlinking other projects inside
the `tools` directory.

20 months ago[intelpt] Update Python tests to account for new errrors
Jakob Johnson [Wed, 26 Oct 2022 22:48:56 +0000 (15:48 -0700)]
[intelpt] Update Python tests to account for new errrors

Update the Python tests (ie tests run via `lldb-dotest -p TestTrace`) to
handle new error introduced in D136610.

Test Plan:
`lldb-dotest -p TestTrace`

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

20 months ago[llvm-debuginfo-analyzer] (08/09) - ELF Reader
Carlos Alberto Enciso [Thu, 27 Oct 2022 11:04:27 +0000 (12:04 +0100)]
[llvm-debuginfo-analyzer] (08/09) - ELF Reader

The fix for the unitest case introduced a dependency on the
MC library causing a failure in:

  https://lab.llvm.org/buildbot/#/builders/121/builds/24567
  clang-ppc64le-multistage/stage1
  undefined reference to symbol 'llvm::TargetRegistry::lookupTarget'

Added:
- MC to the LLVM_LINK_COMPONENTS list.

Reviewed By: jryans

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

20 months ago[mlir] Fix printing when linalg.map has no inputs.
Alexander Belyaev [Thu, 27 Oct 2022 11:01:22 +0000 (13:01 +0200)]
[mlir] Fix printing when linalg.map has no inputs.

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

20 months agoRecommit: [FuncSpec] Fix specialisation based on literals
Momchil Velikov [Thu, 27 Oct 2022 11:23:03 +0000 (12:23 +0100)]
Recommit: [FuncSpec] Fix specialisation based on literals

[fixed test to work with reverse iteration]

The `FunctionSpecialization` pass has support for specialising
functions, which are called with literal arguments. This functionality
is disabled by default and is enabled with the option
`-function-specialization-for-literal-constant` .  There are a few
issues with the implementation, though:

* even with the default, the pass will still specialise based on
   floating-point literals

* even when it's enabled, the pass will specialise only for the `i1`
    type (or `i2` if all of the possible 4 values occur, or `i3` if all
    of the possible 8 values occur, etc)

The reason for this is incorrect check of the lattice value of the
function formal parameter. The lattice value is `overdefined` when the
constant range of the possible arguments is the full set, and this is
the reason for the specialisation to trigger. However, if the set of
the possible arguments is not the full set, that must not prevent the
specialisation.

This patch changes the pass to NOT consider a formal parameter when
specialising a function if the lattice value for that parameter is:

* unknown or undef
* a constant
* a constant range with a single element

on the basis that specialisation is pointless for those cases.

Is also changes the criteria for picking up an actual argument to
specialise if the argument is:

* a LLVM IR constant
* has `constant` lattice value
 has `constantrange` lattice value with a single element.

Reviewed By: ChuanqiXu

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

Change-Id: Iea273423176082ec51339aa66a5fe9fea83557ee

20 months agoHarmonize cmake_policy() across standalone builds of all projects
Michał Górny [Mon, 24 Oct 2022 04:31:37 +0000 (06:31 +0200)]
Harmonize cmake_policy() across standalone builds of all projects

Move `cmake_policy()` settings from `llvm/CMakeLists.txt` into a shared
`cmake/modules/CMakePolicy.cmake`.  Include it from all relevant
projects that support standalone builds, in order to ensure that
the policies are consistently set whether they are built in-tree
or stand-alone.

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

20 months ago[mlir] Fix `AffineMap.dropResults`.
Oleg Shyshkov [Thu, 27 Oct 2022 11:32:52 +0000 (13:32 +0200)]
[mlir] Fix `AffineMap.dropResults`.

`AffineMap.dropResult` erases one result from the array and it changes indexing. Calling `dropResult` is a loop with increasing indexes does not produce a desired result.

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

20 months agoFix iterator corruption in splitBasicBlockBefore
Max Kazantsev [Thu, 27 Oct 2022 10:54:15 +0000 (17:54 +0700)]
Fix iterator corruption in splitBasicBlockBefore

We should not delete block predecessors (via replacing successors
of terminators) while iterating them, otherwise we may skip some
of them. Instead, save predecessors to a separate vector and iterate
over it.

20 months ago[FunctionAttrs] Add additional tests with operand bundles (NFC)
Nikita Popov [Thu, 27 Oct 2022 10:38:55 +0000 (12:38 +0200)]
[FunctionAttrs] Add additional tests with operand bundles (NFC)

20 months ago[mlir][tensor][bufferize] Support memory_space for tensor.pad
Matthias Springer [Thu, 27 Oct 2022 10:24:02 +0000 (12:24 +0200)]
[mlir][tensor][bufferize] Support memory_space for tensor.pad

This change adds memory space support to tensor.pad. (tensor.generate and tensor.from_elements do not support memory spaces yet.)

The memory space is inferred from the buffer of the source tensor.

Instead of lowering tensor.pad to tensor.generate + tensor.insert_slice, it is now lowered to bufferization.alloc_tensor (with the correct memory space) + linalg.map + tensor.insert_slice.

Memory space support for the remaining two tensor ops is left for a later point, as this requires some more design discussions.

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

20 months agoFix buildbot fail
Phoebe Wang [Thu, 27 Oct 2022 10:23:05 +0000 (18:23 +0800)]
Fix buildbot fail

20 months ago[mlir][tensor] Fix build: Add missing line break to test case
Matthias Springer [Thu, 27 Oct 2022 10:20:05 +0000 (12:20 +0200)]
[mlir][tensor] Fix build: Add missing line break to test case

This should have been part of D136767.

20 months ago[mlir][tensor][bufferize] Lower tensor.generate to linalg.map
Matthias Springer [Thu, 27 Oct 2022 09:54:01 +0000 (11:54 +0200)]
[mlir][tensor][bufferize] Lower tensor.generate to linalg.map

There is no memref equivalent of tensor.generate. The purpose of this change is to avoid creating scf.parallel loops during bufferization.

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

20 months ago[BasicAA] Remove redundant libcall handling
Nikita Popov [Thu, 27 Oct 2022 10:00:30 +0000 (12:00 +0200)]
[BasicAA] Remove redundant libcall handling

The writeonly attribute for memset_pattern16 (and other referenced
libcalls) is being added by InferFunctionAttrs nowadays. No need
to special-case it here.

20 months ago[clang] Do not hide base member using-decls with different template head.
Utkarsh Saxena [Thu, 27 Oct 2022 09:50:43 +0000 (11:50 +0200)]
[clang] Do not hide base member using-decls with different template head.

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

**Adding requires clause to template head** or **constraining the template parameter type** is ineffective because, even though it creates a non-equivalent template head [temp.over.link#6](https://eel.is/c++draft/temp.over.link#6) and hence eligible for overload resolution, `Derived::foo` still [hides any previous using decl](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaOverload.cpp#L1283-L1301,).
Clang diverges from gcc here and can be seen more clearly in this example:
```
struct base {
  template <int N, int M>
  int foo() { return 1; };
};

struct bar : public base {
  using base::foo;
  template <int N>
  int foo() { return 2; };
};

int main() {
  bar f;
  f.foo<10, 10>(); // clang previously errored while GCC does not.
}
```
https://godbolt.org/z/v5hnh6czq. We see that `bar::foo` hides `base::foo` because it only differs in the head.

Adding a trailing `requires` to the definition was a nice find. In this case, clang considers them [overloads](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaOverload.cpp#L1148-L1152) because of [mismatching requires clause.](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaOverload.cpp#L1390-L1405). So both of them make it to the overload resolution (where constrained Derived::foo is rejected then).

---

In this patch, we do not ignore matching the template head (template parameters, type contraints and trailing requires) while considering whether the using decl of base member should be hidden. The return type of a templated function is still not considered as different return types would create ambiguous candidates.

The changed tests looks reasonable and also matches GCC behaviour: https://godbolt.org/z/8KqPEThrY

Note: We are now able to create an ambiguity in case where both base member and derived member specialisations satisfy the constraints (when the constraints are not same). Ideally using-decl should not create ambiguity. I plan to fix this later if it gathers more attention.

Reviewed By: ilya-biryukov, #clang-language-wg

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

20 months ago[mlir] Fix circular dialect initialization
Matthias Springer [Thu, 27 Oct 2022 09:45:15 +0000 (11:45 +0200)]
[mlir] Fix circular dialect initialization

This change fixes a bug where a dialect is initialized multiple times. This triggers an assertion when the ops of the dialect are registered (`error: operation named ... is already registered`).

This bug can be triggered as follows:

1. Dialect A depends on dialect B (as per ADialect.td).

2. Somewhere there is an extension of dialect B that depends on dialect A (e.g., it defines external models create ops from dialect A). E.g.:
```
registry.addExtension(+[](MLIRContext *ctx, BDialect *dialect) {
  BDialectOp::attachInterface ...
  ctx->loadDialect<ADialect>();
});
```

3. When dialect A is loaded, its `initialize` function is called twice:

```
     ADialect::ADialect()
        |     |
        |     v
        |   ADialect::initialize()
        v
     getOrLoadDialect<BDialect>()
        |
        v
     (load extension of BDialect)
        |
        v
     ctx->loadDialect<ADialect>()  // user wrote this in the extension
        |
        v
     getOrLoadDialect<ADialect>()  // the dialect is not "fully" loaded yet
        |
        v
     ADialect::ADialect()
        |
        v
     ADialect::initialize()
```

An example of a dialect extension that depends on other dialects is `Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp`. That particular dialect extension does not trigger this bug. (It would trigger this bug if the SCF dialect would depend on the Tensor dialect.)

This change introduces a new dialect state: dialects that are currently being loaded. Same as dialects that were already fully loaded (and initialized), dialects that are in the process of being loaded are not loaded a second time.

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

20 months ago[X86][1/2] SUPPORT RAO-INT
Phoebe Wang [Thu, 27 Oct 2022 09:08:49 +0000 (17:08 +0800)]
[X86][1/2] SUPPORT RAO-INT

For more details about these instructions, please refer to the latest ISE document: https://www.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html

Initial authored by Liu Chen (@LiuChen3)

Reviewed By: RKSimon

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

20 months ago[mlir][vector][bufferize] Implement DestinationStyleOpInterface on TransferWriteOp
Matthias Springer [Thu, 27 Oct 2022 08:59:52 +0000 (10:59 +0200)]
[mlir][vector][bufferize] Implement DestinationStyleOpInterface on TransferWriteOp

This simplifies the BufferizableOpInterface implementation of vector.transfer_write.

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

20 months ago[llvm-debuginfo-analyzer] (08/09) - ELF Reader
Carlos Alberto Enciso [Thu, 27 Oct 2022 08:47:09 +0000 (09:47 +0100)]
[llvm-debuginfo-analyzer] (08/09) - ELF Reader

The unitest and test cases are platform dependent (x86_64)
causing failures in:

  https://lab.llvm.org/buildbot/#/builders/245/builds/146
  https://lab.llvm.org/buildbot/#/builders/188/builds/21397
  No available targets are compatible with triple "x86_64-unknown-unknown".

Added:
- ';REQUIRES: x86-registered-target' to the LIT tests.
- Code to check if the target 'Triple::x86_64' is supported to
  the unittest case.

20 months agoPre-commit test case for D136784
eopXD [Thu, 27 Oct 2022 07:42:31 +0000 (00:42 -0700)]
Pre-commit test case for D136784

This is a pre-commit for the fix in D136784.

Reviewed By: SjoerdMeijer

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

20 months ago[LSR][RISCV] Pre-commit test case for D126043
eopXD [Thu, 29 Sep 2022 09:08:50 +0000 (02:08 -0700)]
[LSR][RISCV] Pre-commit test case for D126043

Pre-commit test case for D126043

Reviewed By: Meinersbur, #loopoptwg

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

20 months ago[mlir][bufferize] Provide default BufferizableOpInterface impl for destination style ops
Matthias Springer [Thu, 27 Oct 2022 08:40:24 +0000 (10:40 +0200)]
[mlir][bufferize] Provide default BufferizableOpInterface impl for destination style ops

tensor.insert and tensor.insert_slice (as destination style ops) do no longer need to implement the entire BufferizableOpInterface.

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

20 months agoFix a -Wunused-const-variable warning.
Haojian Wu [Thu, 27 Oct 2022 08:50:29 +0000 (10:50 +0200)]
Fix a -Wunused-const-variable warning.

20 months ago[LLVM] Use DWARFv4 bitfields when tuning for GDB
David Spickett [Mon, 10 Oct 2022 14:35:15 +0000 (14:35 +0000)]
[LLVM] Use DWARFv4 bitfields when tuning for GDB

GDB implemented data_bit_offset in https://sourceware.org/bugzilla/show_bug.cgi?id=12616
which has been present since GDB 8.0.

GCC started using it at GCC 11.

Reviewed By: dblaikie

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

20 months ago[RISCV] Map pseudos to their BaseInstr to reduce cases
wangpc [Thu, 27 Oct 2022 08:42:26 +0000 (16:42 +0800)]
[RISCV] Map pseudos to their BaseInstr to reduce cases

There are a lot of cases for pseudos of the same instruction, here
we just use existed mapping table to map pseudos to real instructions
to reduce cases.

Reviewed By: kito-cheng

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

20 months ago[IntervalMap] Add move and copy ctors and assignment operators
OCHyams [Thu, 27 Oct 2022 07:52:47 +0000 (08:52 +0100)]
[IntervalMap] Add move and copy ctors and assignment operators

And update the unittest.

Reviewed By: dblaikie

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

20 months ago[NFC] [Modules] Rename modules related things in Preprocessor and AffectingModules
Chuanqi Xu [Thu, 27 Oct 2022 08:34:10 +0000 (16:34 +0800)]
[NFC] [Modules] Rename modules related things in Preprocessor and AffectingModules

Rename module related things according to the consensus in
https://discourse.llvm.org/t/rfc-unifying-the-terminology-about-modules-in-clang/66054/
to reduce further confusings.

This only renames things I can make sure. It doesn't  mean all the names
in Preprocessor are correct now.

20 months agoRevert D136595 "[libc] Switch to new implementation of mem* functions"
Guillaume Chatelet [Thu, 27 Oct 2022 08:36:04 +0000 (08:36 +0000)]
Revert D136595 "[libc] Switch to new implementation of mem* functions"

This patch seems to introduce bugs on aarch64.
Reverting while we investigate the root cause.

This reverts commit 02841488138160f9064f334a833d4bf3e80385c6.

20 months ago[PowerPC] Fix check for ieeelongdouble support
Nikita Popov [Wed, 19 Oct 2022 10:57:41 +0000 (12:57 +0200)]
[PowerPC] Fix check for ieeelongdouble support

Clang detects the GCC version from the libdir. However, modern
GCC versions only include the major version in the libdir
(something like lib/gcc/powerpc64le-linux-gnu/12/), not all
version components. For this reason, even though the system has
a supported libstdcxx, it will still fail the check against the
12.1.0 version requirement.

Fix this by doing the same thing we do for patch versions: Assume
that a missing minor version is larger than any specific version.

To allow this to be tested, we need to fix two additional issues:
First, the GCC toolchain directories used for testing need to
contain a crtbegin.o file to be properly detected. The existing
tests actually ended up using a 0.0.0 version, rather the intended
one. Second, we also need to satisfy the glibc version check based
on the dynamic linker. To do so, respect the --dyld-prefix argument
and add the necessary file to the test toolchain directory.

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

20 months agoRevert "Revert "[mlir] Add vectorization tests for linalg.map,reduce,transpose.""
Alexander Belyaev [Thu, 27 Oct 2022 08:28:38 +0000 (10:28 +0200)]
Revert "Revert "[mlir] Add vectorization tests for linalg.map,reduce,transpose.""

This reverts commit c34de60ea3a0f58ac8d21d6176356161ba5cc875.

20 months ago[mlir][tensor] Implement DestinationStyleOpInterface for tensor.insert/insert_slice
Matthias Springer [Thu, 27 Oct 2022 08:27:11 +0000 (10:27 +0200)]
[mlir][tensor] Implement DestinationStyleOpInterface for tensor.insert/insert_slice

Also allow unranked tensors/memrefs with destination style op outputs.

This allows for a simpler implementation of the BufferizableOpInterface (in a subsequent commit).

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

20 months ago[BasicAA] Replace VisitedPhiBBs with a single flag
Nikita Popov [Mon, 17 Oct 2022 11:09:32 +0000 (13:09 +0200)]
[BasicAA] Replace VisitedPhiBBs with a single flag

When looking through phis, BasicAA has to guard against the
possibility that values from two separate cycle iterations are
being compared -- in this case, even though the SSA values may
be the same, they cannot be considered as equal.

This is currently done by keeping a set of VisitedPhiBBs for any
phis we looked through, and then checking whether the relevant
instruction is reachable from one of the phis.

This patch replaces this set with a single flag. If the flag is
set, then we will not assume equality for any instruction part
of a cycle. While this is nominally less accurate, it makes
essentially no difference in practice. Here are the AA stats
for test-suite:

    aa.NumMayAlias  |   3072005 |  3072016
    aa.NumMustAlias |    337858 |   337854
    aa.NumNoAlias   |  13255345 | 13255349

The motivation for the change is to expose the MayBeCrossIteration
flag to AA users, which will allow fixing miscompiles related to
incorrect handling of cross-iteration AA queries.

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

20 months ago[clang-format] Move InsertBraces unit tests out of FormatTest.cpp
owenca [Tue, 25 Oct 2022 03:22:04 +0000 (20:22 -0700)]
[clang-format] Move InsertBraces unit tests out of FormatTest.cpp

Also add line range examples from #58161.

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

20 months ago[mlir][interfaces] Allow only ranked tensors/memrefs in DestinationStyleOpInterface
Matthias Springer [Thu, 27 Oct 2022 08:17:31 +0000 (10:17 +0200)]
[mlir][interfaces] Allow only ranked tensors/memrefs in DestinationStyleOpInterface

We have currently no need for unranked tensors/memrefs.

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

20 months ago[Support] Use find() for faster StringRef::count (NFC)
Tatsuyuki Ishi [Thu, 27 Oct 2022 08:14:09 +0000 (10:14 +0200)]
[Support] Use find() for faster StringRef::count (NFC)

While profiling InclusionRewriter, it was found that counting lines was
so slow that it took up 20% of the processing time. Surely, calling
memcmp() of size 1 on every substring in the window isn't a good idea.

Use StringRef::find() instead; in the case of N=1 it will forward to
memcmp which is much more optimal. For 2<=N<256 it will run the same
memcmp loop as we have now, which is still suboptimal but at least does
not regress anything.

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

20 months ago[mlir] Print bbArgs of linalg.map/reduce/tranpose on the next line.
Alexander Belyaev [Thu, 27 Oct 2022 07:39:52 +0000 (09:39 +0200)]
[mlir] Print bbArgs of linalg.map/reduce/tranpose on the next line.

```
%mapped = linalg.map
  ins(%arg0 : tensor<64xf32>)
  outs(%arg1 : tensor<64xf32>)
  (%in: f32) {
    %0 = math.absf %in : f32
    linalg.yield %0 : f32
  }
%reduced = linalg.reduce
  ins(%arg0 : tensor<16x32x64xf32>)
  outs(%arg1 : tensor<16x64xf32>)
  dimensions = [1]
  (%in: f32, %init: f32) {
    %0 = arith.addf %in, %init : f32
    linalg.yield %0 : f32
  }
%transposed = linalg.transpose
  ins(%arg0 : tensor<16x32x64xf32>)
  outs(%arg1 : tensor<32x64x16xf32>)
  permutation = [1, 2, 0]
```

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

20 months ago[mlir][tensor] Disallow unranked tensors for tensor.extract/insert
Matthias Springer [Thu, 27 Oct 2022 08:04:38 +0000 (10:04 +0200)]
[mlir][tensor] Disallow unranked tensors for tensor.extract/insert

When writing a tensor.extract/tensor.insert, the rank of the tensor is implied by the number of specified indices. When extracting from/inserting into an unranked tensor, it should first be casted to a ranked version.

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

20 months agoupdate_test_checks.py: allow use with custom tools
Nicolai Hähnle [Thu, 20 Oct 2022 09:33:49 +0000 (11:33 +0200)]
update_test_checks.py: allow use with custom tools

We have a downstream project with a command-line utility that operates
pretty much exactly like `opt`. So it would make sense for us to
maintain tests with update_test_checks.py with our custom tool
substituted for `opt`, as this change allows.

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

20 months agoAccount for memory locations in DIExpression::createFragmentExpression
OCHyams [Wed, 26 Oct 2022 16:15:02 +0000 (17:15 +0100)]
Account for memory locations in DIExpression::createFragmentExpression

createFragmentExpression rejects expressions containing certain ops, like
DW_OP_plus, that may cause the expression to compute a value that can't be
split.

Teach createFragmentExpression that the value loaded from an address computed
using those ops is safe to split.

Update a unittest to account for and test this change.

Reviewed By: StephenTozer

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

20 months agoRevert "[libc] Implement getopt"
Alex Brachet [Thu, 27 Oct 2022 06:47:24 +0000 (06:47 +0000)]
Revert "[libc] Implement getopt"

This reverts commit a678f86351c30a7d57197ffefab4e6e44e61a857.

20 months ago[libc] Implement getopt
Alex Brachet [Thu, 27 Oct 2022 06:23:33 +0000 (06:23 +0000)]
[libc] Implement getopt

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

20 months ago[libc] Cleanup stale documentation.
Siva Chandra [Thu, 27 Oct 2022 05:52:53 +0000 (22:52 -0700)]
[libc] Cleanup stale documentation.

20 months ago[libunwind] Add module maps for libunwind
Ian Anderson [Thu, 6 Oct 2022 00:15:02 +0000 (17:15 -0700)]
[libunwind] Add module maps for libunwind

Add module maps for the libunwind headers. unwind_arm_ehabi.h and unwind_itanium.h aren't covered because they don't get installed on all platforms.

Reviewed By: #libunwind, MaskRay

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

20 months ago[RISCV][NFC] Remove ISel of SPLAT_VECTOR
wangpc [Thu, 27 Oct 2022 05:35:48 +0000 (13:35 +0800)]
[RISCV][NFC] Remove ISel of SPLAT_VECTOR

Since we have converted SPLAT_VECTOR to VMV_V_X_VL
or VFMV_V_F_VL in RISCVDAGToDAGISel::PreprocessISelDAG().

Reviewed By: craig.topper

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

20 months ago[NFC] [AAPointerInfo] OffsetAndSize is no longer an std::pair
Sameer Sahasrabuddhe [Thu, 27 Oct 2022 05:15:29 +0000 (10:45 +0530)]
[NFC] [AAPointerInfo] OffsetAndSize is no longer an std::pair

The struct OffsetAndSize is a simple tuple of two int64_t. Treating it as a
derived class of std::pair has no special benefit, but it makes the code
verbose since we need get/set functions that avoid using "first" and "second" in
client code. Eliminating the std::pair makes this more readable.

Reviewed By: jdoerfert

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

20 months ago[Bazel][llvm-debuginfo-analyzer] Add deps for DebugInfoLogicalView after 4f06d46f465c
Jordan Rupprecht [Thu, 27 Oct 2022 05:24:49 +0000 (22:24 -0700)]
[Bazel][llvm-debuginfo-analyzer] Add deps for DebugInfoLogicalView after 4f06d46f465c

20 months agoAdd clang_CXXMethod_isCopyAssignmentOperator to libclang
Luca Di Sera [Thu, 27 Oct 2022 04:42:35 +0000 (06:42 +0200)]
Add clang_CXXMethod_isCopyAssignmentOperator to libclang

The new method is a wrapper of `CXXMethodDecl::isCopyAssignmentOperator` and
can be used to recognized copy-assignment operators in libclang.

An export for the method, together with its documentation, was added to
"clang/include/clang-c/Index.h" with an implementation provided in
"clang/tools/libclang/CIndex.cpp". The implementation was based on
similar `clang_CXXMethod.*` implementations, following the same
structure but calling `CXXMethodDecl::isCopyAssignmentOperator` for its
main logic.

The new symbol was further added to "clang/tools/libclang/libclang.map"
to be exported, under the LLVM16 tag.

"clang/tools/c-index-test/c-index-test.c" was modified to print a
specific tag, "(copy-assignment operator)", for cursors that are
recognized by `clang_CXXMethod_isCopyAssignmentOperator`.
A new regression test file,
"clang/test/Index/copy-assignment-operator.cpp", was added to ensure
that the correct constructs were recognized or not by the new function.

The "clang/test/Index/get-cursor.cpp" regression test file was updated
as it was affected by the new "(copy-assignment operator)" tag.

A binding for the new function was added to libclang's python's
bindings, in "clang/bindings/python/clang/cindex.py", adding a new
method for `Cursor`, `is_copy_assignment_operator_method`.

The current release note, `clang/docs/ReleaseNotes.rst`, was modified to
report the new addition under the "libclang" section.

Reviewed By: aaron.ballman

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

20 months ago[libc] Add a doc about the libc overlay mode.
Siva Chandra Reddy [Thu, 27 Oct 2022 00:22:20 +0000 (17:22 -0700)]
[libc] Add a doc about the libc overlay mode.

Reviewed By: jeffbailey

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

20 months ago[llvm-debuginfo-analyzer] (08/09) - ELF Reader
Carlos Alberto Enciso [Wed, 26 Oct 2022 18:42:20 +0000 (19:42 +0100)]
[llvm-debuginfo-analyzer] (08/09) - ELF Reader

llvm-debuginfo-analyzer is a command line tool that processes debug
info contained in a binary file and produces a debug information
format agnostic “Logical View”, which is a high-level semantic
representation of the debug info, independent of the low-level
format.

The code has been divided into the following patches:

1) Interval tree
2) Driver and documentation
3) Logical elements
4) Locations and ranges
5) Select elements
6) Warning and internal options
7) Compare elements
8) ELF Reader
9) CodeView Reader

Full details:
https://discourse.llvm.org/t/llvm-dev-rfc-llvm-dva-debug-information-visual-analyzer/62570

This patch:

This is a high level summary of the changes in this patch.

ELF Reader
- Support for ELF/DWARF.
  LVBinaryReader, LVELFReader

Reviewed By: psamolysov, probinson

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

20 months ago[clang] Instantiate concepts with sugared template arguments
Matheus Izvekov [Sun, 23 Oct 2022 09:37:20 +0000 (11:37 +0200)]
[clang] Instantiate concepts with sugared template arguments

Since we don't unique specializations for concepts, we can just instantiate
them with the sugared template arguments, at negligible cost.

If we don't track their specializations, we can't resugar them later
anyway, and that would be more expensive than just instantiating them
sugared in the first place since it would require an additional pass.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136566

20 months ago[clang] Instantiate alias templates with sugar
Matheus Izvekov [Sun, 23 Oct 2022 14:57:12 +0000 (16:57 +0200)]
[clang] Instantiate alias templates with sugar

This makes use of the changes introduced in D134604, in order to
instantiate alias templates witn a final sugared substitution.

This comes at no additional relevant cost.
Since we don't track / unique them in specializations, we wouldn't be
able to resugar them later anyway.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136565

20 months ago[clang] Instantiate NTTPs and template default arguments with sugar
Matheus Izvekov [Sun, 23 Oct 2022 11:41:57 +0000 (13:41 +0200)]
[clang] Instantiate NTTPs and template default arguments with sugar

This makes use of the changes introduced in D134604, in order to
instantiate non-type template parameters and default template arguments
with a final sugared substitution.

This comes at no additional relevant cost.
Since we don't track / unique them in specializations, we wouldn't be
able to resugar them later anyway.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136564

20 months ago[clang] Implement sugared substitution changes to infrastructure
Matheus Izvekov [Sun, 25 Sep 2022 15:18:39 +0000 (17:18 +0200)]
[clang] Implement sugared substitution changes to infrastructure

Implements the changes required to perform substitution with
non-canonical template arguments, and to 'finalize' them
by not placing 'Subst' nodes.

A finalized substitution means we won't resugar them later,
because these templates themselves were eagerly substituted
with the intended arguments at the point of use. We may still
resugar other templates used within those, though.

This patch does not actually implement any uses of this
functionality, those will be added in subsequent patches,
so expect no changes to existing tests.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D134604

20 months ago[SampleFDO] Compute and report profile staleness metrics
wlei [Mon, 24 Oct 2022 17:48:50 +0000 (10:48 -0700)]
[SampleFDO] Compute and report profile staleness metrics

When a profile is stale and profile mismatch could happen, the mismatched samples are discarded, so we'd like to compute the mismatch metrics to quantify how stale the profile is, which will suggest user to refresh the profile if the number is high.

Two sets of metrics are introduced here:

 - (Num_of_mismatched_funchash/Total_profiled_funchash), (Samples_of_mismached_func_hash / Samples_of_profiled_function) : Here it leverages the FunctionSamples's checksums attribute which is a feature of pseudo probe. When the source code CFG changes, the function checksums will be different, later sample loader will discard the whole functions' samples, this metrics can show the percentage of samples are discarded due to this.
 -  (Num_of_mismatched_callsite/Total_profiled_callsite), (Samples_of_mismached_callsite / Samples_of_profiled_callsite) : This shows how many mismatching for the callsite location as callsite location mismatch will affect the inlining which is highly correlated with the performance. It goes through all the callsite location in the IR and profile, use the call target name to match, report the num of samples in the profile that doesn't match a IR callsite.

This is implemented in a new class(SampleProfileMatcher) and under a switch("--report-profile-staleness"), we plan to extend it with a fuzzy profile matching feature in the future.

Reviewed By: hoy, wenlei, davidxl

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

20 months ago[clang] Perform sugared substitution of builtin templates
Matheus Izvekov [Sun, 23 Oct 2022 11:38:39 +0000 (13:38 +0200)]
[clang] Perform sugared substitution of builtin templates

Since these are much like template type aliases, where we don't
track a specialization for them and just substitute them eagerly,
we can't resugar them anyway, and there is no relevant cost in just
performing a finalizing sugared substitution.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D136563

20 months ago[clang] Changes to produce sugared converted template arguments
Matheus Izvekov [Mon, 5 Sep 2022 19:57:37 +0000 (21:57 +0200)]
[clang] Changes to produce sugared converted template arguments

Makes CheckTemplateArgumentList and the template deduction functions
produce a sugared converted argument list in addition to the canonical one.

This is mostly NFC except that we hook this up to a few diagnostics in
SemaOverload.

The infrastructure here will be used in subsequent patches
where we perform a finalized sugared substitution for entities
which we do not unique per specializations on canonical arguments,
and later on will be used for template specialization resugaring.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D133874

20 months ago[clang] Include the type of a pointer or reference non-type template parameter in...
Richard Smith [Sun, 11 Oct 2020 22:57:52 +0000 (15:57 -0700)]
[clang] Include the type of a pointer or reference non-type template parameter in its notion of template argument identity.

We already did this for all the other kinds of non-type template
argument.

Note: Based on earlier reverted patch from zygoloid.

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

20 months ago[mlir][Tensor] Change `createDimValues` to return a list of `OpFoldResult`s.
Mahesh Ravishankar [Thu, 27 Oct 2022 03:12:40 +0000 (03:12 +0000)]
[mlir][Tensor] Change `createDimValues` to return a list of `OpFoldResult`s.

Reviewed By: nicolasvasilache, hanchung, ThomasRaoux

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

20 months agoRevert "[lldb-vscode] Send Statistics Dump in terminated event"
Wanyi Ye [Thu, 27 Oct 2022 02:49:03 +0000 (19:49 -0700)]
Revert "[lldb-vscode] Send Statistics Dump in terminated event"

This reverts commit c8a26f8c6de30dbd814546f02e4c89a4fcb2b4ef.

Returning full statistics result in "terminated" (DAP) event could result in delay in the UI when debugging from VSCode.

If the program run to exit and debug session terminates. The DAP event order will be: exited event --> terminateCommands --> terminated event --> disconnect request --> disconnect response.

The debugging UI in VSCode corresponds to "disconnect" request/response. If the terminated event is taking long to process, the IDE won't quit debugging UI until it's done.

For big binary (tested example has 29 GB of debug info), it can cause ~15s delay in terminated event itself. And the UI could take ~20s to reflect.

This may cause confusion in debug sessions. We should persuit a more lightweight return or other solution to return such info.

20 months ago[AArch64] Adjust operand sequence for Add+Sub to combine more inline shift
chenglin.bi [Thu, 27 Oct 2022 02:04:57 +0000 (10:04 +0800)]
[AArch64] Adjust operand sequence for Add+Sub to combine more inline shift

((X >> C) - Y) + Z --> (Z - Y) + (X >> C)

Fix AArch part: #55714

Reviewed By: dmgreen

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

20 months ago[CodeGen] Improve large stack frame diagnostic
Paul Kirth [Fri, 21 Oct 2022 18:22:03 +0000 (18:22 +0000)]
[CodeGen] Improve large stack frame diagnostic

Add statistics about how much memory is used, in variables, spills, and
unsafestack.

Issue #58168 describes some of the difficulty diagnosing stack size issues
identified by -Wframe-larger-than. D135488 addresses some of those issues by
giving developers a method to view the stack layout and thereby understand
where and how stack memory is used.

However, that solution requires an additional pass, when a short summary about
how the compiler has allocated stack memory can inform developers about where
they should investigate. When they need the complete context, D135488 can
provide them with a more comprehensive set of diagnostics.

Reviewed By: nickdesaulniers

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

20 months ago[NFC][PhaseOrdering] Add new test for SROA misplacement
Roman Lebedev [Thu, 27 Oct 2022 00:08:19 +0000 (03:08 +0300)]
[NFC][PhaseOrdering] Add new test for SROA misplacement

20 months ago[flang] Add atomic_fetch_and to list of intrinsics
Katherine Rasmussen [Tue, 25 Oct 2022 23:26:59 +0000 (16:26 -0700)]
[flang] Add atomic_fetch_and to list of intrinsics

Add the atomic subroutine, atomic_fetch_and, to the list of
intrinsic subroutines, add its last dummy argument to a check
for coindexed-object, and update test.

Reviewed By: jeanPerier

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

20 months ago[Driver] Allow target override containing . in executable name
Dan McGregor [Wed, 26 Oct 2022 23:52:32 +0000 (16:52 -0700)]
[Driver] Allow target override containing . in executable name

The gcc compatible driver has support for overriding the default
target based on the driver's executable name, for instance
x86_64-pc-linux-gnu-clang will set the default target to
x86_64-pc-linux-gnu.

Previously, this failed when the target contained a minor version, for
example x86_64-pc-freebsd13.1, so instead of finding the file's
stem, use the whole file name, but strip off any '.exe' from the tail.

Reviewed By: MaskRay

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

20 months ago[dwarfdump] Fix bogus incompatible tag warning
Jonas Devlieghere [Wed, 26 Oct 2022 23:38:09 +0000 (16:38 -0700)]
[dwarfdump] Fix bogus incompatible tag warning

Because DW_TAG_LLVM_ptrauth_type is not marked as a type, dwarfdump
currently emits a spurious error: DIE has DW_AT_type with incompatible
tag DW_TAG_LLVM_ptrauth_type. This patch fixes that and adds a test.

20 months agoFix MLIR Build with some version of GCC
Mehdi Amini [Wed, 26 Oct 2022 23:22:44 +0000 (23:22 +0000)]
Fix MLIR Build with some version of GCC

mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp:67:30: error: use 'template' keyword to treat 'dyn_cast_or_null' as a dependent template name
                            .dyn_cast_or_null<arith::FastMathFlagsAttr>();
                             ^
                             template

20 months ago[Polly] Add support for -polly-enable-mse with NPM.
Michael Kruse [Wed, 26 Oct 2022 22:24:43 +0000 (17:24 -0500)]
[Polly] Add support for -polly-enable-mse with NPM.

The MaximalStaticExpansionPass was already ported to the NPM in
02f640672e2875c4e7578366bb2e22582548d7c1. Allow adding it to the default
NPM pass builder pipeline using -polly-enable-mse.

20 months ago[Polly] Add support for -polly-export with NPM.
Michael Kruse [Wed, 26 Oct 2022 21:50:50 +0000 (16:50 -0500)]
[Polly] Add support for -polly-export with NPM.

The JSONExporter pass was already ported to the NPM, the pass builder
jsut had to add it to the pass pipeline when requested.

20 months agoAdd a warning for not packing non-POD members in packed structs
David Blaikie [Fri, 28 Jan 2022 22:22:21 +0000 (14:22 -0800)]
Add a warning for not packing non-POD members in packed structs

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

20 months ago[LTO] Fix lto_module_create_in_codegen_context return value on error
Steven Wu [Wed, 26 Oct 2022 22:13:00 +0000 (15:13 -0700)]
[LTO] Fix lto_module_create_in_codegen_context return value on error

According to the documentation, lto_module_create_in_codegen_context
should return NULL on error but currently it is accidentally return
error_code. Since this is a bug fix and it seems to be a one-off bug
that only affects this API, there is no need to bump API version.

rdar://101505192

Reviewed By: pete

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

20 months ago[libc] Add a testing macro for MPFR matchers skipping `explainError` calls.
Tue Ly [Wed, 26 Oct 2022 02:10:32 +0000 (22:10 -0400)]
[libc] Add a testing macro for MPFR matchers skipping `explainError` calls.

Adding `EXPECT_MPFR_MATCH_ROUNDING_SILENTLY` macro that does not call
`explainError` when the tests fail.  This is useful to check the passing or
failing rates, such as hitting percentages of fast passes in math
implementations.

Reviewed By: michaelrj, sivachandra

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

20 months agoExtend the C++03 definition of POD to include defaulted functions
David Blaikie [Sat, 5 Feb 2022 04:06:13 +0000 (20:06 -0800)]
Extend the C++03 definition of POD to include defaulted functions

The AST/conditionally-trivial-smfs tests look a bit questionable, but
are consistent with GCC's POD-ness, at least as far as packing is
concerned: https://godbolt.org/z/36nqPMbKM
(questionable because it looks like the type would be non-copyable, so
how could it be pod? But the calling convention/pass by value seems to
work correctly (local testing verifies that this behavior is preserved
even with this patch: https://godbolt.org/z/3Pa89zsv6 ))

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

20 months ago[bazel][mlir][arith] build fixes for arith fastmath flags
Emilio Cota [Wed, 26 Oct 2022 21:45:25 +0000 (17:45 -0400)]
[bazel][mlir][arith] build fixes for arith fastmath flags

20 months ago[ADT] Add deduction guide for llvm::Optional
David Blaikie [Wed, 26 Oct 2022 21:37:25 +0000 (21:37 +0000)]
[ADT] Add deduction guide for llvm::Optional

Added to address some uses of implicit CTAD added in clang recently.

20 months ago[RISCV] Inline scalar ceil/floor/trunc/rint/round/roundeven.
Craig Topper [Wed, 26 Oct 2022 21:23:51 +0000 (14:23 -0700)]
[RISCV] Inline scalar ceil/floor/trunc/rint/round/roundeven.

This avoids the call overhead as well as the the save/restore of
fflags and the snan handling in the libm function.

The save/restore of fflags and snan handling are needed to be
correct for -ftrapping-math. I think we can ignore them in the
default environment.

The inline sequence will generate an invalid exception for nan
and an inexact exception if fractional bits are discarded.

I've used a custom inserter to explicitly create the control flow
around the float->int->float conversion.

We can probably avoid the final fsgnj after the conversion for
no signed zeros FMF, but I'll leave that for future work.

Note the comparison constant is slightly different than glibc uses.
They use 1<<53 for double, I'm using 1<<52. I believe either are valid.
Numbers >= 1<<52 can't have any fractional bits. It's ok to do the
float->int->float conversion on numbers between 1<<53 and 1<<52 since
they will all fit in 64. We only have a problem if the double can't fit
in i64

Reviewed By: reames

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

20 months ago[mlir][MemRefToLLVM] Lower extract_strided_metadata
Quentin Colombet [Fri, 14 Oct 2022 21:00:55 +0000 (21:00 +0000)]
[mlir][MemRefToLLVM] Lower extract_strided_metadata

The `extract_strided_metadata` operation literally breaks down a memory
descriptor into its different components.
Teach the MemRefToLLVM conversion framework this fact.

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

20 months agogit clang-format HEAD~
Nick Desaulniers [Wed, 26 Oct 2022 21:24:08 +0000 (14:24 -0700)]
git clang-format HEAD~

for
commit ad78ce44bb47 ("[clang][Toolchains][Gnu] pass -gdwarf-* through to
assembler")

20 months ago[InstCombine] add tests for demanded bits of sub; NFC
Sanjay Patel [Wed, 26 Oct 2022 18:34:42 +0000 (14:34 -0400)]
[InstCombine] add tests for demanded bits of sub; NFC

20 months ago[RISCV] Add tests for fixed vector sshl_sat/ushl_sat. NFC
Craig Topper [Wed, 26 Oct 2022 19:09:39 +0000 (12:09 -0700)]
[RISCV] Add tests for fixed vector sshl_sat/ushl_sat. NFC

20 months ago[libc] Enable more entrypoints on aarch64.
Siva Chandra [Wed, 26 Oct 2022 21:02:52 +0000 (14:02 -0700)]
[libc] Enable more entrypoints on aarch64.

20 months ago[dexter-tests] Add attribute optnone to main function
Guozhi Wei [Wed, 26 Oct 2022 20:57:49 +0000 (20:57 +0000)]
[dexter-tests] Add attribute optnone to main function

The test case optnone-simple-functions.cpp is expected to be compiled
unoptimized even under -O2 because of attribute optnone. But this attribute is
missed for main function, and caused the fail in
https://lab.llvm.org/buildbot/#/builders/217/builds/14046 when it triggered
optimizations. This patch fixes that by adding attribute optnone to main
function.

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

20 months ago[Clang][Sema] Add -Wcast-function-type-strict
Sami Tolvanen [Mon, 19 Sep 2022 23:06:18 +0000 (23:06 +0000)]
[Clang][Sema] Add -Wcast-function-type-strict

Clang supports indirect call Control-Flow Integrity (CFI) sanitizers
(e.g. -fsanitize=cfi-icall), which enforce an exact type match between
a function pointer and the target function. Unfortunately, Clang
doesn't provide diagnostics that would help developers avoid function
type casts that lead to runtime CFI failures. -Wcast-function-type,
while helpful, only warns about ABI incompatibility, which isn't
sufficient with CFI.

Add -Wcast-function-type-strict, which checks for a strict type
compatibility in function type casts and helps warn about casts that
can potentially lead to CFI failures.

Reviewed By: nickdesaulniers, aaron.ballman

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

20 months ago[dexter] Temporary disable optnone-simple-functions
Jonas Devlieghere [Wed, 26 Oct 2022 20:06:22 +0000 (13:06 -0700)]
[dexter] Temporary disable optnone-simple-functions

D136396 broke optnone-simple-functions. Temporary disabling the test to
unblock the bot until the Sony folks can have a look.

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/47878/

20 months agoRevert "[NFC] Make format() more amenable to format attributes"
Félix Cloutier [Wed, 26 Oct 2022 19:53:14 +0000 (12:53 -0700)]
Revert "[NFC] Make format() more amenable to format attributes"

This reverts commit fb1e90ef07fec0d64a05c0b6d41117a5ea3e8344.

20 months ago[clang] Move getenv call for SOURCE_DATE_EPOCH out of frontend NFC
Ben Langmuir [Tue, 25 Oct 2022 22:12:24 +0000 (15:12 -0700)]
[clang] Move getenv call for SOURCE_DATE_EPOCH out of frontend NFC

Move the check for SOURCE_DATE_EPOCH to the driver and use a cc1 option
to pass it to the frontend. This avoids hidden state in the cc1
invocation and makes this env variable behave more like other env
variables that clang handles in the driver.

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

20 months ago[OpenMP][FIX] Adjust to clang tests after D136740
Johannes Doerfert [Wed, 26 Oct 2022 19:31:33 +0000 (12:31 -0700)]
[OpenMP][FIX] Adjust to clang tests after D136740

20 months ago[gn build] port cb0eb9d8dd5 (lldb test libc++ refs)
Nico Weber [Wed, 26 Oct 2022 19:30:10 +0000 (15:30 -0400)]
[gn build] port cb0eb9d8dd5 (lldb test libc++ refs)

20 months ago[NFC][Offload Bundler] Formatting clang offloadbundler source file.
raghavmedicherla [Wed, 26 Oct 2022 19:08:10 +0000 (15:08 -0400)]
[NFC][Offload Bundler] Formatting clang offloadbundler source file.

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

20 months ago[NFC] Make format() more amenable to format attributes
Félix Cloutier [Fri, 9 Sep 2022 21:08:19 +0000 (14:08 -0700)]
[NFC] Make format() more amenable to format attributes

This change modifies the implementation of the format() function
so that vendor forks committed to building with compilers that
support __attribute__((format)) on non-variadic functions can
check the format() function with it.

Reviewed By: ahatanak
Differential Revision: https://reviews.llvm.org/D132413
rdar://84571523

20 months ago[test] Fix LLDB tests with just-built libcxx when using a target directory.
Jordan Rupprecht [Wed, 26 Oct 2022 19:07:22 +0000 (12:07 -0700)]
[test] Fix LLDB tests with just-built libcxx when using a target directory.

In certain configurations, libc++ headers all exist in the same directory, and libc++ binaries exist in the same directory as lldb libs. When `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` is enabled (*and* the host is not Apple, which is why I assume this wasn't caught by others?), this is not the case: most headers will exist in the usual `include/c++/v1` directory, but `__config_site` exists in `include/$TRIPLE/c++/v1`. Likewise, the libc++.so binary exists in `lib/$TRIPLE/`, not `lib/` (where LLDB libraries reside).

This also adds the just-built-libcxx functionality to the lldb-dotest tool.

The `LIBCXX_` cmake config is borrowed from `libcxx/CMakeLists.txt`. I could not figure out a way to share the cmake config; ideally we would reuse the same config instead of copy/paste.

Reviewed By: JDevlieghere, fdeazeve

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

20 months ago[mlir][arith] Initial support for fastmath flag attributes in the Arithmetic dialect...
Jeremy Furtek [Wed, 26 Oct 2022 18:07:20 +0000 (11:07 -0700)]
[mlir][arith] Initial support for fastmath flag attributes in the Arithmetic dialect (v2)

This diff adds initial (partial) support for "fastmath" attributes for floating
point operations in the arithmetic dialect. The "fastmath" attributes are
implemented using a default-valued bit enum. The defined flags currently mirror
the fastmath flags in the LLVM dialect (and in LLVM itself). Extending the
set of flags (if necessary) is left as a future task.

In this diff:
- Definition of FastMathAttr as a custom attribute in the Arithmetic dialect
  that inherits from the EnumAttr class.
- Definition of ArithFastMathInterface, which is an interface that is
  implemented by operations that have an arith::fastmath attribute.
- Declaration of a default-valued fastmath attribute for unary and (some) binary
  floating point operations in the Arithmetic dialect.
- Conversion code to lower arithmetic fastmath flags to LLVM fastmath flags

NOT in this diff (but planned or currently in progress):
- Documentation of flag meanings
- Addition of FastMathAttr attributes to other dialects that might lower to the
  Arithmetic dialect (e.g. Math and Complex)
- Folding/rewrite implementations that are enabled by fastmath flags
- Specification of fastmath values from Python bindings (pending other in-
  progress diffs)

Reviewed By: mehdi_amini, vzakhari

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

20 months ago[trace][intelpt] Fix multi CPU decoding TSC assertion error
Jakob Johnson [Mon, 24 Oct 2022 14:01:40 +0000 (07:01 -0700)]
[trace][intelpt] Fix multi CPU decoding TSC assertion error

Occasionally the assertion that enforces increasing TSC values in `DecodedThread::NotifyTsc`
would get tripped during large multi CPU trace decoding.
The root cause of this issue was an assumption that all the data of a
PSB will fit within the start,end TSC of the "owning"
`ThreadContinuousExecution`. After investigating, this is not the case
because PSBs can have multiple TSCs.
This diff works around this issue by introducing a TSC upper bound for
each `PSBBlockDecoder`. This fixes the assertion failure by simply
"dropping" the remaining data of PSB whenever the TSC upper bound is
exceeded during decoding.
Future work will do a larger refactor of the multi CPU decoding to
remove the dependencies on this incorrect assumption so that PSB blocks
that span multiple `ThreadContinuousExecutions` are correctly handled.
correctly

Test Plan:

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

20 months ago[flang] Add semantics tests for lock-stmt
Katherine Rasmussen [Wed, 19 Oct 2022 16:16:28 +0000 (10:16 -0600)]
[flang] Add semantics tests for lock-stmt

Add three tests for lock-stmt. The first includes
standard-conforming statements, the second includes
non-standard-conforming statements because of errors where
something unexpected occurs, such as a missing lock-variable,
and the third includes non-standard-conforming statements
because of semantic errors, such as type or rank mismatches.

Reviewed By: rouson

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

20 months ago[libc] tighten strtofloat cutoffs
Michael Jones [Tue, 25 Oct 2022 17:10:00 +0000 (10:10 -0700)]
[libc] tighten strtofloat cutoffs

When a number for strtofloat has an exponent that's too big or small, it
doesn't need to be calculated precisely since it is guaranteed to be
either INF or 0.0. This tightens those cutoffs to improve performance.

Reviewed By: sivachandra

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

20 months ago[scudo] Fix size of MaxNumCachedHint Trusty Config
Chia-hung Duan [Wed, 26 Oct 2022 00:26:14 +0000 (00:26 +0000)]
[scudo] Fix size of MaxNumCachedHint Trusty Config

Also add a test for TrustyConfig to ensure it'll be awared of any scudo
configuration change.

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

20 months ago[flang][runtime] New APIs for copyin/copyout of non-contiguous objects.
Slava Zakharin [Thu, 20 Oct 2022 20:46:49 +0000 (13:46 -0700)]
[flang][runtime] New APIs for copyin/copyout of non-contiguous objects.

The intention is to use these APIs for copyin/copyout of subprogram
arguments at the call sites. Currently, Flang generates loop nests
to do this, and in some corner cases this results in very long
compilation times due to LLVM loop optimizations.

For example, Flang produces 25245 loops for 521.wrf/module_dm.f90.
If we extract the copyin/copyout loops into runtime, Flang will only
produce 207 loops, and the compilation time may reduce by 47x.

Given that the copyin/copyout loop nests can not be fused with other
loop nests, extracting them into runtime functions should not reduce
performance if the runtime optimizes the leading contiguous dimension
copies.

The implementation will come in separate patches.

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

20 months ago[MIPS] Fix useDeprecatedPositionallyEncodedOperands errors.
James Y Knight [Mon, 19 Sep 2022 20:17:18 +0000 (16:17 -0400)]
[MIPS] Fix useDeprecatedPositionallyEncodedOperands errors.

This is a follow-on to https://reviews.llvm.org/D134073.

The number of MIPS16 changes here is a bit surprising. Many of the
fields with mismatched names were NOT previously choosing the correct
argument positionally, but instead doing something completely wrong
(e.g. it would encode a register where an immediate was expected).

But, machine-code generation for MIPS16 has never actually functioned.
It's also fully untested, thus, the MIPS16 changes, despite changing
behavior, breaks (and fixes) zero tests. This change does not fix
MIPS16 output, but it ought to be at least incrementally less broken.

Outside MIPS16, I believe the only functional change is to the 'ginvi'
instruction: it was previously encoding garbage into a field which was
specified to be '00'. Fortunately, it was covered by tests -- and the
tests were testing the incorrect behavior. So, fixed.

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

20 months ago[Sparc] Fix useDeprecatedPositionallyEncodedOperands errors.
James Y Knight [Mon, 13 Jun 2022 04:14:03 +0000 (04:14 +0000)]
[Sparc] Fix useDeprecatedPositionallyEncodedOperands errors.

This is a follow-on to https://reviews.llvm.org/D134073.

It renames a few fields to have consistent names, as well as renaming
operands to match the field names.

Behavior is unchanged by this cleanup. (The only generated code change
is for the disassembler for LDSTUB/LDSTUBA, but in both old and new
versions, it fails to add enough operands, and thus triggers a runtime
abort. I will address that bug in a future commit.)

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

20 months agoUpdate "Writing a Backend" doc to use named operand matching.
James Y Knight [Mon, 26 Sep 2022 21:56:07 +0000 (17:56 -0400)]
Update "Writing a Backend" doc to use named operand matching.

This brings it in line with recommended practice after the
introduction of sub-operand naming in a538d1f13a13, and the
deprecation of positional argument matching in 5351878ba196.

20 months ago[InstCombine] add tests for demanded bits of sub; NFC
Sanjay Patel [Wed, 26 Oct 2022 16:31:57 +0000 (12:31 -0400)]
[InstCombine] add tests for demanded bits of sub; NFC