platform/upstream/llvm.git
23 months ago[clang-tools-extra] Don't including None.h (NFC)
Kazu Hirata [Wed, 7 Dec 2022 07:22:09 +0000 (23:22 -0800)]
[clang-tools-extra] Don't including None.h (NFC)

These source files no longer use None, so they do not need to include
None.h.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[AMDGPU] Handle `min(max(x, y), max(min(x, y), z))` in med3 combines
Justin Bogner [Wed, 7 Dec 2022 03:49:32 +0000 (19:49 -0800)]
[AMDGPU] Handle `min(max(x, y), max(min(x, y), z))` in med3 combines

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

23 months ago[AMDGPU] Handle nnan and fast on the call in fpmed3 patterns
Justin Bogner [Wed, 7 Dec 2022 06:06:52 +0000 (22:06 -0800)]
[AMDGPU] Handle nnan and fast on the call in fpmed3 patterns

We were only allowing these med3 patterns if the operands were known
to not be NaN, but we should also allow it if the calls to max/min
have the `nnan` or `fast` flags.

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

23 months ago[AMDGPU] Precommit GISel test for min(max(x, y), max(min(x, y), z)) -> med3
Justin Bogner [Wed, 7 Dec 2022 06:42:20 +0000 (22:42 -0800)]
[AMDGPU] Precommit GISel test for min(max(x, y), max(min(x, y), z)) -> med3

These combines will be added by https://reviews.llvm.org/D139508

23 months ago[Propeller] Use Fixed MBB ID instead of volatile MachineBasicBlock::Number.
Rahman Lavaee [Wed, 7 Dec 2022 06:37:33 +0000 (22:37 -0800)]
[Propeller] Use Fixed MBB ID instead of volatile MachineBasicBlock::Number.

Let Propeller use specialized IDs for basic blocks, instead of MBB number.

This allows optimizations not just prior to asm-printer, but throughout the entire codegen.
This patch only implements the functionality under the new `LLVM_BB_ADDR_MAP` version, but the old version is still being used. A later patch will change the used version.

####Background
Today Propeller uses machine basic block (MBB) numbers, which already exist, to map native assembly to machine IR.  This is done as follows.
    - Basic block addresses are captured and dumped into the `LLVM_BB_ADDR_MAP` section just before the AsmPrinter pass which writes out object files. This ensures that we have a mapping that is close to assembly.
    - Profiling mapping works by taking a virtual address of an instruction and looking up the `LLVM_BB_ADDR_MAP` section to find the MBB number it corresponds to.
    - While this works well today, we need to do better when we scale Propeller to target other Machine IR optimizations like spill code optimization.  Register allocation happens earlier in the Machine IR pipeline and we need an annotation mechanism that is valid at that point.
    - The current scheme will not work in this scenario because the MBB number of a particular basic block is not fixed and changes over the course of codegen (via renumbering, adding, and removing the basic blocks).
    - In other words, the volatile MBB numbers do not provide a one-to-one correspondence throughout the lifetime of Machine IR.  Profile annotation using MBB numbers is restricted to a fixed point; only valid at the exact point where it was dumped.
    - Further, the object file can only be dumped before AsmPrinter and cannot be dumped at an arbitrary point in the Machine IR pass pipeline.  Hence, MBB numbers are not suitable and we need something else.
####Solution
We propose using fixed unique incremental MBB IDs for basic blocks instead of volatile MBB numbers. These IDs are assigned upon the creation of machine basic blocks. We modify `MachineFunction::CreateMachineBasicBlock` to assign the fixed ID to every newly created basic block.  It assigns `MachineFunction::NextMBBID` to the MBB ID and then increments it, which ensures having unique IDs.

 To ensure correct profile attribution, multiple equivalent compilations must generate the same Propeller IDs. This is guaranteed as long as the MachineFunction passes run in the same order. Since the `NextBBID` variable is scoped to `MachineFunction`, interleaving of codegen for different functions won't cause any inconsistencies.

The new encoding is generated under the new version number 2 and we keep backward-compatibility with older versions.

####Impact on Size of the `LLVM_BB_ADDR_MAP` Section
Emitting the Propeller ID results in a 23% increase in the size of the `LLVM_BB_ADDR_MAP` section for the clang binary.

Reviewed By: tmsriram

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

23 months ago[llvm] Use std::nullopt instead of None in comments (NFC)
Kazu Hirata [Wed, 7 Dec 2022 06:45:17 +0000 (22:45 -0800)]
[llvm] Use std::nullopt instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[llvm] Don't include Optional.h (NFC)
Kazu Hirata [Wed, 7 Dec 2022 06:34:50 +0000 (22:34 -0800)]
[llvm] Don't include Optional.h (NFC)

These source files no longer use Optional<T>, so they do not need to
include Optional.h.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months agoRevert "[VP][RISCV] Add vp.fshl/fshr and RISC-V support."
Kazu Hirata [Wed, 7 Dec 2022 06:27:43 +0000 (22:27 -0800)]
Revert "[VP][RISCV] Add vp.fshl/fshr and RISC-V support."

This reverts commit 70de0e014013b4d97febe6704881a9a8c893d078.

I'm seeing:

Failed Tests (2):
  LLVM :: CodeGen/RISCV/rvv/fixed-vectors-fshr-fshl-vp.ll
  LLVM :: CodeGen/RISCV/rvv/fshr-fshl-vp.ll

Also reported at:

https://lab.llvm.org/buildbot/#/builders/123/builds/14531

23 months ago[AMDGPU] Precommit GISel test showing missing med3 combines
Justin Bogner [Wed, 7 Dec 2022 06:04:16 +0000 (22:04 -0800)]
[AMDGPU] Precommit GISel test showing missing med3 combines

These combines will be added by https://reviews.llvm.org/D139506

23 months ago[RISCV] Add basic cost model for vp float rounding instructions.
Yeting Kuo [Tue, 6 Dec 2022 00:39:07 +0000 (08:39 +0800)]
[RISCV] Add basic cost model for vp float rounding instructions.

Reviewed By: craig.topper, reames

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

