platform/upstream/llvm.git
14 months agoValueTracking: Check context instruction is in a function
Matt Arsenault [Thu, 18 May 2023 13:39:32 +0000 (14:39 +0100)]
ValueTracking: Check context instruction is in a function

14 months ago[X86][MC] Add labels for BSF in the switch-cases of X86MCInstLower::Lower, NFCI
Shengchen Kan [Thu, 18 May 2023 11:59:09 +0000 (19:59 +0800)]
[X86][MC] Add labels for BSF in the switch-cases of X86MCInstLower::Lower, NFCI

BSF is not special here and leaving it in default label looked weird.

14 months agoReapply "ValueTracking: Handle phi in computeKnownFPClass"
Matt Arsenault [Thu, 18 May 2023 11:56:53 +0000 (12:56 +0100)]
Reapply "ValueTracking: Handle phi in computeKnownFPClass"

This reverts commit e13f88d1ff5234946af6349a9a7cf56fcb6c040e.

Fix off by one recursion limit check.

14 months agoEarlyCSE: Add regression test for computeKnownFPClass phi handling
Matt Arsenault [Thu, 18 May 2023 11:41:28 +0000 (12:41 +0100)]
EarlyCSE: Add regression test for computeKnownFPClass phi handling

This was reduced from the failure that caused the revert in
e13f88d1ff5234946af6349a9a7cf56fcb6c040e

14 months ago[X86][MC] Move the code about fixed register encoding optimization to X86EncodingOpti...
Shengchen Kan [Thu, 18 May 2023 11:40:33 +0000 (19:40 +0800)]
[X86][MC] Move the code about fixed register encoding optimization to X86EncodingOptimization.cpp, NFCI

14 months agoValueTracking: Check instruction is in a parent in computeKnownFPClass
Matt Arsenault [Thu, 18 May 2023 11:16:04 +0000 (12:16 +0100)]
ValueTracking: Check instruction is in a parent in computeKnownFPClass

For some reason the inliner calls simplifyInstruction with disembodied
instructions. I consider this to be an API defect. Either the instruction
should always be inserted prior to simplification, or we at least
should pass in the new function for the context.

14 months agoMachineTraceMetrics: modernize loops (NFC)
Ramkumar Ramachandra [Thu, 18 May 2023 09:22:14 +0000 (10:22 +0100)]
MachineTraceMetrics: modernize loops (NFC)

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

14 months ago[flang][runtime] Add dynamically allocated temporary storage
Tom Eccles [Thu, 27 Apr 2023 09:53:54 +0000 (09:53 +0000)]
[flang][runtime] Add dynamically allocated temporary storage

These functions will be used as part of the HLFIR lowering for
forall/where. The contents of the API were requested by @jeanPerier.

The API is designed around that use case, assuming that the caller knows
through some side channel what size to allocate for boxes returned from
the pop() function.

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

14 months ago[flang][hlfir] Add pass to inline elementals
Tom Eccles [Tue, 25 Apr 2023 09:07:11 +0000 (09:07 +0000)]
[flang][hlfir] Add pass to inline elementals

Implement hlfir.elemental inlining as proposed in
flang/docs/HighLevelFIR.md.

This is a separate pass to make the code easier to understand. One
alternative would have been to modify the hlfir.elemental lowering in
the HLFIR bufferization pass.

Currently, a hlfir.elemental can only be inlined once; if there are
more uses, the existing bufferization is used instead.

Usage of mlir::applyPatternsAndFoldGreedily was suggested by @jeanPerier

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

14 months ago[AArch64][LoopVectorize] Enable tail-folding of simple loops on neoverse-v1
David Sherwood [Tue, 25 Apr 2023 08:46:41 +0000 (08:46 +0000)]
[AArch64][LoopVectorize] Enable tail-folding of simple loops on neoverse-v1

This patch enables the tail-folding of simple loops by default
when targeting the neoverse-v1 CPU. Simple loops exclude those
with recurrences or reductions or loops that are reversed.

New tests have been added here:

Transforms/LoopVectorize/AArch64/sve-tail-folding-option.ll

In terms of SPEC2017 only one benchmark is really affected when
building with "-Ofast -mcpu=neoverse-v1 -flto", which is
(+ faster, - slower):

525.x264: +7.0%

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

14 months ago[LV] Add extra uniformity tests with UDIV and UREM.
Florian Hahn [Thu, 18 May 2023 10:35:17 +0000 (11:35 +0100)]
[LV] Add extra uniformity tests with UDIV and UREM.

Extra tests for D148841.

14 months ago[X86][MC] Move encoding optimization for VCMP to X86::optimizeInstFromVEX3ToVEX2...
Shengchen Kan [Thu, 18 May 2023 10:30:54 +0000 (18:30 +0800)]
[X86][MC] Move encoding optimization for VCMP to X86::optimizeInstFromVEX3ToVEX2, NFCI

This is a follow-up for c13ed1cc7578

14 months ago[X86][MC] Simplify code for X86::optimizeInstFromVEX3ToVEX2
Shengchen Kan [Thu, 18 May 2023 10:08:57 +0000 (18:08 +0800)]
[X86][MC] Simplify code for X86::optimizeInstFromVEX3ToVEX2

14 months ago [X86][MC] Move the code about MOV encoding optimization to X86EncodingOptimization...
Shengchen Kan [Thu, 18 May 2023 09:26:00 +0000 (17:26 +0800)]
 [X86][MC] Move the code about MOV encoding optimization to X86EncodingOptimization.cpp, NFCI

14 months ago[clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)
Balázs Kéri [Thu, 18 May 2023 09:16:17 +0000 (11:16 +0200)]
[clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)

