platform/upstream/llvm.git
22 months ago[mlir][Tosa] Apply ClangTidy performance findings (NFC)
Adrian Kuegel [Thu, 22 Dec 2022 13:13:30 +0000 (14:13 +0100)]
[mlir][Tosa] Apply ClangTidy performance findings (NFC)

22 months ago[NVPTX] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 13:01:56 +0000 (14:01 +0100)]
[NVPTX] Convert test to opaque pointers (NFC)

22 months ago[MIR] Convert tests to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 12:58:29 +0000 (13:58 +0100)]
[MIR] Convert tests to opaque pointers (NFC)

22 months ago[CodeGen] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 12:57:14 +0000 (13:57 +0100)]
[CodeGen] Convert test to opaque pointers (NFC)

22 months agoclang/HIP: Fix broken implementations of __make_mantissa* functions
Matt Arsenault [Mon, 21 Nov 2022 03:30:09 +0000 (19:30 -0800)]
clang/HIP: Fix broken implementations of __make_mantissa* functions

The optimizer was folding the entire function to return 0. This
meant to be checking the character content of the pointer is the
string terminator, not null.

Also just make null inputs undefined. My docs for nanf say the
behavior of the argument is unspecified and segfaults on my system.

22 months ago[BPF] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 22 Dec 2022 11:56:50 +0000 (12:56 +0100)]
[BPF] Convert test to opaque pointers (NFC)

22 months ago[AMDGPU] Simplify simplifyAMDGCNMemoryIntrinsicDemanded. NFC.
Jay Foad [Thu, 22 Dec 2022 11:21:11 +0000 (11:21 +0000)]
[AMDGPU] Simplify simplifyAMDGCNMemoryIntrinsicDemanded. NFC.

