platform/upstream/llvm.git
21 months ago[libc] Remove OpenMP and build the GPU libc directly
Joseph Huber [Mon, 30 Jan 2023 23:40:26 +0000 (17:40 -0600)]
[libc] Remove OpenMP and build the GPU libc directly

The current `libcgpu.a` is actually an archive of fatbinaries. The host
file contains nothing but a section called `LLVM_OFFLOADING` that
contains embedded device code. This used to be handled implicitly by
borrowing the OpenMP toolchain, which did this packaging internally.
Passing the OpenMP flags causes problems with trying to move to testing.
This patch pulls this logic out into the CMake and handles it manually.

This patch is a lot of noise, but it fundamentally comes down to the
following changes.
1. Build the source for every GPU architecture (GPU architectures are
   generally not backwards compatible)
2. Combine all of these files into a single binary blob
3. Embed that binary blob into a host file
4. Package these host files into a `.a` archive.
5. The device code will be extracted and managed by the offloading
   linker.

Another important point. Right now we are maintaining an important
distinction with the GPU build. That is, when we build the exported
library we will build for many GPU architectures. However, the internal
version will only be built for a single GPU architecture, one that was
found on the user's system. This is intended to be used for internal
testing, very similar to the current path where `libc` is compiled for a
single target triple.

Reviewed By: sivachandra

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

21 months ago[Libomptarget] Fix the NVPTX Libomptarget test
Joseph Huber [Thu, 2 Feb 2023 15:45:19 +0000 (09:45 -0600)]
[Libomptarget] Fix the NVPTX Libomptarget test

Summary:
This was broken, we weren't adding these for the NVPTX tests.

21 months ago[AArch64] Add tests for reassociating to mls. NFC
David Green [Thu, 2 Feb 2023 15:40:32 +0000 (15:40 +0000)]
[AArch64] Add tests for reassociating to mls. NFC

21 months ago[NFC][clang-tidy] Disable test for `bugprone-unsafe-functions` for PlayStation
Whisperity [Thu, 2 Feb 2023 15:30:14 +0000 (16:30 +0100)]
[NFC][clang-tidy] Disable test for `bugprone-unsafe-functions` for PlayStation