23 months ago[RISCV] Codegen support for Zfhmin.
Monk Chiang [Wed, 30 Nov 2022 09:07:14 +0000 (17:07 +0800)]
[RISCV] Codegen support for Zfhmin.

The Zfhmin subset only has FLH, FSH, FMV.X.H, FMV.H.X, FCVT.S.H, and FCVT.H.S.
If the D extension is present, the FCVT.D.H and FCVT.H.D instructions are also included.
Since most instructions are not included for Zfhmin, so most operations are promoted.
The patch primarily about making f16 a legal type.

RISC-V ISA info:
https://wiki.riscv.org/display/HOME/Recently+Ratified+Extensions

Reviewed By: craig.topper

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

23 months ago[RISCV] Remove trailing whitespace. NFC
Craig Topper [Wed, 7 Dec 2022 04:54:08 +0000 (20:54 -0800)]
[RISCV] Remove trailing whitespace. NFC

23 months ago[llvm-profdata] Drop profile symbol list during merging AutoFDO profiles.
Hongtao Yu [Tue, 6 Dec 2022 23:22:50 +0000 (15:22 -0800)]
[llvm-profdata] Drop profile symbol list during merging AutoFDO profiles.

Adding a switch to drop profile symbol list during merging AutoFDO profiles. This is needed to minimize the impact on default profiles when the profile symbol list is enabled for the source input profiles. The symbol list is quite large and could potentially slow down the compiler.

Reviewed By: davidxl, wenlei

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

23 months ago[mlir][spirv] Fix integer dot product format attr validation
Jakub Kuderski [Wed, 7 Dec 2022 04:29:41 +0000 (23:29 -0500)]
[mlir][spirv] Fix integer dot product format attr validation

Do not allow formats for non-scalar vector operands.

Reviewed By: antiagainst

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

23 months ago[VP][RISCV] Add vp.fshl/fshr and RISC-V support.
Yeting Kuo [Sun, 20 Nov 2022 15:11:56 +0000 (23:11 +0800)]
[VP][RISCV] Add vp.fshl/fshr and RISC-V support.

The patch made VectorLegalizer expand ISD::VP_FSHL and ISD::VP_FSHR to
achieve the codegen.

Reviewed By: craig.topper

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

23 months ago[ADT] Don't including None.h (NFC)
Kazu Hirata [Wed, 7 Dec 2022 04:14:51 +0000 (20:14 -0800)]
[ADT] Don't including None.h (NFC)

These source files no longer use None, so they do not need to include
None.h.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[llvm] Don't include STLForwardCompat.h (NFC)
Kazu Hirata [Wed, 7 Dec 2022 04:09:56 +0000 (20:09 -0800)]
[llvm] Don't include STLForwardCompat.h (NFC)

STLForwardCompat.h defines remove_cvref and remove_cvref_t.  These
source files use neither one of those.

23 months ago[OMPT][test] Fix mismatch error between the current address and the return address...
zhanglimin [Wed, 7 Dec 2022 03:57:34 +0000 (11:57 +0800)]
[OMPT][test] Fix mismatch error between the current address and the return address for LoongArch

This patch fixes tests masked.c and master.c on LoongArch.

Reviewed By: SixWeining, protze.joachim

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

23 months agoRevert "Store OptTable::Info::Name as a StringRef"
Douglas Yung [Wed, 7 Dec 2022 03:37:05 +0000 (19:37 -0800)]
Revert "Store OptTable::Info::Name as a StringRef"

This reverts commit 5951b0bb23f3265bea16f28c2af9d278b9d829c6.

This is causing 24 test failures on the PS4 linux bot: https://lab.llvm.org/buildbot/#/builders/139/builds/32263

23 months ago[C++20] [Modules] [Serialization] Deserialize
Chuanqi Xu [Tue, 6 Dec 2022 09:38:57 +0000 (17:38 +0800)]
[C++20] [Modules] [Serialization] Deserialize
LValuePathSerializationHelper's type properly

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

Tested with libcxx's modules build.

When we read the type of
LValuePathSerializationHelper, we didn't read the correct type. We read
the element type as its name suggests. But the problem here is that it
looks like that both the usage and serialization use its type as the
top level type. So here is the mismatch.

Actually, the type of LValuePathSerializationHelper is never used after
Deserialization without the assertion. So it doesn't matter for the
release users. And this patch shouldn't change the behavior too.

Reviewed By: erichkeane

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

23 months ago[lld-macho][nfc] Fix up missing FileCheck on objc.s
Vincent Lee [Tue, 6 Dec 2022 07:55:07 +0000 (23:55 -0800)]
[lld-macho][nfc] Fix up missing FileCheck on objc.s

I'll be making changes to the ObjC implementation (bug fix) in a later
change, and I noticed that this test isn't being tested at all. Fix that up
here separately so further changes are easier to differentiate.

Reviewed By: #lld-macho, thakis, int3

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

23 months ago[mlir][TilingInterface] Add test for tile + fuse of sequence of reductions.
Mahesh Ravishankar [Tue, 6 Dec 2022 02:18:18 +0000 (02:18 +0000)]
[mlir][TilingInterface] Add test for tile + fuse of sequence of reductions.

This just adds a test. With CSE of single block ops, and other
previously landed changes, this works at HEAD. Just adding a test that
triggered this line of work that I missed adding.

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

23 months ago[RISCV][CostModel] Add a test for reverse shuffles cost on RISCV, NFC
liqinweng [Wed, 7 Dec 2022 02:16:20 +0000 (10:16 +0800)]
[RISCV][CostModel] Add a test for reverse shuffles cost on RISCV, NFC

Reviewed By: benshi001

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

23 months ago[MLIR][Arith] Add Canonicalize test for trunci
liqinweng [Wed, 7 Dec 2022 02:06:21 +0000 (10:06 +0800)]
[MLIR][Arith] Add Canonicalize test for trunci

Reviewed By: Mogball

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

23 months ago[libc++][Android] Rename user NS to User to avoid conflict with struct
Ryan Prichard [Wed, 30 Nov 2022 01:06:14 +0000 (17:06 -0800)]
[libc++][Android] Rename user NS to User to avoid conflict with struct

