Commit Graph

104664 Commits

Author SHA1 Message Date
Justin Bogner
4f54d71501
[HLSL][DirectX] Move handling of resource element types into the frontend
Rather than shepherding a type name all the way to the backend as a
string and attempting to parse it, get the element type out of the AST
and store that in the resource annotation metadata directly.

Pull Request: https://github.com/llvm/llvm-project/pull/75674
2023-12-18 11:43:52 -07:00
Ziqing Luo
4123b95949
[-Wunsafe-buffer-usage] Add a subgroup -Wunsafe-buffer-usage-in-container (#75665)
Add a sub diagnostic group under `-Wunsafe-buffer-usage` controlled by
`-Wunsafe-buffer-usage-in-container`. The subgroup will include warnings
on misuses of `std::span`, `std::vector`, and `std::array`.
2023-12-18 10:39:15 -08:00
Fangrui Song
96aca7c517
[LTO] Improve diagnostics handling when parsing module-level inline assembly (#75726)
Non-LTO compiles set the buffer name to "<inline asm>"
(`AsmPrinter::addInlineAsmDiagBuffer`) and pass diagnostics to
`ClangDiagnosticHandler` (through the `MCContext` handler in
`MachineModuleInfoWrapperPass::doInitialization`) to ensure that
the exit code is 1 in the presence of errors. In contrast, LTO compiles
spuriously succeed even if error messages are printed.

```
% cat a.c
void _start() {}
asm("unknown instruction");
% clang -c a.c
<inline asm>:1:1: error: invalid instruction mnemonic 'unknown'
    1 | unknown instruction
      | ^
1 error generated.
% clang -c -flto a.c; echo $?  # -flto=thin is the same
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~~~~~
error: invalid instruction mnemonic 'unknown'
unknown instruction
^~~~~~~
0
```

`CollectAsmSymbols` parses inline assembly and is transitively called by
both `ModuleSummaryIndexAnalysis::run` and `WriteBitcodeToFile`, leading
to duplicate diagnostics.

This patch updates `CollectAsmSymbols` to be similar to non-LTO
compiles.
```
% clang -c -flto=thin a.c; echo $?
<inline asm>:1:1: error: invalid instruction mnemonic 'unknown'
    1 | unknown instruction
      | ^
1 errors generated.
1
```

The `HasErrors` check does not prevent duplicate warnings but assembler
warnings are very uncommon.
2023-12-18 09:46:58 -08:00
Joseph Huber
8e2cc19e2e
[LinkerWrapper] Forward more arguments to the CPU offloading linker (#75757)
Summary:
The CPU target currently inherits all the libraries from the normal link
job to ensure that it has access to the same envrionment that the host
does. However, this previously was not respecting argument libraries
that are passed by name rather than `-l` as well as the whole archive
flags. This patch fixes this to allow the CPU linker to correctly pick
up the libraries associated with things like address sanitizers.

Fixes: https://github.com/llvm/llvm-project/issues/75651
2023-12-18 11:16:49 -06:00
Sam Tebbs
fade67565e
[AArch64][SME2] Enable bfm builtins for sme2 (#71927)
This patch enables the following builtins for SME2
    svbfmlslb_f32
    svbfmlslb_lane_f32
    svbfmlslt_f32
    svbfmlslt_lane_f32

Patch by: Kerry McLaughlin <kerry.mclaughlin@arm.com>

---------

Co-authored-by: Matthew Devereau <matthew.devereau@arm.com>
2023-12-18 16:51:10 +00:00
Momchil Velikov
35a77fc13c
[Clang][SVE2.1] Update names of the svwhileXX builtins with predicate-as-counter (#75200)
The `_s64`/`_u64` part can be omitted now and the name variants do not
include unsigned comparison mnemonics. Both are inferred from
the argument types.
2023-12-18 16:49:59 +00:00
Kerry McLaughlin
f888e739d3
[Clang][SME2] Add multi-vector zip & unzip builtins (#74841)
Adds the following SME2 builtins:
 - svzip (x2 & x4)
 - svzipq (x2 & x4)
 - svuzp (x2 & x4)
 - svuzpq (x2 & x4)

See https://github.com/ARM-software/acle/pull/217/files

Patch by David Sherwood <david.sherwood@arm.com>
2023-12-18 16:38:36 +00:00
Sam Tebbs
a0a3c793d2
[Clang][SME] Warn when a function doesn't have ZA state (#75805)
This patch adds a warning that's emitted when a builtin call uses ZA
state but the calling function doesn't provide any.

Patch by David Sherwood <david.sherwood@arm.com>.
2023-12-18 16:14:25 +00:00
Momchil Velikov
fd527def7e
[Clang][SVE2.1] Add floating-point variants of svrevd_XX (#75117) 2023-12-18 15:52:28 +00:00
Abhina Sree
8a233d8cfd
[SystemZ][z/OS] Add guard for dl_info and dladdr (#75637)
This patch fixes the following build error on z/OS `error: unknown type name 'Dl_info'` by adding a guard to check if we have dladdr.
2023-12-18 10:33:23 -05:00
Shilei Tian
0f5eef1fb3
[OpenMP][Clang] Force use of num_teams and thread_limit for bare kernel (#68373)
This patch makes `num_teams` and `thread_limit` mandatory for bare
kernels,
similar to a reguar kernel language that when launching a kernel, the
grid size
has to be set explicitly.
2023-12-18 10:29:26 -05:00
Nikita Popov
a5f3415533 [InstCombine] Replace non-demanded undef vector with poison
If an operand (esp to shufflevector or insertelement) is not
demanded, canonicalize it from undef to poison.
2023-12-18 16:12:37 +01:00
Podchishchaeva, Mariya
5cda366221 Revert "[clang] Fix false positive -Wmissing-field-initializer for anonymous unions (#70829)"
This reverts commit a01307a6ee and its
follow-up fix 32d5221ec4.

It caused unexpected warnings emitted for nested designators in C.
2023-12-18 07:08:27 -08:00
Gheorghe-Teodor Bercea
4ef6587715
[Clang][OpenMP] Fix mapping of structs to device (#75642)
Fix mapping of structs to device.

The following example fails:

```
#include <stdio.h>
#include <stdlib.h>

struct Descriptor {
  int *datum;
  long int x;
  int xi;
  long int arr[1][30];
};

int main() {
  Descriptor dat = Descriptor();
  dat.datum = (int *)malloc(sizeof(int)*10);
  dat.xi = 3;
  dat.arr[0][0] = 1;

  #pragma omp target enter data map(to: dat.datum[:10]) map(to: dat)

  #pragma omp target
  {
    dat.xi = 4;
    dat.datum[dat.arr[0][0]] = dat.xi;
  }

  #pragma omp target exit data map(from: dat)

 return 0;
}
```

This is a rework of the previous attempt:
https://github.com/llvm/llvm-project/pull/72410
2023-12-18 09:47:59 -05:00
antoine moynault
9727919a2e
Revert "[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal … (#75789)
…toolchain (#73765)"

This reverts commit 111a229065,

as it broke several bots
  https://lab.llvm.org/buildbot/#/builders/245/builds/18162
  https://lab.llvm.org/buildbot/#/builders/188/builds/39436
  https://lab.llvm.org/buildbot/#/builders/187/builds/13723
  https://lab.llvm.org/buildbot/#/builders/182/builds/8449
  https://lab.llvm.org/buildbot/#/builders/198/builds/7438
  https://lab.llvm.org/buildbot/#/builders/176/builds/7419
  https://lab.llvm.org/buildbot/#/builders/186/builds/13781
  https://lab.llvm.org/buildbot/#/builders/183/builds/18116
  https://lab.llvm.org/buildbot/#/builders/197/builds/11410
  https://lab.llvm.org/buildbot/#/builders/184/builds/8651

When reapplying, please take care of another commit that have been
merged after this one:
c7cdf3cd5d [clang] Use 'starts_with' instead of 'startswith' in
Gnu.cpp (NFC)
2023-12-18 13:52:21 +01:00
Paul Walker
dea16ebd26
[LLVM][IR] Replace ConstantInt's specialisation of getType() with getIntegerType(). (#75217)
The specialisation will not be valid when ConstantInt gains native
support for vector types.

This is largely a mechanical change but with extra attention paid to constant
folding, InstCombineVectorOps.cpp, LoopFlatten.cpp and Verifier.cpp to
remove the need to call `getIntegerType()`.

Co-authored-by: Nikita Popov <github@npopov.com>
2023-12-18 11:58:42 +00:00
Simon Pilgrim
df3ddd78f6 CGBuiltin - fix gcc Wunused-variable warning. NFC. 2023-12-18 11:51:24 +00:00
Haojian Wu
42239d2e96
[clang] Fix CTAD not respect default template arguments that were added after the definition. (#75569)
Fixes https://github.com/llvm/llvm-project/issues/69987
2023-12-18 12:37:29 +01:00
Momchil Velikov
1faa1cd02d
[Clang][SVE2.1] Add intrinsics for WHILEcc resulting in predicate pair (#75107)
Add intrinsics of the form:

    svboolx2_t svwhile<cond>_b{8,16,32,64}_[{s,u}64]_x2([u]int64_t, [u]int64_t);

and their overloaded variants as specified in
https://github.com/ARM-software/acle/pull/257
2023-12-18 11:03:39 +00:00
Sam Tebbs
945c645acb
[AArch64][SME] Warn when using a streaming builtin from a non-streaming function (#75487)
This PR adds a warning that's emitted when a non-streaming or
non-streaming-compatible builtin is called in an unsuitable function.

Uses work by Kerry McLaughlin.

This is a re-upload of #74064 and fixes a compile time increase.
2023-12-18 09:32:34 +00:00
Jie Fu
c7cdf3cd5d [clang] Use 'starts_with' instead of 'startswith' in Gnu.cpp (NFC)
llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp:1757:14:
 error: 'startswith' is deprecated: Use starts_with instead [-Werror,-Wdeprecated-declarations]
 1757 |     if (Flag.startswith("!march=") || Flag.startswith("-march="))
      |              ^~~~~~~~~~
      |              starts_with
2023-12-18 16:10:49 +08:00
martinboehme
ca1034341c
[clang][dataflow] Fix an issue with Environment::getResultObjectLocation(). (#75483)
So far, if there was a chain of record type prvalues,
`getResultObjectLocation()` would assign a different result object
location to
each one. This makes no sense, of course, as all of these prvalues end
up
initializing the same result object.

This patch fixes this by propagating storage locations up through the
entire
chain of prvalues.

The new implementation also has the desirable effect of making it
possible to
make `getResultObjectLocation()` const, which seems appropriate given
that,
logically, it is just an accessor.
2023-12-18 09:10:03 +01:00
Brandon Wu
111a229065
[RISCV] Implement multi-lib reuse rule for RISC-V bare-metal toolchain (#73765)
Extend the multi-lib re-use selection mechanism for RISC-V.
This funciton will try to re-use multi-lib if they are compatible.
Definition of compatible:
  - ABI must be the same.
  - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
    is a subset of march=rv32imc.
  - march that contains atomic extension can't reuse multi-lib that
    doesn't has atomic, vice versa. e.g. multi-lib=march=rv32im and
    march=rv32ima are not compatible, because software and hardware
    atomic operation can't work together correctly.
2023-12-18 15:52:14 +08:00
Akira Hatanaka
31429e7a89
[CodeGen] Emit a more accurate alignment for non-temporal loads/stores (#75675)
Call EmitPointerWithAlignment to compute the alignment based on the
underlying lvalue's alignment when it's available.
2023-12-17 18:22:44 -08:00
Owen Pan
401f0396c3
[clang-format] Fix a bug in IndentExternBlock: NoIndent (#75731)
Fixes #36620.
Fixes #75719.
2023-12-17 15:07:11 -08:00
Kazu Hirata
2aaeef1fad [Index] Fix recursive-cxx-member-calls.cpp
b8f89b84bc inadvertently replaced
startswith/endswith with starts_with/ends_with even though the test
uses a custom StringRef.  This patch reverts the change.
2023-12-16 16:24:32 -08:00
Kazu Hirata
b8f89b84bc Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-16 15:02:17 -08:00
Kazu Hirata
395f9ce30e Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-16 10:14:44 -08:00
Youngsuk Kim
f49e2b05bf
[clang][CGCUDANV] Unify PointerType members of CGNVCUDARuntime (NFC) (#75668)
Unify 3 `Pointertype *` members which all refer to the same llvm type.

Opaque pointer clean-up effort.
2023-12-16 11:47:37 -05:00
Dinar Temirbulatov
50f5b5a80b
[AArch64][SME2] Add FCLAMP, CNTP builtins for SME2 (#72487)
This change enables FCLAMP, CNTP builtins for SME2 target.
2023-12-16 12:03:54 +00:00
Andrzej Warzyński
76041a45bb
[flang][nfc] Refactor linker invocation logic (#75648)
Refactor how the Fortran runtime libs are added to the linker
invocation. This is a non-functional change.

This is an updated version of #75534. This iteration makes sure that
FortranMain.a comes before FortranRuntme.a (the former depends on the
latter).
2023-12-16 11:13:20 +00:00
smanna12
7a0fd97ac1
[NFC][CLANG] Rename duplicate loop attributes diagnostic functions (#75657)
This patch renames CheckForDuplicateCodeAlignAttrs() to
CheckForDuplicateLoopAttrs() and corresponding other functions that call
it to be used for other statement attributes in future.
2023-12-15 22:09:19 -06:00
Fangrui Song
9950bb9944 [ASTReader] Fix readability-inconsistent-declaration-parameter-name. NFC 2023-12-15 17:11:21 -08:00
Augusto Noronha
eccc1cca71 Revert "[NFC] [Serialization] Packing more bits and refactor AbbrevToUse"
This reverts commit 9cdb825a4f.
2023-12-15 14:43:25 -08:00
Augusto Noronha
87bd71efd0 Revert "[NFC] Fix the warning Wcovered-switch-default"
This reverts commit e55bda06dc.
2023-12-15 14:43:25 -08:00
Lei Huang
aaa3f72c1c
[PowerPC] Emit libcall to frexpl for calls to frexp(ppcDoublDouble) (#75226)
On Linux PPC call lib func ``frexpl`` for calls to ``frexp()`` for input
of type PPCDoubleDouble.

Fixes bug: https://github.com/llvm/llvm-project/issues/64426
2023-12-15 17:23:16 -05:00
Philip Reames
0b7dda3d4c Revert "[flang][nfc] Refactor linker invocation logic (#75534)"
This reverts commit 71bbfabd08.  Breaks check-flang on x86_64 host.
2023-12-15 11:08:09 -08:00
Andrzej Warzyński
71bbfabd08
[flang][nfc] Refactor linker invocation logic (#75534)
Refactor how the Fortran runtime libs are added to the linker
invocation. This is a non-functional change.
2023-12-15 15:04:37 +00:00
Jessica Del
32f9983c06
[AMDGPU] - Add address space for strided buffers (#74471)
This is an experimental address space for strided buffers. These buffers
can have structs as elements and
a stride > 1.
These pointers allow the indexed access in units of stride, i.e., they
point at `buffer[index * stride]`.
Thus, we can use the `idxen` modifier for buffer loads.

We assign address space 9 to 192-bit buffer pointers which contain a
128-bit descriptor, a 32-bit offset and a 32-bit index. Essentially,
they are fat buffer pointers with an additional 32-bit index.
2023-12-15 15:49:25 +01:00
fel-cab
b522675816
Revert "[LinkerWrapper] Add 'Freestanding' config to the LTO pass" (#75528)
This reverts commit 47d9fbc04b.

It creates a segmentation falt on SPEChpc soma on Frontier on a GPU for
the kernel generate_new_beads

Co-authored-by: fel-cab <fel-cab@github.com>
2023-12-15 08:25:14 -06:00
Mariya Podchishchaeva
32d5221ec4
[clang] Fix unexpected warnings after a01307a (#75591)
a01307a broke silencing of -Wmissing-field-initializers warnings in C
for nested designators. This fixes the issue.
2023-12-15 15:25:01 +01:00
Timm Bäder
f32662a40b [clang][Interp][NFC] Remove outdated FIXME comment
This rework has already happened.
2023-12-15 14:30:44 +01:00
Phoebe Wang
f5e48fed04
[X86][AVX10] Allow 64-bit mask register used without EVEX512 (#75571)
This is to reflect new document change that 64-bit mask is support by
AVX10 256-bit targets.

Latest documents can be found in:
https://cdrdv2.intel.com/v1/dl/getContent/784267
https://cdrdv2.intel.com/v1/dl/getContent/784343
2023-12-15 20:41:42 +08:00
Ulrich Weigand
a65ccc1b9f
[SystemZ] Support i128 as legal type in VRs (#74625)
On processors supporting vector registers and SIMD instructions, enable
i128 as legal type in VRs. This allows many operations to be implemented
via native instructions directly in VRs (including add, subtract,
logical operations and shifts). For a few other operations (e.g.
multiply and divide, as well as atomic operations), we need to move the
i128 value back to a GPR pair to use the corresponding instruction
there. Overall, this is still beneficial.

The patch includes the following LLVM changes:
- Enable i128 as legal type
- Set up legal operations (in SystemZInstrVector.td)
- Custom expansion for i128 add/subtract with carry
- Custom expansion for i128 comparisons and selects
- Support for moving i128 to/from GPR pairs when required
- Handle 128-bit integer constant values everywhere
- Use i128 as intrinsic operand type where appropriate
- Updated and new test cases

In addition, clang builtins are updated to reflect the intrinsic operand
type changes (which also improves compatibility with GCC).
2023-12-15 12:55:15 +01:00
CarolineConcatto
77c40ea3d2
[Clang][AArch64]Add QCVTN builtin to SVE2.1 (#75454)
``` c
   // All the intrinsics below are [SVE2.1 or SME2]
   // Variants are also available for _u16[_s32]_x2 and _u16[_u32]_x2
   svint16_t svqcvtn_s16[_s32_x2](svint32x2_t zn);
   ```

According to PR#257[1]

[1]https://github.com/ARM-software/acle/pull/257
2023-12-15 11:42:00 +00:00
Mariusz Sikora
966416b9e8
[AMDGPU][GFX12] Add new v_permlane16 variants (#75475) 2023-12-15 10:14:38 +01:00
Mariya Podchishchaeva
cd09f21b22
[clang] Report narrowing conversions with const references (#75332)
Fixes https://github.com/llvm/llvm-project/issues/63151

---------

Co-authored-by: Erich Keane <ekeane@nvidia.com>
2023-12-15 09:42:20 +01:00
Craig Topper
73beefc5d7 [RISCV] Remove 'experimental-' from extension name in diagnostic message.
I'm not sure how to test this because the intrinsic availability
already seems to check this.
2023-12-14 21:54:15 -08:00
Fangrui Song
ce1faec3ad [Serialization] Fix -Wpessimizing-move after 9cdb825a4f 2023-12-14 19:40:09 -08:00
Chuanqi Xu
e55bda06dc [NFC] Fix the warning Wcovered-switch-default
There is a warning saying:

ASTWriter.h:766:5: error: default label in switch which covers all
enumeration values [-Werror,-Wcovered-switch-default]
  766 |     default:
      |     ^
1 error generated.

And this patch tries to fix this.
2023-12-15 11:39:20 +08:00