platform/upstream/llvm.git
20 months ago[flang][hlfir] Emit hlfir.declare inside internal procedures
Jean Perier [Tue, 7 Feb 2023 14:29:35 +0000 (15:29 +0100)]
[flang][hlfir] Emit hlfir.declare inside internal procedures

Captured variables inside internal procedure do not go though
Fortran::lower::instantiateVar because the specification expressions
should no be lowered again, and instead, all the information must be
taken from the host link argument.

There is nothing very special to do for HLFIR, but the hlfir.declare
should be emitted for the instantiated captured variable and mapped
to the symbol.

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

20 months ago[flang][hlfir] Lower evaluate::DescriptorInquiry
Jean Perier [Tue, 7 Feb 2023 14:27:19 +0000 (15:27 +0100)]
[flang][hlfir] Lower evaluate::DescriptorInquiry

Lower extents and lower bounds inquiries with a compile time
constant DIM that cannot be folded by the front-end.

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

20 months ago[ARM] Perform lane interleaving from reductions.
David Green [Tue, 7 Feb 2023 14:12:51 +0000 (14:12 +0000)]
[ARM] Perform lane interleaving from reductions.

We have a pass for MVE to perform lane interleaving to make use of top/bottom
instructions, that adds shuffles before extends and after truncates. This
extends it to also start from add reductions, where the order of lanes does not
matter so the shuffle is not needed. We need to be careful about not breaking
the form of existing reductions, but otherwise can save some instructions and
awkward extends.

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

20 months agoFix broken Bazel targets
Guillaume Chatelet [Tue, 7 Feb 2023 14:00:56 +0000 (14:00 +0000)]
Fix broken Bazel targets

20 months ago[clangd] Fix a crash in semantic highlighting.
Haojian Wu [Tue, 7 Feb 2023 11:40:00 +0000 (12:40 +0100)]
[clangd] Fix a crash in semantic highlighting.

We encounter a few internal reports that we're dereference a nullptr.
Unfortunately, no small reproduce testcase for this crash yet, but it makes the
clangd more robost on broken code.

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

20 months ago[include-mapping] Regenerate the StdSymbolMap.inc from the 20220730 html book.
Viktoriia Bakalova [Fri, 3 Feb 2023 09:02:01 +0000 (10:02 +0100)]
[include-mapping] Regenerate the StdSymbolMap.inc from the 20220730 html book.

Merge the zoombie names into the StdSymbols as well.

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

20 months ago[mlir][scf] Fix builder of WhileOp with region builder arguments.
Ingo Müller [Tue, 31 Jan 2023 06:39:31 +0000 (06:39 +0000)]
[mlir][scf] Fix builder of WhileOp with region builder arguments.

The overload of WhileOp::build with arguments for builder functions for
the regions of the op was broken: It did not compute correctly the types
(and locations) of the region arguments, which lead to failed assertions
when the result types were different from the operand types.
Specifically, it used the result types (and operand locations) for *both*
regions, instead of the operand types (and locations) for the 'before'
region and the result types (and loecations) for the 'after' region.

Reviewed By: Mogball, mehdi_amini

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

20 months ago[include-mapping] Better #includes support for std input/output symbols
Haojian Wu [Tue, 7 Feb 2023 09:37:44 +0000 (10:37 +0100)]
[include-mapping] Better #includes support for std input/output symbols

Reviewed By: kadircet

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

20 months ago[Tooling/Inclusion] Support multiple headers in the stdlib APIs.
Haojian Wu [Fri, 3 Feb 2023 22:50:25 +0000 (23:50 +0100)]
[Tooling/Inclusion] Support multiple headers in the stdlib APIs.

Unittest will be added in https://reviews.llvm.org/D143280

Patch by Viktoriia Bakalova.

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

20 months ago[libc][NFC] Move attributes from common to macros folder
Guillaume Chatelet [Tue, 7 Feb 2023 13:16:33 +0000 (13:16 +0000)]
[libc][NFC] Move attributes from common to macros folder

20 months ago[libc][NFC] Sort dependencies
Guillaume Chatelet [Tue, 7 Feb 2023 12:58:26 +0000 (12:58 +0000)]
[libc][NFC] Sort dependencies

20 months ago[libc][NFC] Use LIBC_TARGET_IS_GPU instead of defining PACKAGE_FOR_GPU
Guillaume Chatelet [Tue, 7 Feb 2023 12:57:52 +0000 (12:57 +0000)]
[libc][NFC] Use LIBC_TARGET_IS_GPU instead of defining PACKAGE_FOR_GPU

20 months ago[NFC][TargetParser] Remove llvm/ADT/Triple.h
Archibald Elliott [Tue, 7 Feb 2023 12:21:51 +0000 (12:21 +0000)]
[NFC][TargetParser] Remove llvm/ADT/Triple.h

I also ran `git clang-format` to get the headers in the right order for
the new location, which has changed the order of other headers in two
files.

20 months ago[debug-info] Followup to e0374fb2f4, avoid changing codegen
Jeremy Morse [Tue, 7 Feb 2023 12:20:32 +0000 (12:20 +0000)]
[debug-info] Followup to e0374fb2f4, avoid changing codegen