As discussed in [D91000](http://reviews.llvm.org/D91000) with @dyung, the
PlayStation-specific targets are using some custom standard library for
which the current written tests are not appropriate. Even though the
test code defines the `__STDC_LIB_EXT1__` and `__STDC_WANT_LIB_EXT1__`
macros and expected *Annex K.* support, the actual Clang
parser/preprocessor will report these macros as not existing, and thus
fail the tests.

The check reports the **non**-Annex K. functions as suggestions, such as
`fgets()` instead of `gets_s()` to replace `gets()`, so some safe
library suggestions are still there.

This patch is primarily done to unblock the relevant buildbot
[`llvm-clang-x86_64-sie-ubuntu-fast`](http://lab.llvm.org/buildbot/#/builders/139).

This commit partially reverts ed740e741ec22f9aaea09bfc0b87d0801a7c492f,
as the changes to the "caching logic" was not fixing anything.

21 months agoAdd a new modules test to ensure we dont rebreak diagnostic
Erich Keane [Thu, 2 Feb 2023 14:39:53 +0000 (06:39 -0800)]
Add a new modules test to ensure we dont rebreak diagnostic

Fixes: 60336

Seemingly the concepts sugaring patch caused us to not catch this
situation, which has been confirmed to be a valid error.  Make sure that
we catch this situation in the future, particularly if the concepts
sugaring patch gets re added.

21 months ago[NFC] [mlir] fix file header for SCFToControlFlow.h
Xiang Li [Thu, 2 Feb 2023 15:14:22 +0000 (10:14 -0500)]
[NFC] [mlir] fix file header for SCFToControlFlow.h

Fill description and fix filename mismatch.

21 months ago[clang-tidy] Attempt fixing wrong caching result in `bugprone-unsafe-functions`
Whisperity [Thu, 2 Feb 2023 14:22:04 +0000 (15:22 +0100)]
[clang-tidy] Attempt fixing wrong caching result in `bugprone-unsafe-functions`

There is a supposedly platform-specific crash related to not recognising
the availability of *Annex K.* properly? This patch is an attempt for
fixing this by moving the reset logic for the cache to a different
place.

It's really a coin-flip at this point whether this is really a fix...

21 months ago[DX] Hopefully really fix the big endian bots
Chris Bieneman [Thu, 2 Feb 2023 14:13:26 +0000 (08:13 -0600)]
[DX] Hopefully really fix the big endian bots

Slly mistake in my first attempt. Hopefully this will do it.

21 months agoRevert "[Clang] Add builtin_nondeterministic_value"
Nico Weber [Thu, 2 Feb 2023 13:59:27 +0000 (08:59 -0500)]
Revert "[Clang] Add builtin_nondeterministic_value"

This reverts commit 4a1832a5c801a61bf4c30891aaebe63993712fd9.
Test fail on (at least) macOS and Windows, see
https://reviews.llvm.org/D142388#4099441

21 months ago[X86] canonicalizeShuffleWithBinOps - all merging shuffles with INSERT_SUBVECTOR...
Simon Pilgrim [Thu, 2 Feb 2023 13:48:42 +0000 (13:48 +0000)]
[X86] canonicalizeShuffleWithBinOps - all merging shuffles with INSERT_SUBVECTOR as well as generic target shuffles.

We can probably expand this to more faux shuffles as time goes on.

21 months agoBump CINDEX_VERSION_MINOR due to additional APIs
Aaron Ballman [Thu, 2 Feb 2023 13:25:21 +0000 (08:25 -0500)]
Bump CINDEX_VERSION_MINOR due to additional APIs

0a51bc731bcc2c27e4fe97957a83642d93d989be added a new API to libclang
but forgot to bump the minor version number.

There is no reasonable way to test this change, hence the lack of test
coverage.

21 months ago[NFC] Fix function naming conventions in PHITransAddr methods
Sergey Kachkov [Thu, 2 Feb 2023 09:49:04 +0000 (12:49 +0300)]
[NFC] Fix function naming conventions in PHITransAddr methods

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

21 months ago[AArch64][CostModel]: Add costs for zero/sign extend.
Hassnaa Hamdi [Thu, 2 Feb 2023 11:46:11 +0000 (11:46 +0000)]
[AArch64][CostModel]: Add costs for zero/sign extend.

Add cost for extending to illegal scalable vector types.
Add testing file for the extend operations.

Reviewed By: sdesmalen

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

21 months ago[gn build] Port f27c8ac83e7c
LLVM GN Syncbot [Thu, 2 Feb 2023 13:12:41 +0000 (13:12 +0000)]
[gn build] Port f27c8ac83e7c

21 months ago[clang-tidy] Add the `bugprone-unsafe-functions` check
Gergely Fűtő [Mon, 29 Nov 2021 08:56:48 +0000 (09:56 +0100)]
[clang-tidy] Add the `bugprone-unsafe-functions` check

Checks for unsafe functions, mostly those listed in the
SEI CERT C Coding Standard Recommendation `MSC24-C` and Rule `MSC33-C`.

For the listed functions, an alternative, more secure replacement is
suggested, if such is available. The checker heavily relies on the
functions from "Annex K" (Bounds-checking interfaces) from C11, but
there are several other recommendations not directly from Annex K.

Differential Revision: http://reviews.llvm.org/D91000

Reviewed-By: aaron.ballman, dkrupp, steakhal, whisperity
Co-Authored-By: Tamás Koller <koller.tamas1996@gmail.com>
Co-Authored-By: Balázs Benics <balazs.benics@sigmatechnology.se>
Co-Authored-By: Whisperity <whisperity@gmail.com>
21 months ago[X86] combineConcatVectorOps - add FADD/FSUB/FMUL/FDIV handling
Simon Pilgrim [Thu, 2 Feb 2023 12:28:56 +0000 (12:28 +0000)]
[X86] combineConcatVectorOps - add FADD/FSUB/FMUL/FDIV handling

21 months ago[X86] Add test coverage showing failure to load/binop combine adjacent v2f32 float ops
Simon Pilgrim [Thu, 2 Feb 2023 12:14:21 +0000 (12:14 +0000)]
[X86] Add test coverage showing failure to load/binop combine adjacent v2f32 float ops

Pulled out of Issue #60441 - we really need that handling in the middle-end, but there's some obvious DAG cleanups we can try as well

21 months ago[gn build] Port ad93908e3b55
LLVM GN Syncbot [Thu, 2 Feb 2023 12:37:18 +0000 (12:37 +0000)]
[gn build] Port ad93908e3b55

21 months ago[gn build] Port 8a8f77c1b849
LLVM GN Syncbot [Thu, 2 Feb 2023 12:37:18 +0000 (12:37 +0000)]
[gn build] Port 8a8f77c1b849

21 months ago[X86][FP16][NFC] Add round and fptosi tests to show suboptimal codegen
Phoebe Wang [Thu, 2 Feb 2023 12:16:29 +0000 (20:16 +0800)]
[X86][FP16][NFC] Add round and fptosi tests to show suboptimal codegen

21 months ago[lldb][SymbolFileDWARF] Support by-name lookup of global variables in inline namespaces
Michael Buch [Wed, 1 Feb 2023 13:42:24 +0000 (13:42 +0000)]
[lldb][SymbolFileDWARF] Support by-name lookup of global variables in inline namespaces

Currently evaluating an expression involving a global variable inside
an inline namespace will fail to lookup said variable. This is because
the `SymbolFileDWARF::FindGlobalVariables` discards from consideration
all DIEs whose decl_context doesn't exactly match that of the lookup.

This patch relaxes this restriction by checking whether C++ rules
would permit the lookup. This is permitted by the DWARFv5 spec in
chapter `3.2.2 Namespace Entries`:
```
A namespace may have a DW_AT_export_symbols attribute which is a flag
which indicates that all member names defined within the namespace may be
referenced as if they were defined within the containing namespace.
```

The motivation for this is evaluating `std::ranges` expressions, which
heavily rely on global variables inside inline namespaces. E.g.,
`std::views::all(...)` is just an invocation of the `operator()`
on `std::ranges::views::__cpo::all`.

**Testing**

* Added API tests

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

21 months ago[lldb][Test] Fix import-std-module and data-formatter tests on older compilers
Michael Buch [Tue, 31 Jan 2023 18:05:41 +0000 (18:05 +0000)]
[lldb][Test] Fix import-std-module and data-formatter tests on older compilers

Fixes API tests for older compilers.
Since https://reviews.llvm.org/D141828 defaulted
arguments will be omitted, but older Clang's won't.

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

21 months ago[runtimes] Don't override LLVM_ENABLE_PER_TARGET_RUNTIME_DIR set from llvm
David Spickett [Wed, 7 Dec 2022 14:25:42 +0000 (14:25 +0000)]
[runtimes] Don't override LLVM_ENABLE_PER_TARGET_RUNTIME_DIR set from llvm

LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is set in llvm/CMakeLists.txt
and in llvm/runtimes/CMakeLists.txt.

This meant that anything you passed down, or any platform not using
this layout yet would have it enabled despite it being OFF earlier.

To fix this, check if we have already defined the variable
and if so, use that value.

bultin_register_target I don't fully understand the purpose of.
So for now I have left it setting the value to ON. The rest will
respect what was previously set.

Reviewed By: MaskRay

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

21 months ago[InstCombine] Promote expression tree with @llvm.vscale when zero-extending result.
Sander de Smalen [Tue, 31 Jan 2023 22:20:46 +0000 (22:20 +0000)]
[InstCombine] Promote expression tree with @llvm.vscale when zero-extending result.

The LoopVectorizer emits the (scaled) element count as i32, which for
scalable VFs results in calls to @llvm.vscale.i32(). This value is scaled
and further zero-extended to i64.

The zero-extend can be folded away by executing the whole expression in i64
type using @llvm.vscale.i64(). Any logical `and` that would needed to mask
the result can be further folded away by KnownBits analysis when
vscale_range is set.

Reviewed By: nikic

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

21 months ago[Clang] Add builtin_nondeterministic_value
ManuelJBrito [Thu, 2 Feb 2023 10:11:53 +0000 (10:11 +0000)]
[Clang] Add builtin_nondeterministic_value

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

21 months ago[FLANG][MLIR] Update all module symbol references after changing FuncOp symbol during...
Andrew Gozillon [Wed, 1 Feb 2023 18:29:59 +0000 (12:29 -0600)]
[FLANG][MLIR] Update all module symbol references after changing FuncOp symbol during external name mangling

This fixes an issue where the symbols for operations that were not directly
handled by the rewriting in ExternalNameConversion.cpp were not updated
accurately when a FuncOp symbol was modified. Resulting in a name
mismatch between the FuncOp and the operation holding a symbol to
the FuncOp.

This fix works by updating all of the symbols relating to a FuncOp in a
module, this did not show up as an issue previously as fir::CallOps were
getting specific handling and only fir::CallOps were being tested. So
as the more larger case is now being handled the specific handling for
fir::CallOps has been removed (but is still handled by the fix).

Reviewers:
clementval

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

21 months ago[TTI][NFC] Introduce option to set predictable branch threshold
Serguei Katkov [Thu, 2 Feb 2023 09:56:13 +0000 (16:56 +0700)]
[TTI][NFC] Introduce option to set predictable branch threshold

Currently TargetTransformInfo::getPredictableBranchThreshold() method
returns hardcoded value 99. This value affects the decision whether to
convert select instruction to branch or not in several passes:
SelectOptimize, CodeGenPrepare, SimplifyCFG.

It would be useful to make possible to play with that threshold in order
to test select-optimize heuristics.

Option was originally introduced in the TargetLoweringBase, but was
removed in the revision 664d0c052c315 and not restored in the TTI

Patch Author: aleksandr.popov
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D143060

21 months ago[C++20][Modules] Handle template declarations in header units.
Iain Sandoe [Fri, 27 Jan 2023 10:56:45 +0000 (10:56 +0000)]
[C++20][Modules] Handle template declarations in header units.

This addresses part of https://github.com/llvm/llvm-project/issues/60079

The test for external functions was not considering function templates.

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

21 months ago[mlir][tensor|memref] Harden the checks on dim op
Quentin Colombet [Tue, 24 Jan 2023 10:29:37 +0000 (11:29 +0100)]
[mlir][tensor|memref] Harden the checks on dim op

Prior to this patch it was possible to use the dim operation on a 0-D
memref/tensor.
Unless we want to change the semantic of a 0-D shape, this doesn't make
sense because, paraphrasing the dim op semantic, this is guaranteed to
produce something that is undefined. (The requested index is guaranteed
to be equal to or greater than the rank.)

Harden the type requirements for the dim op by disallowing 0-D shaped
types.

This "fixes" llvm.org/PR60195 by rejecting dim op on 0-D shapes instead of
crashing during LLVM conversion.

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

21 months ago[Attributor][NFC] Improve debug messages
Johannes Doerfert [Thu, 2 Feb 2023 10:10:07 +0000 (02:10 -0800)]
[Attributor][NFC] Improve debug messages

21 months ago[OpenMP][FIX] Ensure to determine aligned regions properly
Johannes Doerfert [Thu, 2 Feb 2023 10:01:40 +0000 (02:01 -0800)]
[OpenMP][FIX] Ensure to determine aligned regions properly

There were missing checks in the aligned region code, copy-paste errors
(= usage of the IsReachedFromAlignedBarrierOnly value instead of
IsReachingAlignedBarrierOnly value on the forward pass), and a missing
update of the call state for sync declarations and definitions.

Partially fixes https://github.com/llvm/llvm-project/issues/60425

21 months ago[Attributor][FIX] Ensure we use the right AAExecutionDomain
Johannes Doerfert [Thu, 2 Feb 2023 09:06:00 +0000 (01:06 -0800)]
[Attributor][FIX] Ensure we use the right AAExecutionDomain

Before we might have ended up queriying the AAExecutionDomain of a
different function, which resulted in wrong optimistic results.

Partially fixes https://github.com/llvm/llvm-project/issues/60425

21 months ago[lldb] Try harder to optimize away a test variable
Pavel Labath [Thu, 2 Feb 2023 10:09:40 +0000 (11:09 +0100)]
[lldb] Try harder to optimize away a test variable

The test was checking that we can print an error message when a variable
is optimized away, but the optimizer got smarter (D140404) in tracking
the variable's value (so that we were not able to recover its value).

Using a value in an argument registers (argc) makes it more likely to be
overwritten by subsequent function calls (and permanently lost).

21 months ago[DAGCombine] Fold redundant select
Samuel Parker [Mon, 30 Jan 2023 09:36:15 +0000 (09:36 +0000)]
[DAGCombine] Fold redundant select

If a chain of two selects share a true/false value and are controlled
by two setcc nodes, that are never both true, we can fold away one of
the selects. So, the following:
(select (setcc X, const0, eq), Y,
  (select (setcc X, const1, eq), Z, Y))

Can be combined to:
  select (setcc X, const1, eq) Z, Y

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

21 months ago[lld] Fix gcc compiler warnings related to variadic macro [NFC]
Mikael Holmen [Thu, 2 Feb 2023 09:26:25 +0000 (10:26 +0100)]
[lld] Fix gcc compiler warnings related to variadic macro [NFC]

gcc warned like
 ../../lld/ELF/InputSection.cpp:75:37: warning: ISO C++11 requires at least one argument for the "..." in a variadic macro
    75 |     invokeELFT(parseCompressedHeader);
       |                                     ^

21 months ago[flang] Use rank from the allocate object when allocate with mold
Valentin Clement [Thu, 2 Feb 2023 09:23:06 +0000 (10:23 +0100)]
[flang] Use rank from the allocate object when allocate with mold

The rank from the allocate object might be different from the rank
from the mold expression. Use the rank from the allocate object
when applying to mold so the bounds can be set correctly.

Reviewed By: jeanPerier

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

21 months ago[X86][NFC] Move MemoryFoldTable2Addr MemoryFoldTable0~4 into X86InstrFoldTables.def
Bing1 Yu [Wed, 1 Feb 2023 14:51:06 +0000 (22:51 +0800)]
[X86][NFC] Move MemoryFoldTable2Addr MemoryFoldTable0~4 into X86InstrFoldTables.def

Reviewed By: pengfei, skan

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

21 months ago[Clang][RISCV] Bump rvv intrinsics version to v0.11
eopXD [Wed, 1 Feb 2023 04:49:31 +0000 (20:49 -0800)]
[Clang][RISCV] Bump rvv intrinsics version to v0.11

The LLVM now supports v0.11 of the RVV intrinsics. Users can use the macro
`riscv_v_intrinsic` to distinguish what kind of intrinsics is supported in
the compiler.

Please refer to tag descriptions under

https://github.com/riscv-non-isa/rvv-intrinsic-doc/tags

Reviewed By: kito-cheng, asb

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

21 months ago[clang-tidy] Implement CppCoreGuideline F.54
Chris Cotter [Thu, 2 Feb 2023 07:01:14 +0000 (07:01 +0000)]
[clang-tidy] Implement CppCoreGuideline F.54

Warn when a lambda specifies a default capture and captures
``this``. Offer FixIts to correct the code.

Reviewed By: njames93, carlosgalvezp

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

21 months ago[RISCV] Add precommit tests for D142071;
LiaoChunyu [Thu, 2 Feb 2023 07:13:45 +0000 (15:13 +0800)]
[RISCV] Add precommit tests for D142071;

21 months ago[clang] Fix warning about unused variable [NFC]
Mikael Holmen [Thu, 2 Feb 2023 06:50:59 +0000 (07:50 +0100)]
[clang] Fix warning about unused variable [NFC]

gcc warned about
 ../../clang/lib/Sema/AnalysisBasedWarnings.cpp:2187:23: warning: unused variable 'FC' [-Wunused-variable]
  2187 |       if (const auto *FC = dyn_cast<CallExpr>(Operation)) {
       |                       ^~

21 months ago[Local][InstCombine][GVN] Handle !noundef metadata in combineMetadata
luxufan [Wed, 1 Feb 2023 06:10:57 +0000 (14:10 +0800)]
[Local][InstCombine][GVN] Handle !noundef metadata in combineMetadata

Handle !noundef metadata in comhineMetadata. The behavior of violating
!noundef metadata is undefined behavior. So if K dominates J, we can
preserve it uncontionally, otherwise, we preserve it if both K and J
have !noundef metadata been set.

This patch also makes !noundef metadata added in KnownIDs when doing
instruction combine for phi node or global value numbering for loads.

Reviewed By: nikic

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

21 months ago[LoongArch] Implement TargetLowering::isLegalAddressingMode() hook
gonglingqin [Thu, 2 Feb 2023 06:00:04 +0000 (14:00 +0800)]
[LoongArch] Implement TargetLowering::isLegalAddressingMode() hook

Use the exact addressing mode information instead of the default to
make better use of offsets in instructions.

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

21 months ago[PowerPC] Use default attributes for more intrinsics
Qiu Chaofan [Thu, 2 Feb 2023 05:59:51 +0000 (13:59 +0800)]
[PowerPC] Use default attributes for more intrinsics

Reviewed By: shchenz, amyk

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

21 months agoUse ArrayRef instead of raw pointers. NFC
Serge Pavlov [Wed, 1 Feb 2023 05:43:43 +0000 (12:43 +0700)]
Use ArrayRef instead of raw pointers. NFC

Change signature of TargetLowering::getRoundingControlRegisters so that
it returns ArrayRef, not plain pointer.

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

21 months ago[DX] Speculative fix for big endian encoding
Chris Bieneman [Thu, 2 Feb 2023 05:19:35 +0000 (23:19 -0600)]
[DX] Speculative fix for big endian encoding

I missed byte swapping the size field.

21 months ago[LoongArch] Honor the `--target-abi` option when generating e_flags
Weining Lu [Thu, 2 Feb 2023 03:39:25 +0000 (11:39 +0800)]
[LoongArch] Honor the `--target-abi` option when generating e_flags

Reviewed By: xen0n, MaskRay

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

21 months ago[LoongArch] Implement handling of triple-implied ABIs
WANG Xuerui [Thu, 2 Feb 2023 03:33:59 +0000 (11:33 +0800)]
[LoongArch] Implement handling of triple-implied ABIs

According to the [[ https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html | LoongArch Toolchain Conventions ]]
it is possible to specify the ABI modifier (the "D" part of "LP64D")
via the environment field in the target triple. This is needed for
proper support for Debian-style multiarch tuples as well, so add triple
awareness to `LoongArchSubtarget` via addition of
`LoongArchABI::computeTargetABI`. Let the explicit `--target-abi`
argument intuitively take precedence over the triple-implied ABI.

Reviewed By: SixWeining

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

21 months ago[ExecutionEngine] Enable ExecutionEngine regression tests on LoongArch
wanglei [Thu, 2 Feb 2023 02:34:27 +0000 (10:34 +0800)]
[ExecutionEngine] Enable ExecutionEngine regression tests on LoongArch

This patch also sets `UNSUPPORTED` on some tests which need `mcjit` and
`emulated tls` support.

Depends on D142950

Reviewed By: lhames

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

21 months ago[mlir] Require explicit casts when using TypedValue
Rahul Kayaith [Sun, 29 Jan 2023 00:18:19 +0000 (19:18 -0500)]
[mlir] Require explicit casts when using TypedValue

Currently `TypedValue` can be constructed directly from `Value`, hiding
errors that could be caught at compile time. For example the following
will compile, but crash/assert at runtime:
```
void foo(TypedValue<IntegerType>);
void bar(TypedValue<FloatType> v) {
  foo(v);
}
```

This change removes the constructors and replaces them with explicit
llvm casts.

Depends on D142852

Reviewed By: rriddle

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

21 months ago[mlir] Use TypedValue in single result traits
Rahul Kayaith [Thu, 26 Jan 2023 18:43:56 +0000 (13:43 -0500)]
[mlir] Use TypedValue in single result traits

Ops with a single result currently get a `getResult()` method +
conversion operator to `Value` through the `OneResult` trait. By moving
these to the `OneTypedResult` trait instead, we can use `TypedValue` as
the return type to get more specfic types.

When the result type is unknown ODS adds the
`OneTypedResult<mlir::Type>` trait, in which case there is no change in
the resulting API.

Reviewed By: rriddle

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

21 months ago[mlir] Simplify a few cast implementations
Rahul Kayaith [Mon, 30 Jan 2023 04:34:10 +0000 (23:34 -0500)]
[mlir] Simplify a few cast implementations

`{Attribute,Type}::classof` are never actually called at runtime due to
the early exit in their `CastInfo` implementations. By using `if
constexpr` we can avoid needing to define them.

We also don't need to check `is_same_v` here, since this is already
covered by `is_base_of_v`.

Reviewed By: rriddle

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

21 months ago[MC] Simplify code with parseComma
Fangrui Song [Thu, 2 Feb 2023 02:41:02 +0000 (18:41 -0800)]
[MC] Simplify code with parseComma

21 months ago[LoongArch] Implement isUsedByReturnOnly for tailcall more libcalls
wanglei [Wed, 1 Feb 2023 02:14:43 +0000 (10:14 +0800)]
[LoongArch] Implement isUsedByReturnOnly for tailcall more libcalls

Similar to D131087 for RISCV.

Reviewed By: xen0n

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

21 months ago[X86][MC][bugfix] Report error for mismatched modifier in inline asm and remove funct...
Shengchen Kan [Sun, 29 Jan 2023 07:07:15 +0000 (15:07 +0800)]
[X86][MC][bugfix] Report error for mismatched modifier in inline asm and remove function getX86SubSuperRegisterOrZero

```
MCRegister getX86SubSuperRegister*(MCRegister Reg, unsigned Size,
                                  bool High = false);
```
A strange behavior of the functions `getX86SubSuperRegister*` was
introduced by llvm-svn:145579: The returned register may not
match the parameters when a 8-bit high register is required.

And llvm-svn: 175762 refined the code and dropped the comments, then we
knew nothing happened there from the code :-(

These two functions are only called with `Size=8` and `High=true` in two places.
One is in `X86FixupBWInsts.cpp` for liveness of registers and the other is in
`X86AsmPrinter.cpp` for inline asm.

For the first one, we provide an alternative in this patch.
For the second one, the strange behaviour caused a bug that an erorr was not reported for mismatched modifier.

```
void f() {
  char x;
  asm volatile ("mov %%ah, %h0" :"=r"(x)::"%eax", "%ebx", "%ecx", "%edx", "edi", "esi");
}
```

```
$ gcc -S test.c

error: extended registers have no high halves
```

```
$ clang -S test.c

no error
```

so we fix the bug in this patch.

`getX86SubSuperRegister` is just a wrapper of `getX86SubSuperRegisterOrZero` with a `assert`.
I belive we should remove the latter.

Reviewed By: pengfei

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

21 months ago[DAGCombiner] handle more store value forwarding
Chen Zheng [Fri, 9 Dec 2022 05:27:14 +0000 (00:27 -0500)]
[DAGCombiner] handle more store value forwarding

When lowering calls on target like PPC, some stack loads
will be generated for by value parameters. Node CALLSEQ_START
prevents such loads from being combined.

Suggested by @RolandF, this patch removes the unnecessary
loads for the byval parameter by extending ForwardStoreValueToDirectLoad

Reviewed By: nemanjai, RolandF

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

21 months ago[DAGCombiner][NFC] add testcases for D138899
Chen Zheng [Fri, 9 Dec 2022 10:08:03 +0000 (05:08 -0500)]
[DAGCombiner][NFC] add testcases for D138899

21 months ago[JITLink] Ensure that in-flight alloc is abandoned on error in post-alloc phase.
Lang Hames [Thu, 2 Feb 2023 01:42:30 +0000 (17:42 -0800)]
[JITLink] Ensure that in-flight alloc is abandoned on error in post-alloc phase.

If an error occurs during the post-allocation phase (JITLinkerBase::linkPhase2)
then we need to call JITLinkMemoryManager::InFlightAlloc::abandon so that the
allocation has a chance to clean up. This was already handled for later phases,
but we were skipping the abandon step when we bailed out of phase 2.

21 months ago[RISCV][MC] Simplify .option and make error messages more conventional
Fangrui Song [Thu, 2 Feb 2023 01:58:23 +0000 (17:58 -0800)]
[RISCV][MC] Simplify .option and make error messages more conventional

and add line/column information to tests.

21 months agoRevert (and fix properly) "Uninitialize the file descriptor."
Mircea Trofin [Thu, 2 Feb 2023 01:39:34 +0000 (17:39 -0800)]
Revert (and fix properly) "Uninitialize the file descriptor."

This reverts commit f514b0e144db063931d19a8ebc2dc42083d0eb2f.

The culprit is that InEC is initialized before Inbound, and Inbound's
initialization happens through a call to openFileForRead. However, the
typical initialization order warnings don't fire; so the behavior was:
Inbound is initialized correctly by openFileForRead; then it's reset to
whatever initializer value (0 originally).

A fix is to move Inbound's decl upfront. I'd still prefer initializing
it to something - and -1 seems like a more appropriate value (it causes
a fail-fast rather than a hang due to trying to read from a
valid-looking but unopen fd).

21 months ago[HWASAN] Set os_id in Thread::Init to make sure that the thread can be found by GetTh...
Kirill Stoimenov [Thu, 2 Feb 2023 01:32:16 +0000 (01:32 +0000)]
[HWASAN] Set os_id in Thread::Init to make sure that the thread can be found by GetThreadByOsIDLocked.

Reviewed By: vitalybuka

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

21 months agoUninitialize the file descriptor.
Mircea Trofin [Thu, 2 Feb 2023 01:30:05 +0000 (17:30 -0800)]
Uninitialize the file descriptor.

Unblocking the build. Investigating why the value can't be initialized
(even to e.g. -1) before calling open.

21 months ago[HLSL] [Dirver] add dxv as a VerifyDebug Job
Xiang Li [Fri, 13 Jan 2023 18:05:36 +0000 (13:05 -0500)]
[HLSL] [Dirver] add dxv as a VerifyDebug Job

New option --dxv-path is  added for dxc mode to set the installation path for dxv.
If cannot find dxv, a warning will be report.

dxv will be executed with command line dxv file_name -o file_name.
It will validate and sign the file and overwrite it.

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

21 months ago[libc++] Avoid ODR violations in __exception_guard
Nikolas Klauser [Wed, 1 Feb 2023 15:04:53 +0000 (16:04 +0100)]
[libc++] Avoid ODR violations in __exception_guard

Having an ODR violation with `__exception_guard` seems to be problematic in LTO builds. To avoid the ODR violation, give the class different names for exception/no-exceptions mode and have an alias to the correct class.

Reviewed By: ldionne, #libc, alexfh

Spies: aeubanks, dblaikie, joanahalili, alexfh, rupprecht, libcxx-commits

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

21 months ago[DX] Begin adding support for pipeline state
Chris Bieneman [Thu, 2 Feb 2023 00:39:01 +0000 (18:39 -0600)]
[DX] Begin adding support for pipeline state

DirectX shader pipeline state validation information is a fairly
complicated to serialize data structure. This patch adds the first bit
of support for reading and writing the runtime info structure which
comes first in the encoded data.

Subsequent patches will flesh out the remaining fields of the data
structure.

There is no official documentation for the format, but the format is
roughly documented in the code comment here:
https://github.com/microsoft/DirectXShaderCompiler/blob/main/include/dxc
/DxilContainer/DxilPipelineStateValidation.h#L731

Reviewed By: python3kgae

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

21 months agoFix typo: FineLineEntriesForFileIndex -> FindLineEntriesForFileIndex.
Jim Ingham [Thu, 2 Feb 2023 00:40:32 +0000 (16:40 -0800)]
Fix typo: FineLineEntriesForFileIndex -> FindLineEntriesForFileIndex.

21 months ago[ORC] Merge redundant jitlink::Symbol -> JITSymbolFlags mappings.
Lang Hames [Wed, 1 Feb 2023 22:48:46 +0000 (14:48 -0800)]
[ORC] Merge redundant jitlink::Symbol -> JITSymbolFlags mappings.

Adds a getJITSymbolFlagsForSymbol function that returns the JITSymbolFlags
for a given jitlink::Symbol, and replaces severalredundant copies of that
mapping with calls to the new function. This fixes a bug in
LinkGraphMaterializationUnit::scanLinkGraph where we were failing to set the
JITSymbolFlags::Weak flag for weak symbols, and a bug in
ObjectLinkingLayer::claimOrExternalizeWeakAndCommonSymbols where we were
failing to set the JITSymbolFlags::Callable flag for callable symbols.

21 months ago[LSAN] Add GetUserAddr function which returns the user visible address of an internal...
Kirill Stoimenov [Wed, 1 Feb 2023 22:00:13 +0000 (22:00 +0000)]
[LSAN] Add GetUserAddr function which returns the user visible address of an internal pointer

For HWASAN this would be the tagged address. It is the same pointer when pointer tagging is not used. Coincidently this also fixes some test which rely on comparing pointers.

Reviewed By: vitalybuka

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

21 months agoRevert "[Clang] Add -Wtype-limits to -Wextra for GCC compatibility"
Shivam Gupta [Thu, 2 Feb 2023 00:28:04 +0000 (05:58 +0530)]
Revert "[Clang] Add -Wtype-limits to -Wextra for GCC compatibility"

This reverts commit 95668c0d97e6184729f3a3e9621a58d9edffb6b0.

This discovers a warning in
https://reviews.llvm.org/rGa68d4b11465f5b3326be1dd820f59fac275b7581.

and broke the x86_64-linux sanitizer
buildbot: https://lab.llvm.org/buildbot/#/builders/37/builds/19910.

21 months ago[Driver][Fuchsia] Remove relative vtable multilib
Petr Hosek [Wed, 1 Feb 2023 08:11:22 +0000 (08:11 +0000)]
[Driver][Fuchsia] Remove relative vtable multilib

We have made relative vtable the default for Fuchsia C++ ABI so this
is no longer needed.

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

21 months agoFix windows bot breakages due to D143110
Mircea Trofin [Thu, 2 Feb 2023 00:27:44 +0000 (16:27 -0800)]
Fix windows bot breakages due to D143110

21 months ago[RISCV] Slightly simplify how the X*_PD registers for Zdinx are declared. NFC
Craig Topper [Wed, 1 Feb 2023 23:29:06 +0000 (15:29 -0800)]
[RISCV] Slightly simplify how the X*_PD registers for Zdinx are declared. NFC

Instead of manually listing 16 different even numbers, use a range
and then multiply.

21 months ago[mlgo] Make InteractiveModelRunner actually work with named pipes
Mircea Trofin [Wed, 1 Feb 2023 22:01:55 +0000 (14:01 -0800)]
[mlgo] Make InteractiveModelRunner actually work with named pipes

Turns out raw_fd_stream doesn't work with named pipes, so we just need
to lower the abstraction. Updated the unittest accordingly. Because
mkfifo's path argument requires a certain naming pattern on Windows
(IIUC), restricted the test to Linux only.

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

21 months ago[LSAN] Enable some tests which are passing as is in HWASAN.
Kirill Stoimenov [Wed, 1 Feb 2023 22:01:32 +0000 (22:01 +0000)]
[LSAN] Enable some tests which are passing as is in HWASAN.

Reviewed By: vitalybuka

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

21 months ago[Clang][DependencyScanner] Remove secondary actions from -cc1
Michael Spencer [Wed, 1 Feb 2023 01:52:51 +0000 (17:52 -0800)]
[Clang][DependencyScanner] Remove secondary actions from -cc1

The -arcmt-action= and -objcmt-migrate* actions were being passed to
module builds. This caused these builds to fail, as they are secondary
actions that suppress emitting modules.

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

21 months agoRemove another unnecessary integer-check.
Mitch Phillips [Wed, 1 Feb 2023 23:08:06 +0000 (15:08 -0800)]
Remove another unnecessary integer-check.

Same as b3b940d1501e39563ac549c3a5a89b25ae8ab7b8

21 months agoRemove unnecessary comparison.
Mitch Phillips [Wed, 1 Feb 2023 23:04:06 +0000 (15:04 -0800)]
Remove unnecessary comparison.

Popped up after https://reviews.llvm.org/D142826 added extra flags to
-Wextra, which is used by our sanitizer buildbots
(https://lab.llvm.org/buildbot/#/builders/37/builds/19910).

This check seems unnecessary, it's a bad cargo-cult after the buffer
size was expanded to allow >= 4GiB after
https://reviews.llvm.org/rGd6c15b661ab0aabb00f1219ce4af7136938e67e2.

21 months ago[flang] Allow compiler directives in the specification part of a module
V Donaldson [Wed, 1 Feb 2023 20:52:42 +0000 (12:52 -0800)]
[flang] Allow compiler directives in the specification part of a module

Lowering code currently allows for directives inside a program or
subprogram, or outside any program unit. Directives may also appear
in the specification part of a module, as in:

module mm
  interface
     subroutine ss(aa)
       !dir$ ignore_tkr(tkr) aa
       integer :: aa(*)
     end subroutine ss
  end interface
end module

With some exceptions such as OpenMP directives, most directives are
currently ignored, so this code should generate an "ignoring all compiler
directives" message.

21 months agoRevert "[GVN] Improve PRE on load instructions"
Guozhi Wei [Wed, 1 Feb 2023 22:48:31 +0000 (22:48 +0000)]
Revert "[GVN] Improve PRE on load instructions"

This reverts commit 5f1448fe1585b5677d5f0064e4eeac3b493d8a18.

21 months agoRevert "[GVN] Don't count debug instructions when limit the number of checked instruc...
Guozhi Wei [Wed, 1 Feb 2023 22:48:06 +0000 (22:48 +0000)]
Revert "[GVN] Don't count debug instructions when limit the number of checked instructions"

This reverts commit f494b366ff8a076a72a8e1b7a6f401686d6eb0e6.

21 months ago[flang] Avoid crashing from recursion on very tall expression parse trees
Peter Klausler [Thu, 19 Jan 2023 22:32:09 +0000 (14:32 -0800)]
[flang] Avoid crashing from recursion on very tall expression parse trees

In the parse tree visitation framework (Parser/parse-tree-visitor.h)
and in the semantic analyzer for expressions (Semantics/expression.cpp)
avoid crashing due to stack size limitations by using an iterative
traversal algorithm rather than straightforward recursive tree walking.
The iterative approach is the obvious one of building a work queue and
using it to (in the case of the parse tree visitor) call the visitor
object's Pre() and Post() routines on subexpressions in the same order
as they would have been called during a recursive traversal.

This change helps the compiler survive some artificial stress tests
and perhaps with future exposure to machine-generated source code.

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

21 months ago[flang] Fix build warning
Peter Klausler [Wed, 1 Feb 2023 22:05:57 +0000 (14:05 -0800)]
[flang] Fix build warning

It's basically impossible to write a switch statement with a case
for every enumerator in an enum class if the cases each have a
return statement and get it to compile without warnings for all
of our build compilers & versions.  Rewrite as a sequence of
if statements.

21 months ago[libc++] Look for Clang 17 when compiling clang-tidy checks
Nikolas Klauser [Tue, 31 Jan 2023 12:03:57 +0000 (13:03 +0100)]
[libc++] Look for Clang 17 when compiling clang-tidy checks

This allows compiling the clang-tidy checks when you only have ToT clang

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

21 months ago[flang] Fix a warning
Kazu Hirata [Wed, 1 Feb 2023 21:54:51 +0000 (13:54 -0800)]
[flang] Fix a warning

This patch fixes:

  flang/lib/Evaluate/check-expression.cpp:509:3: error: default label
  in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

21 months ago[Clang] avoid relying on StringMap iteration order when roundtripping -analyzer-config
Erik Desjardins [Wed, 1 Feb 2023 21:46:59 +0000 (13:46 -0800)]
[Clang] avoid relying on StringMap iteration order when roundtripping -analyzer-config

I am working on another patch that changes StringMap's hash function,
which changes the iteration order here, and breaks some tests,
specifically:

    clang/test/Analysis/NSString.m
    clang/test/Analysis/shallow-mode.m

with errors like:

    generated arguments do not match in round-trip
    generated arguments #1 in round-trip: <...> "-analyzer-config" "ipa=inlining" "-analyzer-config" "max-nodes=75000" <...>
    generated arguments #2 in round-trip: <...> "-analyzer-config" "max-nodes=75000" "-analyzer-config" "ipa=inlining" <...>

To avoid this, sort the options by key, instead of using the default map
iteration order.

Reviewed By: jansvoboda11, MaskRay

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

21 months ago[RISCV] Reuse RISCVRegWithSubRegs class to shorten some code in RISCVRegisterInfo...
Craig Topper [Wed, 1 Feb 2023 21:38:03 +0000 (13:38 -0800)]
[RISCV] Reuse RISCVRegWithSubRegs class to shorten some code in RISCVRegisterInfo.td. NFC

21 months ago[clang][deps] Give the fake file a unique name in by-module-name scans
Jan Svoboda [Wed, 1 Feb 2023 21:42:19 +0000 (13:42 -0800)]
[clang][deps] Give the fake file a unique name in by-module-name scans

When scanning dependencies of a module, the command line we're given doesn't have an input file, which the driver needs to be happy. We've been creating a fake in-memory input file named after the module. However, this can hide files/directories on the actual filesystem, leading to errors.

This patch works around that issue by generating a unique file name, which won't collide with the actual file system.

We could also change the driver APIs so that we're able to specify an "assumed" input file. This would be more work, though, since the driver assumes the input name comes from the actual command-line.

Depends on D140176.

Reviewed By: artemcm

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

21 months ago[clang][deps] NFC: Split out the module-based API from the TU-based API
Jan Svoboda [Wed, 1 Feb 2023 21:35:11 +0000 (13:35 -0800)]
[clang][deps] NFC: Split out the module-based API from the TU-based API

For users of the C++ API, the return type of `getFullDependencies` doesn't make sense when asking for dependencies of a module. In the returned `FullDependenciesResult` instance, only `DiscoveredModules` is useful (the graph of modular dependecies). The `FullDeps` member is trying to describe a translation unit it was never given. Its command line also refers to a file in the in-memory VFS we create in the scanner, leaking the implementation detail.

This patch splits the API and improves layering and naming of the return types.

Depends on D140175.

Reviewed By: artemcm

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

21 months ago[clang][deps] Remove support for the deprecated driver API
Jan Svoboda [Wed, 1 Feb 2023 21:03:11 +0000 (13:03 -0800)]
[clang][deps] Remove support for the deprecated driver API

This API is no longer necessary, so let's remove it to simplify the internal APIs.

Reviewed By: benlangmuir, artemcm

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

21 months ago[flang] Check for global name conflicts (19.2)
Peter Klausler [Sat, 7 Jan 2023 01:49:15 +0000 (17:49 -0800)]
[flang] Check for global name conflicts (19.2)

Global names should be checked for conflicts even when not BIND(C).

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

21 months ago[clang-format] Support clang-format on/off line comments as prefix
Owen Pan [Sat, 28 Jan 2023 10:51:36 +0000 (02:51 -0800)]
[clang-format] Support clang-format on/off line comments as prefix

Closes #60264.

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

21 months ago[BOLT][CMake] Add dependency on llvm_vcsrevision_h
Amir Ayupov [Wed, 1 Feb 2023 20:35:46 +0000 (12:35 -0800)]
[BOLT][CMake] Add dependency on llvm_vcsrevision_h

The dependence is needed since Utils includes VCSRevision.h, and other
LLVM components that include this header also have the llvm_vcsrevision_h
dependency.

Fixes #60460.

Reviewed By: #bolt, ayermolo

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

21 months ago[libc][math] Fix setting exceptional value for tanf to work with gcc.
Tue Ly [Wed, 1 Feb 2023 19:25:25 +0000 (14:25 -0500)]
[libc][math] Fix setting exceptional value for tanf to work with gcc.

See https://github.com/llvm/llvm-project/issues/59866

Reviewed By: sivachandra

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

21 months ago[flang] Catch bad inquiries in specification expressions
Peter Klausler [Thu, 5 Jan 2023 22:11:54 +0000 (14:11 -0800)]
[flang] Catch bad inquiries in specification expressions

When a descriptor inquiry or inquiry function's result is
not constant and is known to be impossible to correctly determine
at runtime, raise an error.  For example, LEN(X) when X is
a local allocatable variable with deferred length.

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

21 months ago[mlir][spirv] Fix vector type mismatch in UnifyAliasedResourcePass
Lei Zhang [Wed, 1 Feb 2023 19:35:25 +0000 (19:35 +0000)]
[mlir][spirv] Fix vector type mismatch in UnifyAliasedResourcePass

For the cases where we have aliases of `vector<4xf16>` and
`vector<4xf32>`, we need to do casting before composite
construction.

Reviewed By: kuhar

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

21 months agoadd arcanist patch to fix arc diff
Aditya Kumar [Wed, 1 Feb 2023 20:10:56 +0000 (12:10 -0800)]
add arcanist patch to fix arc diff

Another patch to fix arcanist on newer php versions. See previous patch
here: https://reviews.llvm.org/D129232

Authored by: Justin Stitt (justinstitt)
Reviewed by: nickdesaulniers, hiraditya, foad
Differential Revision: https://reviews.llvm.org/D131699

21 months ago[flang] Catch character length errors in pointer associations
Peter Klausler [Tue, 3 Jan 2023 23:09:50 +0000 (15:09 -0800)]
[flang] Catch character length errors in pointer associations

When character lengths are known at compilation time, report an error
when a data target with a known length does not match the explicit length
of a pointer that is being associated with it; see 10.2.2.3 paragraph 5.

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

21 months ago[Clang] Fix test after changing the order of input files
Joseph Huber [Wed, 1 Feb 2023 19:52:22 +0000 (13:52 -0600)]
[Clang] Fix test after changing the order of input files

Summary:
Forget to update these tests after moving the input earlier.

21 months ago[LinkerWrapper] Adjust placement of input files for the linker
Joseph Huber [Wed, 1 Feb 2023 19:48:27 +0000 (13:48 -0600)]
[LinkerWrapper] Adjust placement of input files for the linker

Summary:
The placement of input files can change the result of the linker. We
should put the input files earlier to avoid this.

21 months ago[Driver][Fuchsia] Support --emit-static-lib in Fuchsia driver
Petr Hosek [Wed, 1 Feb 2023 09:45:35 +0000 (09:45 +0000)]
[Driver][Fuchsia] Support --emit-static-lib in Fuchsia driver

This allows building static libraries with Clang driver.

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