22 months ago[Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w
gonglingqin [Thu, 22 Dec 2022 11:18:22 +0000 (19:18 +0800)]
[Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w

Add these intrinsics to keep consistent with GCC [1].

[1]: https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/larchintrin.h#L33

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

22 months ago[Clang][LoongArch] Add intrinsic for asrtle, asrtgt, lddir, ldpte and cpucfg
gonglingqin [Thu, 22 Dec 2022 08:59:56 +0000 (16:59 +0800)]
[Clang][LoongArch] Add intrinsic for asrtle, asrtgt, lddir, ldpte and cpucfg

`__cpucfg` is required by Linux [1].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/asm/loongarch.h#n59

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

22 months ago[clang-format] Add InsertBraces to operator== in Format.h
Owen Pan [Thu, 22 Dec 2022 10:24:01 +0000 (02:24 -0800)]
[clang-format] Add InsertBraces to operator== in Format.h

22 months ago[AArch64][SVE] Remove dso_local and local_unnamed_addr from muladdsub.ll
Matt Devereau [Thu, 22 Dec 2022 10:00:57 +0000 (10:00 +0000)]
[AArch64][SVE] Remove dso_local and local_unnamed_addr from muladdsub.ll

22 months ago[clang-format] Add 'friend' to QualifierOrder
Micah Weston [Thu, 22 Dec 2022 09:54:04 +0000 (01:54 -0800)]
[clang-format] Add 'friend' to QualifierOrder

For cases of defining friend functions, qualifier ordering can
allow multiple positions for the 'friend' token.

Closes #59450.

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

22 months ago[AArch64][InstCombine] Fuse ADD+MUL and SUB+MUL AArch64 instrinsics
Matt Devereau [Thu, 15 Dec 2022 16:09:13 +0000 (16:09 +0000)]
[AArch64][InstCombine] Fuse ADD+MUL and SUB+MUL AArch64 instrinsics

Fold (ADD p c (MUL p a b)) into (MAD p a b c)
Fold (FADD p c (FMUL p a b)) into (FMAD p a b c)
Fold (FSUB p c (FMUL p a b)) into (FNMSB p a b c)

Fold (ADD p (MUL p a b) c) into (MLA p c a b)
Fold (FADD p (FMUL p a b) c) into (FMLA p c a b)
Fold (SUB p (MUL p a b) C) into (MLS p c a b)
Fold (FSUB p (FMUL p a b) c) into (FMLS p c a b)

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

22 months ago[mlir][vector] Fold vector.extractelement(vector.broadcast)
Matthias Springer [Thu, 22 Dec 2022 09:22:37 +0000 (10:22 +0100)]
[mlir][vector] Fold vector.extractelement(vector.broadcast)

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

22 months ago[X86] Support ANDNP combine through vector_shuffle
Evgenii Kudriashov [Wed, 21 Dec 2022 12:45:41 +0000 (20:45 +0800)]
[X86] Support ANDNP combine through vector_shuffle

Combine
```
   and (vector_shuffle<Z,...,Z>
            (insert_vector_elt undef, (xor X, -1), Z), undef), Y
   ->
   andnp (vector_shuffle<Z,...,Z>
              (insert_vector_elt undef, X, Z), undef), Y
```

Reviewed By: RKSimon, pengfei

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

22 months agoRevert "Revert "[DebugInfo] Correctly recognize bitfields when emitting dwarf""
Juan Manuel MARTINEZ CAAMAÑO [Thu, 22 Dec 2022 08:31:36 +0000 (03:31 -0500)]
Revert "Revert "[DebugInfo] Correctly recognize bitfields when emitting dwarf""

https://reviews.llvm.org/D140195 should have fixed the fail in
green-dragon that was reported in https://reviews.llvm.org/D96334 and
resulted in the revert.

This reverts commit 920de9c94caff0b3ac21bf637487b07cb9aea98a.

22 months ago[bazel] Fix some --features=layering_check issues
Fangrui Song [Thu, 22 Dec 2022 08:12:58 +0000 (00:12 -0800)]
[bazel] Fix some --features=layering_check issues

22 months ago[mlir][llvm] Cleanup LLVM IR control flow import test (NFC).
Tobias Gysi [Thu, 22 Dec 2022 07:49:00 +0000 (08:49 +0100)]
[mlir][llvm] Cleanup LLVM IR control flow import test (NFC).

Use a FileCheck variable to match the switch op argument
instead of hardcoding the argument name.

Reviewed By: ftynse, Dinistro

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

22 months ago[bazel] Make TargetParser depend on config to fix --features=layering_check
Fangrui Song [Thu, 22 Dec 2022 06:59:36 +0000 (22:59 -0800)]
[bazel] Make TargetParser depend on config to fix --features=layering_check

While here, apply `buidifier`.

22 months ago[RISCV] Add more abs+zext test cases. NFC
Craig Topper [Wed, 21 Dec 2022 23:08:12 +0000 (15:08 -0800)]
[RISCV] Add more abs+zext test cases. NFC

22 months ago[clang][C++20] Add test for crash in NestedRequirement.
Utkarsh Saxena [Thu, 22 Dec 2022 05:49:29 +0000 (06:49 +0100)]
[clang][C++20] Add test for crash in NestedRequirement.

22 months ago[RISCV] Merge Masked and unMasked RVV manual codegen
Piyou Chen [Thu, 22 Dec 2022 04:27:44 +0000 (20:27 -0800)]
[RISCV] Merge Masked and unMasked RVV manual codegen

RVV intrinsic function will generate riscv_vector_builtin_cg.inc for CGBuiltin.cpp to produce the corresponding RVV intrinsic LLVM IR.

In this stage, riscv_vector.td will describe the bunch of manual codegen C++ code to tell CGBuiltin how to handle these instructions.

In this patch, we merge the masked RVV manual codegen and unmasked RVV manual codegen to reduce the number of manual codegen, and make more policy addition easier in the future.

This is a clean-up job that will not affect the RVV intrinsic functionality.

Reviewed By: kito-cheng

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

22 months agoFix out-of-bound access in TransformNestedRequirement.
Utkarsh Saxena [Thu, 22 Dec 2022 04:18:45 +0000 (05:18 +0100)]
Fix out-of-bound access in TransformNestedRequirement.

22 months ago[AMDGPU][Test] Update perfhint test to use opaque pointers
Yashwant Singh [Thu, 22 Dec 2022 04:17:28 +0000 (09:47 +0530)]
[AMDGPU][Test] Update perfhint test to use opaque pointers

Reviewed By: arsenm

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

22 months agoLinker: Disallow linking appending globals with different addrspaces
Matt Arsenault [Wed, 21 Dec 2022 17:35:42 +0000 (12:35 -0500)]
Linker: Disallow linking appending globals with different addrspaces

The current appending linkage handling implicitly assumes this by
using a basic ConstantExpr::getBitCast to resolve type
mismatches. Avoid this edge case so we don't need to keep the type
mismatch replacement code around after opaque pointers.

22 months ago[RISCV][NFC] Use Arrayref in TargetLowering functions.
ping.deng [Wed, 21 Dec 2022 12:25:00 +0000 (20:25 +0800)]
[RISCV][NFC] Use Arrayref in TargetLowering functions.

Reviewed By: kito-cheng

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

22 months ago[NFC] Rename Function::isDebugInfoForProfiling to shouldEmit[...]
Mircea Trofin [Thu, 22 Dec 2022 02:36:59 +0000 (18:36 -0800)]
[NFC] Rename Function::isDebugInfoForProfiling to shouldEmit[...]

The function name was misleading - the expectation set both by the name
and by other members of Function (like isDeclaration or isIntrinsic)
would be that the function somehow would "be" "debug info for
profiling". But that's not the case - the property indicates (as the
comment over the declaration also explains) whether debug info should be
emitted (for profiling).

22 months ago[M68k] Fix MachineFunctionInfo initialization after 69e75ae695d9ef1360a2a1fbefd6e0e04...
Fangrui Song [Thu, 22 Dec 2022 02:07:39 +0000 (18:07 -0800)]
[M68k] Fix MachineFunctionInfo initialization after 69e75ae695d9ef1360a2a1fbefd6e0e0456c3f7b

22 months ago[ARC][M68k] Fix INITIALIZE_PASS after D140364
Fangrui Song [Thu, 22 Dec 2022 01:53:11 +0000 (17:53 -0800)]
[ARC][M68k] Fix INITIALIZE_PASS after D140364

22 months agoAMDGPU: Use DenormalMode type in FP mode tracking
Matt Arsenault [Tue, 6 Dec 2022 16:59:49 +0000 (11:59 -0500)]
AMDGPU: Use DenormalMode type in FP mode tracking

This simplies a future patch. The MIR handling should be fixed. We're
still printing these in custom MachineFunctionInfo as bools (plus the
inverted meaning is hard to follow).

22 months ago[bazel] fix bazel file
Peiming Liu [Thu, 22 Dec 2022 01:24:52 +0000 (01:24 +0000)]
[bazel] fix bazel file

Reviewed By: yijia1212

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

22 months ago[LoongArch] Fix build after createMachineFunctionInfo change c774fd55008dbd2be51bc25f...
wanglei [Thu, 22 Dec 2022 01:13:42 +0000 (09:13 +0800)]
[LoongArch] Fix build after createMachineFunctionInfo change c774fd55008dbd2be51bc25f4c6f534978e73d95

22 months ago[OpenMP][libomptarget] Centralize host pinned buffers map to NextGen's PluginInterface
Kevin Sala [Wed, 21 Dec 2022 22:04:13 +0000 (23:04 +0100)]
[OpenMP][libomptarget] Centralize host pinned buffers map to NextGen's PluginInterface

This patch moves the management/tracking of host pinned buffers to the common PluginInterface
in NextGen plugins. For the moment, the management consists of tracking the host pinned
allocations into a map in each device.

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

22 months ago[mlir] Gate test checking statistics on their availability.
Will Dietz [Thu, 22 Dec 2022 00:46:27 +0000 (18:46 -0600)]
[mlir] Gate test checking statistics on their availability.

Fixes #59620.

22 months ago[NFC][OpenMP][libomptarget] Return null if error detected during allocation in NextGe...
Kevin Sala [Thu, 22 Dec 2022 00:41:50 +0000 (01:41 +0100)]
[NFC][OpenMP][libomptarget] Return null if error detected during allocation in NextGen AMDGPU

22 months agoRevert "Revert "[mlir][py] Enable building ops with raw inputs""
Jacques Pienaar [Thu, 22 Dec 2022 00:22:39 +0000 (16:22 -0800)]
Revert "Revert "[mlir][py] Enable building ops with raw inputs""

Fix Python 3.6.9 issue encountered due to type checking here. Will
add back in follow up.

This reverts commit 1f47fee2948ef48781084afe0426171d000d7997.

22 months ago[mlir] Fix a warning
Kazu Hirata [Thu, 22 Dec 2022 00:15:09 +0000 (16:15 -0800)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Dialect/MemRef/Transforms/RuntimeOpVerification.cpp:33:12:
  error: variable 'foundDynamicDim' set but not used
  [-Werror,-Wunused-but-set-variable]

22 months ago[NFC][SROA] More tests for variable indexed promotion
Roman Lebedev [Thu, 22 Dec 2022 00:12:17 +0000 (03:12 +0300)]
[NFC][SROA] More tests for variable indexed promotion

22 months ago[mlir] Fix a warning
Kazu Hirata [Thu, 22 Dec 2022 00:10:28 +0000 (16:10 -0800)]
[mlir] Fix a warning

This patch fixes:

  mlir/include/mlir/Analysis/AliasAnalysis/LocalAliasAnalysis.h:24:7:
  error: 'mlir::LocalAliasAnalysis' has virtual functions but
  non-virtual destructor [-Werror,-Wnon-virtual-dtor]

22 months ago[libc][obvious] fix bazel after removing vector
Michael Jones [Wed, 21 Dec 2022 23:22:27 +0000 (15:22 -0800)]
[libc][obvious] fix bazel after removing vector

The vector class was removed from the source code and cmake but not from
the bazel which caused bazel issues. This patch fixes that.

Reviewed By: sivachandra

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

22 months ago[gn build] Port ec11388b3342
LLVM GN Syncbot [Wed, 21 Dec 2022 23:32:10 +0000 (23:32 +0000)]
[gn build] Port ec11388b3342

22 months ago[gn] another fixup for 47df55f3ef5 -- LoongArch is experimental, not RISCV
Nico Weber [Wed, 21 Dec 2022 23:31:39 +0000 (18:31 -0500)]
[gn] another fixup for 47df55f3ef5 -- LoongArch is experimental, not RISCV

22 months ago[gn] fixup for 47df55f3ef5
Nico Weber [Wed, 21 Dec 2022 23:25:45 +0000 (18:25 -0500)]
[gn] fixup for 47df55f3ef5

22 months ago[gn] Don't include RISCV in targets build for 'all'
Nico Weber [Wed, 21 Dec 2022 23:23:47 +0000 (18:23 -0500)]
[gn] Don't include RISCV in targets build for 'all'

RISCV build and tests are often broken.

You can use `llvm_targets_to_build = "experimental"` to enable
_all_ targets, including the experimental ones. If RISCV is listed
in llvm_targets_to_build, it's built as before.

22 months ago[NFC] test commit
Nilay Vaish [Wed, 21 Dec 2022 22:54:25 +0000 (14:54 -0800)]
[NFC] test commit

22 months ago[LiveDebugValues] Remove LexicalScope param from VarLoc (NFC)
Heejin Ahn [Thu, 15 Dec 2022 21:58:51 +0000 (13:58 -0800)]
[LiveDebugValues] Remove LexicalScope param from VarLoc (NFC)

It doesn't seem to be used anymore.

Reviewed By: dschuff

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

22 months agoclang: Add __builtin_elementwise canonicalize and copysign
Matt Arsenault [Thu, 8 Dec 2022 03:48:27 +0000 (22:48 -0500)]
clang: Add __builtin_elementwise canonicalize and copysign

Just copy paste from the other functions. I also need fma, but
the current code seems to assume 1 or 2 arguments.

22 months agoRevert "[mlir][py] Enable building ops with raw inputs"
Jacques Pienaar [Wed, 21 Dec 2022 22:53:12 +0000 (14:53 -0800)]
Revert "[mlir][py] Enable building ops with raw inputs"

Reverting to fix build bot.

This reverts commit 3781b7905d8d808e5d4e97d597263f8ac48541b8.

22 months ago[NFC][SROA] More tests for variable indexed promotion
Roman Lebedev [Wed, 21 Dec 2022 22:35:23 +0000 (01:35 +0300)]
[NFC][SROA] More tests for variable indexed promotion

22 months ago[clangd] Fix crashing race in ClangdServer shutdown with stdlib indexing
Sam McCall [Wed, 21 Dec 2022 18:16:14 +0000 (19:16 +0100)]
[clangd] Fix crashing race in ClangdServer shutdown with stdlib indexing

In principle it's OK for stdlib-indexing tasks to run after the TUScheduler is
destroyed, as mostly they just update the dynamic index. We do drain the
stdlib-indexing queue before destroying the index.

However the task captures references to the PreambleCallbacks object, which is
owned by the TUScheduler. Once this is destroyed (explicitly, early in
~ClangdServer) an outstanding stdlib-indexing task may use-after-free.

The fix here is to avoid capturing references to the PreambleCallbacks.
Alternatives would be to have TUScheduler (exclusively) not own its callbacks
so they could live longer, or explicitly stopping the TUScheduler instead of
early-destroying it. These both seem more invasive.

See https://reviews.llvm.org/D115232 for some more context.

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

22 months ago[lld-macho] Emit map file entries for more synthetic sections
Jez Ng [Wed, 21 Dec 2022 22:26:02 +0000 (17:26 -0500)]
[lld-macho] Emit map file entries for more synthetic sections

We now handle the GOT, TLV, and stubs/lazy pointer sections.

Reviewed By: #lld-macho, thevinster, thakis

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

22 months agoLoongArch: Update for MachineFunctionInfo construction change
Matt Arsenault [Wed, 21 Dec 2022 22:24:59 +0000 (17:24 -0500)]
LoongArch: Update for MachineFunctionInfo construction change

22 months ago[NFC][SROA] More tests for promotion with variable index
Roman Lebedev [Wed, 21 Dec 2022 21:59:56 +0000 (00:59 +0300)]
[NFC][SROA] More tests for promotion with variable index

Also, delete the InstCombine test, it's not going to be relevant.

22 months ago[LV] Add createTripCountSCEV helper (NFC).
Florian Hahn [Wed, 21 Dec 2022 22:02:31 +0000 (22:02 +0000)]
[LV] Add createTripCountSCEV helper (NFC).

Split off helper function in preparation for D135017.

22 months ago[SPIR-V] Add atomic_flag builtin implementation
Michal Paszkowski [Wed, 21 Dec 2022 21:51:59 +0000 (22:51 +0100)]
[SPIR-V] Add atomic_flag builtin implementation

This change provides implementation details for atomic_flag builtins and
adds an extended atomic_flag.ll test from the LLVM SPIR-V Translator.

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

22 months agoReland "[NFC][SROA] `speculateSelectInstLoads()`: play nice with typed pointers for...
Roman Lebedev [Wed, 21 Dec 2022 21:08:16 +0000 (00:08 +0300)]
Reland "[NFC][SROA] `speculateSelectInstLoads()`: play nice with typed pointers for now"

This reverts commit bf88ba0f8718c1e89e28e977839ad0a6186d44fe,
relands 9f27f4536e19e93349b0662338408efe6d1cb2fd, but without a bug:
we *REALLY* should not be defaulting to address space 0
when address space is not specified...

22 months ago[llvm][SelectionDAGISel] support -{start|stop}-{before|after}= for remaining targets
Nick Desaulniers [Wed, 21 Dec 2022 21:11:36 +0000 (13:11 -0800)]
[llvm][SelectionDAGISel] support -{start|stop}-{before|after}= for remaining targets

Follow up to the series:
1. https://reviews.llvm.org/D140161
2. https://reviews.llvm.org/D140349
3. https://reviews.llvm.org/D140331
4. https://reviews.llvm.org/D140323

Completes the work from the previous two for remaining targets.

This creates the following named passes that can be run via
`llc -{start|stop}-{before|after}`:
- arc-isel
- arm-isel
- avr-isel
- bpf-isel
- csky-isel
- hexagon-isel
- lanai-isel
- loongarch-isel
- m68k-isel
- msp430-isel
- mips-isel
- nvptx-isel
- ppc-codegen
- riscv-isel
- sparc-isel
- systemz-isel
- ve-isel
- wasm-isel
- xcore-isel

A nice way to write tests for SelectionDAGISel might be to use a RUN:
line like:
llc -mtriple=<triple> -start-before=<arch>-isel -stop-after=finalize-isel -o -

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

Reviewed By: asb, zixuan-wu

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

22 months ago[lld][COFF] Fix lld-link crash when several .obj files built with /Zi refer to a...
Sylvain Audi [Thu, 15 Dec 2022 15:56:47 +0000 (10:56 -0500)]
[lld][COFF] Fix lld-link crash when several .obj files built with /Zi refer to a .pdb file that failed to load

This patch relaxes the constraints on the error message saved in PDBInputFile when failing to load a pdb file.

Storing an `Error` member infers that it must be accessed exactly once, which doesn't fit in several scenarios:
- If an invalid PDB file is provided as input file but never used, a loading error is created but never handled, causing an assert at shutdown.
- PDB file created using MSVC's `/Zi` option : The loading error message must be displayed once per obj file.

Also, the state of `PDBInputFile` was altered when reading (taking) the `Error` member, causing issues:
 - accessing it (taking the `Error`) makes the object look valid whereas it's not properly initialized
 - read vs write concurrency on a same `PDBInputFile` in the ghash parallel algorithm

The solution adopted here was to instead store an optional error string, and generate Error objects from it on demand.

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

22 months ago[libc][Obvious] Fix an off-by-one error introduced by eb9cc253cb048b6dbf2fcd73ac55b5e...
Siva Chandra Reddy [Wed, 21 Dec 2022 21:10:42 +0000 (21:10 +0000)]
[libc][Obvious] Fix an off-by-one error introduced by eb9cc253cb048b6dbf2fcd73ac55b5eda0184ed3.

22 months ago[llvm][AArch64ISelDAGToDAG] support -{start|stop}-{before|after}=aarch64-isel
Nick Desaulniers [Wed, 21 Dec 2022 20:28:37 +0000 (12:28 -0800)]
[llvm][AArch64ISelDAGToDAG] support -{start|stop}-{before|after}=aarch64-isel

Follow a similar pattern as AMDGPUDAGToDAGISel's constructor so that we
can use INITIALIZE_PASS to register a pass. This allows for more fine
grain testability of SelectionDAGISel via:

   llc -stop-{before,after}=aarch64-isel

Link: https://github.com/llvm/llvm-project/issues/59538
See also: https://reviews.llvm.org/D140323

Reviewed By: MaskRay

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

22 months ago[libc] Gracefully handle allocation failures around BlockStore.
Siva Chandra Reddy [Wed, 21 Dec 2022 07:27:08 +0000 (07:27 +0000)]
[libc] Gracefully handle allocation failures around BlockStore.

Reviewed By: lntue

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

22 months ago[libc][NFC] Use the custom operator new from strndup.
Siva Chandra Reddy [Wed, 21 Dec 2022 07:36:23 +0000 (07:36 +0000)]
[libc][NFC] Use the custom operator new from strndup.

Reviewed By: lntue

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

22 months ago[RISCV] Check the sign bits of the input of RISCVISD::ABSW in computeNumSignBitsForTa...
Craig Topper [Wed, 21 Dec 2022 20:50:10 +0000 (12:50 -0800)]
[RISCV] Check the sign bits of the input of RISCVISD::ABSW in computeNumSignBitsForTargetNode.

We created a SIGN_EXTEND_INREG when we created the ABSW so the
input should have 33 sign bits, but check it to be safe.

22 months ago[RISCV] Add test cases for i8/i16 abs followed by zext.
Craig Topper [Wed, 21 Dec 2022 20:08:07 +0000 (12:08 -0800)]
[RISCV] Add test cases for i8/i16 abs followed by zext.

The andi, zext.h and slli+srli shift pairs at the end of the generated
output are unnecessary if the input is sign extended.

22 months agosort some method declarations. NFC
Nick Desaulniers [Wed, 21 Dec 2022 20:22:22 +0000 (12:22 -0800)]
sort some method declarations. NFC

Precommit sort and format of methods from D140331.

Link: https://reviews.llvm.org/D140331
Link: https://github.com/llvm/llvm-project/issues/59538
22 months ago[NFC][SROA] Add tests for alloca promotion in presence of variably-indexed load
Roman Lebedev [Wed, 21 Dec 2022 20:13:17 +0000 (23:13 +0300)]
[NFC][SROA] Add tests for alloca promotion in presence of variably-indexed load

22 months ago[DIrectX backend] emit metadata for entry.
Xiang Li [Mon, 12 Dec 2022 17:51:33 +0000 (12:51 -0500)]
[DIrectX backend] emit metadata for entry.

New named metadata "dx.entryPoints" is added to save all entries.

Each entry is in format of
!{ptr to function, name, signature, resource table, extra}

For compute shader, the extra will save num of threads in format of {i32 x, i32 y, i32 z}

For library profile, an empty entry will be added to save the resource table for the library.

Signature and resource table metadata is not generated yet.

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

22 months ago[mlir] Clear running passes in crashreporter
Jacques Pienaar [Wed, 21 Dec 2022 19:43:03 +0000 (11:43 -0800)]
[mlir] Clear running passes in crashreporter

Clear active contexts and running passes whenever finalizing crash
report message. Ran into segfault where a failure in dynamic pipeline
resulted in querying a pass whose passmanager had already been destroyed
come time for creating summary of running passes. Conservatively clear
both running states as I don't think there is recovery intended from
pass pipeline failure.

Additionally restrict to one reproducer per report - else we end up
clobbering the same reproducer file over and over again. So instead of
ending with last reproducer we now end up with the first reproducer
while not creating and clobbering reproducers over and over again.

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

22 months ago[Flang] Reword the overview document
Peter Steinfeld [Fri, 16 Dec 2022 20:05:16 +0000 (12:05 -0800)]
[Flang] Reword the overview document

I brought the overview document up to date and added information for
most compilation phases to dump out the reeults of the phase.

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

22 months agoHeaders: further refine the `stdatomic.h` MSVC inclusion
Saleem Abdulrasool [Wed, 21 Dec 2022 16:45:28 +0000 (16:45 +0000)]
Headers: further refine the `stdatomic.h` MSVC inclusion

The `stdatomic.h` header cannot be included under MSVC when in C++ mode
as the toolsets prior to 17.5.0 Preview 2 do not support the C11
atomics.  However, some toolsets prior to the aforementioned version
support the atomics under the C++ mode.  In these versions the MSVC
toolset protects against the contamination by entirely eliding the
declarations, resulting in build failures in some cases.  Unfortunately,
e0c3142af075e2ef89395dbed5939071345eb622 accidentally regressed the C
case when fixing the C++ support.

Unfortunately, we cannot test this reliably as we need to inject a
header after the resource path as a system header path, which we do not
have a reliable means of doing.

Fixes: #59640

22 months ago[AArch64] Guard {vmull_p64, vmull_high_p64} with 'aes' target guard.
Mingming Liu [Tue, 20 Dec 2022 21:53:34 +0000 (13:53 -0800)]
[AArch64] Guard {vmull_p64, vmull_high_p64} with 'aes' target guard.

The 'aes' target guard includes both FEAT_AES and FEAT_PMULL currently.

In this way, cpp code that uses these intrinsics without specifying the required extension gets better hint.
- Before, compile crashes with LLVM ISel internal message (see issue [[ https://github.com/llvm/llvm-project/issues/59599 | 59599 ]]).
- After, clang hints that target 'aes' is required in the command.

Reviewed By: dmgreen

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

22 months ago[RISCV] Add DAG combine to fold (select C, (add X, Y), Y) -> (add (select C, X, 0...
Craig Topper [Wed, 21 Dec 2022 18:39:41 +0000 (10:39 -0800)]
[RISCV] Add DAG combine to fold (select C, (add X, Y), Y) -> (add (select C, X, 0), Y).

Similar for sub, or, and xor. These are all operations that have 0
as a neutral value. This is based on a similar tranform in InstCombine.

This allows us to remove some XVentanaCondOps patterns and
some code from DAGCombine for RISCVISD::SELECT_CC.

Reviewed By: asb

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

22 months ago[Clang] Modify sanity check assert in AggExprEmitter::VisitInitListExpr to cover...
Shafik Yaghmour [Wed, 21 Dec 2022 18:47:52 +0000 (10:47 -0800)]
[Clang] Modify sanity check assert in AggExprEmitter::VisitInitListExpr to cover anonymous struct in a union GNU extension

AggExprEmitter::VisitInitListExpr sanity checks that an empty union is really
empty and not a semantic analysis failure. The assert is missing that we allow
anonymous structs as a GNU extension. I have updated the assert to take that into account.

This fixes: https://github.com/llvm/llvm-project/issues/58800

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

22 months ago[BOLT][NFC] Make DWOId std::optional
Amir Ayupov [Wed, 21 Dec 2022 18:09:46 +0000 (10:09 -0800)]
[BOLT][NFC] Make DWOId std::optional

Reviewed By: #bolt, ayermolo

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

22 months ago[RISCV] Add more test cases to select.ll. NFC
Craig Topper [Wed, 21 Dec 2022 18:20:59 +0000 (10:20 -0800)]
[RISCV] Add more test cases to select.ll. NFC

These are test for select (and (x , 0x1) == 0), (z ^ y), y ) and select (and (x , 0x1) == 0), (z | y), y )

These can be made branchless by using ((x-1) & z ) ^ y.

22 months ago[ARC] Fix build after createMachineFunctionInfo change 69e75ae695d9ef1360a2a1fbefd6e0...
Fangrui Song [Wed, 21 Dec 2022 18:35:05 +0000 (10:35 -0800)]
[ARC] Fix build after createMachineFunctionInfo change 69e75ae695d9ef1360a2a1fbefd6e0e0456c3f7b

22 months ago[AArch64] Additional RSHRN pattern tests. NFC
David Green [Wed, 21 Dec 2022 18:32:52 +0000 (18:32 +0000)]
[AArch64] Additional RSHRN pattern tests. NFC

22 months ago[libc++] Rename __tuple to __tuple_dir to avoid file collision
Michał Górny [Sun, 4 Dec 2022 06:39:41 +0000 (07:39 +0100)]
[libc++] Rename __tuple to __tuple_dir to avoid file collision

Rename the `__tuple` directory in libc++ headers to `__tuple_dir`
to avoid file collision when installing.  Historically, `__tuple` has
been a file and it has been replaced by a directory
in 2d52c6bfae801b016dd3627b8c0e7c4a99405549.  Replacing a regular file
with a directory (or more importantly, the other way around when
downgrading) is not universally supported.  Since this is an internal
header, its actual name should not matter, so just rename it to avoid
problems.

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

22 months ago[mlir][py] Enable building ops with raw inputs
Jacques Pienaar [Wed, 21 Dec 2022 18:10:31 +0000 (10:10 -0800)]
[mlir][py] Enable building ops with raw inputs

For cases where we can automatically construct the Attribute allow for more
user-friendly input. This is consistent with C++ builder generation as well
choice of which single builder to generate here (most
specialized/user-friendly).

Registration of attribute builders from more pythonic input is all Python side.
The downside is that
  * extra checking to see if user provided a custom builder in op builders,
  * the ODS attribute name is load bearing
upside is that
  * easily change these/register dialect specific ones in downstream projects,
  * adding support/changing to different convenience builders are all along with
    the rest of the convenience functions in Python (and no additional changes
    to tablegen file or recompilation needed);

Allow for both building with Attributes as well as raw inputs. This change
should therefore be backwards compatible as well as allow for avoiding
recreating Attribute where already available.

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

22 months ago[flang] Use Assign() runtime for copy-in/copy-out.
Slava Zakharin [Wed, 21 Dec 2022 01:13:25 +0000 (17:13 -0800)]
[flang] Use Assign() runtime for copy-in/copy-out.

The loops generated under IsContiguous check for copy-in/copy-out
result in LLVM backend spending too much time optimizing them.
At the same time, the copy loops do not provide any optimization
opportunities with the surrounding code (since they are executed
under runtime IsContiguous check), so the copy code may be optimized
on its own and this can be done in runtime.

I thought I could implement and use new APIs for packing/unpacking
non-contiguous data (interfaces added in D136378), but then I found
that Assign() is already doing what is needed. If performance
becomes an issue for these loops, we can optimize code in Assign()
rather than creating new APIs.

Thus, this change makes use of Assign() for copy-in/copy-out
of boxed objects, and this is done only if the objects
are non-contiguous during execution. Copies for non-boxed
objects (e.g. for passing as VALUE dummy argument) are still
done inline, because they can potentially be optimized with
surrounding loops.

I added internal -inline-copyinout-for-boxes option to revert to the old
behavior just to make it easier to triage performance regressions,
if any appear after the change.

CPU2017/521.wrf compiles for 2179 seconds without the change and
the module_dm.f90 compiled with -O0 (without -O0 this single
module compiles for 5775 seconds). With the change total compilation
time of the benchmark reduces to 722 seconds.

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

22 months ago[mlir] Fix SameOperandsAndResultType to check encoding.
Jacques Pienaar [Wed, 21 Dec 2022 17:49:18 +0000 (09:49 -0800)]
[mlir] Fix SameOperandsAndResultType to check encoding.

Encoding was accidentally left out here even though it forms part of the type.
This is small tightening step and I'll look at follow on to tighten more.

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

22 months agomlir/LinalgOps: fix name of generated .yamlgen in comments
Ramkumar Ramachandra [Tue, 13 Dec 2022 16:43:36 +0000 (17:43 +0100)]
mlir/LinalgOps: fix name of generated .yamlgen in comments

Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D139946

22 months ago[Driver] Fix tests not to fail randomly on Windows
Paul Robinson [Wed, 21 Dec 2022 17:36:36 +0000 (09:36 -0800)]
[Driver] Fix tests not to fail randomly on Windows

These used a regex that didn't guard against backslashes, so
getting "lucky" with a temp dir name could make them fail.

22 months agoRevert "BEGIN_PUBLIC"
Mitch Phillips [Wed, 21 Dec 2022 17:18:01 +0000 (09:18 -0800)]
Revert "BEGIN_PUBLIC"

This reverts commit a6d6d40d8bd062514fc379a6bf70fb1b7220be6f.

Reason: Broke the ASan/MSan bots. More information in phabricator:
https://reviews.llvm.org/D140406

22 months ago[libc++] Add FreeBSD ABI list
Ed Maste [Tue, 20 Dec 2022 20:21:11 +0000 (15:21 -0500)]
[libc++] Add FreeBSD ABI list

Generated via `nina generate-cxx-abilist`.

Reviewed By: Mordante, ldionne, philnik
Differential Revision: https://reviews.llvm.org/D140431

22 months ago[NFC][libc++][chrono] Improves test coverage.
Mark de Wever [Thu, 1 Dec 2022 17:56:40 +0000 (18:56 +0100)]
[NFC][libc++][chrono] Improves test coverage.

The function year_month_weekday::sys_days should work properly with a
weekday index of 0 per [time.cal.ymwd.members]/20. This adds a test for
this case.

Reviewed By: #libc, ldionne

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

22 months ago[NFC] Add --check-globals to an autogen test cmdline
Jeremy Morse [Wed, 21 Dec 2022 16:42:34 +0000 (16:42 +0000)]
[NFC] Add --check-globals to an autogen test cmdline

In c6d7e80ec4c17 this test was converted from hand written to autogenerated,
during which the relevant metadata CHECKs were dropped. In D85172 the intention
of the CHECK lines is to ensure that for two dbg.declares with different
inlining scopes, attached to the same alloca, two sets of dbg.values will be
generated with the same set of inlining scopes. Without metadata checks, a
single DILocation can match the !dbg CHECKs.

22 months ago[docs] Update an example
Paul Robinson [Wed, 21 Dec 2022 16:41:38 +0000 (08:41 -0800)]
[docs] Update an example

22 months ago[docs] Add tips on writing test constraints
Paul Robinson [Wed, 21 Dec 2022 15:09:35 +0000 (07:09 -0800)]
[docs] Add tips on writing test constraints

22 months ago[libc++] Adds __cpp_lib_constexpr_algorithms to utility.
Mark de Wever [Tue, 20 Dec 2022 17:02:36 +0000 (18:02 +0100)]
[libc++] Adds __cpp_lib_constexpr_algorithms to utility.

Implements:
- LWG3792 __cpp_lib_constexpr_algorithms should also be defined in <utility>

Depends on D140407

Reviewed By: #libc, philnik, ldionne

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

22 months ago[libc++][doc] Adds Kona plenary papers and issues.
Mark de Wever [Tue, 20 Dec 2022 06:59:11 +0000 (07:59 +0100)]
[libc++][doc] Adds Kona plenary papers and issues.

Directly marked entries with Nothing to do where applicable.

Reviewed By: #libc, ldionne

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

22 months ago[clang] Remove overly restrictive aggregate paren init logic
Alan Zhao [Mon, 19 Dec 2022 18:04:06 +0000 (10:04 -0800)]
[clang] Remove overly restrictive aggregate paren init logic

Previously, we would only attempt to perform a parenthesized aggregate
initialization if constructor initialization failed for only the default
constructor, default copy constructor, and default move constructor. The
original intent of this logic was to reject initializing objects that
have failed resolving a user-defined constructor. However, this check is
redundant because we check for isAggregate() before attempting to
perform a parenthesized aggregate initialization, and classes that have
user-defined or user-declared constructors are not aggregates.
Furthermore, this check is too restrictive - the following valid
examples fail:
* Aggregate class with user-defined destructor - fails because default
  move constructors are not generated for classes with user-defined
  destructors
  (https://github.com/llvm/llvm-project/issues/54040#issuecomment-1356926048)
* Concept-guarded conversion operator on an aggregate's member:
  (https://github.com/llvm/llvm-project/issues/54040#issuecomment-1356931745)

The solution therefore is to remove this logic; existing tests still
pass, and the previously failing examples now compile.

Reviewed By: ilya-biryukov

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

22 months ago[InstCombine] Bubble vector.reverse of binop operands to their result.
Paul Walker [Mon, 17 Oct 2022 13:45:09 +0000 (14:45 +0100)]
[InstCombine] Bubble vector.reverse of binop operands to their result.

This mirrors a similar shufflevector transformation so the same
effect is obtained for scalable vectors. The transformation is
only performed when it can be proven the number of resulting
reversals is not increased. By bubbling the reversals from operand
to result this should typically be the case and ideally leads to
back-back shuffles that can be elimitated entirely.

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

22 months ago[InstCombine] Bubble vector.reverse of select operands to their result.
Paul Walker [Mon, 17 Oct 2022 13:45:09 +0000 (14:45 +0100)]
[InstCombine] Bubble vector.reverse of select operands to their result.

This mirrors a similar shufflevector transformation so the same
effect is obtained for scalable vectors. The transformation is
only performed when it can be proven the number of resulting
reversals is not increased. By bubbling the reversals from operand
to result this should typically be the case and ideally leads to
back-back shuffles that can be elimitated entirely.

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

22 months ago[InstCombine] Bubble vector.reverse of compare operands to their result.
Paul Walker [Mon, 17 Oct 2022 13:45:09 +0000 (14:45 +0100)]
[InstCombine] Bubble vector.reverse of compare operands to their result.

This mirrors a similar shufflevector transformation so the same
effect is obtained for scalable vectors. The transformation is
only performed when it can be proven the number of resulting
reversals is not increased. By bubbling the reversals from operand
to result this should typically be the case and ideally leads to
back-back shuffles that can be elimitated entirely.

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

22 months agollvm-reduce: Remove test dependence on registered targets
Matt Arsenault [Wed, 21 Dec 2022 15:46:23 +0000 (10:46 -0500)]
llvm-reduce: Remove test dependence on registered targets

This reverts e4b126cc2d33033a5538d72a88f6aa153ac8b757 and
e57ab8fe91f06e71d3de2df07e6c7efd2f0c6078.

This previously depended on where the target happened to construct (or
not) the MachineFunctionInfo during the initial MIR construction. Now
that the MachineFunctionInfo is consistently constructed at
MachineFunction construction time, this should always work.

22 months agoCodeGen: Don't lazily construct MachineFunctionInfo
Matt Arsenault [Thu, 18 Jun 2020 13:00:16 +0000 (09:00 -0400)]
CodeGen: Don't lazily construct MachineFunctionInfo

This fixes what I consider to be an API flaw I've tripped over
multiple times. The point this is constructed isn't well defined, so
depending on where this is first called, you can conclude different
information based on the MachineFunction. For example, the AMDGPU
implementation inspected the MachineFrameInfo on construction for the
stack objects and if the frame has calls. This kind of worked in
SelectionDAG which visited all allocas up front, but broke in
GlobalISel which hasn't visited any of the IR when arguments are
lowered.

I've run into similar problems before with the MIR parser and trying
to make use of other MachineFunction fields, so I think it's best to
just categorically disallow dependency on the MachineFunction state in
the constructor and to always construct this at the same time as the
MachineFunction itself.

A missing feature I still could use is a way to access an custom
analysis pass on the IR here.

22 months ago[PowerPC] Implement P10 Byte Reverse Insructions
Lei Huang [Tue, 20 Dec 2022 16:11:55 +0000 (10:11 -0600)]
[PowerPC] Implement P10 Byte Reverse Insructions

Generate brh, brw and brd instructions for byte-swap operations
on P10 and generating a single instruction for a 32-bit swap followed
by a 16-bit right shift.

Reviewed By: stefanp

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

22 months ago[AArch64] Combine Trunc(DUP) -> DUP
David Green [Wed, 21 Dec 2022 14:59:59 +0000 (14:59 +0000)]
[AArch64] Combine Trunc(DUP) -> DUP

This adds a simple fold of TRUNCATE(AArch64ISD::DUP) -> AArch64ISD::DUP,
which can help generate more optimal UMULL sequences, and seems useful
in general.

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

22 months ago[InstCombine] Recursively replace select value equivalence
Nikita Popov [Wed, 21 Dec 2022 14:41:54 +0000 (15:41 +0100)]
[InstCombine] Recursively replace select value equivalence

In the X == C ? f(X) : Y -> X == C ? f(C) : Y fold, perform the
replacement in f(X) recursively. For now, this just goes two
instructions up rather than one instruction up.