As discussed on D140404, calling GetValueInMiddleOfBlock can force PHI
nodes to be created, but the patch was only supposed to fetch a Value if it
wasn't going to generate any PHIs. Fix this by using GetValueAtEndOfBlock
instead of the Middle variant, which was the original intention given the
check of HasValueForBlock.

We don't need to consider the "middle of block" scenario as we're only
dealing with blocks where there are no value definitions.

20 months ago[CodeGen] Make more use of MachineOperand::getOperandNo. NFC.
Jay Foad [Fri, 3 Feb 2023 10:04:28 +0000 (10:04 +0000)]
[CodeGen] Make more use of MachineOperand::getOperandNo. NFC.

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

20 months ago[CodeGen] Define and use MachineOperand::getOperandNo
Jay Foad [Fri, 3 Feb 2023 09:42:25 +0000 (09:42 +0000)]
[CodeGen] Define and use MachineOperand::getOperandNo

This is a helper function to very slightly simplify many calls to
MachineInstruction::getOperandNo.

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

20 months ago[AMDGPU] Remove the unused u8imm operand definition.
Ivan Kosarev [Tue, 7 Feb 2023 11:38:34 +0000 (11:38 +0000)]
[AMDGPU] Remove the unused u8imm operand definition.

Reviewed By: foad

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

20 months ago[LoopVectorize] Use DataLayout::getIndexType instead of i32 for non-constant GEP...
Sander de Smalen [Mon, 6 Feb 2023 11:03:52 +0000 (11:03 +0000)]
[LoopVectorize] Use DataLayout::getIndexType instead of i32 for non-constant GEP indices.

This is specifically relevant for loops that vectorize using a scalable VF,
where the code results in:

  %vscale = call i32 llvm.vscale.i32()
  %vf.part1 = mul i32 %vscale, 4
  %gep = getelementptr  ..., i32 %vf.part1

Which InstCombine then changes into:

  %vscale = call i32 llvm.vscale.i32()
  %vf.part1 = mul i32 %vscale, 4
  %vf.part1.zext = sext i32 %vf.part1 to i64
  %gep = getelementptr  ..., i32 %vf.part1.zext

D143016 tried to remove these extends, but that only works when
the call to llvm.vscale.i32() has a single use. After doing any
kind of CSE on these calls the combine no longer kicks in.

It seems more sensible to ask DataLayout what type to use, rather
than relying on InstCombine to insert the extend and hoping it can
fold it away.

I've only changed this for indices that are not constant, because
I vaguely remember there was a reason for sticking with i32. It
would also mean patching up loads more tests.

Reviewed By: paulwalker-arm

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

20 months ago[clang-tidy] Fix `cppcoreguidelines-init-variables` for invalid vardecl
Sockke [Tue, 7 Feb 2023 11:30:05 +0000 (19:30 +0800)]
[clang-tidy] Fix `cppcoreguidelines-init-variables` for invalid vardecl

https://godbolt.org/z/n4cK4fo3o
The checker missed a check for invalid vardecl and this could cause a false positive.

Reviewed By: carlosgalvezp

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

20 months ago[AArch64][SME2] Add multi-vector frint intrinsics
Kerry McLaughlin [Tue, 7 Feb 2023 11:21:37 +0000 (11:21 +0000)]
[AArch64][SME2] Add multi-vector frint intrinsics

Adds x2 and x4 vector intrinsics for the following instructions:
 - frinta
 - frintm
 - frintn
 - frintp

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

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

20 months ago[ARM] Tests for lane interleaving from reductions. NFC
David Green [Tue, 7 Feb 2023 11:16:11 +0000 (11:16 +0000)]
[ARM] Tests for lane interleaving from reductions. NFC

20 months ago[libc][NFC] Rename compiler_feature macros
Guillaume Chatelet [Tue, 7 Feb 2023 11:05:53 +0000 (11:05 +0000)]
[libc][NFC] Rename compiler_feature macros

20 months ago[libc][NFC] Move sanitizer to macros folder
Guillaume Chatelet [Tue, 7 Feb 2023 10:58:13 +0000 (10:58 +0000)]
[libc][NFC] Move sanitizer to macros folder

20 months ago[AArch64][SME2] Add multi-vector floating point min/max number intrinsics
Kerry McLaughlin [Tue, 7 Feb 2023 10:45:29 +0000 (10:45 +0000)]
[AArch64][SME2] Add multi-vector floating point min/max number intrinsics

Adds IR intrinsics for the following SME2 instructions:
 - fmaxnm/fminnm (single, 2 & 4 vector)
 - fmaxnm/fminnm (multi, 2 & 4 vector)

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

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

20 months ago[NFC][TargetParser] Remove llvm/Support/TargetParser.h
Archibald Elliott [Tue, 7 Feb 2023 11:08:21 +0000 (11:08 +0000)]
[NFC][TargetParser] Remove llvm/Support/TargetParser.h

20 months ago[NFC][TargetParser] Remove llvm/Support/X86TargetParser.h
Archibald Elliott [Fri, 3 Feb 2023 14:38:31 +0000 (14:38 +0000)]
[NFC][TargetParser] Remove llvm/Support/X86TargetParser.h