Documentation is made more exact, term "constraint" is removed entirely,
description of checker option is corrected.

Reviewed By: Szelethus, gamesh411

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

14 months ago[DebugInfo][SelectionDAG] Do not drop dbg intrinsics with empty metadata locs
OCHyams [Wed, 17 May 2023 17:15:57 +0000 (18:15 +0100)]
[DebugInfo][SelectionDAG] Do not drop dbg intrinsics with empty metadata locs

Without this patch SelectionDAG silently drops dbg.values using `!{}` operands.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

This causes assignment-tracking to behaviour to match non-assignment-tracking
behaviour after a recent change (see D140990).

Reviewed By: jmorse

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

14 months ago[XCore] Use backwards scavenging in frame index elimination
Jay Foad [Tue, 16 May 2023 10:26:30 +0000 (11:26 +0100)]
[XCore] Use backwards scavenging in frame index elimination

This is preferred because it does not rely on accurate kill flags.

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

14 months ago[Lanai] Use backwards scavenging in frame index elimination
Jay Foad [Mon, 15 May 2023 15:58:16 +0000 (16:58 +0100)]
[Lanai] Use backwards scavenging in frame index elimination

This is preferred because it does not rely on accurate kill flags.

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

14 months ago[ARC] Use backwards scavenging in frame index elimination
Jay Foad [Mon, 15 May 2023 15:52:59 +0000 (16:52 +0100)]
[ARC] Use backwards scavenging in frame index elimination

This is preferred because it does not rely on accurate kill flags.

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

14 months agoRevert "ValueTracking: Handle phi in computeKnownFPClass"
Matt Arsenault [Thu, 18 May 2023 08:42:54 +0000 (09:42 +0100)]
Revert "ValueTracking: Handle phi in computeKnownFPClass"

This reverts commit cac9e427eb1ff3dabda8ac08968b998c3bc5ab47.

Causing crashes in lencod

14 months ago[test][clang-repl] Disable test incompatible with msan
Vitaly Buka [Sat, 13 May 2023 01:46:43 +0000 (18:46 -0700)]
[test][clang-repl] Disable test incompatible with msan

14 months agoRevert "AMDGPU: Add baseline test for f16 fmed3 matching"
Matt Arsenault [Thu, 18 May 2023 08:22:54 +0000 (09:22 +0100)]
Revert "AMDGPU: Add baseline test for f16 fmed3 matching"

This reverts commit b233eb70cd82ca3c320fac4bb8c2cccd1fe97696.

14 months ago[AST] Initialized AutoTypeLocInfo::FoundDecl
Vitaly Buka [Fri, 12 May 2023 22:35:28 +0000 (15:35 -0700)]
[AST] Initialized AutoTypeLocInfo::FoundDecl

Msan complains if getFoundDecl called before it's set.
This looks like data class, so I see no reason to keep
the single field uninitialized.

14 months ago[NFC][AST] Align one line
Vitaly Buka [Thu, 18 May 2023 08:18:01 +0000 (01:18 -0700)]
[NFC][AST] Align one line

14 months ago[AST] Initialize local counter
Vitaly Buka [Fri, 12 May 2023 22:20:58 +0000 (15:20 -0700)]
[AST] Initialize local counter

I assume it's optional and ReadAST does not have to set the
counter on success.

Without the patch msan complains that we pass
uninitialized value into noundef parameters of setCounterValue.

Reviewed By: bnbarham, barannikov88

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

14 months ago[C++20] [Modules] Emit an warning for experimental header units
Chuanqi Xu [Thu, 18 May 2023 08:11:20 +0000 (16:11 +0800)]
[C++20] [Modules] Emit an warning for experimental header units

Currently, the header units are rarely used and it is not well tested.
To avoid further misunderstandings, let's mark it as experimental and
emit a warning when users wants to import it.

This is discussed in modules developers meeting.

14 months ago[LSAN] Use ThreadArgRetval in LSAN
Vitaly Buka [Mon, 8 May 2023 19:42:50 +0000 (12:42 -0700)]
[LSAN] Use ThreadArgRetval in LSAN

Fixes false leaks on thread retval.

Reviewed By: thurston

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

14 months ago[ASAN] Use ThreadArgRetval in ASAN
Vitaly Buka [Mon, 8 May 2023 07:50:26 +0000 (00:50 -0700)]
[ASAN] Use ThreadArgRetval in ASAN

Fixes false leaks on thread retval.

Reviewed By: thurston

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

14 months ago[NFC][HWASAN] Fix pthread_attr_getdetachstate use
Vitaly Buka [Thu, 18 May 2023 07:53:53 +0000 (00:53 -0700)]
[NFC][HWASAN] Fix pthread_attr_getdetachstate use

Luckely of Linux PTHREAD_CREATE_DETACHED is 1.

14 months agoAMDGPU: Fold fmed3 of fpext sources to f16 fmed3
Matt Arsenault [Fri, 5 May 2023 17:16:58 +0000 (13:16 -0400)]
AMDGPU: Fold fmed3 of fpext sources to f16 fmed3

InstCombine already does this for minnum/maxnum. If we
also apply this to fmed3, we don't need to explicitly
use 16-bit fmed3 if we're not sure the target
supports 16-bit instructions yet.

14 months agoAMDGPU: Add baseline test for f16 fmed3 matching
Matt Arsenault [Fri, 5 May 2023 16:15:23 +0000 (12:15 -0400)]
AMDGPU: Add baseline test for f16 fmed3 matching

