platform/upstream/llvm.git
23 months ago[mlir:PDL] Add support for DialectConversion with pattern configurations
River Riddle [Thu, 8 Sep 2022 23:59:39 +0000 (16:59 -0700)]
[mlir:PDL] Add support for DialectConversion with pattern configurations

Up until now PDL(L) has not supported dialect conversion because we had no
way of remapping values or integrating with type conversions. This commit
rectifies that by adding a new "pattern configuration" concept to PDL. This
essentially allows for attaching external configurations to patterns, which
can hook into pattern events (for now just the scope of a rewrite, but we
could also pass configs to native rewrites as well). This allows for injecting
the type converter into the conversion pattern rewriter.

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

23 months ago[Test] Fix driverkit-path.c with lib64 dir
Thomas Preud'homme [Sat, 5 Nov 2022 10:07:21 +0000 (10:07 +0000)]
[Test] Fix driverkit-path.c with lib64 dir

Reviewed By: yln

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

23 months ago[AArch64]SME2 MOV Instructions
Caroline Concatto [Wed, 2 Nov 2022 09:36:50 +0000 (09:36 +0000)]
[AArch64]SME2 MOV Instructions

This patch adds the assembly/disassembly for the following instructions:

MOVA (array to vector, four registers): Move four ZA single-vector groups to four vector registers.
     (array to vector, two registers): Move two ZA single-vector groups to two vector registers.
     (tile to vector, four registers): Move four ZA tile slices to four vector registers.
     (tile to vector, single): Move ZA tile slice to vector register.
     (tile to vector, two registers): Move two ZA tile slices to two vector registers.
     (vector to array, four registers): Move four vector registers to four ZA single-vector groups.
     (vector to array, two registers): Move two vector registers to two ZA single-vector groups.
     (vector to tile, four registers): Move four vector registers to four ZA tile slices.
     (vector to tile, single): Move vector register to ZA tile slice.
     (vector to tile, two registers): Move two vector registers to two ZA tile slices.

The reference can be found here:

https://developer.arm.com/documentation/ddi0602/2022-09

It add more sizes for Matrix Operand:
MatrixOp8 and MatrixOp16
two implicit operands uimm0s2range and uimm0s4range.
and  uimm1s2range that are immediates

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

23 months ago[AArch64][SVE2] Add the SVE2.1 FP quadword reduction instructions
David Sherwood [Thu, 3 Nov 2022 11:51:29 +0000 (11:51 +0000)]
[AArch64][SVE2] Add the SVE2.1 FP quadword reduction instructions

This patch adds the assembly/disassembly for the following instructions:

faddqv   : Floating-point add recursive reduction of quadword vector segments
fmaxqv   : Floating-point maximum reduction of quadword vector segments
fmaxnmqv : Floating-point maximum number recursive reduction of quadword vector segments
fminqv   : Floating-point minimum recursive reduction of quadword vector segments
fminnmqv : Floating-point minimum number recursive reduction of quadword vector segments

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

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

23 months ago[clang][pdb] Don't include -fmessage-length in PDB buildinfo
Tobias Hieta [Tue, 8 Nov 2022 08:23:10 +0000 (09:23 +0100)]
[clang][pdb] Don't include -fmessage-length in PDB buildinfo

As discussed in https://reviews.llvm.org/D136474 -fmessage-length
creates problems with reproduciability in the PDB files.

This patch just drops that argument when writing the PDB file.

Reviewed By: hans

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

23 months ago[mlir][vector] Add vector.scalable.insert/extract ops
Javier Setoain [Wed, 15 Jun 2022 13:27:25 +0000 (14:27 +0100)]
[mlir][vector] Add vector.scalable.insert/extract ops

These new operations match the semantics of
llvm.experimental.vector.insert and llvm.experimental.vector.extract.

`vector.scalable.insert` and `vector.scalable.extract` allow,
respectively, insert vectors into scalable vectors, and extract vectors
from scalable vectors.

The discussion about the inclusion of these operations is here:
https://discourse.llvm.org/t/rfc-interfacing-between-fixed-length-and-scalable-vectors-for-vls-vector-code-on-scalable-vector-architectures

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

23 months ago[mlir][llvm] Test LLVM IR constant import separately.
Tobias Gysi [Tue, 8 Nov 2022 08:23:48 +0000 (10:23 +0200)]
[mlir][llvm] Test LLVM IR constant import separately.

The revision moves tests related to LLVM IR constant import
into a separate constant.ll file and adds tests for integer,
null and undef immediates.

Depends on D136679

Reviewed By: ftynse

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

23 months ago[Statepoint] Use default attributes for some GC intrinsics
Nikita Popov [Fri, 28 Oct 2022 09:21:30 +0000 (11:21 +0200)]
[Statepoint] Use default attributes for some GC intrinsics

This adds the default intrinsic attributes (nosync, nofree, nocallback,
willreturn) to the gc.result, gc.relocate, gc.pointer.base and
gc.pointer.offset intrinsics. As far as I understand, all of these
are supposed to be pure. Some quotes from LangRef:

> A gc.result is modeled as a ‘readnone’ pure function. It has no
> side effects since it is just a projection of the return value of
> the previous call represented by the gc.statepoint.

> A gc.relocate is modeled as a readnone pure function. It has no
> side effects since it is just a way to extract information about
> work done during the actual call modeled by the gc.statepoint.

Having willreturn in particular will be important to avoid
optimization regressions in the future.

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

23 months ago[X86] Use default attributes for even more intrinsics
Nikita Popov [Mon, 7 Nov 2022 15:08:15 +0000 (16:08 +0100)]
[X86] Use default attributes for even more intrinsics

Another followup to D136939: This switches readonly X86 intrinsics
to use default attributes (nosync, nofree, nocallback and willreturn).

With this, all readnone/readonly intrinsics should be covered,
only memory writing intrinsics are left.

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

23 months ago[mlir][llvm] Update insertion point handling in LLVM import.
Tobias Gysi [Tue, 8 Nov 2022 07:46:39 +0000 (09:46 +0200)]
[mlir][llvm] Update insertion point handling in LLVM import.

Insert constants and globals in order by maintaining the position
of the constant and global inserted last. Update the tests
to reflect the updated insertion order. Also make sure functions
are always inserted at the end of the module instead of at
the second last position and delete a spurious function in
the intrinsic.ll that seems to exist to avoid the first
function under test ends up at the end of the module.

Reviewed By: ftynse

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

23 months ago[AMDGPU][GlobalISel] Support mad/fma_mix selection
Pierre van Houtryve [Wed, 28 Sep 2022 07:47:35 +0000 (07:47 +0000)]
[AMDGPU][GlobalISel] Support mad/fma_mix selection

Adds support for selecting the following instructions using GlobalISel:
- v_mad_mix/v_fma_mix
- v_mad_mixhi/v_fma_mixhi
- v_mad_mixlo/v_fma_mixlo

To select those instructions properly, some additional changes were
needed which impacted other tests as well.

Reviewed By: arsenm

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