20 months ago[NFC][TargetParser] Remove llvm/Support/X86TargetParser.def
Archibald Elliott [Fri, 3 Feb 2023 14:37:04 +0000 (14:37 +0000)]
[NFC][TargetParser] Remove llvm/Support/X86TargetParser.def

20 months ago[NFC][TargetParser] Remove llvm/Support/LoongArchTargetParser.h
Archibald Elliott [Fri, 3 Feb 2023 14:35:45 +0000 (14:35 +0000)]
[NFC][TargetParser] Remove llvm/Support/LoongArchTargetParser.h

20 months ago[NFC][TargetParser] Remove llvm/Support/CSKYTargetParser.h
Archibald Elliott [Fri, 3 Feb 2023 14:34:32 +0000 (14:34 +0000)]
[NFC][TargetParser] Remove llvm/Support/CSKYTargetParser.h

20 months ago[NFC][TargetParser] Remove llvm/Support/ARMTargetParserCommon.h
Archibald Elliott [Fri, 3 Feb 2023 14:31:29 +0000 (14:31 +0000)]
[NFC][TargetParser] Remove llvm/Support/ARMTargetParserCommon.h

20 months ago[NFC][TargetParser] Remove llvm/Support/ARMTargetParser.h
Archibald Elliott [Fri, 3 Feb 2023 14:29:12 +0000 (14:29 +0000)]
[NFC][TargetParser] Remove llvm/Support/ARMTargetParser.h

20 months ago[SDAG] Check fminnum/fmaxnum for non-zero operand.
Samuel Parker [Mon, 6 Feb 2023 15:32:52 +0000 (15:32 +0000)]
[SDAG] Check fminnum/fmaxnum for non-zero operand.

Currently, in TargetLowering, if the target does not support fminnum, we lower
to fminimum if neither operand could be a NaN. But this isn't quite correct
because fminnum and fminimum treat +/-0 differently; so, we need to prove that
one of the operands isn't a zero, or we don't have signed zeros.

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

20 months ago[NFC] minnum/maxnum intrinsic tests
Samuel Parker [Tue, 7 Feb 2023 10:45:14 +0000 (10:45 +0000)]
[NFC] minnum/maxnum intrinsic tests

ARM and WebAssembly tests.

20 months ago[ARM] Remove reduce(shuffle) if all the lanes are used
David Green [Tue, 7 Feb 2023 10:44:35 +0000 (10:44 +0000)]
[ARM] Remove reduce(shuffle) if all the lanes are used

This looks for vaddv(shuffle) or vmlav(shuffle, shuffle), with a shuffle where
all the lanes are used once. Due to the reduction being commutative the shuffle
can be removed.

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

20 months ago[libc][NFC] Move compiler_features to macros folder
Guillaume Chatelet [Tue, 7 Feb 2023 10:40:08 +0000 (10:40 +0000)]
[libc][NFC] Move compiler_features to macros folder

20 months ago[mlir][bufferize] Add noAnalysisFuncFilter to OneShotBufferizationOptions struct
Maya Amrami [Mon, 6 Feb 2023 17:13:33 +0000 (19:13 +0200)]
[mlir][bufferize] Add noAnalysisFuncFilter to OneShotBufferizationOptions struct

This change is needed in order to set the flag when running the pass not via the command line.
It also allows simplifying the signature of some functions.

Reviewed By: springerm

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

20 months agoRevert "[DAGCombine] Fold redundant select"
Samuel Parker [Tue, 7 Feb 2023 10:30:39 +0000 (10:30 +0000)]
Revert "[DAGCombine] Fold redundant select"

This reverts commit bbdf24357932b064f2aa18ea1356b474e0220dde.

20 months ago[libc][NFC] Move cpu_features to macros folder
Guillaume Chatelet [Tue, 7 Feb 2023 10:32:03 +0000 (10:32 +0000)]
[libc][NFC] Move cpu_features to macros folder

20 months ago[flang] add -fstack-arrays flag
Tom Eccles [Wed, 4 Jan 2023 13:03:31 +0000 (13:03 +0000)]
[flang] add -fstack-arrays flag

The implementation of -fstack-arrays was added in
https://reviews.llvm.org/D140415

The new macro BoolOptionWithoutMarshalling in Options.td avoids
generating code to store the flags in clang data structures. For
example, writing something like

  defm stack_arrays : BoolOption<"f", "stack-arrays",
                                 CodeGenOpts<"StackArrays">, [...]

Would generate code referring to `clang::CodeGenOpts::StackArrays`, which
does not exist.

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

20 months ago[flang] add a pass to move array temporaries to the stack
Tom Eccles [Fri, 9 Dec 2022 18:07:31 +0000 (18:07 +0000)]
[flang] add a pass to move array temporaries to the stack

This pass implements the `-fstack-arrays` flag. See the RFC in
`flang/docs/fstack-arrays.md` for more information.

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

20 months ago[libc][NFC] Rename architecture macros and move to macros folder
Guillaume Chatelet [Tue, 7 Feb 2023 10:19:12 +0000 (10:19 +0000)]
[libc][NFC] Rename architecture macros and move to macros folder

20 months ago[ARM] Add various tests for reductions of shuffles. NFC
David Green [Tue, 7 Feb 2023 10:06:58 +0000 (10:06 +0000)]
[ARM] Add various tests for reductions of shuffles. NFC