14 months agoGlobalISel: Refactor unary FP op constant folding
Matt Arsenault [Tue, 9 May 2023 08:52:44 +0000 (09:52 +0100)]
GlobalISel: Refactor unary FP op constant folding

14 months ago[gcov] Make .gcno/.gcda paths absolute
Fangrui Song [Thu, 18 May 2023 07:27:10 +0000 (00:27 -0700)]
[gcov] Make .gcno/.gcda paths absolute

This restores 737a452173a67f88d111f27b688bf3696c260db9 (2013) which was removed
by my a07b135ce0c0111bd83450b5dc29ef0381cdbc39.
This behavior turns out to be depended on by `bazel coverage`.

Add a `PWD=/proc/self/cwd %clang -### -c --coverage %s -o foo/bar.o` test.

14 months ago[LiveDebugValues] Initialized variable to avoid msan reports
Vitaly Buka [Tue, 16 May 2023 17:54:41 +0000 (10:54 -0700)]
[LiveDebugValues] Initialized variable to avoid msan reports

Reproducible with =-1 and assert: https://reviews.llvm.org/P8309

Reviewed By: jmorse

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

14 months ago[X86]Fix wrong asm match for MASKMOVDQU
Wang, Xin10 [Thu, 18 May 2023 07:14:24 +0000 (03:14 -0400)]
[X86]Fix wrong asm match for MASKMOVDQU

Missing work for D150835, aside from VMASKMOVDQU, MASKMOVDQU will also be affected by D150436.

Reviewed By: skan

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

14 months agoValueTracking: Handle phi in computeKnownFPClass
Matt Arsenault [Sat, 29 Apr 2023 23:31:01 +0000 (19:31 -0400)]
ValueTracking: Handle phi in computeKnownFPClass

Doesn't try the all the tricks computeKnownBits does.

14 months agoInstCombine: Pass all parameters to isKnownNeverNaN
Matt Arsenault [Tue, 11 Apr 2023 18:56:50 +0000 (14:56 -0400)]
InstCombine: Pass all parameters to isKnownNeverNaN

Allows assume handling to work.

14 months agoValueTracking: Delete body of isKnownNeverNaN
Matt Arsenault [Mon, 10 Apr 2023 15:00:21 +0000 (11:00 -0400)]
ValueTracking: Delete body of isKnownNeverNaN

This should now be redundant with the nan handling in computeKnownFPClass.

14 months agoValueTracking: Delete body of isKnownNeverInfinity
Matt Arsenault [Mon, 10 Apr 2023 13:58:22 +0000 (09:58 -0400)]
ValueTracking: Delete body of isKnownNeverInfinity

computeKnownFPClass should now handle infinity checks equally as
well as what this could do before so delete the redundant code.

14 months ago[RISCV][NFC] Simplify code.
Jianjian GUAN [Thu, 18 May 2023 03:07:01 +0000 (11:07 +0800)]
[RISCV][NFC] Simplify code.

Use AllVectors to replace !listconcat(AllIntegerVectors, AllFloatVectors).

Reviewed By: craig.topper

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

14 months ago[RISCV] Replace 'sve' with 'rvv' in some test file names. NFC
Craig Topper [Thu, 18 May 2023 06:32:31 +0000 (23:32 -0700)]
[RISCV] Replace 'sve' with 'rvv' in some test file names. NFC

14 months ago[RISCV] Remove unneedded comment. NFC
Craig Topper [Thu, 18 May 2023 05:49:28 +0000 (22:49 -0700)]
[RISCV] Remove unneedded comment. NFC

This was copied from SVE, but is currently not applicable to RISC-V.

14 months agoRevert "[clang][X86] Add __cpuidex function to cpuid.h"
Aiden Grossman [Thu, 18 May 2023 05:37:48 +0000 (05:37 +0000)]
Revert "[clang][X86] Add __cpuidex function to cpuid.h"

This reverts commit 286cefcf35d0f55c57184c4219b95e82c96f1420.

Patch caused build failures for downstream projects on Windows due to
the fact that __cpuidex was added as a built in on Windows in D121653.
Reverting for now so that others aren't blocked and I can figure out a
proper solution.

14 months agoFix MLIR crash on 32 bits platforms
Mehdi Amini [Thu, 18 May 2023 04:53:05 +0000 (21:53 -0700)]
Fix MLIR crash on 32 bits platforms

The properties size is compressed as a member of the Operation class
to assume a multiple of 8B is used for the storage. This matched the
natural alignment / padding on 64 bits platforms, however we need some
explicit padding on 32 bits platforms, llvm::TrailingObjects will
compress and misalign.

Fixes #62763

14 months ago[BOLT][NFC] Add MCPlusBuilder defOperands/useOperands helpers
Amir Ayupov [Thu, 18 May 2023 04:51:33 +0000 (21:51 -0700)]
[BOLT][NFC] Add MCPlusBuilder defOperands/useOperands helpers

Make intent more explicit with the use of new helper methods.

Reviewed By: #bolt, maksfb

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

14 months ago[AMDGPU][Uniformity] V_MBCNT* is never uniform
Carl Ritson [Thu, 18 May 2023 04:27:58 +0000 (13:27 +0900)]
[AMDGPU][Uniformity] V_MBCNT* is never uniform

Mark V_MBCNT instructions add thread/lane position so will never
be uniform.

Reviewed By: foad

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

14 months ago[SimpleLoopUnswitch] turnGuardIntoBranch use BB utils to update DT
Joshua Cao [Thu, 18 May 2023 03:40:40 +0000 (20:40 -0700)]
[SimpleLoopUnswitch] turnGuardIntoBranch use BB utils to update DT