Bionic's sys/user.h declares a "struct user". The header tends to be
included, and when it is, it conflicts with "namespace user". Rename
user to User.

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

23 months ago[mlir][spirv] Define `spirv.*DotAccSat` integer dot product ops
Jakub Kuderski [Wed, 7 Dec 2022 01:22:47 +0000 (20:22 -0500)]
[mlir][spirv] Define `spirv.*DotAccSat` integer dot product ops

This covers `SDotAccSat`, `SUDotAccSat`, and `UDotAccSat`.

Reviewed By: antiagainst

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

23 months ago[mlir][spirv] Define `spirv.*Dot` integer dot product ops
Jakub Kuderski [Wed, 7 Dec 2022 01:17:40 +0000 (20:17 -0500)]
[mlir][spirv] Define `spirv.*Dot` integer dot product ops

This covers `SDot`, `SUDot`, and `UDot`. The `*AccSat` version will be
added in a follow-up revision.

Reviewed By: antiagainst

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

23 months ago[RISCV][CodeGen] Kill dead pseudo classes and replace with specific LMUL versions...
Michael Maitland [Wed, 7 Dec 2022 01:11:20 +0000 (17:11 -0800)]
[RISCV][CodeGen] Kill dead pseudo classes and replace with specific LMUL versions. NFC

Since changes to account for LMUL in scheduler model existed over patches, we had to keep
both LMUL specific and all LMUL classes around. Now that only the LMUL specific
classes are used, we can remove the old ones.

23 months ago[RISCV][CodeGen] Account for LMUL for Vector Integer load store instructions
Michael Maitland [Thu, 3 Nov 2022 21:30:58 +0000 (14:30 -0700)]
[RISCV][CodeGen] Account for LMUL for Vector Integer load store instructions

It is likley that subtargets act differently for a vector load store instructions based on the LMUL.
This patch creates seperate SchedRead, SchedWrite, WriteRes, ReadAdvance for each relevant LMUL.

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

23 months ago[RISCV][CodeGen] Account for LMUL for Vector Permutation Instructions
Michael Maitland [Thu, 3 Nov 2022 18:44:06 +0000 (11:44 -0700)]
[RISCV][CodeGen] Account for LMUL for Vector Permutation Instructions

It is likley that subtargets act differently for vector fixed-point arithmetic instructions
based on the LMUL. This patch creates seperate SchedRead, SchedWrite, WriteRes, ReadAdvance
for each relevant LMUL.

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

23 months ago[NFC][SimplifyCFG] Add more fold-branch-to-common-dest tests
Roman Lebedev [Wed, 7 Dec 2022 00:31:30 +0000 (03:31 +0300)]
[NFC][SimplifyCFG] Add more fold-branch-to-common-dest tests

23 months ago[NFC] Use Register instead of unsigned for variables that receive a Register object
Gregory Alfonso [Wed, 7 Dec 2022 00:23:34 +0000 (00:23 +0000)]
[NFC] Use Register instead of unsigned for variables that receive a Register object

Reviewed By: MaskRay

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

23 months agoRevert "[ObjYAML] Use strcmp instead of strncmp"
Fangrui Song [Wed, 7 Dec 2022 00:14:16 +0000 (00:14 +0000)]
Revert "[ObjYAML] Use strcmp instead of strncmp"

This reverts commit f45195784168cced1e12fe888d6a906b8a4b424f.

The change is wrong. segname may not be NUL-terminated if it has 16 bytes.

23 months ago[ObjYAML] Use strcmp instead of strncmp
Gregory Alfonso [Wed, 7 Dec 2022 00:06:01 +0000 (00:06 +0000)]
[ObjYAML] Use strcmp instead of strncmp

Reviewed By: MaskRay

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

23 months ago[ConstraintElim] Fix sort order to not comparing insts in different bbs.
Florian Hahn [Tue, 6 Dec 2022 23:47:23 +0000 (23:47 +0000)]
[ConstraintElim] Fix sort order to not comparing insts in different bbs.

Update the sort order to make sure that comesBefore is never used from
conditional facts, which are instructions but may use DFS numbers from
different blocks.

This fixes a crash in the added test on some platforms.

23 months ago[RISCV] Move VSPILL/VRELOAD expansion for vector tuples to eliminateFrameIndex.
Craig Topper [Tue, 6 Dec 2022 23:15:20 +0000 (15:15 -0800)]
[RISCV] Move VSPILL/VRELOAD expansion for vector tuples to eliminateFrameIndex.

We need a scratch GPR to increment the base pointer for each subsequent
register. We currently reuse the input GPR for the base pointer without
declaring it as a Def of the pseudo.

We can't add it as a Def of the pseudo at creation time because it doesn't
get register allocated. This was tried in D109405.

Seems the only choice we have is to scavenge the GPR. This patch
moves the expansion to eliminateFrameIndex where we can create
virtual registers that will be scavenged. This also eliminates the
extra operand for passing vlenb from frame lowering to expand pseudos.

I need to do more testing on real world code, but wanted to get this
up for early review.

I hope this will fix the issue reported in D123394, but I haven't
checked yet.

Reviewed By: reames

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

23 months ago[mlir][sparse] cleanup some pass documentation
Aart Bik [Tue, 6 Dec 2022 23:09:22 +0000 (15:09 -0800)]
[mlir][sparse] cleanup some pass documentation

Reviewed By: Peiming

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

23 months ago[count] Use correct integral type
Gregory Alfonso [Tue, 6 Dec 2022 23:30:25 +0000 (15:30 -0800)]
[count] Use correct integral type

Make the types consistent with each other, and return size_t instead of a long int.

Reviewed By: MaskRay

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

23 months ago[Mips] Convert a test to check 'target=...'
Paul Robinson [Tue, 6 Dec 2022 23:24:23 +0000 (15:24 -0800)]
[Mips] Convert a test to check 'target=...'

Although it should base the check on host, not target, if possible.

Part of the project to eliminate special handling for triples in lit
expressions.

23 months ago[Mips,i686,others] Convert tests to check 'target=...'
Paul Robinson [Tue, 6 Dec 2022 23:12:41 +0000 (15:12 -0800)]
[Mips,i686,others] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