20 months ago[PHITransAddr] Simplify casts in PHITransAddr
Sergey Kachkov [Thu, 2 Feb 2023 10:21:48 +0000 (13:21 +0300)]
[PHITransAddr] Simplify casts in PHITransAddr

Try to simplify cast in similar way as for GEP and ADD with
constant (e.g. sext/zext + trunc).

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

20 months ago[NFC] Add pre-commit test for simplifyCastInst in PHITransAddr
Sergey Kachkov [Fri, 3 Feb 2023 10:19:59 +0000 (13:19 +0300)]
[NFC] Add pre-commit test for simplifyCastInst in PHITransAddr

20 months ago[NFC][clang] Fix static analyzer concern about uninitialized variable
Mariya Podchishchaeva [Tue, 7 Feb 2023 09:25:05 +0000 (04:25 -0500)]
[NFC][clang] Fix static analyzer concern about uninitialized variable

Reviewed By: xazax.hun

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

20 months ago[libc][doc] Update compiler
Guillaume Chatelet [Mon, 6 Feb 2023 13:03:18 +0000 (13:03 +0000)]
[libc][doc] Update compiler

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

20 months ago[Tooling/Inclusion] Move the StdSpecialSymbolMap.inc to the private lib place.
Haojian Wu [Tue, 7 Feb 2023 09:25:48 +0000 (10:25 +0100)]
[Tooling/Inclusion] Move the StdSpecialSymbolMap.inc to the private lib place.

I missed it in c751264aa19865beab12d94db3ea966c6accd428.

20 months ago[libc][doc] Add macros guidelines
Guillaume Chatelet [Mon, 6 Feb 2023 16:46:31 +0000 (16:46 +0000)]
[libc][doc] Add macros guidelines

This is a first follow up on the libc tuning RFC
https://discourse.llvm.org/t/rfc-llvm-libc-tuning/67980

Once we agree on the format. I'll land a couple of patches to match the guidelines.

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

20 months ago[Tooling/Inclusion] Introduce a human-edit file for C++ std symbols
Haojian Wu [Tue, 7 Feb 2023 09:13:45 +0000 (10:13 +0100)]
[Tooling/Inclusion] Introduce a human-edit file for C++ std symbols

This file is allowed to be edit by human, and it overlays the generated symbol file.
It contains a list of multiple-header symbols.
This patch introduces the file only. Usage will come afterwards.

Reviewed By: kadircet

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

20 months ago[Tooling/Inclusion] Move the generated mapping .inc file to private places.
Haojian Wu [Mon, 6 Feb 2023 15:07:20 +0000 (16:07 +0100)]
[Tooling/Inclusion] Move the generated mapping .inc file to private places.

The .inc files are private now, clients should tooling::stdlib APIs instead.

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

20 months ago[flang][hlfir] place scalar in memory in convertToBox/convertToAddress
Jean Perier [Tue, 7 Feb 2023 08:25:31 +0000 (09:25 +0100)]
[flang][hlfir] place scalar in memory in convertToBox/convertToAddress

Implement the TODO. Be careful to use and propagate the expression
type to create the temporary since the mlir value may have been computed
with a different value type (e.g., i1 for logical) that should not be
used for in memory values that must have Fortran types.

Co-authored-by: Tom Eccles <tom.eccles@arm.com>
Differential Revision: https://reviews.llvm.org/D143421

20 months ago[flang][NFC] addSymbol/lookupSymbol clean-up
Jean Perier [Tue, 7 Feb 2023 08:22:47 +0000 (09:22 +0100)]
[flang][NFC] addSymbol/lookupSymbol clean-up

HLFIR requires mapping symbol to a single mlir::Value (produced
by a fir::FortranVariableOpInterface), while the current lowering
maps the value to a fir::ExtdendedValue.

So far, the HLFIR symbol query was a special one. Hence, all the code
directly using symMap.lookupSymbol and symMap.addSymbol did not work
with the lowering to HLFIR.

Refactor the code so that symbol lookup and add symbol go through
the converter in a centralize place that handles the HLFIR case
(translate fir::FortranVariableOpInterface to fir::ExtdendedValue
in lookups, and generate hlfir.declare when adding symbols).

In the refactoring, fir::FortranVariableOpInterface is added as
a symbolBox variant to avoid special casing all lookups (shallowLookup...).

Remove some unused SymbolBox member function instead of updating
them.

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

20 months ago[flang] Use PointerAssociateLowerBounds when there is lower bounds
Valentin Clement [Tue, 7 Feb 2023 08:15:54 +0000 (09:15 +0100)]
[flang] Use PointerAssociateLowerBounds when there is lower bounds

The current code was not taking provided lower bounds when the pointer
is polymorphic and was just calling PointerAssociate. This patch
updates the behavior and use PointerAssociateLowerBounds with the provided
lower bounds.

Reviewed By: jeanPerier

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

20 months ago[cmake] Use LLVM_ENABLE_ASSERTIONS to enable assertions in libstdc++
Jay Foad [Sat, 21 Jan 2023 09:32:50 +0000 (09:32 +0000)]
[cmake] Use LLVM_ENABLE_ASSERTIONS to enable assertions in libstdc++