turnGuardIntoBranch() can use splitBlockAndInsertIfThen to update the
DominatorTree rather than implementing it itself.

14 months ago[RISCV] Use IRBuilder::CreateInsertVector/CreateExtractVector to simplify code. NFC
Craig Topper [Thu, 18 May 2023 04:31:51 +0000 (21:31 -0700)]
[RISCV] Use IRBuilder::CreateInsertVector/CreateExtractVector to simplify code. NFC

Reviewed By: eopXD

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

14 months ago[Utils] Use LLVMContext::MD_loop (NFC)
Kazu Hirata [Thu, 18 May 2023 04:28:38 +0000 (21:28 -0700)]
[Utils] Use LLVMContext::MD_loop (NFC)

14 months ago[SCCP] Remove unused forward declarations (NFC)
Kazu Hirata [Thu, 18 May 2023 04:06:29 +0000 (21:06 -0700)]
[SCCP] Remove unused forward declarations (NFC)

While we are at it, this patch removes unnecessary includes.

14 months ago[IPO] Remove unused declaration RemoveUnusedGlobalValue
Kazu Hirata [Thu, 18 May 2023 03:49:31 +0000 (20:49 -0700)]
[IPO] Remove unused declaration RemoveUnusedGlobalValue

The corresponding function definition was removed by:

  commit 9071393c18e5264e3bbf3ca3f3584fa5f45be6c2
  Author: Jay Foad <jay.foad@amd.com>
  Date:   Thu Feb 17 14:17:36 2022 +0000

14 months ago[X86]Fix wrong asm match for VMASKMOVDQU
Wang, Xin10 [Thu, 18 May 2023 03:36:15 +0000 (23:36 -0400)]
[X86]Fix wrong asm match for VMASKMOVDQU

VMASKMOVDQU supports 32bit/64bit version in 64bitmode, previously we prefer to use VMASKMOVDQU64 in 64bitmode because the 32bit one need 0x67 prefix.
After D150436, asm match table changed a little, which makes in 64bit mode "vmaskmovdqu     %xmm0, %xmm1" will match VMASKMOVDQU other than VMASKMOVDQU64, this patch correct the asm match order for this instruction.

Reviewed By: skan

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

14 months ago[TableGen] Remove unused getMinimalTypeForEnumBitfield
Kazu Hirata [Thu, 18 May 2023 03:32:37 +0000 (20:32 -0700)]
[TableGen] Remove unused getMinimalTypeForEnumBitfield

The last use was removed by:

  commit e98944ed47acd04279184343017aa2bf34999111
  Author: Stanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
  Date:   Mon Mar 11 17:04:35 2019 +0000

14 months ago[X86][MC] Move the code about INC/DEC encoding optimization to X86EncodingOptimizatio...
Shengchen Kan [Thu, 18 May 2023 03:09:57 +0000 (11:09 +0800)]
[X86][MC] Move the code about INC/DEC encoding optimization to X86EncodingOptimization.cpp, NFCI

14 months ago[clang-format] Ignore first token when finding MustBreak
Emilia Kond [Thu, 18 May 2023 02:50:10 +0000 (05:50 +0300)]
[clang-format] Ignore first token when finding MustBreak

When in ColumnLimit 0, the formatter looks for MustBreakBefore in the
line in order to check if a line is allowed to be merged onto one line.

However, since MustBreakBefore is really a property of the gap between
the token and the one previously, I belive the check is erroneous in
checking all the tokens in a line, since whether the previous line ended
with a forced line break should have no effect on whether the current
line is allowed to merge with the next one.

This patch changes the check to skip the first token in
`LineJoiner.containsMustBreak`.

This patch also changes a test, which is not ideal, but I believe the
test also suffered from this bug. The test case in question sets
AllowShortFunctionsOnASingleLine to "Empty", but the empty function in
said test case isn't merged to a single line, because of the very same
bug this patch fixes.

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

14 months ago[flang] Apply the check for the constraint `C1172` to more stmts
Katherine Rasmussen [Wed, 17 May 2023 00:55:01 +0000 (17:55 -0700)]
[flang] Apply the check for the constraint `C1172` to more stmts

Apply the check for the constraint `C1172` to `unlock-stmt`,
`change-team-stmt`, `end-team-stmt`, and `critical-stmt`, which
all have `sync-stat-lists` and so `C1172` applies to them. Add
a test to check the `sync-stat-lists` for these 4 statements.

Reviewed By: PeteSteinfeld

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

14 months ago[RISCV] Refactor predicates for rvv SDNode patterns.
Jianjian GUAN [Wed, 17 May 2023 06:19:37 +0000 (14:19 +0800)]
[RISCV] Refactor predicates for rvv SDNode patterns.

This patch is similar to https://reviews.llvm.org/D150550, it adds accurate predicates for SDNode patterns depending on vector type.

Reviewed By: craig.topper

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

14 months ago[clang][CodeGen] Reformat ABIInfo.h (NFC)
Sergei Barannikov [Thu, 18 May 2023 01:28:31 +0000 (04:28 +0300)]
[clang][CodeGen] Reformat ABIInfo.h (NFC)

Preparatory change for D148094.

14 months ago[lldb][NFCI] Qualify param type in SBDebugger::FindTargetWithProcessID
Alex Langford [Thu, 18 May 2023 00:33:13 +0000 (17:33 -0700)]
[lldb][NFCI] Qualify param type in SBDebugger::FindTargetWithProcessID

We should specify that this is the pid_t as defined in the lldb
namespace, not some other pid_t. This doesn't really affect builds but
it makes writing tooling against the SBAPI easier.