23 months ago[NFC] [C++20] [Modules] Rename ASTWriter::isWritingStdCXXNamedModules
Chuanqi Xu [Tue, 8 Nov 2022 07:53:08 +0000 (15:53 +0800)]
[NFC] [C++20] [Modules] Rename ASTWriter::isWritingStdCXXNamedModules

According to the discussion in
https://discourse.llvm.org/t/rfc-unifying-the-terminology-about-modules-in-clang/66054,
this patch rename ASTWriter::isWritingNamedModules to ASTWriter::isWrittingStdCXXNamedModules
to make the name more clear.

23 months ago[AMDGPU] Add & use `hasNamedOperand`, NFC
Pierre van Houtryve [Mon, 7 Nov 2022 11:54:18 +0000 (11:54 +0000)]
[AMDGPU] Add & use `hasNamedOperand`, NFC

In a lot of places, we were just calling `getNamedOperandIdx` to check if the result was != or == to -1.
This is fine in itself, but it's verbose and doesn't make the intention clear, IMHO. I added a `hasNamedOperand` and replaced all cases I could find with regexes and manually.

Reviewed By: arsenm, foad

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

23 months ago[SIFoldOperands] Small code cleanups, NFC.
Pierre van Houtryve [Mon, 7 Nov 2022 11:32:44 +0000 (11:32 +0000)]
[SIFoldOperands] Small code cleanups, NFC.