On my machine this showed no new failures in check-llvm and increased
the testing time from 138 to 142 seconds, for a Release build with
assertions enabled.

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

20 months ago[IR] Fix bug in DemoteRegToStack where DenseMap is not used
riChar [Tue, 7 Feb 2023 07:15:15 +0000 (15:15 +0800)]
[IR] Fix bug in DemoteRegToStack where DenseMap is not used

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

20 months ago[lldb] Fix typo in LoongArch unittest
Weining Lu [Tue, 7 Feb 2023 07:09:04 +0000 (15:09 +0800)]
[lldb] Fix typo in LoongArch unittest

20 months ago[SCEV] Support sext in SCEVLoopGuardRewriter
Max Kazantsev [Tue, 7 Feb 2023 06:09:46 +0000 (13:09 +0700)]
[SCEV] Support sext in SCEVLoopGuardRewriter

There is no particular reason why it's not supported, and it is useful.

Differential Revision: https://reviews.llvm.org/D143257
Reviewed By: fhahn

20 months ago[mlir][linalg] Check for tensor of 0 dims during vectorization
Thomas Raoux [Tue, 7 Feb 2023 06:14:28 +0000 (06:14 +0000)]
[mlir][linalg] Check for tensor of 0 dims during vectorization

tensor with dims of size 0 cannot be vectorized. Add precondition to
prevent a crash in vectorization.

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

20 months ago[C++20] [Modules] Allow ADL in dependent context for modules
Chuanqi Xu [Tue, 7 Feb 2023 05:58:11 +0000 (13:58 +0800)]
[C++20] [Modules] Allow ADL in dependent context for modules

Close https://github.com/llvm/llvm-project/issues/60488.

Previously, when we instantiate a template, the argument dependent
lookup is performed in the context of the instantiation, which implies that the
functions not visible in the context can't be found by the argument
dependent lookup.

But this is not true, according to [module.context]p3, the instantiation
context for the implicit instantiation of a template should contain the
context of the primary module interface if the template is defined in
the module interface unit.

Note that the fix didn't implemnet [module.context]p3 precisely, see the
comments for example.

20 months ago[mlir]: Added IntArrayNthElemMaxValue & IntArrayNthElemInRange predicates (NFC)
Aviad Cohen [Sun, 5 Feb 2023 05:51:45 +0000 (07:51 +0200)]
[mlir]: Added IntArrayNthElemMaxValue & IntArrayNthElemInRange predicates (NFC)

Reviewed By: rriddle

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

20 months ago[SCEV][NFC] Remove check for rewriteable types
Max Kazantsev [Tue, 7 Feb 2023 05:17:24 +0000 (12:17 +0700)]
[SCEV][NFC] Remove check for rewriteable types

I guess its only reason to exist is potential CT optimization, otherwise it is
just creating cohesion between this code and rewriter internals. We plan to
extend the rewriter. I'd rather not have this cohesion, unless there is a serious
reason to have it.

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

20 months ago[DAGCombiner] fix comments for D138899; NFC
Chen Zheng [Tue, 7 Feb 2023 05:31:45 +0000 (00:31 -0500)]
[DAGCombiner] fix comments for D138899; NFC

20 months ago[RISCV] Refactor RISCVDisassembler::getInstruction to remove repeated code. NFC
Craig Topper [Tue, 7 Feb 2023 05:23:21 +0000 (21:23 -0800)]
[RISCV] Refactor RISCVDisassembler::getInstruction to remove repeated code. NFC

For 4 byte instructions we were always setting size to 4 eventually. Same
for 2 byte instructions. So do it as soon as we know the from the opcode.

Add a return to the end of the 4 byte code so we don't have to have an else
around the 2 byte code.

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

20 months ago[libc++][NFC] _VSTD -> std in ryu
Louis Dionne [Tue, 7 Feb 2023 05:08:53 +0000 (21:08 -0800)]
[libc++][NFC] _VSTD -> std in ryu

Those ones are extremely mechanical and since that's not libc++ code
in the first place, there's even more of an incentive to do the rename.

20 months ago[libc++] Add missing _LIBCPP_HIDE_FROM_ABI
Louis Dionne [Tue, 7 Feb 2023 01:33:20 +0000 (17:33 -0800)]
[libc++] Add missing _LIBCPP_HIDE_FROM_ABI

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

20 months agoMIPS: fix build from IR files, nan2008 and FpAbi
YunQiang Su [Tue, 7 Feb 2023 04:36:11 +0000 (20:36 -0800)]
MIPS: fix build from IR files, nan2008 and FpAbi

When we use llc or lld to compiler IR files, the features +nan2008 and +fpxx/+fp64 are not used.
Thus wrong format files are produced.

In IR files, the attributes are only set for function while not the whole compile units.
So we extract the attributes from the first function and use it for the whole unit.

isFPXXDefault: for o32, the FPXX should always be the default, no matter about the vendors.
Of course some distributions with FP64 default enabled should be listed explicit.
Let's add them in future if we know about one.

Reviewed By: MaskRay

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

20 months ago[Instcombine] Precommit tests for D143373; NFC
chenglin.bi [Tue, 7 Feb 2023 04:08:36 +0000 (12:08 +0800)]
[Instcombine] Precommit tests for D143373; NFC