I have verified that this does not change the emitted mangled name and
does not break ABI.

14 months ago[mlir][sparse] Fixing sparse_reshape.mlir integration test (followup to D150822)
wren romano [Wed, 17 May 2023 23:32:19 +0000 (16:32 -0700)]
[mlir][sparse] Fixing sparse_reshape.mlir integration test (followup to D150822)

For some reason, even though D150822 passed the buildbot, it failed to
catch this test

Reviewed By: anlunx

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

14 months ago[clang] NFC: Modernize Decl iteration via IdentifierResolver
Jan Svoboda [Wed, 17 May 2023 23:45:18 +0000 (16:45 -0700)]
[clang] NFC: Modernize Decl iteration via IdentifierResolver

14 months ago[gcov] Simplify cc1 options and remove CodeGenOptions EmitCovNotes/EmitCovArcs
Fangrui Song [Wed, 17 May 2023 23:09:12 +0000 (16:09 -0700)]
[gcov] Simplify cc1 options and remove CodeGenOptions EmitCovNotes/EmitCovArcs

After a07b135ce0c0111bd83450b5dc29ef0381cdbc39, we always pass
-coverage-notes-file/-coverage-data-file for driver options
-ftest-coverage/-fprofile-arcs/--coverage. As a bonus, we can make the following
simplification to cc1 options:

* `-ftest-coverage -coverage-notes-file a.gcno` => `-coverage-notes-file a.gcno`
* `-fprofile-arcs -coverage-data-file a.gcda` => `-coverage-data-file a.gcda`

and remove EmitCovNotes/EmitCovArcs.

14 months ago[libc] Restrict access to the RPC Process internals
Joseph Huber [Tue, 16 May 2023 18:39:28 +0000 (13:39 -0500)]
[libc] Restrict access to the RPC Process internals

This patch changes the `Process` struct to only provide the functions
expected to be visible by the interface. So, now we only export the
open, reset, and size query functions. This prevents users of the
interface from messing with the internals of the process, so now the
only existing failure mode is mismatched send and recieve calls.

Reviewed By: michaelrj

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

14 months ago[Clang] Remove direct linking of offloading runtimes from the arch tools
Joseph Huber [Wed, 17 May 2023 18:20:34 +0000 (13:20 -0500)]
[Clang] Remove direct linking of offloading runtimes from the arch tools

The tools `amdgpu-arch` and `nvptx-arch` are used to query the supported
GPUs on a system to implement features like `--offload-arch=native` as
well as generally being useful for setting up tests. However, we
currently directly link these if they are availible. This patch removes
this because it causes many problems on the user not having the libaries
present or misconfigured at build time. Since these are built
unconditionally we shoudl keep the dependencies away from clang.

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

Reviewed By: ye-luo

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

14 months ago[InferAddressSpaces] Handle vector of pointers type & Support intrinsic masked gather...
CaprYang [Wed, 17 May 2023 20:39:36 +0000 (21:39 +0100)]
[InferAddressSpaces] Handle vector of pointers type & Support intrinsic masked gather/scatter

14 months agoValueTracking: Handle sign bit for fptrunc in computeKnownFPClass
Matt Arsenault [Tue, 18 Apr 2023 02:14:36 +0000 (22:14 -0400)]
ValueTracking: Handle sign bit for fptrunc in computeKnownFPClass

14 months agoValueTracking: Implement computeKnownFPClass for various rounding intrinsics
Matt Arsenault [Sun, 9 Apr 2023 11:13:26 +0000 (07:13 -0400)]
ValueTracking: Implement computeKnownFPClass for various rounding intrinsics

14 months agoRevert "[Driver] Support multi /guard: options"
Arthur Eubanks [Wed, 17 May 2023 22:33:03 +0000 (15:33 -0700)]
Revert "[Driver] Support multi /guard: options"

This reverts commit 3b6f7e45a20990fdbc2b43dc08457fc79d53bd39.

See comments on D150645.

14 months ago[mlir][sparse] Fixing GPU tests (followup to D150330)
wren romano [Wed, 17 May 2023 21:59:02 +0000 (14:59 -0700)]
[mlir][sparse] Fixing GPU tests (followup to D150330)

The GPU tests weren't updated when rebasing D150330, so this patch fixes that.

Reviewed By: anlunx

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

14 months agoFix assertion when try is used inside catch(...) block
Jennifer Yu [Wed, 10 May 2023 22:01:52 +0000 (15:01 -0700)]
Fix assertion when try is used inside catch(...) block

Current assert wiht /EHa:
A single unwind edge may only enter one EH pad
  invoke void @llvm.seh.try.begin()
          to label %invoke.cont1 unwind label %catch.dispatch2

Current IR:
%1 = catchpad within %0 [ptr null, i32 0, ptr null]
   invoke void @llvm.seh.try.begin()
           to label %invoke.cont5 unwind label %catch.dispatch2

The problem is the invoke to llvm.seh.try.begin() missing "funclet"

Accodring: https://llvm.org/docs/LangRef.html#ob-funclet
If any "funclet" EH pads have been entered but not exited (per the
description in the EH doc), it is undefined behavior to execute a
call or invoke.

To fix the problem, when emit seh_try_begin,  call EmitSehTryScopeBegin,
instead of calling EmitRuntimeCallOrInvoke for proper "funclet"
gerenration.

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

14 months ago[test] Minor changes to optnone-opt.ll
Arthur Eubanks [Wed, 17 May 2023 21:37:02 +0000 (14:37 -0700)]
[test] Minor changes to optnone-opt.ll

Test doesn't require asserts.
Remove a CHECK line in preparation for an upcoming change.