23 months ago[mlir][tensor][linalg] Introduce DataLayoutPropagation pass.
Hanhan Wang [Sat, 26 Nov 2022 01:50:38 +0000 (17:50 -0800)]
[mlir][tensor][linalg] Introduce DataLayoutPropagation pass.

It introduces a pattern that swaps `linalg.generic + tensor.pack` to
`tensor.pack + linalg.generic`. It requires all the iteration types
being parallel; the indexing map of output operand is identiy. They can
all be relaxed in the future.

The user can decide whether the propagation should be applied or not by
passing a control function.

Reviewed By: mravishankar

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

23 months ago[RISCV] Pass ZB_Undefined to countTrailingZeros/countLeadingZeros. NFC
Craig Topper [Tue, 6 Dec 2022 22:00:04 +0000 (14:00 -0800)]
[RISCV] Pass ZB_Undefined to countTrailingZeros/countLeadingZeros. NFC

We know the input is not zero so we can simplify the generated code.

23 months ago[RISCV] Return InstSeq from generateInstSeqImpl instead of using an output parameter...
Craig Topper [Tue, 6 Dec 2022 21:43:49 +0000 (13:43 -0800)]
[RISCV] Return InstSeq from generateInstSeqImpl instead of using an output parameter. NFC

We should be able to rely on RVO here.

23 months agoRevert "DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions"
David Blaikie [Tue, 6 Dec 2022 22:51:39 +0000 (22:51 +0000)]
Revert "DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions"

Some buildbots are failing in Clang and LLDB tests. (I guess the LLDB
failure is due to the explicit C language tests in DwarfUnit.cpp that
need to be updated - not sure what the Clang failures are about, they
seem to be still emitting C99 when we're expecting C11 and I checked
those tests pass... maybe systems with a different C language version
default?)

This reverts commit 3c312e48f325c1b1ee11404ee6cfa08ee00037b0.

23 months ago[BOLT][NFC] Use std::optional in MCPlusBuilder
Amir Ayupov [Tue, 6 Dec 2022 22:15:54 +0000 (14:15 -0800)]
[BOLT][NFC] Use std::optional in MCPlusBuilder

Reviewed By: maksfb, #bolt

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

23 months ago[BOLT][NFC] Use std::optional for findAttributeInfo
Amir Ayupov [Tue, 6 Dec 2022 22:15:50 +0000 (14:15 -0800)]
[BOLT][NFC] Use std::optional for findAttributeInfo

LLVM started switching from `llvm::Optional` to `std::optional`:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716/11

Reviewed By: #bolt, maksfb

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

23 months ago[OpenMP] Refactor CMake files related to `PluginInterface` in `plugins-nextgen`
Shilei Tian [Tue, 6 Dec 2022 22:39:24 +0000 (17:39 -0500)]
[OpenMP] Refactor CMake files related to `PluginInterface` in `plugins-nextgen`

This patch uses refactors CMake files related to `PluginInterface` in `plugins-nextgen` to handle LLVM dependences in a better way.

Reviewed By: jhuber6

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

23 months ago[mlir][sparse] make fusion for SDDMM more robust
Aart Bik [Tue, 6 Dec 2022 21:22:34 +0000 (13:22 -0800)]
[mlir][sparse] make fusion for SDDMM more robust

Reviewed By: Peiming

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

23 months ago[clang-format] Fix an assertion failure in block parsing
Owen Pan [Sun, 4 Dec 2022 21:52:01 +0000 (13:52 -0800)]
[clang-format] Fix an assertion failure in block parsing

This assertion failure was introduced in 9ed2e68c9ae5 and is
manifested when both RemoveBracesLLVM and MacroBlockBegin are set.

Fixes #59335.

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

23 months ago[NFC] #include MCSymbol.h to avoid an incomplete type
Jordan Rupprecht [Tue, 6 Dec 2022 22:03:56 +0000 (14:03 -0800)]
[NFC] #include MCSymbol.h to avoid an incomplete type

Note: this header already has a dep on MC headers via MCContext.

23 months agoStore OptTable::Info::Name as a StringRef
serge-sans-paille [Sun, 4 Dec 2022 08:33:14 +0000 (09:33 +0100)]
Store OptTable::Info::Name as a StringRef

This is a recommit of 8ae18303f97d5dcfaecc90b4d87effb2011ed82e,
with a few cleanups.

This avoids implicit conversion to StringRef at several points, which in
turns avoid redundant calls to strlen.

As a side effect, this greatly simplifies the implementation of
StrCmpOptionNameIgnoreCase.

It also eventually gives a consistent, humble speedup in compilation
time (timing updated since original commit).

https://llvm-compile-time-tracker.com/compare.php?from=de4b6a1bc64db33643f001ad45fae7b92b4a4688&to=c23a93d1292052b4be2fbe8c586fa31143d0c7ed&stat=instructions:u

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

23 months agoFix buffer-overflow in llvm-mt's notify_update feature.
Mitch Phillips [Tue, 6 Dec 2022 21:45:52 +0000 (13:45 -0800)]
Fix buffer-overflow in llvm-mt's notify_update feature.

The 3-parameter std::equal used in this code access FileBuffer from [0,
OutputBuffer->getBufferEnd() - OutputBuffer->getBufferStart()). If the
size of FileBuffer is shorter than OutputBuffer, this ends up
overflowing.

This wasn't found on the sanitizer buildbots as they use an instrumented
libcxx, and libcxx implements std::equal using a loop. libstdc++ on my
local macine finds the bug, as it implements std::equal using bcmp(),
which ASan intercepts and does a range check.

The existing test doesn't technically do a buffer-overflow, but the code
definitely can. If OutputBuffer was "AAABBB" and FileBuffer was "AAA",
then the code would overflow.

Reviewed By: abrachet

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

23 months agoReland "[lld-macho] Fix bugs around EH_Frame symbols"
Jez Ng [Thu, 1 Dec 2022 06:21:04 +0000 (01:21 -0500)]
Reland "[lld-macho] Fix bugs around EH_Frame symbols"