20 months ago[libc++] Fix path to versioned clang-format in the CI job
Louis Dionne [Tue, 7 Feb 2023 03:17:39 +0000 (19:17 -0800)]
[libc++] Fix path to versioned clang-format in the CI job

20 months ago[AArch64][SVE] Fix crash for DestructiveBinaryCommWithRev zero merging
zhongyunde [Tue, 7 Feb 2023 03:09:13 +0000 (11:09 +0800)]
[AArch64][SVE] Fix crash for DestructiveBinaryCommWithRev zero merging

Address more Destructive type according the review on D141471

* DestructiveUnaryPassthru and DestructiveBinaryImm always return true, don't need fix
* DestructiveTernaryCommWithRev may also return false, but now don't define FalseLanesZero in the backend codegen

Reviewed By: paulwalker-arm

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

20 months ago[AArch64][SVE] Replace destructive operand of vector zeros with a bundled MOVPRFX...
zhongyunde [Tue, 7 Feb 2023 02:59:04 +0000 (10:59 +0800)]
[AArch64][SVE] Replace destructive operand of vector zeros with a bundled MOVPRFX instruction

Replace unary instructions where the destructive operand is a vector of zeros
with a bundled MOVPRFX instruction, e.g:
       Transform:
           %X0 = DUP_ZI_S 0, 0
           %X0 = FLOGB_ZPmZ_S X0, P0, X2
        into:
            X0 = MOVPRFX P0/z, X1  // doesn't introduce any fake register dependencies compare to X0 = MOVPRFX P0/z, X0
            X0 = FLOGB_ZPmZ_S X0, P0, X2
NOTE: This patch add a @earlyclobber constraint to PredOneOpPassthruPseudo to ensure
    safe register allocation for movprfx usage.

Depends on D105889

Reviewed By: paulwalker-arm

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

20 months agoRevert "[RISCV] Allow mismatched SmallDataLimit and use Min for conflicting values"
wangpc [Tue, 7 Feb 2023 02:57:45 +0000 (10:57 +0800)]
Revert "[RISCV] Allow mismatched SmallDataLimit and use Min for conflicting values"

This reverts commit 28bd84f55fc087d4aefd3fe5360f8648d1d50980 because
`CodeGen/RISCV/rvv-intrinsics-handcrafted/vlenb.c` hasn't been updated.

20 months ago[libc++] Export CXX and CC env vars in format and documentation CI jobs
Louis Dionne [Tue, 7 Feb 2023 02:59:19 +0000 (18:59 -0800)]
[libc++] Export CXX and CC env vars in format and documentation CI jobs

This is necessary now that the Docker images don't contain unversionned
clang binaries.

20 months ago[BOLT] Reintroduce allow-stripped
Amir Ayupov [Tue, 7 Feb 2023 02:06:54 +0000 (18:06 -0800)]
[BOLT] Reintroduce allow-stripped

Reject stripped binaries as a policy.

The core issue with stripped binaries is that we can't detect the presence
of split functions which require extra handling. Therefore BOLT can't ensure
functional correctness of produced binary if the input stripped binary contains
split functions. Supporting such cases is an interesting problem but it goes
against BOLT's intended goal of achieving peak program performance.

Reviewed By: maksfb

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

20 months ago[BOLT][NFC] Replace anonymous namespace functions with static
Amir Ayupov [Tue, 7 Feb 2023 01:38:20 +0000 (17:38 -0800)]
[BOLT][NFC] Replace anonymous namespace functions with static