14 months ago[Clang][Sema] Substitute constraints only for declarations with different lexical...
Alexander Shaposhnikov [Wed, 17 May 2023 21:02:02 +0000 (21:02 +0000)]
[Clang][Sema] Substitute constraints only for declarations with different lexical contexts

Substitute constraints only for declarations with different lexical contexts.
This results in avoiding the substitution of constraints during the redeclaration check
inside a class (and by product caching the wrong substitution result).

Test plan: ninja check-all

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

14 months ago[mlir][sparse] Renaming the STEA field `dimLevelType` to `lvlTypes`
wren romano [Wed, 17 May 2023 20:09:53 +0000 (13:09 -0700)]
[mlir][sparse] Renaming the STEA field `dimLevelType` to `lvlTypes`

This commit is part of the migration of towards the new STEA syntax/design.  In particular, this commit includes the following changes:
* Renaming compiler-internal functions/methods:
  * `SparseTensorEncodingAttr::{getDimLevelType => getLvlTypes}`
  * `Merger::{getDimLevelType => getLvlType}` (for consistency)
  * `sparse_tensor::{getDimLevelType => buildLevelType}` (to help reduce confusion vs actual getter methods)
* Renaming external facets to match:
  * the STEA parser and printer
  * the C and Python bindings
  * PyTACO

However, the actual renaming of the `DimLevelType` itself (along with all the "dlt" names) will be handled in a separate commit.

Reviewed By: aartbik

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

14 months ago[libc] Add a convenience CMake function `add_unittest_framework_library`.
Siva Chandra Reddy [Tue, 16 May 2023 17:19:10 +0000 (17:19 +0000)]
[libc] Add a convenience CMake function `add_unittest_framework_library`.

This function is used to add unit test and hermetic test framework libraries.
It avoids the duplicated code to add compile options to each every test
framework libraries.

Reviewed By: jhuber6

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

14 months ago[mlir][irdl] Add `irdl.any_of` operation
Mathieu Fehr [Wed, 8 Mar 2023 20:21:54 +0000 (21:21 +0100)]
[mlir][irdl] Add `irdl.any_of` operation

The `irdl.any_of` operation represent a constraint that is satisfied
if any of its subconstraint is satisfied.

For instance, in the following example:
```
%0 = irdl.is f32
%1 = irdl.is f64
%2 = irdl.any_of(f32, f64)
```

`%2` can only be satisfied by `f32` or `f64`.

Note that the verification algorithm required by `irdl.any_of` is
non-trivial, since we want that the order of arguments of
`irdl.any_of` to not matter. For this reason, our registration
algorithm fails if two constraints used by `any_of` might be
satisfied by the same `Attribute`. This is approximated by checking
the possible `Attribute` bases of each constraints.

Depends on D145734

Reviewed By: Mogball

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

14 months ago[lldb][NFCI] Clean up ThreadSafeDenseMap
Alex Langford [Wed, 17 May 2023 20:22:24 +0000 (13:22 -0700)]
[lldb][NFCI] Clean up ThreadSafeDenseMap

- Change header guard after 147a61618989
- Fix file header
- Remove the `_MutexType` template parameter, I did not see this used
  anywhere on llvm.org or on Apple's downstream forks.

14 months agoRevert 'hwasan: lay groundwork for importing subset of sanitizer_common interceptors...
Thurston Dang [Wed, 17 May 2023 18:56:52 +0000 (18:56 +0000)]
Revert 'hwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]'

It was reported in https://reviews.llvm.org/D150708 that my patch has broken
stage2/hwasan check: https://lab.llvm.org/buildbot/#/builders/236/builds/4069

Reverting that patch (and the followup fixes) until I can investigate this further

14 months ago[clang] Convert remaining OpenMP tests to opaque pointers
Sergei Barannikov [Tue, 16 May 2023 11:09:51 +0000 (14:09 +0300)]
[clang] Convert remaining OpenMP tests to opaque pointers

Reviewed By: nikic

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

14 months ago[lldb][NFCI] Move ThreadSafeDenseMap to Utility
Alex Langford [Wed, 17 May 2023 19:50:36 +0000 (12:50 -0700)]
[lldb][NFCI] Move ThreadSafeDenseMap to Utility

This seems better suited for Utility than Core

14 months ago[CUDA] Relax restrictions on GPU-side variadic functions
Artem Belevich [Tue, 16 May 2023 19:30:22 +0000 (12:30 -0700)]
[CUDA] Relax restrictions on GPU-side variadic functions

Allow parsing GPU-side variadic functions when we're compiling with CUDA-9 or
newer. We still do not allow accessing variadic arguments.

CUDA-9 was the version which introduced PTX-6.0 which allows implementing
variadic functions, so older versions can't have variadics in principle.

This is required for dealing with headers in recent CUDA versions that rely on
variadic function declarations in some of the templated code in libcu++.
E.g. https://github.com/llvm/llvm-project/issues/58410

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

14 months ago[Driver][gcov] Derive .gcno .gcda file names from -o and -dumpdir
Fangrui Song [Wed, 17 May 2023 19:43:49 +0000 (12:43 -0700)]
[Driver][gcov] Derive .gcno .gcda file names from -o and -dumpdir

Resolve a FIXME.
When -ftest-profile, -fprofile-arcs, or --coverage is specified and the
driver performs both compilation and linking phases, derive the .gcno &
.gcda file names from -o and -dumpdir.

`clang --coverage d/a.c d/b.c -o e/x && e/x` will now emit
`e/x-[ab].gc{no,da}` like GCC.