This reverts commit e2c868fbf7c304ed1814ed53fdeb7605042f3c8c.

The buildbot failure from the earlier land has been fixed by 7c7e39db7a.

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

23 months agoReland "[lld-macho] Emit map file entry for compact unwind info"
Jez Ng [Thu, 1 Dec 2022 06:20:54 +0000 (01:20 -0500)]
Reland "[lld-macho] Emit map file entry for compact unwind info"

This reverts commit ac3096e1dd77a2687797d38976d5f8c93f7353e5.

The buildbot failure from the earlier patch set has been fixed by 7c7e39db7a.

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

23 months ago[Windows] Convert tests to check 'target=...'
Paul Robinson [Tue, 6 Dec 2022 21:15:11 +0000 (13:15 -0800)]
[Windows] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

23 months ago[gn build] Add LoongArch target
Nico Weber [Sat, 3 Dec 2022 12:52:00 +0000 (07:52 -0500)]
[gn build] Add LoongArch target

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

23 months agoDebugInfo: Add/support new DW_LANG codes for recent C and C++ versions
David Blaikie [Tue, 6 Dec 2022 01:15:52 +0000 (01:15 +0000)]
DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

This may be a breaking change for consumers if they're trying to detect
if code is C or C++, since it'll start using new codes that they may not
be ready to recognize, in which case they may fall back to non-C
handling.

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

23 months ago[Clang][Sema] Fix attribute((format)) bug on non-variadic functions
Félix Cloutier [Tue, 6 Dec 2022 21:00:12 +0000 (13:00 -0800)]
[Clang][Sema] Fix attribute((format)) bug on non-variadic functions

The [initial implementation][1] of __attribute__((format)) on non-variadic functions
accidentally only accepted one data argument. This worked:

```c
__attribute__((format(printf, 1, 2)))
void f(const char *, int);
```

but this didn't:

```c
__attribute__((format(printf, 1, 2)))
void f(const char *, int, int);
```

This is due to an oversight in changing the way diagnostics are emitted for
`attribute((format))`, and to a coincidence in the handling of the variadic case. Test
cases only covered the case that worked by coincidence.

Before the previous change, using `__attribute__((format))` on a non-variadic function at
all was an error and clang bailed out. After that change, it only generates a GCC
compatibility warning. However, as execution falls through, it hits a second diagnostic
when the first data argument is neither 0 nor the last parameter of the function.

This change updates that check to allow any parameter after the format string to be the
first data argument when the function is non-variadic. When the function is variadic, it
still needs to be the index of the `...` "parameter". Attribute documentation is updated
to reflect the change and new tests are added to verify that it works with _two_ data
parameters.

[1]: https://reviews.llvm.org/D112579

Radar-Id: rdar://102069446
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D137603

23 months ago[flang] Support fir.class in scalar user defined assignment lowering
Valentin Clement [Tue, 6 Dec 2022 21:01:14 +0000 (22:01 +0100)]
[flang] Support fir.class in scalar user defined assignment lowering

Support fir.class in genScalarUserDefinedAssignmentCall so
emboxing is done correctly.

Reviewed By: jeanPerier, PeteSteinfeld

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

23 months ago[YAML] Convert Optional to std::optional
Krzysztof Parzyszek [Mon, 5 Dec 2022 23:19:30 +0000 (15:19 -0800)]
[YAML] Convert Optional to std::optional

23 months ago[NFC][PowerPC] Add NFC fixes to PPCInstrinfo.cpp when getting the defined machine...
Amy Kwan [Tue, 6 Dec 2022 17:52:52 +0000 (11:52 -0600)]
[NFC][PowerPC] Add NFC fixes to PPCInstrinfo.cpp when getting the defined machine instruction.

This patch adds the following NFC fixes to PPCInstrInfo.cpp when getting the DefMI:
- Fix documentation error to state that we want to flag a use of register
  between the def and the MI (in post-RA)
- Setting the DefMI to null if the DefMI is neither an LI or and ADDI
  (while still being in SSA form).

In terms of setting the DefMI to null, this change aims to account for the
scenario of when we end up going through all operands on the machine instruction
MI and updating OpNoForForwarding accordingly once an ADDI is found as the DefMI.

It is possible that once an ADDI is found, we will continue to go through all
operands in attempts to find an LI, but end up looking at every operand until
we reach the end if we have not yet found an LI. In the case where the end is
reached and we never end up finding an LI/ADDI, DefMI would be pointing to the
last operand of MI while OpNoForForwarding would still be pointing at the
previous ADDI operand found. We reset DefMI to avoid having DefMI point to an
instruction that differs from the one represented by OpNoForForwarding.

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

23 months ago[mlir] [docs] Broken link in MLIR Toy docs
Wheest [Tue, 6 Dec 2022 20:13:20 +0000 (12:13 -0800)]
[mlir] [docs] Broken link in MLIR Toy docs