Follow LLVM Coding Standards guideline on using anonymous namespaces
(https://llvm.org/docs/CodingStandards.html#anonymous-namespaces)
and use `static` modifier for function definitions.

Reviewed By: #bolt, maksfb

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

20 months ago[libc++][NFC] Remove FP from_chars from the <charconv> synopsis since we don't implem...
Louis Dionne [Tue, 7 Feb 2023 02:00:28 +0000 (18:00 -0800)]
[libc++][NFC] Remove FP from_chars from the <charconv> synopsis since we don't implement it yet

20 months ago[mlir][sparse] fix bug when packing tensor with 32 bit pointer width.
Peiming Liu [Tue, 7 Feb 2023 01:21:10 +0000 (01:21 +0000)]
[mlir][sparse] fix bug when packing tensor with 32 bit pointer width.

Reviewed By: wrengr

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

20 months ago[mlir][py] Fix unused var
Jacques Pienaar [Tue, 7 Feb 2023 01:44:47 +0000 (17:44 -0800)]
[mlir][py] Fix unused var

20 months ago[mlir][NFC] Add omitted operations to Transform dialect's doc
Kohei Yamaguchi [Tue, 7 Feb 2023 01:02:06 +0000 (17:02 -0800)]
[mlir][NFC] Add omitted operations to Transform dialect's doc

Add omitted transform operations, including Affine/MemRef/Vector, to Transform dialect's doc to fix a broken side-bar doc.

Reviewed By: jpienaar

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

20 months ago[mlir][py] Fix infer return type invocation for variadics
Jacques Pienaar [Thu, 2 Feb 2023 20:23:46 +0000 (12:23 -0800)]
[mlir][py] Fix infer return type invocation for variadics

Previously we only allowed the flattened list passed in, but the same
input provided here as to buildGeneric so flatten accordingly. We have
less info here than in buildGeneric so the error is more generic if
unpacking fails.

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

20 months ago[RISCV] Clean up stack-protector-target test
Roland McGrath [Mon, 6 Feb 2023 03:06:23 +0000 (19:06 -0800)]
[RISCV] Clean up stack-protector-target test

Add some missed polish from https://reviews.llvm.org/D143355.

Reviewed By: jrtc27

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

20 months ago[HWASAN] Add unlikely to if in HwasanAllocate.
Kirill Stoimenov [Tue, 7 Feb 2023 00:39:17 +0000 (00:39 +0000)]
[HWASAN] Add unlikely to if in HwasanAllocate.

20 months ago[HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0
Kirill Stoimenov [Tue, 7 Feb 2023 00:34:26 +0000 (00:34 +0000)]
[HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0

This should keep it consistent with LSAN and ASAN,

Reviewed By: vitalybuka, MaskRay

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

20 months ago[libc] Fix typo is processing LIBC_GPU_TEST_ARCHITECTURE.
Siva Chandra Reddy [Tue, 7 Feb 2023 00:17:54 +0000 (00:17 +0000)]
[libc] Fix typo is processing LIBC_GPU_TEST_ARCHITECTURE.

Reviewed By: jhuber6

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

20 months ago[lldb/Plugins] Fix method dispatch bug when using multiple scripted processes
Med Ismail Bennani [Tue, 7 Feb 2023 00:02:51 +0000 (16:02 -0800)]
[lldb/Plugins] Fix method dispatch bug when using multiple scripted processes

This patch should address a bug when a user have multiple scripted
processes in the same debugging session.

In order for the scripted process plugin to be able to call into the
scripted object instance methods to fetch the necessary data to
reconstruct its state, the scripted process plugin calls into a
scripted process interface, that has a reference to the created script
object instance.

However, prior to this patch, we only had a single instance of the
scripted process interface, living the script interpreter. So every time
a new scripted process plugin was created, it would overwrite the script
object instance that was held by the single scripted process interface
in the script interpreter.

That would cause all the method calls made to the scripted process
interface to be dispatched by the last instanciated script object
instance, which is wrong.

In order to prevent that, this patch moves the scripted process
interface reference to be help by the scripted process plugin itself.

rdar://104882562

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
20 months ago[HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0
Kirill Stoimenov [Mon, 6 Feb 2023 23:53:48 +0000 (23:53 +0000)]
[HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0

This should keep it consistent with LSAN and ASAN,

Reviewed By: vitalybuka, MaskRay

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

20 months ago[HWASAN] Fix Metadata::IsAllocatedMetadata::IsAllocated to return true even if the...
Kirill Stoimenov [Mon, 6 Feb 2023 22:41:20 +0000 (22:41 +0000)]
[HWASAN] Fix Metadata::IsAllocatedMetadata::IsAllocated to return true even if the requested size is 0.

Reviewed By: MaskRay

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

20 months ago[RISCV] Allow mismatched SmallDataLimit and use Min for conflicting values
AdityaK [Wed, 1 Feb 2023 20:18:35 +0000 (12:18 -0800)]
[RISCV] Allow mismatched SmallDataLimit and use Min for conflicting values

Authored By: joshua-arch1 (Jun Sha)
Reviewed By: shiva0217, apazos, luismarques, asb, jrtc27, MaskRay
Reviewers: MaskRay, jrtc27

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

This patch is to fix an issue about module linking with LTO.

When compiling with PIE, the small data limitation needs to be consistent with that in PIC, otherwise there will be linking errors due to conflicting values.

bar.c

int bar() { return 1; }
foo.c

int foo() { return 1; }
clang --target=riscv64-unknown-linux-gnu -flto -c foo.c -o foo.o -fPIE
clang --target=riscv64-unknown-linux-gnu -flto -c bar.c -o bar.o -fPIC

clang --target=riscv64-unknown-linux-gnu -flto foo.o bar.o -flto -nostdlib -v -fuse-ld=lld
ld.lld: error: linking module flags 'SmallDataLimit': IDs have conflicting values in 'bar.o' and 'ld-temp.o'
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
What we are trying to do here is to use Min instead of Error for conflicting SmallDataLimit when combining -fno-PIC code with -fPIC code.

Signed-off-by: xiaojing.zhang <xiaojing.zhang@xcalibyte.com>
Signed-off-by: jianxin.lai <jianxin.lai@xcalibyte.com>
20 months ago[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b
Vladislav Dzhidzhoev [Thu, 26 Jan 2023 03:55:27 +0000 (04:55 +0100)]
[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b

Widen element types of vector arguments of G_ADD, G_SUB, G_MUL, G_AND,
G_OR, G_XOR to the minumum supported size, in order to support vectors
of narrow types.

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

20 months agoRevert "[Fuchsia] Simplify Fuchsia stage2 toolchain setup"
Haowei Wu [Mon, 6 Feb 2023 23:00:59 +0000 (15:00 -0800)]
Revert "[Fuchsia] Simplify Fuchsia stage2 toolchain setup"

This reverts commit f9ff49882a65ab26ab347f4df8f2a58368d37185.
Accidentally landed a draft patch.

20 months ago[Fuchsia] Build windows runtimes using cross compilation on Linux
Haowei Wu [Tue, 31 Jan 2023 22:20:50 +0000 (14:20 -0800)]
[Fuchsia] Build windows runtimes using cross compilation on Linux

This patch provides initial support of building Clang runtimes for
Windows when using Fuchsia Clang toolchains under Linux.

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

20 months ago[Fuchsia] Simplify Fuchsia stage2 toolchain setup
Haowei Wu [Mon, 30 Jan 2023 23:43:09 +0000 (15:43 -0800)]
[Fuchsia] Simplify Fuchsia stage2 toolchain setup

WIP

20 months agoIn InitializeZerothFrame check for a CFA/AFA or error out
Jason Molenda [Mon, 6 Feb 2023 22:45:41 +0000 (14:45 -0800)]
In InitializeZerothFrame check for a CFA/AFA or error out

There is a failure where we somehow get an invalid register
number being used to calculate the canonical frame address,
and this ends up with lldb crashing with a null deref because it
assumes that it is always able to find information about that
register.

This patch adds a check for a failure to get a register, and
declares the frame invalid in that case, with some additional
logging or an assert for debug builds.

Differential Revision: https://reviews.llvm.org/D143232
rdar://104428038

20 months agoRevert "[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b"
Vladislav Dzhidzhoev [Mon, 6 Feb 2023 22:45:25 +0000 (23:45 +0100)]
Revert "[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b"

This reverts commit 254e2ad84407fce81f3b0c07e75f23671b8cb56a.
It contains broken test.

20 months ago[MSan] Fix calling pointers to varargs functions on SystemZ
Ilya Leoshkevich [Mon, 6 Feb 2023 22:28:06 +0000 (23:28 +0100)]
[MSan] Fix calling pointers to varargs functions on SystemZ

VarArgSystemZHelper.visitCallBase() checks whether the callee has the
"use-soft-float" attribute, but if the callee is a function pointer, a
null pointer dereference happens.

Fix by checking this attribute on the current function. Alternatively,
one could try the callee first, but this is pointless, since one should
not be mixing hardfloat and softfloat code anyway.

Reviewed By: uweigand

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

20 months ago[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b
Vladislav Dzhidzhoev [Thu, 26 Jan 2023 03:55:27 +0000 (04:55 +0100)]
[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b

Widen element types of vector arguments of G_ADD, G_SUB, G_MUL, G_AND,
G_OR, G_XOR to the minumum supported size, in order to support vectors
of narrow types.

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

20 months ago[llvm-profdata] Fix bug llvm-profdata crashes when reading a text sample profile...
William Huang [Mon, 6 Feb 2023 22:26:10 +0000 (22:26 +0000)]
[llvm-profdata] Fix bug llvm-profdata crashes when reading a text sample profile with an empty line with spaces.

Text editors can introduce spaces aligning the previous line's indentation. This crashes llvm-profdata. Added check to handle this case.

Reviewed By: snehasish

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

20 months ago[randstruct] Don't allow implicit forward decl to stop struct randomization
Bill Wendling [Mon, 6 Feb 2023 22:26:16 +0000 (14:26 -0800)]
[randstruct] Don't allow implicit forward decl to stop struct randomization

If a struct/enum type used in a record doesn't have a forward decl /
def, an implicit one is injected into the struct. This stops clang from
randomizing the structure in some situations---i.e. when the struct
contains only function pointers. So we accept forward decls so they
don't prevent randomization.

Fixes 60349

Reviewed By: MaskRay, nickdesaulniers

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

20 months ago[mlir][vector] add proper verification to vector.print operation
Aart Bik [Mon, 6 Feb 2023 20:48:05 +0000 (12:48 -0800)]
[mlir][vector] add proper verification to vector.print operation

Rationale:
Only proper vectors and scalars of floating-point or integral types
are actually lowered to calls into the light-weight output library.

Reviewed By: ThomasRaoux

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

20 months ago[mlir][sparse] compute allocation size_hint
Aart Bik [Sat, 4 Feb 2023 01:26:04 +0000 (17:26 -0800)]
[mlir][sparse] compute allocation size_hint

This adds the hint to a number of tensor allocations in codegens,
shaving off quite some time from e.g. reading in sparse matrices
due to zero-reallocation scheme. Note that we can probably provide
hints on all allocations, and refine the heuristics that use them
for general tensors.

Reviewed By: bixia

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

20 months ago[mlgo][regalloc] Handle training case when no regalloc happens.
Mircea Trofin [Mon, 6 Feb 2023 01:16:46 +0000 (17:16 -0800)]
[mlgo][regalloc] Handle training case when no regalloc happens.

There's an early-exit case for regalloc when we don't even get a chance
to ask for an advisor (priority or eviction), and switch the context.
Then, when we want to log the reward for that function (==the one with
the early exit case), we hit the error case where the function's name
doesn't match the last-seen context.

There are a few possible fixes, one would be to just switch context when
output-ing the reward, which would be correct. This patch opts for the
alternative where we check any loging happened in the first place - just
to re-validate that no function would have been regaloc-ed without first
log-ing its reward.

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