For -fprofile-dir=, we make the deliberate decision to not mangle the
input filename if relative.

The following script demonstrates the .gcno and .gcda filenames.

```
PATH=/tmp/Rel/bin:$PATH                # adapt according to your build directory
mkdir -p d e f
echo 'int main() {}' > d/a.c
echo > d/b.c

a() { rm $@ || exit 1; }

clang --coverage d/a.c d/b.c && ./a.out
a a-[ab].gc{no,da}
clang --coverage d/a.c d/b.c -o e/x && e/x
a e/x-[ab].gc{no,da}
clang --coverage d/a.c d/b.c -o e/x -dumpdir f/ && e/x
a f/[ab].gc{no,da}
clang --coverage -fprofile-dir=f d/a.c d/b.c -o e/x && e/x
a e/x-[ab].gcno f/e/x-[ab].gcda

clang -c --coverage d/a.c d/b.c && clang --coverage a.o b.o && ./a.out
a [ab].gc{no,da}
clang -c --coverage -fprofile-dir=f d/a.c d/b.c && clang --coverage a.o b.o && ./a.out
a [ab].gcno f/[ab].gcda

clang -c --coverage d/a.c -o e/xa.o && clang --coverage e/xa.o && ./a.out
a e/xa.gc{no,da}
clang -c --coverage d/a.c -o e/xa.o -dumpdir f/g && clang --coverage e/xa.o && ./a.out
a f/ga.gc{no,da}
```

The gcov code accidentally claims -c and -S, so -fsyntax-only -c/-S and
-E -c/-S don't lead to a -Wunused-command-line-argument warning. Keep
the unintended code for now.

14 months ago[clang][X86] Add __cpuidex function to cpuid.h
Aiden Grossman [Wed, 17 May 2023 18:01:37 +0000 (18:01 +0000)]
[clang][X86] Add __cpuidex function to cpuid.h

MSVC has a `__cpuidex` function implemented to call the underlying cpuid
instruction which accepts a leaf, subleaf, and data array that the output
data is written into. This patch adds this functionality into clang
under the cpuid.h header. This also makes clang match GCC's behavior.
GCC has had `__cpuidex` in its cpuid.h since 2020.

Reviewed By: craig.topper

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

14 months ago[gn build] Port da42b2846c82
LLVM GN Syncbot [Wed, 17 May 2023 19:02:47 +0000 (19:02 +0000)]
[gn build] Port da42b2846c82

14 months ago[gcov][test] Add -dumpdir ./
Fangrui Song [Wed, 17 May 2023 18:54:38 +0000 (11:54 -0700)]
[gcov][test] Add -dumpdir ./

These tests rely on an unintended behavior that when the driver performs both
compilation and linking phases, the .gcno & .gcda files are placed in PWD. The
behavior will be fixed to respect -o (match -ftime-trace, -gsplit-dwarf, and
GCC).

Add -dumpdir ./ so that the tests will work with or without the behavior change,
and make it easy to compare the coverage behavior with GCC.

14 months ago[CodeGen] Support allocating of arguments by decreasing offsets
Sergei Barannikov [Mon, 1 May 2023 08:56:39 +0000 (11:56 +0300)]
[CodeGen] Support allocating of arguments by decreasing offsets

Previously, `CCState::AllocateStack` always allocated stack space by increasing
offsets. For targets with stack growing up (away from zero) it is more
convenient to allocate arguments by decreasing offsets, so that the first
argument is at the top of the stack. This is important when calling a function
with variable number of arguments: the callee does not know the size of the
stack, but must be able to access "fixed" arguments. For that to work, the
"fixed" arguments should have fixed offsets relative to the stack top, i.e. the
variadic arguments area should be at the stack bottom (at lowest addresses).

The in-tree target with stack growing up is AMDGPU, but it allocates
arguments by increasing addresses. It does not support variadic arguments.

A drive-by change is to promote stack size/offset to 64-bit integer.
This is what MachineFrameInfo expects.

Reviewed By: arsenm

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

14 months ago[CodeGen] Replace CCState's getNextStackOffset with getStackSize (NFC)
Sergei Barannikov [Mon, 1 May 2023 02:39:30 +0000 (05:39 +0300)]
[CodeGen] Replace CCState's getNextStackOffset with getStackSize (NFC)

The term "next stack offset" is misleading because the next argument is
not necessarily allocated at this offset due to alignment constrains.
It also does not make much sense when allocating arguments at negative
offsets (introduced in a follow-up patch), because the returned offset
would be past the end of the next argument.

Reviewed By: arsenm

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

14 months ago[NFC][hwasan][Fuchsia] Instead wrap contents of InitLoadedGlobals with if constexpr...
Leonard Chan [Wed, 17 May 2023 18:45:44 +0000 (18:45 +0000)]
[NFC][hwasan][Fuchsia] Instead wrap contents of InitLoadedGlobals with if constexpr (!SANITIZER_FUCHSIA)

This prevents spamming the build log with unused InitLoadedGlobals when building fuchsia runtimes.

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

14 months ago[clangd] Tweak "provides" hover card when symbols have the same name
Sam McCall [Tue, 16 May 2023 15:24:48 +0000 (17:24 +0200)]
[clangd] Tweak "provides" hover card when symbols have the same name

Previously for overloaded functions we'd show:
  Provides: foo, bar bar bar bar

The symbol name is duplicated
  ==> only show unique names, since we're not displaying the signature

Commas are missing
  ==> fix the logic which was checking for "last element" by value
      (though after the above fix this bug is dead anyway)

While here, remove a redundant bounds check before take_front().

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