In the Ch6 of the Toy Example for MLIR, there is a broken link.  If ones goes to [the page for Chapter 6](https://mlir.llvm.org/docs/Tutorials/Toy/Ch-6/), and click on the link "Conversion to the LLVM IR Dialect", one will see it takes you to a page that no longer exists.

I believe this should actually be [this link](https://mlir.llvm.org/docs/TargetLLVMIR/).

Note to reviewers that this is my first submitted patch to LLVM, and using the phabricator system, so there is a higher risk that I have made an error, and brief feedback on these patch notes would be appreciated.

Reviewer rational: Users who git blame say contributed to the tutorial.

I believe that automated tests on these markdown docs could reduce the risk of this kind of error occurring again.  For example, [this Python package](https://pypi.org/project/linkcheckmd/) checks for broken markdown links.  However, I am unsure where in the existing testing infrastructure this could go, I am only somewhat familiar with the C++ side.

Reviewed By: Mogball

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

23 months ago[mlir][tensor] Adapt FoldTensorCastProducerOp pattern on DPS interface.
Hanhan Wang [Mon, 5 Dec 2022 23:52:35 +0000 (15:52 -0800)]
[mlir][tensor] Adapt FoldTensorCastProducerOp pattern on DPS interface.

This revision adapts the pattern in LinAlg to work on DPS interface, and
adds it to canonicalization patterns of tensor dialect. The
InsertSliceOp is skipped in the pattern because it has its own logic
about folding tensor.cast ops.

Reviewed By: pifon2a

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

23 months agoUse consistent spacing before custom directives for op and attr/type assemblyFormat.
Kevin Gleason [Tue, 6 Dec 2022 19:56:53 +0000 (11:56 -0800)]
Use consistent spacing before custom directives for op and attr/type assemblyFormat.

Currently, assemblyFormat `custom<A>($a) custom<B>($b)` has different spacing
if used for Ops vs Attrs/Types. Ops insert a space if needed before the custom directive,
while attributes and types do not.

This leads to the following two patterns in attributes / types:

```
# 1. Whitespace literal
let assemblyFormat = "... ` ` custom<A>($a)"

# 2. Custom printer code includes spacing
void printB(...) {
  printer << ' ' << b;
}
```

Moving this spacing into the generated code allows for some cleanup in mlir and
improves the consistency of custom directives.

Reviewed By: mehdi_amini

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

23 months ago[exegesis] Attempt to workaround GCC7 compiler bug
Roman Lebedev [Tue, 6 Dec 2022 19:54:22 +0000 (22:54 +0300)]
[exegesis] Attempt to workaround GCC7 compiler bug

https://lab.llvm.org/staging/#/builders/235/builds/731/steps/5/logs/FAIL__Building_CXX_object_tools_llvm-exegesis_lib_

23 months ago[SystemZ] Add "REQUIRES: systemz-registered-target" on test.
Jonas Paulsson [Tue, 6 Dec 2022 19:36:45 +0000 (13:36 -0600)]
[SystemZ] Add "REQUIRES: systemz-registered-target" on test.

The clang test that emits assembly needs this line as well.

23 months ago[CodeExtractor] Correctly propagate scope information post extraction
Felipe de Azevedo Piovezan [Thu, 1 Dec 2022 18:47:10 +0000 (13:47 -0500)]
[CodeExtractor] Correctly propagate scope information post extraction

When a new function "NewF" is created with instructions extracted from
another function "OldF", the CodeExtractor only preserves debug
line/column of the extracted instructions. However:

1. Any inlinedAt nodes are dropped.
2. The scope chain is replaced with a single node, the Subprogram of NewF.

Both of these are incorrect: most of the debug metadata from the
original instructions should be preserved. We only need to update the
Subprogram found at the scope of the last node of the inline chain; this
Subprogram used to be OldF but now should be NewF.

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

23 months ago[libunwind] Use .irp directives. NFC
Fangrui Song [Tue, 6 Dec 2022 19:05:04 +0000 (19:05 +0000)]
[libunwind] Use .irp directives. NFC

The repeated instructions make the file long and difficult to read.
Simplify them with .irp directives.

Reviewed By: #libunwind, compnerd

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

23 months agoAdd missing include
Adrian Prantl [Tue, 6 Dec 2022 18:54:46 +0000 (10:54 -0800)]
Add missing include

23 months ago[SystemZ] Emit a .gnu_attribute for an externally visible vector abi.
Jonas Paulsson [Mon, 28 Jun 2021 23:18:39 +0000 (18:18 -0500)]
[SystemZ] Emit a .gnu_attribute for an externally visible vector abi.

On SystemZ, the vector ABI changes depending on the presence of hardware
vector support. Therefore, each binary compiled with a visible vector ABI
(e.g. one that calls an external function with a vector argument) should be
marked with a .gnu_attribute describing this.

Reviewed By: uweigand

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

23 months ago[clang][Tooling] Add support for generating #import edits
David Goldman [Fri, 2 Dec 2022 15:04:51 +0000 (10:04 -0500)]
[clang][Tooling] Add support for generating #import edits

And make use of this from clangd's CodeComplete and IncludeFixer, although currently they are both restricted only to #include symbols.

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

23 months ago[clangd] Add new IncludeDirective to IncludeHeaderWithReferences
David Goldman [Fri, 2 Dec 2022 15:04:31 +0000 (10:04 -0500)]
[clangd] Add new IncludeDirective to IncludeHeaderWithReferences

The IncludeDirective contains both Include (the current behavior) and Import,
which we can use in the future to provide #import suggestions for
Objective-C files/symbols.

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

23 months ago[InstCombine] fold add-carry of bools to logic
Sanjay Patel [Tue, 6 Dec 2022 18:12:10 +0000 (13:12 -0500)]
[InstCombine] fold add-carry of bools to logic

((zext BoolX) + (zext BoolY)) >> 1 --> zext (BoolX && BoolY)
https://alive2.llvm.org/ce/z/LvZFKj

This was noted as a missing fold in D138814.

23 months ago[InstCombine] add tests for bool math; NFC
Sanjay Patel [Tue, 6 Dec 2022 16:53:06 +0000 (11:53 -0500)]
[InstCombine] add tests for bool math; NFC

This pattern came up in D138814.

23 months ago[RISCV] Teach RISCVMatInt to prefer li+slli over lui+addi(w) for compressibility.
Craig Topper [Tue, 6 Dec 2022 18:31:13 +0000 (10:31 -0800)]
[RISCV] Teach RISCVMatInt to prefer li+slli over lui+addi(w) for compressibility.

With C extension, li with a 6 bit immediate followed by slli is 4 bytes.
The lui+addi(w) sequence is at least 6 bytes.

The two sequences probably have similar execution latency. The exception
being if the target supports lui+addi(w) macrofusion.

Since the execution latency is probably the same I didn't restrict
this to C extension.

Reviewed By: reames

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

23 months agoReapply "[mlgo] Dependency-free training mode logger"
Mircea Trofin [Tue, 6 Dec 2022 18:21:13 +0000 (10:21 -0800)]
Reapply "[mlgo] Dependency-free training mode logger"

This reverts commit 8abe7b11f74bea63d3134c144137b72146da0c7b.

Added the missing cast which was causing a build problem on certain compilers.

23 months ago[ARM] IselLowering unsigned overflow to crash using APInt in PerformSHLSimplify
Peter Rong [Sat, 3 Dec 2022 01:06:40 +0000 (17:06 -0800)]
[ARM] IselLowering unsigned overflow to crash using APInt in PerformSHLSimplify

This diff fixes issue https://github.com/llvm/llvm-project/issues/59317

We should check if bitwidth is lower than the shift amount before we subtract them to avoid unsigned overflow.

Reviewed By: dmgreen

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

23 months agoProcess: convert Optional to std::optional
Krzysztof Parzyszek [Tue, 6 Dec 2022 17:53:37 +0000 (09:53 -0800)]
Process: convert Optional to std::optional

This applies to GetEnv and FindInEnvPath.

23 months agoRevert "[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in...
Roman Lebedev [Tue, 6 Dec 2022 17:47:20 +0000 (20:47 +0300)]
Revert "[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`"

This is still not working for me:
```
-- Configuring done
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.amdgpu" which requires target "elf_common" that is not in any export set.
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.cuda" which requires target "elf_common" that is not in any export set.
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.x86_64" which requires target "elf_common" that is not in any export set.
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.cuda.nextgen" which requires target "elf_common" that is not in any export set.
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.cuda.nextgen" which requires target "PluginInterface" that is not in any export set.
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.x86_64.nextgen" which requires target "elf_common" that is not in any export set.
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.x86_64.nextgen" which requires target "PluginInterface" that is not in any export set.
-- Generating done
```

This reverts commit e682a76c3bf61c52628d79d6ec4db221430768c0.

23 months agoRevert "[mlir] Add hoisting of transfer ops in affine loops"
Mitch Phillips [Tue, 6 Dec 2022 17:44:07 +0000 (09:44 -0800)]
Revert "[mlir] Add hoisting of transfer ops in affine loops"

This reverts commit 825da072a8ede585be9d23829f7ac483f2dbae78.

Reason: Broke the sanitizer buildbots. See original review for more
details: https://reviews.llvm.org/D137600

23 months agoAdd missing include
Adrian Prantl [Tue, 6 Dec 2022 17:43:55 +0000 (09:43 -0800)]
Add missing include

23 months ago[SCEV] `MatchBinaryOp()`: try to recognize `or` as `add`-in-disguise (w/ no common...
Roman Lebedev [Tue, 6 Dec 2022 17:04:26 +0000 (20:04 +0300)]
[SCEV] `MatchBinaryOp()`: try to recognize `or` as `add`-in-disguise (w/ no common bits set)

LLVM *loves* to convert `add` of operands with no common bits
into an `or`. But SCEV really doesn't deal with `or` that well,
so try extra hard to recognize this `or` as an `add`.

I believe, previously this wasn't being done because of the recursive
of this, but now that the `createSCEV()` is not recursive,
this should be fine. Unless this is *too* costly compile-time wise...

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

23 months ago[RISCV] Restrict when RISCVMatInt will retry SLLI as a last step. NFC
Craig Topper [Tue, 6 Dec 2022 17:25:20 +0000 (09:25 -0800)]
[RISCV] Restrict when RISCVMatInt will retry SLLI as a last step. NFC

The main algorithm will already end with a SLLI when there are 12
or more trailing zeros. We only need to retry when there are less
than 12 trailing zeros since the main algorithm will pick an ADDI
or ADDIW at the end for those cases.

23 months agoRevert "[mlgo] Dependency-free training mode logger"
Florian Hahn [Tue, 6 Dec 2022 17:20:46 +0000 (17:20 +0000)]
Revert "[mlgo] Dependency-free training mode logger"

This reverts commit c5ff6f72342e0a4b0ba2ec9f603bedca86721e80.

This breaks building on macOS:

FAILED: lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TensorSpec.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/Analysis -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/lib/Analysis -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/include -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14  -fno-exceptions -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TensorSpec.cpp.o -MF lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TensorSpec.cpp.o.d -o lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TensorSpec.cpp.o -c /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/lib/Analysis/TensorSpec.cpp
In file included from /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/lib/Analysis/TensorSpec.cpp:16:
In file included from /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include/llvm/Analysis/TensorSpec.h:16:
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include/llvm/Support/JSON.h:354:29: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'int64_t' (aka 'long long') in initializer list [-Wc++11-narrowing]
    create<int64_t>(int64_t{I});
                            ^
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/lib/Analysis/TensorSpec.cpp:55:18: note: in instantiation of function template specialization 'llvm::json::Value::Value<unsigned long, void, void, void>' requested here
        OS.value(D);
                 ^
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include/llvm/Support/JSON.h:354:29: note: insert an explicit cast to silence this issue
    create<int64_t>(int64_t{I});
                            ^
                            static_cast<int64_t>( )
1 error generated.

https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/33120/consoleFull#-145995569149ba4694-19c4-4d7e-bec5-911270d8a58c

23 months ago[ConstraintElim] Add addition GEP tests with signed predicates.
Florian Hahn [Tue, 6 Dec 2022 17:11:54 +0000 (17:11 +0000)]
[ConstraintElim] Add addition GEP tests with signed predicates.

23 months ago[llvm-c][test] Remove typed pointer support from llvm-c-test echo
Arthur Eubanks [Mon, 5 Dec 2022 21:15:02 +0000 (13:15 -0800)]
[llvm-c][test] Remove typed pointer support from llvm-c-test echo

Reviewed By: nikic

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

23 months agoRevert "Revert "[mlir][sparse] Refactoring: abstract sparse tensor memory scheme...
Peiming Liu [Tue, 6 Dec 2022 01:25:38 +0000 (01:25 +0000)]
Revert "Revert "[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a SparseTensorDescriptor class.""

This reverts commit 10033a179f0c73f28f051ac70b058a0c61882e3a. Plus, it fixed windows warnings and gcc errors

Reviewed By: aartbik

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

23 months ago[ADT, Support] Move operator<< to raw_ostream.h (NFC)
Kazu Hirata [Tue, 6 Dec 2022 17:10:25 +0000 (09:10 -0800)]
[ADT, Support] Move operator<< to raw_ostream.h (NFC)

Without this patch, operator<< for Optional<T> and std::optional<T>
are in Optional.h.  This means that a C++ source file must include
Optional.h even if it just needs to stream std::optional<T> and has
nothing to do with Optional<T>, which is counter-intuitive.

This patch moves the operator<< to raw_ostream.h.

As a bonus, we get to resolve a circular dependency.  Optional.h no
longer needs to forward-declare raw_ostream.  That is, raw_ostream.h
depends on Optional.h, not vice versa.

As a preparation for this patch, I've checked in
77609717410372e8c43aca49a268511378f58297 to forward-declare
raw_ostream in those header files that were relying on the forward
declaration of raw_ostream in Optional.h.

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

23 months ago[AMDGPU] Add MC tests for s_endpgm's optional immediate operand
Jay Foad [Tue, 6 Dec 2022 16:34:10 +0000 (16:34 +0000)]
[AMDGPU] Add MC tests for s_endpgm's optional immediate operand

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

23 months agoRevert "[amdgpu] Reimplement LDS lowering"
Nico Weber [Tue, 6 Dec 2022 17:01:36 +0000 (12:01 -0500)]
Revert "[amdgpu] Reimplement LDS lowering"

This reverts commit 982017240d7f25a8a6969b8b73dc51f9ac5b93ed.
Breaks check-llvm, see https://reviews.llvm.org/D139433#3974862

23 months ago[mlir][crunner] Add support for random number generation.
bixia1 [Mon, 5 Dec 2022 23:57:30 +0000 (15:57 -0800)]
[mlir][crunner] Add support for random number generation.

Reviewed By: aartbik

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

23 months ago[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins...
Shilei Tian [Tue, 6 Dec 2022 16:36:07 +0000 (11:36 -0500)]
[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`

This patch uses `add_llvm_library` to build the target `PluginInterface` since it can handle LLVM dependences much better. One temporary drawback of using this is that currently LLVM CMake macro doesn't support object libraries very well (there was a try a couple years ago but it was reverted later https://github.com/llvm/llvm-project/commit/29e57229497711a3a294f437b59afa6ddc36a3d8). After switching to that, `CXX_VISIBILITY_PRESET` can not be set correctly, which can cause runtime error that a function call from one plugin could go to another. As a consequence, `PluginInterface` is built as a static library for now. I have asked the question in CMake community (https://discourse.cmake.org/t/set-target-properties-doesnt-work-properly/7016). Once that issue is solved, I'll switch it back to object library. It is not necessarily too bad to use static library, especially `BUILDTREE_ONLY` is already set such that `PluginInterface.a` will not be installed.

Reviewed By: jhuber6

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

23 months ago[SDAG] try to convert bit set/clear to signbit test when trunc is free
Sanjay Patel [Tue, 6 Dec 2022 16:17:52 +0000 (11:17 -0500)]
[SDAG] try to convert bit set/clear to signbit test when trunc is free

(X & Pow2MaskC) == 0 --> (trunc X) >= 0
(X & Pow2MaskC) != 0 --> (trunc X) <  0

This was noted as a regression in the post-commit feedback for D112634
(where we canonicalized IR differently).

For x86, this saves a few instruction bytes. AArch64 seems neutral.

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

23 months ago[AArch64][RISCV][x86] add tests for masked val equality with 0; NFC
Sanjay Patel [Mon, 5 Dec 2022 19:15:58 +0000 (14:15 -0500)]
[AArch64][RISCV][x86] add tests for masked val equality with 0; NFC

23 months ago[libc++][CI] Upgrades clang-format version used.
Mark de Wever [Mon, 5 Dec 2022 17:23:51 +0000 (18:23 +0100)]
[libc++][CI] Upgrades clang-format version used.

The version used is now determined by Buildkite instead of using the
hard-coded version in the Docker image.

Reviewed By: #libc, ldionne

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

23 months ago[amdgpu] Reimplement LDS lowering
Jon Chesterfield [Tue, 6 Dec 2022 16:10:42 +0000 (16:10 +0000)]
[amdgpu] Reimplement LDS lowering

Renames the current lowering scheme to "module" and introduces two new
ones, "kernel" and "table", plus a "hybrid" that chooses between those three
on a per-variable basis.

Unit tests are set up to pass with the default lowering of "module" or "hybrid"
with this patch defaulting to "module", which will be a less dramatic codegen
change relative to the current. This reflects the sparsity of test coverage for
the table lowering method. Hybrid is better than module in every respect and
will be default in a subsequent patch.

Reviewed By: arsenm

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

23 months ago[exegesis] ParallelSnippetGenerator: SingleStaticRegPerOperand if 2+ use regs
Roman Lebedev [Tue, 6 Dec 2022 16:26:31 +0000 (19:26 +0300)]
[exegesis] ParallelSnippetGenerator: SingleStaticRegPerOperand if 2+ use regs

For instrs with tied operands, that strategy will not produce anything
different from `SingleStaticReg` unless there are at least two registers.

23 months ago[Test] Add test exposing crash in SimplifyCFG when hoisting llvm.deoptimize
Dmitry Makogon [Tue, 6 Dec 2022 16:16:48 +0000 (23:16 +0700)]
[Test] Add test exposing crash in SimplifyCFG when hoisting llvm.deoptimize

23 months ago[mlgo] Dependency-free training mode logger
Mircea Trofin [Mon, 5 Dec 2022 21:41:27 +0000 (13:41 -0800)]
[mlgo] Dependency-free training mode logger

This is the next step in dropping the dependency on protobuf.

The simple logger produces an output consisting of lines of json
strings. Tensor values - which should constitute the bulk of the data -
are serialized as raw byte buffers. This allows for light-weight reading
of the values.

The next step is to switch the training logic to the new logging format,
following which the protobuf-based logger will be dropped, together with
the training dependency on protobuf.

Subsequent changes will also stop buffering and stream, instead - the
buffering model is just as a convenient point-in-time.

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

23 months ago[BasicAA] Guard against empty successors list (PR59360)
Nikita Popov [Tue, 6 Dec 2022 15:56:19 +0000 (16:56 +0100)]
[BasicAA] Guard against empty successors list (PR59360)

Succs can be empty here if a phi predecessor is unreachable.

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