I've been trying to understand the backend better and decided to read the code of this pass.
While doing so, I noticed parts that could be refactored to be a tiny bit clearer.
I tried to keep the changes minimal, a non-exhaustive list of changes is:
- Stylistic changes to better fit LLVM's coding style
- Removing dead/useless functions (e.g. FoldCandidate had getters, but it's a public struct!)
 - Saving regs/opcodes in variables if they're going to be used multiple times in the same condition

Reviewed By: arsenm, foad

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

23 months ago[Driver] Add -fsample-profile-use-profi
haoyuintel [Tue, 8 Nov 2022 06:51:14 +0000 (14:51 +0800)]
[Driver] Add -fsample-profile-use-profi

This patch enable `-sample-profile-use-profi` in Clang frontend as user-facing
feature. By using this patch, we can use the cflag of `-fsample-profile-use-profi`
instead of `-mllvm -sample-profile-use-profi`.

Reviewed By: hans, MaskRay

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

23 months ago[SIFoldOperands] Move `isFoldableCopy` into a separate helper, NFC.
Pierre van Houtryve [Mon, 7 Nov 2022 11:33:43 +0000 (11:33 +0000)]
[SIFoldOperands] Move `isFoldableCopy` into a separate helper, NFC.

There was quite a bit of logic there that was just in the middle of core loop. I think it makes it easier to follow when it's split off in a separate helper like the others.

Reviewed By: arsenm

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

23 months ago[X86] Add In64BitMode predicates for LOCK_INC64m, LOCK_DEC64m
Haohai Wen [Tue, 8 Nov 2022 06:04:10 +0000 (14:04 +0800)]
[X86] Add In64BitMode predicates for LOCK_INC64m, LOCK_DEC64m

These two instructions are only encodable in 64bit mode.

Reviewed By: pengfei

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

23 months ago[SimpleLoopUnswitch] Skip trivial selects in guards conditions unswitch candidates
Dmitry Makogon [Wed, 2 Nov 2022 12:44:22 +0000 (19:44 +0700)]
[SimpleLoopUnswitch] Skip trivial selects in guards conditions unswitch candidates

We do this for conditional branches, but not for guards for some reason.

Fixes pr58666.

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

23 months ago[Docs] Add my Office Hours
Paulo Matos [Tue, 8 Nov 2022 05:59:48 +0000 (21:59 -0800)]
[Docs] Add my Office Hours

23 months agoInstCombine: Fold fdiv nnan x, 0 -> copysign(inf, x)
Matt Arsenault [Mon, 17 Oct 2022 05:49:30 +0000 (22:49 -0700)]
InstCombine: Fold fdiv nnan x, 0 -> copysign(inf, x)

https://alive2.llvm.org/ce/z/gLBFKB

23 months ago[PowerPC][NFC] remove the rop-protect attribute in LIT cases.
Chen Zheng [Tue, 8 Nov 2022 05:43:06 +0000 (05:43 +0000)]
[PowerPC][NFC] remove the rop-protect attribute in LIT cases.

This flag will cause LLC warning:

"'-rop-protection' is not a recognized feature for this target
(ignoring feature)"

Remove this unused feature first. We may also need to check why
llc emits this warning as we declare '-rop-protection' not
'+rop-protection'.

23 months agollvm-reduce: Try to turn calls into something else
Matt Arsenault [Sat, 22 Oct 2022 17:05:54 +0000 (10:05 -0700)]
llvm-reduce: Try to turn calls into something else

Try to turn calls that look like operators into known
intrinsics. Also try to turn calls that look like a load or
a store into a load or store.

23 months ago[SLP][NFC] Restructure areTwoInsertFromSameBuildVector
skc7 [Mon, 7 Nov 2022 16:36:12 +0000 (22:06 +0530)]
[SLP][NFC] Restructure areTwoInsertFromSameBuildVector

Reviewed By: ABataev

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

23 months ago[mlir][arith] Convert fastmath to LLVM dialect for some arith ops.
Slava Zakharin [Tue, 8 Nov 2022 03:38:36 +0000 (19:38 -0800)]
[mlir][arith] Convert fastmath to LLVM dialect for some arith ops.

This is a follow-up on D126305 and D136225.
We can now preserve fastmath for arith::MaxFOp,MinFOp,RemFOp during
ArithToLLVM conversion.

Reviewed By: rriddle

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

23 months ago[lldb] Fix issue with re.Pattern availability
Dave Lee [Mon, 7 Nov 2022 21:20:48 +0000 (13:20 -0800)]
[lldb] Fix issue with re.Pattern availability

`re.Pattern` is introduced in Python 3.7. To support Python 3.6, fallback to typechecking against `SRE_Pattern`.

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

23 months agoMIPS/compiler_rt: use synci to flush icache on r6
YunQiang Su [Tue, 8 Nov 2022 01:43:41 +0000 (17:43 -0800)]
MIPS/compiler_rt: use synci to flush icache on r6

syscall makes it failed to build on mips64 for mipsel:
```
compiler-rt/lib/builtins/clear_cache.c:97:3: error:
call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  syscall(__NR_cacheflush, start, (end_int - start_int), BCACHE);
```

In this patch, we use `rdhwr` to get synci_step.
If synci_step is zero, it means that the hardware will maintain the coherence. We need to do nothing.
Then for r6+, `synci` is required to keep icache global.
So we can use `synci` to flush icache.
The ISA documents ask a `sync` and a `jr.hb` after `synci`.

For pre-r6, we can use cacheflush libc function, which is same on Linux and FreeBSD.

Reviewed By: MaskRay

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

23 months ago[CMake] Fix -Wstrict-prototypes
Sam James [Tue, 8 Nov 2022 01:36:43 +0000 (01:36 +0000)]
[CMake] Fix -Wstrict-prototypes

Fixes warnings (or errors, if someone injects -Werror in their build system,
which happens in fact with some folks vendoring LLVM too) with Clang 16:
```
+/var/tmp/portage.notmp/portage/sys-devel/llvm-15.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: warning: a function declaration without a prototype
is deprecated in all versions of C [-Wstrict-prototypes]
-/var/tmp/portage.notmp/portage/sys-devel/llvm-14.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: error: a function declaration without a prototype is
deprecated in all versions of C [-Werror,-Wstrict-prototypes]
 int main() {return 0;}
         ^
          void
```

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

23 months ago[flang] Add atomic_xor to list of intrinsics
Katherine Rasmussen [Tue, 1 Nov 2022 21:14:08 +0000 (14:14 -0700)]
[flang] Add atomic_xor to list of intrinsics

Add the atomic subroutine, atomic_xor, to the list of
intrinsic subroutines, add its last dummy argument to a check
for a coindexed-object, and update test.

Reviewed By: PeteSteinfeld

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

23 months ago[Debuginfod] DEBUGINFOD_HEADERS_FILE environment variable
Daniel Thornburgh [Tue, 18 Oct 2022 22:20:49 +0000 (15:20 -0700)]
[Debuginfod] DEBUGINFOD_HEADERS_FILE environment variable

This change adds a DEBUGINFOD_HEADERS_FILE environment variable provides
a file containing HTTP headers to attach to outgoing HTTP requests, one
per line. This allows a file permissioned with OS access control
mechanisms to supply bearer credentials for Debuginfod requests.

This matches the mechanism recently added to elfutils' libdebuginfod.

Reviewed By: MaskRay

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

23 months ago[mlir][spirv] Don't return value when cannot fold spirv.bitcast
Lei Zhang [Tue, 8 Nov 2022 00:11:46 +0000 (19:11 -0500)]
[mlir][spirv] Don't return value when cannot fold spirv.bitcast

Returing a value would make the canonicalization infrastructure
think that folding succeeded so the pattern will be tried again
when invoked via, e.g., `applyPatternsAndFoldGreedily` and
eventually fail due to not converging after 10 times by default.

Reviewed By: hanchung

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

23 months ago[gn build] Port 428ac8f3a0f9
LLVM GN Syncbot [Mon, 7 Nov 2022 23:22:09 +0000 (23:22 +0000)]
[gn build] Port 428ac8f3a0f9

23 months agoRevert "[NFC] Move getDebugValueLoc from static in Local.cpp to DebugInfo.h"
Shubham Sandeep Rastogi [Mon, 7 Nov 2022 23:18:20 +0000 (15:18 -0800)]
Revert "[NFC] Move getDebugValueLoc from static in Local.cpp to DebugInfo.h"

This reverts commit 80378a4ca725eeeae940b99220b3913f7b73c895.

    I am reverting this patch because I need to revert 171f7024cc82e8702abebdedb699d37b50574be7 and without reverting this patch, reverting 171f7024cc82e8702abebdedb699d37b50574be7 causes conflicts.

     Patch 171f7024cc82e8702abebdedb699d37b50574be7 introduced a cyclic dependancy in the module build.

        https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48197/consoleFull#-69937453049ba4694-19c4-4d7e-bec5-911270d8a58c

        In file included from <module-includes>:1:
        /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/IR/Argument.h:18:10: fatal error: cyclic dependency in module 'LLVM_IR': LLVM_IR -> LLVM_intrinsic_gen -> LLVM_IR
                 ^
        While building module 'LLVM_MC' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:
        While building module 'LLVM_IR' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCPseudoProbe.h:57:
        In file included from <module-includes>:12:
        /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/IR/DebugInfo.h:24:10: fatal error: could not build module 'LLVM_intrinsic_gen'
         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
        While building module 'LLVM_MC' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:
        In file included from <module-includes>:15:
        In file included from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCContext.h:23:
        /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCPseudoProbe.h:57:10: fatal error: could not build module 'LLVM_IR'
         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
        /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:10: fatal error: could not build module 'LLVM_MC'
         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
        4 errors generated.

23 months ago[mlir:SubElementInterfaces] Remove unnecessary static check
River Riddle [Mon, 7 Nov 2022 23:13:09 +0000 (15:13 -0800)]
[mlir:SubElementInterfaces] Remove unnecessary static check

We already constrain the template on just attributes/types.

23 months agoRevert "[Assignment Tracking][5/*] Add core infrastructure for instruction reference"
Shubham Sandeep Rastogi [Mon, 7 Nov 2022 23:04:16 +0000 (15:04 -0800)]
Revert "[Assignment Tracking][5/*] Add core infrastructure for instruction reference"

This reverts commit 171f7024cc82e8702abebdedb699d37b50574be7.

Reverting this patch because it causes a cyclic dependency in the module build

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48197/consoleFull#-69937453049ba4694-19c4-4d7e-bec5-911270d8a58c

In file included from <module-includes>:1:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/IR/Argument.h:18:10: fatal error: cyclic dependency in module 'LLVM_IR': LLVM_IR -> LLVM_intrinsic_gen -> LLVM_IR
         ^
While building module 'LLVM_MC' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:
While building module 'LLVM_IR' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCPseudoProbe.h:57:
In file included from <module-includes>:12:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/IR/DebugInfo.h:24:10: fatal error: could not build module 'LLVM_intrinsic_gen'
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
While building module 'LLVM_MC' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:
In file included from <module-includes>:15:
In file included from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCContext.h:23:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCPseudoProbe.h:57:10: fatal error: could not build module 'LLVM_IR'
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:10: fatal error: could not build module 'LLVM_MC'
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.

23 months agoRevert "Fix warning: comparison of integers of different signs"
Shubham Sandeep Rastogi [Mon, 7 Nov 2022 22:59:03 +0000 (14:59 -0800)]
Revert "Fix warning: comparison of integers of different signs"

This reverts commit 028df7fab11bd8c26d8f5689e049186eb8b39092.

I am reverting this patch because I need to revert 171f7024cc82e8702abebdedb699d37b50574be7 and without reverting this patch, reverting 171f7024cc82e8702abebdedb699d37b50574be7 causes conflicts.

 Patch 171f7024cc82e8702abebdedb699d37b50574be7 introduced a cyclic dependancy in the module build.

    https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48197/consoleFull#-69937453049ba4694-19c4-4d7e-bec5-911270d8a58c

    In file included from <module-includes>:1:
    /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/IR/Argument.h:18:10: fatal error: cyclic dependency in module 'LLVM_IR': LLVM_IR -> LLVM_intrinsic_gen -> LLVM_IR
             ^
    While building module 'LLVM_MC' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:
    While building module 'LLVM_IR' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCPseudoProbe.h:57:
    In file included from <module-includes>:12:
    /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/IR/DebugInfo.h:24:10: fatal error: could not build module 'LLVM_intrinsic_gen'
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
    While building module 'LLVM_MC' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:
    In file included from <module-includes>:15:
    In file included from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCContext.h:23:
    /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCPseudoProbe.h:57:10: fatal error: could not build module 'LLVM_IR'
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
    /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:10: fatal error: could not build module 'LLVM_MC'
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
    4 errors generated.

23 months agoRevert "[Assignment Tracking][5.1/*] Add deleteAssignmentMarkers function"
Shubham Sandeep Rastogi [Mon, 7 Nov 2022 22:57:43 +0000 (14:57 -0800)]
Revert "[Assignment Tracking][5.1/*] Add deleteAssignmentMarkers function"

This reverts commit 4c44fa1c3829c2d0c6ce10b576dafbc2e0631d47.

This patch has to be reverted because I need to revert 171f7024cc82e8702abebdedb699d37b50574be7 and without reverting this patch, reverting 171f7024cc82e8702abebdedb699d37b50574be7 causes conflicts.

Patch 171f7024cc82e8702abebdedb699d37b50574be7 introduced a cyclic dependency in the module build.

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48197/consoleFull#-69937453049ba4694-19c4-4d7e-bec5-911270d8a58c

In file included from <module-includes>:1:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/IR/Argument.h:18:10: fatal error: cyclic dependency in module 'LLVM_IR': LLVM_IR -> LLVM_intrinsic_gen -> LLVM_IR
         ^
While building module 'LLVM_MC' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:
While building module 'LLVM_IR' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCPseudoProbe.h:57:
In file included from <module-includes>:12:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/IR/DebugInfo.h:24:10: fatal error: could not build module 'LLVM_intrinsic_gen'
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
While building module 'LLVM_MC' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:
In file included from <module-includes>:15:
In file included from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCContext.h:23:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/MC/MCPseudoProbe.h:57:10: fatal error: could not build module 'LLVM_IR'
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/lib/MC/MCAsmInfoCOFF.cpp:14:10: fatal error: could not build module 'LLVM_MC'
 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.

23 months ago[Clang][Sema] Add -Wincompatible-function-pointer-types-strict
Sami Tolvanen [Mon, 7 Nov 2022 22:55:24 +0000 (22:55 +0000)]
[Clang][Sema] Add -Wincompatible-function-pointer-types-strict

Clang supports indirect call Control-Flow Integrity (CFI) sanitizers
(e.g. -fsanitize=cfi-icall), which enforce an exact type match
between a function pointer and the target function. Unfortunately,
Clang doesn't provide diagnostics that help developers avoid
function pointer assignments that can lead to runtime CFI
failures. -Wincompatible-function-pointer-types doesn't warn about
enum to integer mismatches if the types are otherwise compatible, for
example, which isn't sufficient with CFI.

Add -Wincompatible-function-pointer-types-strict, which checks for a
stricter function type compatibility in assignments and helps warn about
assignments that can potentially lead to CFI failures.

Reviewed By: aaron.ballman, nickdesaulniers

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

23 months ago[Clang][AArch64][Darwin] Enable GlobalISel by default for Darwin ARM64 platforms.
Amara Emerson [Wed, 2 Nov 2022 16:25:59 +0000 (09:25 -0700)]
[Clang][AArch64][Darwin] Enable GlobalISel by default for Darwin ARM64 platforms.

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

23 months ago[clangd] Rename QueryDriverDatabase.cpp to SystemIncludeExtractor.cpp
Nathan Ridge [Fri, 4 Nov 2022 08:39:46 +0000 (04:39 -0400)]
[clangd] Rename QueryDriverDatabase.cpp to SystemIncludeExtractor.cpp

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

23 months ago[clangd] Perform system include extraction inside CommandMangler
Nathan Ridge [Mon, 12 Sep 2022 08:29:29 +0000 (04:29 -0400)]
[clangd] Perform system include extraction inside CommandMangler

It needs to run after edits from config files are applied to
the compile command (because the config file may specify the
compiler), and before resolveDriver() runs at the end of
CommandMangler.

As part of this change, QueryDriverDatabase is renamed to
SystemIncludeExtractor and is no longer a GlobalCompilationDatabase.

Fixes https://github.com/clangd/clangd/issues/1089
Fixes https://github.com/clangd/clangd/issues/1173
Fixes https://github.com/clangd/clangd/issues/1263

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

23 months ago[clangd] Pass the entire tooling::CompileCommand to CommandMangler
Nathan Ridge [Sun, 25 Sep 2022 08:07:58 +0000 (01:07 -0700)]
[clangd] Pass the entire tooling::CompileCommand to CommandMangler

This gives CommandMangler access to other fields of
tooling::CompileCommand as well, e.g. Directory.

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

23 months ago[lld-macho] Ensure that chained fixups data comes first in __LINKEDIT
Daniel Bertalan [Sat, 5 Nov 2022 15:29:11 +0000 (16:29 +0100)]
[lld-macho] Ensure that chained fixups data comes first in __LINKEDIT

libstuff-based tools (e.g. `codesign` and `strip`) require
`__chainfixups` to be the first section in `__LINKEDIT`, and print a
"file not in an order that can be processed" error message if that is
not the case.

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

23 months ago[libomp] Add -Wl,--undefined-version workaround
Fangrui Song [Mon, 7 Nov 2022 22:15:28 +0000 (22:15 +0000)]
[libomp] Add -Wl,--undefined-version workaround

Issue #58858: when linking libomp.so, exports_so.txt has non-existent/undefined
symbols which cause errors to ld --no-undefined-version. Use
-Wl,--undefined-version if available (gold, ld.lld, future GNU ld 2.40).

23 months ago[LLD] Enable --no-undefined-version by default.
Dan Albert [Thu, 6 Oct 2022 22:22:55 +0000 (15:22 -0700)]
[LLD] Enable --no-undefined-version by default.

Allowing incorrect version scripts is not a helpful default. Flip that
to help users find their bugs at build time rather than at run time.

Reviewed By: MaskRay

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

23 months ago[libc][obvious] fix tests using wrong size for string
Michael Jones [Mon, 7 Nov 2022 22:02:32 +0000 (14:02 -0800)]
[libc][obvious] fix tests using wrong size for string

In the code
const char *str = "abc"
if you do sizeof(str) you get the size of the pointer, not the string.
This patch fixes that mistake.

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

23 months ago[HLSL] Added HLSL this as a reference
Grace Jennings [Mon, 7 Nov 2022 21:16:54 +0000 (13:16 -0800)]
[HLSL] Added HLSL this as a reference

This change makes `this` a reference instead of a pointer in
HLSL. HLSL does not have the `->` operator, and accesses through `this`
are with the `.` syntax.

Tests were added and altered to make sure
the AST accurately reflects the types.

Reviewed By: aaron.ballman

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

23 months ago[libc] add scanf string converters
Michael Jones [Thu, 3 Nov 2022 21:22:34 +0000 (14:22 -0700)]
[libc] add scanf string converters

This patch adds the basic conversion facilities to scanf as well as unit
tests for them. It also adds scanf_main which will be used for the
eventual scanf entrypoints.

Reviewed By: sivachandra

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

23 months ago[libc] add scanf reader
Michael Jones [Wed, 19 Oct 2022 20:33:05 +0000 (13:33 -0700)]
[libc] add scanf reader

This is the interface that will be used to read from a file or string in
scanf. This patch also adds the string and file implementations of the
reader, although the file reader is not yet complete since ungetc has
not yet been implemented.

Reviewed By: sivachandra

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

23 months ago[libc] Add implementation of getc, getc_unlocked and fgetc_unlocked.
Siva Chandra Reddy [Sun, 6 Nov 2022 06:25:15 +0000 (06:25 +0000)]
[libc] Add implementation of getc, getc_unlocked and fgetc_unlocked.

Reviewed By: michaelrj

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

23 months ago[mlir][sparse] extend foreach operation to accept reduction arguments; fix sparse...
Peiming Liu [Fri, 4 Nov 2022 17:52:21 +0000 (17:52 +0000)]
[mlir][sparse] extend foreach operation to accept reduction arguments; fix sparse tensor rewriting patterns that do not propagate sparse tensor SSA properly.

This patch re-commit D137468 and D137463, which were reverted by mistakes.

Reviewed By: aartbik

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

23 months ago[libc] Add implementations of ftell.
Siva Chandra Reddy [Fri, 4 Nov 2022 05:42:49 +0000 (05:42 +0000)]
[libc] Add implementations of ftell.

Reviewed By: michaelrj, lntue

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

23 months agoFix MLIR doc build
Mehdi Amini [Mon, 7 Nov 2022 21:26:21 +0000 (21:26 +0000)]
Fix MLIR doc build

23 months agoApply clang-tidy fixes for performance-unnecessary-value-param in LinalgOps.cpp ...
Mehdi Amini [Thu, 3 Nov 2022 20:12:14 +0000 (20:12 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in LinalgOps.cpp (NFC)

23 months agoApply clang-tidy fixes for performance-move-const-arg in IndexOps.cpp (NFC)
Mehdi Amini [Thu, 3 Nov 2022 20:10:11 +0000 (20:10 +0000)]
Apply clang-tidy fixes for performance-move-const-arg in IndexOps.cpp (NFC)

23 months ago[NFC] clang-format part of TypePrinter.cpp
Arthur Eubanks [Mon, 7 Nov 2022 21:20:09 +0000 (13:20 -0800)]
[NFC] clang-format part of TypePrinter.cpp

Fixes weird clang-format indentation with an upcoming patch.

23 months agoExplicitly initialize opaque pointer mode in CodeGenAction
Matthias Braun [Fri, 4 Nov 2022 23:19:18 +0000 (16:19 -0700)]
Explicitly initialize opaque pointer mode in CodeGenAction

Explicitly call `LLVMContext::setOpaquePointers` in `CodeGenAction`
before loading any IR files. With this we use the mode specified on the
command-line rather than lazily initializing it based on the contents of
the IR.

This helps when using `-fthinlto-index` which may end up mixing files
with typed and opaque pointer types which fails when the first file
happened to use typed pointers since we cannot downgrade IR with opaque
pointer types to typed pointer types.

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

23 months ago[bazel][mlir] NVGPUToNVVM fixes for 708185f03ff
Emilio Cota [Mon, 7 Nov 2022 19:21:06 +0000 (14:21 -0500)]
[bazel][mlir] NVGPUToNVVM fixes for 708185f03ff

23 months ago[NFC] Comment in MLInlineAdvisor as to why use std::map for FPICache
Mircea Trofin [Mon, 7 Nov 2022 19:10:58 +0000 (11:10 -0800)]
[NFC] Comment in MLInlineAdvisor as to why use  std::map for FPICache

23 months ago[libc][obvious] fix printf failing to stop on %\0
Michael Jones [Thu, 3 Nov 2022 22:21:30 +0000 (15:21 -0700)]
[libc][obvious] fix printf failing to stop on %\0

Previously, the printf parser would treat "%\0" as a conversion with the
name "\0", and advance past the null byte causing a buffer overflow.
This patch corrects that in both printf and scanf.

Reviewed By: sivachandra

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

23 months agoAMDGPU: Fix DivergenceAnalysis for llvm.read_register
Matt Arsenault [Mon, 31 Oct 2022 23:49:43 +0000 (16:49 -0700)]
AMDGPU: Fix DivergenceAnalysis for llvm.read_register

This was treating all calls as uniform by default, which
is wrong if used to read a VGPR.

23 months ago[NFC][lldb] Remove unnecessary branch in TypeSystemClang::DumpTypeDescription()
Arthur Eubanks [Fri, 4 Nov 2022 21:02:11 +0000 (14:02 -0700)]
[NFC][lldb] Remove unnecessary branch in TypeSystemClang::DumpTypeDescription()

Reviewed By: Michael137

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

23 months ago[clang][NFC] Use c++17 style variable type traits
Nathan James [Mon, 7 Nov 2022 18:25:46 +0000 (18:25 +0000)]
[clang][NFC] Use c++17 style variable type traits

This was done as a test for D137302 and it makes sense to push these changes

Reviewed By: shafik

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

23 months ago[LTO] Make local linkage GlobalValue in non-prevailing COMDAT available_externally
Fangrui Song [Mon, 7 Nov 2022 18:07:10 +0000 (10:07 -0800)]
[LTO] Make local linkage GlobalValue in non-prevailing COMDAT available_externally

For a local linkage GlobalObject in a non-prevailing COMDAT, it remains defined while its
leader has been made available_externally. This violates the COMDAT rule that
its members must be retained or discarded as a unit.

To fix this, update the regular LTO change D34803 to track local linkage
GlobalValues, and port the code to ThinLTO (GlobalAliases are not handled.)

This fixes two problems.

(a) `__cxx_global_var_init` in a non-prevailing COMDAT group used to
linger around (unreferenced, hence benign), and is now correctly discarded.
```
int foo();
inline int v = foo();
```

(b) Fix https://github.com/llvm/llvm-project/issues/58215:
as a size optimization, we place private `__profd_` in a COMDAT with a
`__profc_` key. When FuncImport.cpp makes `__profc_` available_externally due to
a non-prevailing COMDAT, `__profd_` incorrectly remains private. This change
makes the `__profd_` available_externally.

```
cat > c.h <<'eof'
extern void bar();
inline __attribute__((noinline)) void foo() {}
eof
cat > m1.cc <<'eof'
#include "c.h"
int main() {
  bar();
  foo();
}
eof
cat > m2.cc <<'eof'
#include "c.h"
__attribute__((noinline)) void bar() {
  foo();
}
eof

clang -O2 -fprofile-generate=./t m1.cc m2.cc -flto -fuse-ld=lld -o t_gen
rm -fr t && ./t_gen && llvm-profdata show -function=foo t/default_*.profraw

clang -O2 -fprofile-generate=./t m1.cc m2.cc -flto=thin -fuse-ld=lld -o t_gen
rm -fr t && ./t_gen && llvm-profdata show -function=foo t/default_*.profraw
```

If a GlobalAlias references a GlobalValue which is just changed to
available_externally, change the GlobalAlias as well (e.g. C5/D5 comdats due to
cc1 -mconstructor-aliases). The GlobalAlias may be referenced by other
available_externally functions, so it cannot easily be removed.

Depends on D137441: we use available_externally to mark a GlobalAlias in a
non-prevailing COMDAT, similar to how we handle GlobalVariable/Function.
GlobalAlias may refer to a ConstantExpr, not changing GlobalAlias to
GlobalVariable gives flexibility for future extensions (the use case is niche.
For simplicity we don't handle it yet). In addition, available_externally
GlobalAlias is the most straightforward implementation and retains the aliasee
information to help optimizers.

Reviewed By: tejohnson

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

23 months ago[mlir][sparse] support parallel for/reduction in sparsification.
Peiming Liu [Mon, 7 Nov 2022 17:10:01 +0000 (17:10 +0000)]
[mlir][sparse] support parallel for/reduction in sparsification.

This patch fix the re-revert D135927 (which caused a windows build failure) to re-enable parallel for/reduction. It also fix a warning caused by D137442.

Reviewed By: aartbik

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

23 months ago[mlir] Fix a warning (NFC)
Kazu Hirata [Mon, 7 Nov 2022 17:54:10 +0000 (09:54 -0800)]
[mlir] Fix a warning (NFC)

This patch fixes:

  mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp:717:48:
  error: comparison of integers of different signs: 'int64_t' (aka
  'long') and 'uint64_t' (aka 'unsigned long')
  [-Werror,-Wsign-compare]

23 months ago[mlir] Lower async.func with async.coro and async.runtime operations
yijiagu [Mon, 7 Nov 2022 17:47:53 +0000 (09:47 -0800)]
[mlir] Lower async.func with async.coro and async.runtime operations

Lower async.func with async.coro and async.runtime operations

- This patch modifies AsyncToAsyncRuntime pass to add lowering async.func ops with coroutine cfg.
Example:

```
async.func @foo() -> !async.value<f32> {
  %cst = arith.constant 42.0 : f32
  return %cst: f32
}
```

After lowering:

```
func.func @foo() -> !async.value<f32> attributes {passthrough = ["presplitcoroutine"]} {
    %0 = async.runtime.create : !async.value<f32>
    %1 = async.coro.id
    %2 = async.coro.begin %1
    cf.br ^bb1
  ^bb1:  // pred: ^bb0
    %cst = arith.constant 4.200000e+01 : f32
    async.runtime.store %cst, %0 : <f32>
    async.runtime.set_available %0 : !async.value<f32>
    cf.br ^bb2
  ^bb2:  // pred: ^bb1
    async.coro.free %1, %2
    cf.br ^bb3
  ^bb3:  // pred: ^bb2
    async.coro.end %2
    return %0 : !async.value<f32>
}
```

Reviewed By: ezhulenev

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

23 months ago[AMDGPU] Merge GlobalISel tests into SelectionDAG tests. NFC.
Jay Foad [Mon, 7 Nov 2022 07:36:11 +0000 (07:36 +0000)]
[AMDGPU] Merge GlobalISel tests into SelectionDAG tests. NFC.

Remove GlobalISel test files that only contained RUN lines running the
code from the SelectionDAG version of the same test.

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

23 months agoRevert "[mlir][sparse] extend foreach operation to accept reduction arguments."
Stella Stamenova [Mon, 7 Nov 2022 17:34:10 +0000 (09:34 -0800)]
Revert "[mlir][sparse] extend foreach operation to accept reduction arguments."

This reverts commit 53d5d3401120f2aa741a73a5a9ba0ce012ca532c.

This is causing a build failure on the windows mlir bot that was previously hidden by another sparse tensor change that caused failures:

https://lab.llvm.org/buildbot/#/builders/13/builds/28006

23 months ago[lld] Check errors from expanding response files
Hans Wennborg [Sat, 5 Nov 2022 03:37:45 +0000 (04:37 +0100)]
[lld] Check errors from expanding response files

Previously the response file expansion code would print the error, but
lld would not exit, which was odd.

lld does response file expansion in the different drivers, but it's also
done in main() first, so it's enough to check there.

By checking for these errors we would have caught when D136090
introduced a bug that made lld print errors for response files which
contained "-rpath @foo".

Differental revision: https://reviews.llvm.org/D137477

23 months agoUse double hashes for non-run/check lines in lld/test/ELF/basic.s
Hans Wennborg [Mon, 7 Nov 2022 17:22:05 +0000 (18:22 +0100)]
Use double hashes for non-run/check lines in lld/test/ELF/basic.s

23 months ago[flang] Configure FirOpBuilder based on math driver options.
Slava Zakharin [Mon, 7 Nov 2022 17:05:27 +0000 (09:05 -0800)]
[flang] Configure FirOpBuilder based on math driver options.

Added MathOptionsBase to share fastmath config between different
components. Frontend driver translates LangOptions into MathOptionsBase.
FirConverter configures FirOpBuilder using MathOptionsBase
config passed to it via LoweringOptions.

Depends on D137390

Reviewed By: jeanPerier

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

23 months ago[flang] Allow fir.class as fir.save_result operand #0
Valentin Clement [Mon, 7 Nov 2022 17:23:22 +0000 (18:23 +0100)]
[flang] Allow fir.class as fir.save_result operand #0

Reviewed By: jeanPerier, PeteSteinfeld

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

23 months ago[cmake] Add missing CMakePushCheckState include to FindLibEdit.cmake
Michał Górny [Mon, 7 Nov 2022 13:46:58 +0000 (14:46 +0100)]
[cmake] Add missing CMakePushCheckState include to FindLibEdit.cmake

Add the missing include to fix an error when `cmake_push_check_state()`
is called and incidentally the CMakePushCheckState module is not loaded
by any other check running prior to `FindLibEdit.cmake`:

    CMake Error at /var/no-tmpfs/portage/dev-util/lldb-15.0.4/work/cmake/Modules/FindLibEdit.cmake:24 (cmake_push_check_state):
      Unknown CMake command "cmake_push_check_state".
    Call Stack (most recent call first):
      cmake/modules/LLDBConfig.cmake:52 (find_package)
      cmake/modules/LLDBConfig.cmake:59 (add_optional_dependency)
      CMakeLists.txt:28 (include)

Gentoo Bug: https://bugs.gentoo.org/880065

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

23 months ago[InstCombine] Avoid passing pow attributes to sqrt
Miguel Saldivar [Mon, 7 Nov 2022 16:26:30 +0000 (11:26 -0500)]
[InstCombine] Avoid passing pow attributes to sqrt

As described in issue #58475, we could pass the attributes of pow to sqrt and crash.

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

23 months ago[VectorCombine] add test with non-canonical shuffle mask; NFC
Sanjay Patel [Sun, 6 Nov 2022 15:44:54 +0000 (10:44 -0500)]
[VectorCombine] add test with non-canonical shuffle mask; NFC

D137341

23 months ago[flang] Initial support for FastMathAttr setup in FirOpBuilder.
Slava Zakharin [Mon, 7 Nov 2022 16:25:19 +0000 (08:25 -0800)]
[flang] Initial support for FastMathAttr setup in FirOpBuilder.

Provide FirOpBuilder::setFastMathFlags() to configure FastMathFlags
for the builder. Set FastMathAttr for operations based on FirOpBuilder
configuration via mlir::OpBuilder::Listener.

This is a little bit hacky solution, because we lose the ability
to hook other listeners to FirOpBuilder. There are also potential
issues with OpBuilder::clone() - the hook will be invoked for cloned
operations and will effectively overwrite FastMathAttr with the ones
configured in FirOpBuilder, which should not be happening.
We should teach mlir::OpBuilder about FastMathAttr setup in future.

Reviewed By: jeanPerier, kiranchandramohan

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

23 months ago[IR] Allow available_externally GlobalAlias
Fangrui Song [Mon, 7 Nov 2022 17:03:23 +0000 (09:03 -0800)]
[IR] Allow available_externally GlobalAlias

GlobalVariable and Function can be available_externally. GlobalAlias is used
similarly. Allowing available_externally is a natural extension and helps
ThinLTO discard GlobalAlias in a non-prevailing COMDAT (see D135427).

For now, available_externally GlobalAlias must point to an
available_externally GlobalValue (not ConstantExpr).

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

23 months agoRevert "[mlir][sparse] fix sparse tensor rewriting patterns that do not propagate...
Stella Stamenova [Mon, 7 Nov 2022 17:00:08 +0000 (09:00 -0800)]
Revert "[mlir][sparse] fix sparse tensor rewriting patterns that do not propagate sparse tensor SSA properly."

This reverts commit 70508b614e6478ba2c3fc79e935e2c68e2d79b71.

This change depends on a reverted change that broke the windows mlir buildbot; reverting to bring remaining mlir bots to green

23 months agoInstCombine: Add baseline checks for fdiv
Matt Arsenault [Mon, 17 Oct 2022 19:20:02 +0000 (12:20 -0700)]
InstCombine: Add baseline checks for fdiv

23 months agoRevert "[mlir][sparse] support Parallel for/reduction."
Stella Stamenova [Mon, 7 Nov 2022 16:48:52 +0000 (08:48 -0800)]
Revert "[mlir][sparse] support Parallel for/reduction."

This reverts commit 838389780e56f1a198a94f66ea436359466bf5ed.

This broke the windows mlir buildbot: https://lab.llvm.org/buildbot/#/builders/13/builds/27934

23 months agoInstSimplify: Fold fdiv nnan ninf x, 0 -> poison
Matt Arsenault [Mon, 17 Oct 2022 05:27:36 +0000 (22:27 -0700)]
InstSimplify: Fold fdiv nnan ninf x, 0 -> poison

https://alive2.llvm.org/ce/z/JxX5in

23 months agoInstSimplify: Add new baseline tests for fdiv
Matt Arsenault [Mon, 17 Oct 2022 05:26:13 +0000 (22:26 -0700)]
InstSimplify: Add new baseline tests for fdiv

23 months ago[mlir][NVGPU] Add support for structured sparsity MMA variants
Christopher Bate [Sat, 5 Nov 2022 15:43:24 +0000 (09:43 -0600)]
[mlir][NVGPU] Add support for structured sparsity MMA variants

This change adds a new NVGPU operation that targets the PTX `mma.sp.sync`
instruction variants. A lowering to NVVM is provided using inline
assembly.

Reviewed By: ThomasRaoux, manishucsd

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

23 months ago[Clang] Update test after wasm intrinsics attribute change (NFC)
Nikita Popov [Mon, 7 Nov 2022 16:40:30 +0000 (17:40 +0100)]
[Clang] Update test after wasm intrinsics attribute change (NFC)

I missed this test in d35fcf0e97e7bb02381506a71e61ec282b292c50.

23 months agoRevert "[SLP]Redesign vectorization of the gather nodes."
Alexey Bataev [Mon, 7 Nov 2022 16:33:41 +0000 (08:33 -0800)]
Revert "[SLP]Redesign vectorization of the gather nodes."

This reverts commit 8ddd1ccdf89317be1c40fa9183e214878a56151e to fix
buildbots failures reported in https://lab.llvm.org/buildbot#builders/74/builds/14839

23 months ago[mlir][sparse] Add sparse_tensor.sort_coo operator.
bixia1 [Mon, 7 Nov 2022 16:18:53 +0000 (08:18 -0800)]
[mlir][sparse] Add sparse_tensor.sort_coo operator.

Reviewed By: aartbik

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

23 months ago[WebAssembly] Use default attributes for intrinsics
Nikita Popov [Mon, 7 Nov 2022 14:50:05 +0000 (15:50 +0100)]
[WebAssembly] Use default attributes for intrinsics

This switches wasm intrinsics to use default attributes,
i.e. nofree, nosync, nocallback and willreturn. Especially
willreturn will be required to avoid optimization regressions
in the future.

The attributes are omitted from the trapping fptoi intrinsics
(where I assume trapping is considered well-defined, and as such
these aren't willreturn), the throw/rethrow intrinsics (which
will unwind) and the atomic intrinsics (which aren't nosync).

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

23 months ago[InstCombine] Handle load smaller than one byte in memset forward
Nikita Popov [Mon, 7 Nov 2022 16:02:19 +0000 (17:02 +0100)]
[InstCombine] Handle load smaller than one byte in memset forward

APInt::getSplat() requires that the new size is >= the original
one. If we're loading less than 8 bits, truncate instead.

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

23 months ago[NFC][BlockPlacement]Add an option to renumber blocks based on function layout order.
Mingming Liu [Fri, 4 Nov 2022 05:07:58 +0000 (22:07 -0700)]
[NFC][BlockPlacement]Add an option to renumber blocks based on function layout order.

Use case:
- When block layout is visualized after MBP pass, the basic blocks are labeled in layout order; meanwhile blocks could be numbered in a different order.
- As a result, it's hard to map between the graph and pass output. With this option on, the basic blocks are renumbered in function layout order.

This option is only useful when a function is to be visualized (i.e., when view options are on) to make it debugging only.

Use https://godbolt.org/z/5WTW36bMr as an example:
- As MBP pass output (shown in godbolt output window), `func2` is in a basic block numbered `2` (`bb.2`), and `func1` is in a basic block numbered `3` (`bb.3`);
    `bb.3` is a block with higher block frequency than `bb.2`, and `bb.3` is placed before `bb.2` in the functin layout.
- Use [1] to get the dot graph (graph uploaded in [2]), the blocks are re-numbered.
   - `func1` is in 'if.end' block, and labeled `1` in visualized dot; `func2` is in 'if.then' blocks, and labeled `3` --> the labeled number and bb number won't map.
   - [[ https://github.com/llvm/llvm-project/blob/b5626ae9751f0d82aa04791a21689b289721738e/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp#L127 | DOTGraphTraits<MachineBlockFrequencyInfo *>::getNodeLabel ]] is where labeled numbers are based on function layout number, and [[ https://github.com/llvm/llvm-project/blob/a8d93783f37c042ace67069ae4ca6f8fd849c2d0/llvm/include/llvm/Support/GraphWriter.h#L209
 | called by graph writer ]].
        So call 'MachineFunction::RenumberBlocks' would make labeled number (in dot graph) and block number (in pass output) consistent with each other.

[1] `./bin/clang++ -O3 -S -mllvm -view-block-layout-with-bfi=count -mllvm -view-bfi-func-name=_Z9func_loopv -mllvm -print-after=block-placement -mllvm  -filter-print-funcs=_Z9func_loopv test.c`

[2] {F25201785}

Reviewed By: davidxl

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

23 months ago[AArch64][SVE2] Add the SVE2.1 quadword variants of ld1w/ld1d/st1w/st1d
David Sherwood [Tue, 1 Nov 2022 17:11:47 +0000 (17:11 +0000)]
[AArch64][SVE2] Add the SVE2.1 quadword variants of ld1w/ld1d/st1w/st1d

This patch adds the assembly/disassembly for the following instructions:

st1w: Contiguous store words from vector (128-bit vector elements)
st1d: Contiguous store doublewords from vector (128-bit vector elements)
ld1w: Contiguous load unsigned words to vector (128-bit vector elements)
ld1d: Contiguous load unsigned doublewords to vector (128-bit vector elements)

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

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

23 months ago[InstCombine] Remove redundant splats in InstCombineVectorOps
Matt Devereau [Wed, 12 Oct 2022 09:20:05 +0000 (09:20 +0000)]
[InstCombine] Remove redundant splats in InstCombineVectorOps

Splatting the first vector element of the result of a BinOp, where any of the
BinOp's operands are the result of a first vector element splat can be simplified to
splatting the first vector element of the result of the BinOp

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

23 months ago[mlir][sparse] Improve the non-stable sort implementation.
bixia1 [Mon, 7 Nov 2022 02:46:49 +0000 (18:46 -0800)]
[mlir][sparse] Improve the non-stable sort implementation.

Replace the quick sort partition method with one that is more similar to the
method used by C++ std quick sort. This improves the runtime for sorting
sk_2005.mtx by more than 10x.

Reviewed By: aartbik

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

23 months ago[AArch64][SVE2] Add the SVE2.1 BF16 instructions
David Sherwood [Wed, 2 Nov 2022 14:58:34 +0000 (14:58 +0000)]
[AArch64][SVE2] Add the SVE2.1 BF16 instructions

This patch adds the new FEAT_B16B16 feature as well as the
assembly/disassembly for all of the B16B16 instructions:

bfadd:   BFloat16 floating-point add vectors
bfsub:   BFloat16 floating-point subtract vectors
bfmul:   BFloat16 floating-point multiply vectors
bfclamp: BFloat16 floating-point clamp to minimum/maximum number
bfmax:   BFloat16 floating-point maximum
bfmaxnm: BFloat16 floating-point maximum number
bfmin:   BFloat16 floating-point minimum
bfminnm: BFloat16 floating-point minimum number
bfmla:   BFloat16 floating-point fused multiply-add vectors
bfmls:   BFloat16 floating-point fused multiply-subtract vectors

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

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

23 months ago[X86] Folded MOVDDUPrm has the same sched behaviour as MOVSHDUPrm/MOVSLDUPrm on Haswe...
Simon Pilgrim [Mon, 7 Nov 2022 15:17:23 +0000 (15:17 +0000)]
[X86] Folded MOVDDUPrm has the same sched behaviour as MOVSHDUPrm/MOVSLDUPrm on Haswell/IceLake

There can be a difference for MOVDDUPrr but not the load folded broadcast that is purely on Port23

Fixes an old TODO (inherited from SkylakeServer which was fixed at c7662dc3e52801ec824d8473278fb976107d3e57)

Confirmed on Agner + uops.info

23 months agoInstCombine: Fold compare with smallest normal if input denormals are flushed
Matt Arsenault [Fri, 4 Nov 2022 01:26:59 +0000 (18:26 -0700)]
InstCombine: Fold compare with smallest normal if input denormals are flushed

Try to simplify comparisons with the smallest normalized value. If
denormals will be treated as 0, we can simplify by using an equality
comparison with 0.

fcmp olt fabs(x), smallest_normalized_number -> fcmp oeq x, 0.0
fcmp ult fabs(x), smallest_normalized_number -> fcmp ueq x, 0.0
fcmp oge fabs(x), smallest_normalized_number -> fcmp one x, 0.0
fcmp ult fabs(x), smallest_normalized_number -> fcmp ueq x, 0.0

The device libraries have a few range checks that look like
this for denormal handling paths.

23 months agoInstCombine: Add baseline tests for fcmp and select on denormal range
Matt Arsenault [Fri, 4 Nov 2022 01:27:47 +0000 (18:27 -0700)]
InstCombine: Add baseline tests for fcmp and select on denormal range

A future change will try to fold (if input denormals are treated as 0)
fcmp olt fabs(x), smallest_normalized_number -> fcmp oeq x, 0.0
fcmp ult fabs(x), smallest_normalized_number -> fcmp ueq x, 0.0
fcmp oge fabs(x), smallest_normalized_number -> fcmp one x, 0.0
fcmp ult fabs(x), smallest_normalized_number -> fcmp ueq x, 0.0

23 months ago[NFC] Move getDebugValueLoc from static in Local.cpp to DebugInfo.h
OCHyams [Mon, 7 Nov 2022 15:12:18 +0000 (15:12 +0000)]
[NFC] Move getDebugValueLoc from static in Local.cpp to DebugInfo.h

Move getDebugValueLoc so that it can be accessed from DebugInfo.h for the
Assignment Tracking patch stack and remove redundant parameter Src.

Reviewed By: jryans

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

23 months ago[SLP]Redesign vectorization of the gather nodes.
Alexey Bataev [Fri, 16 Sep 2022 20:57:04 +0000 (13:57 -0700)]
[SLP]Redesign vectorization of the gather nodes.

Gather nodes are vectorized as simply vector of the scalars instead of
relying on the actual node. It leads to the fact that in some cases
we may miss incorrect transformation (non-matching set of scalars is
just ended as a gather node instead of possible vector/gather node).
Better to rely on the actual nodes, it allows to improve stability and
better detect missed cases.

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

23 months ago[Assignment Tracking][5.1/*] Add deleteAssignmentMarkers function
OCHyams [Mon, 7 Nov 2022 12:47:11 +0000 (12:47 +0000)]
[Assignment Tracking][5.1/*] Add deleteAssignmentMarkers function

deleteAssignmentMarkers(const Instruction *Inst) does exactly as you'd expect -
it deletes any dbg.assign intrinsics linked to Inst.

Reviewed By: jmorse

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

23 months ago[AArch64] Add SME2.1 target feature for Armv9-A 2022 Architecture Extension
David Sherwood [Thu, 3 Nov 2022 11:25:41 +0000 (11:25 +0000)]
[AArch64] Add SME2.1 target feature for Armv9-A 2022 Architecture Extension

First patch in a series adding MC layer support for SME2.1.

This patch adds the following feature:

sme2p1

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

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