14 months ago[mlir][openacc] Add firstprivate representation
Valentin Clement [Wed, 17 May 2023 18:11:42 +0000 (11:11 -0700)]
[mlir][openacc] Add firstprivate representation

Add a representation for firstprivate clause modeled on the
private representation added in D150622.
The firstprivate recipe operation has an additional mandatory
region representing a sequences of operations needed to copy
the initial value to the created private copy.

Depends on D150622

Reviewed By: razvanlupusoru

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

14 months ago[RISCV] Implement storeOfVectorConstantIsCheap hook to prevent store merging at VL=2
Philip Reames [Wed, 17 May 2023 18:06:24 +0000 (11:06 -0700)]
[RISCV] Implement storeOfVectorConstantIsCheap hook to prevent store merging at VL=2

In general, VL=2 vectors are very questionable profitability wise. For constants specifically, our inability to materialize many vector constants cheaply biases us strongly towards unprofitability at VL=2.

This hook is very close to the x86 implementation. The difference is that X86 whitelists stores of zeros, and we're better off letting that stay scalar at VL=2.

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

14 months ago[RISCV] Expand testing for store merging of multiple constant stores
Philip Reames [Wed, 17 May 2023 17:01:16 +0000 (10:01 -0700)]
[RISCV] Expand testing for store merging of multiple constant stores

14 months ago[mlir][openacc] Add private representation
Valentin Clement [Wed, 17 May 2023 18:06:07 +0000 (11:06 -0700)]
[mlir][openacc] Add private representation

Currently privatization is not well represented in the OpenACC dialect. This
patch is a prototype to model privatization with a dedicated operation that
declares how the private value is created and destroyed.

The newly introduced operation is `acc.private.recipe` and it declares
an OpenACC privatization. The operation requires one mandatory and
one optional region.

  1. The initializer region specifies how to create and initialize a new
     private value. For example in Fortran, a derived-type might have a
     default initialization. The region has an argument that contains the
     value that need to be privatized. This is useful if the type is not
     a known at compile time and the private value is needed to create its
     copy.
  2. The destroy region specifies how to destruct the value when it reaches
     its end of life. It takes the privatized value as argument.

A same privatization can be used for multiple operand if they have the same
type and do not require a specific default initialization.

Example:

```mlir
acc.private.recipe @privatization_f32 : f32 init {
^bb0(%0: f32):
  // init region contains a sequence of operations to create and initialize the
  // copy if needed.
} destroy {
^bb0(%0: f32):
  // destroy region contains a sequences of operations to destruct the created
  // copy.
}

// The privatization symbol is then used in the corresponding operation.
acc.parallel private(@privatization_f32 -> %a : f32) {
}
```

Reviewed By: razvanlupusoru, jeanPerier

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

14 months agobuiltins: fix a -Wshorten-64-to-32 in gcc_personality_v0
Jon Roelofs [Tue, 16 May 2023 20:43:34 +0000 (13:43 -0700)]
builtins: fix a -Wshorten-64-to-32 in gcc_personality_v0

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

14 months ago[BOLT][NFC] Use llvm::make_range
Amir Ayupov [Tue, 16 May 2023 20:57:41 +0000 (13:57 -0700)]
[BOLT][NFC] Use llvm::make_range

Use `llvm::make_range` convenience wrapper from ADT.

Reviewed By: #bolt, rafauler

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

14 months ago[Hexagon] Split SETCC on float16/float32 HVX pairs
Krzysztof Parzyszek [Wed, 17 May 2023 17:41:46 +0000 (10:41 -0700)]
[Hexagon] Split SETCC on float16/float32 HVX pairs

14 months ago[RISCV] Refactor parseVTypeI and use ParseFail if we parsed more than one identifier.
Craig Topper [Wed, 17 May 2023 17:31:39 +0000 (10:31 -0700)]
[RISCV] Refactor parseVTypeI and use ParseFail if we parsed more than one identifier.

Previously we lexed into a SmallVector and unlexed the tokens if
the parsing failed.

This patch gets rid of the SmallVector and the unlexing.

If the first token fails to parse, return MatchFail. This allows us
to fallback to parsing as an immediate. If we successfully parsed the
first token, use ParseFail if any later tokens fail to parse. This
avoids needing to UnLex the tokens.

I've used a state machine to keep track of what component we've
parsed so far.

Reviewed By: asb

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

14 months ago[Fuchsia] Correctly pass lists from STAGE2_ vars
Alex Brachet [Wed, 17 May 2023 17:24:58 +0000 (17:24 +0000)]
[Fuchsia] Correctly pass lists from STAGE2_ vars

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

14 months ago[AArch64] Sink operands for faster bitselect vector instructions
Pranav Kant [Wed, 10 May 2023 00:38:59 +0000 (00:38 +0000)]
[AArch64] Sink operands for faster bitselect vector instructions

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

14 months ago[OpenMP]Fix trivial build failure in MacOS
Mats Petersson [Tue, 16 May 2023 16:15:17 +0000 (17:15 +0100)]
[OpenMP]Fix trivial build failure in MacOS

MacOS build of LLVM with OpenMP enabled fails with an error
that it doesn't know what std::abs is. Fix by including <cmath>
so that the relevant function declaration is included.

No functional change intended.

Reviewed By: tianshilei1992

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

14 months ago[libc++] Implement P2505R5(Monadic operations for std::expected).
yronglin [Wed, 17 May 2023 17:05:13 +0000 (01:05 +0800)]
[libc++] Implement P2505R5(Monadic operations for std::expected).

Implement P2505R5(https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2505r5.html)

Reviewed By: #libc, philnik, ldionne

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