423449 Commits

Author SHA1 Message Date
Jonas Hahnfeld
e451d55234 [ORC] Fix sorting of contructors by priority
The code was incorrectly sorting by the function address.

Differential Revision: https://reviews.llvm.org/D123311
2022-05-11 09:06:41 +02:00
Xiang Li
85285be9c3 [DirectX backend] Add pass to lower llvm intrinsic into dxil op function.
A new pass DXILOpLowering was added.
It will scan all llvm intrinsics, create dxil op function if it can map to dxil op function.
Then translate call instructions on the intrinsic into call on dxil op function.
dxil op function will add i32 argument to the begining of args for dxil opcode.
So cannot use setCalledFunction to update the call instruction on intrinsic.

This commit only support sin to start the work.

Reviewed By: kuhar, beanz

Differential Revision: https://reviews.llvm.org/D124805
2022-05-11 00:03:05 -07:00
Yeting Kuo
4537aae0d5 [RISCV] Make PseudoReadVL have the vtypes of the corresponding VLEFF/VLSEGFF.
The patch make PseudoReadVL have the vtypes of the corresponding VLEFF/VLSEGFF.
It's useful to get the vtypes of locations of PseudoReadVL without finding the
corresponding VLEFF/VLSEGFF.
It could simplify optimizations in RISCVInsertVSETVLI like D123581.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D125199
2022-05-11 14:07:58 +08:00
jacquesguan
2509dcd58a [RISCV] Add rvv codegen support for vp.fpext.
This patch adds rvv codegen support for vp.fpext. The lowering of fp_round, vp.fptrunc, fp_extend and vp.fpext share most code so use a common lowering function to handle these four.
And this patch changes the intermediate cast from ISD::FP_EXTEND/ISD::FP_ROUND to the RVV VL version op RISCVISD::FP_EXTEND_VL and RISCVISD::FP_ROUND_VL for scalable vectors.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D123975
2022-05-11 03:28:25 +00:00
Peter Steinfeld
d4609ae47d [flang] Change "bad kind" messages in the runtime to "not yet implemented"
Similar to change D125046.

If a programmer is able to compile and link a program that contains types that
are not yet supported by the runtime, it must be because they're not yet
implemented.

This change will make it easier to find unimplemented code in tests.

Differential Revision: https://reviews.llvm.org/D125267
2022-05-10 20:08:03 -07:00
Mingming Liu
cb22cb2691 [X86] Fix 80 column violation in X86InstrInfo.cpp. NFC
Differential Revision: https://reviews.llvm.org/D125345
2022-05-10 19:56:14 -07:00
Mingming Liu
852f3d9987 Revert "[NFC] Run clang-format on llvm/lib/Target/X86/X86InstroInfo.cpp"
This reverts commit 8bef5476de3ec7388ad0c72b26dcc82ac7fd970a.

Need to revert, update commit message and reapply.
2022-05-10 19:53:31 -07:00
Alexander Shaposhnikov
da823382d2 [Transform][Utils][NFC] Clean up CtorUtils.cpp 2022-05-11 01:07:54 +00:00
Xiang1 Zhang
2ea8f203cd [CodeGen] Fix ConvertNodeToLibcall for STRICT_FPOWI
Reviewed By: PengfeiWang

Differential Revision: https://reviews.llvm.org/D125159
2022-05-11 08:58:06 +08:00
Mingming Liu
8bef5476de [NFC] Run clang-format on llvm/lib/Target/X86/X86InstroInfo.cpp
Differential Revision: https://reviews.llvm.org/D125345
2022-05-10 17:56:51 -07:00
Ting Wang
289236d597 [PowerPC] Fix PPCISD::STBRX selection issue on A2
Enable FeatureISA2_06 on Power A2 target

Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D125203
2022-05-10 20:47:51 -04:00
Eduard Zingerman
256a18997e [BPF] Add a test for making FI_ri as isPseudo
Commit 8a63326150ee ("[BPF] Mark FI_ri as isPseudo to avoid
assertion during disassembly") added isPseudo to FI_ri insn
in BPFInstrInfo.td file. This patch added the missing test file.

Differential Revision: https://reviews.llvm.org/D125185
2022-05-10 17:46:07 -07:00
Eduard Zingerman
8a63326150 [BPF] Mark FI_ri as isPseudo to avoid assertion during disassembly
When a specific sequence of bytes is present in the file during
disassembly the disassembler fails with the following assertion:

  ...
       0:	18 20 00 00 00 00 00 00	lea
  ... Assertion `idx < size()' failed.
  ...
  llvm::SmallVectorTemplateCommon<...>::operator[](...) ...
  llvm::MCInst::getOperand(unsigned int) ...
  llvm::BPFInstPrinter::printOperand(...) ...
  llvm::BPFInstPrinter::printInstruction() ...
  llvm::BPFInstPrinter::printInst(...) ...
  ...

The byte sequence causing the error is (little endian):

18 20 00 00  00 00 00 00  00 00 00 00  00 00 00 00

The issue could be reproduced using the program bellow:

  test.ir:

  @G = constant
         [16 x i8]
         [i8 u0x18, i8 u0x20, i8 u0x00, i8 u0x00, i8 u0x00, i8 u0x00, i8 u0x00, i8 u0x00,
          i8 u0x00, i8 u0x00, i8 u0x00, i8 u0x00, i8 u0x00, i8 u0x00, i8 u0x00, i8 u0x00],
         section "foo", align 8

Compiled and disassembled as follows:

  cat test.ir | llc -march=bpfel -filetype=obj -o - \
              | llvm-objdump --arch=bpfel --section=foo -d -

This byte sequence corresponds to FI_ri instruction declared in the
BPFInstrInfo.td as follows:

  def FI_ri
      : TYPE_LD_ST<BPF_IMM.Value, BPF_DW.Value,
                   (outs GPR:$dst),
                   (ins MEMri:$addr),
                   "lea\t$dst, $addr",
                   [(set i64:$dst, FIri:$addr)]> {
    // This is a tentative instruction, and will be replaced
    // with MOV_rr and ADD_ri in PEI phase
    let Inst{51-48} = 0;
    let Inst{55-52} = 2;
    let Inst{47-32} = 0;
    let Inst{31-0} = 0;
    let BPFClass = BPF_LD;
  }

Notes:
- First byte (opcode) is formed as follows:
  - BPF_IMM.Value is 0x00
  - BPF_DW.Value  is 0x18
  - BPF_LD        is 0x00
- Second byte (registers) is formed as follows:
  - let Inst{55-52} = 2;
  - let Inst{51-48} = 0;

The FI_ri instruction is always replaced by MOV_rr ADD_ri instructions
pair in the BPFRegisterInfo::eliminateFrameIndex method. Thus, this
instruction should be invisible to disassembler. This patch achieves
this by adding "isPseudo" flag for this instruction.

The bug was found by decompiling of one of the BPF tests from Linux
kernel (llvm-objdump -D tools/testing/selftests/bpf/bpf_iter_sockmap.o)

Differential Revision: https://reviews.llvm.org/D125185
2022-05-10 17:07:52 -07:00
Florian Mayer
de67bc8edb [HWASan symbolize] Write error to stderr. 2022-05-10 17:00:57 -07:00
Florian Mayer
be17d18ae8 [HWASan] deflake hwasan_symbolize test more.
Don't fail on corrupted ELF file on indexing. This happens because files
change in the directory from concurrent tests.
2022-05-10 16:57:44 -07:00
Peter Klausler
2cd95504df [flang] Allow local variables and function result inquiries in specification expressions
Inquiries into the bounds, size, and length of local variables (and function results)
are acceptable specification expressions.  A recent change allowed them for dummy
arguments that are not OPTIONAL or INTENT(OUT), but didn't address other object
entities.

Differential Revision: https://reviews.llvm.org/D125343
2022-05-10 16:47:03 -07:00
Nick Desaulniers
c167c0a4dc [BuildLibCalls] infer inreg param attrs from NumRegisterParameters
We're having a hard time booting the ARCH=i386 Linux kernel with clang
after removing -ffreestanding because instcombine was dropping inreg
from callers during libcall simplification, but not the callees defined
in different translation units. This led the callers and callees to have
wildly different calling conventions, which (predictably) blew up at
runtime.

Infer the inreg param attrs on function declarations from the module
metadata "NumRegisterParameters." This allows us to boot the ARCH=i386
Linux kernel (w/ -ffreestanding removed).

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

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D125285
2022-05-10 16:21:17 -07:00
Wende Tan
6baaad740a [Bitcode] Include indirect users of BlockAddresses in bitcode
The original fix (commit 23ec5782c3cc) of
https://github.com/llvm/llvm-project/issues/52787 only adds `Function`s
that have `Instruction`s that directly use `BlockAddress`es into the
bitcode (`FUNC_CODE_BLOCKADDR_USERS`).

However, in either @rickyz's original reproducing code:

```
void f(long);

__attribute__((noinline)) static void fun(long x) {
  f(x + 1);
}

void repro(void) {
  fun(({
    label:
      (long)&&label;
  }));
}
```

```
...
define dso_local void @repro() #0 {
entry:
  br label %label

label:                                            ; preds = %entry
  tail call fastcc void @fun()
  ret void
}

define internal fastcc void @fun() unnamed_addr #1 {
entry:
  tail call void @f(i64 add (i64 ptrtoint (i8* blockaddress(@repro, %label) to i64), i64 1)) #3
  ret void
}
...
```

or the xfs and overlayfs in the Linux kernel, `BlockAddress`es (e.g.,
`i8* blockaddress(@repro, %label)`) may first compose `ConstantExpr`s
(e.g., `i64 ptrtoint (i8* blockaddress(@repro, %label) to i64)`) and
then used by `Instruction`s. This case is not handled by the original
fix.

This patch adds *indirect* users of `BlockAddress`es, i.e., the
`Instruction`s using some `Constant`s which further use the
`BlockAddress`es, into the bitcode as well, by doing depth-first
searches.

Fixes: https://github.com/llvm/llvm-project/issues/52787
Fixes: 23ec5782c3cc ("[Bitcode] materialize Functions early when BlockAddress taken")

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D124878
2022-05-10 16:03:42 -07:00
Mingming Liu
fc58d7a326 [Peephole-opt][X86] Enhance peephole opt to see through SUBREG_TO_REG
(following AND) and eliminates redundant TEST instruction.

Differential Revision: https://reviews.llvm.org/D124118
2022-05-10 15:56:20 -07:00
Chia-hung Duan
96e642652b [mlir] Print some message for op-printing verification
Before dump, Insetad of switching to generic form silently after
verification failure. Print some debug logs to help identify why an op
may be printed in a different way.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D125136
2022-05-10 22:48:47 +00:00
Thomas Raoux
15bcc36eed [mlir][gpu] Move async copy ops to NVGPU and add caching hints
Move async copy operations to NVGPU as they only exist on NV target and are
designed to match ptx semantic. This allows us to also add more fine grain
caching hint attribute to the op.
Add hint to bypass L1 and hook it up to NVVM op.

Differential Revision: https://reviews.llvm.org/D125244
2022-05-10 22:30:24 +00:00
Vasileios Porpodas
71bcead98b [SLP] Make reordering aware of external vectorizable scalar stores.
The current reordering scheme only checks the ordering of in-tree operands.
There are some cases, however, where we need to adjust the ordering based on
the ordering of a future SLP-tree who's instructions are not part of the
current tree, but are external users.

This patch is a simple implementation of this. We keep track of scalar stores
that are users of TreeEntries and if they look profitable to vectorize, then
we keep track of their ordering. During the reordering step we take this new
index order into account. This can remove some shuffles in cases like in the
lit test.

Differential Revision: https://reviews.llvm.org/D125111
2022-05-10 15:25:35 -07:00
Philip Reames
7731935ffc [riscv] Consolidate logic for SEW/VL operand offset calculations [nfc] 2022-05-10 15:06:26 -07:00
Philip Reames
413052310a [riscv] Minor style cleanup so that code more obviously matches comments [nfc] 2022-05-10 14:20:26 -07:00
Mike Rice
0dbaef61b5 [OpenMP] Fix mangling for linear modifiers with variable stride
This adds support for variable stride with the val, uval, and ref linear
modifiers.  Previously only the no modifer type ls<argno> was supported.

  val  -> Ls<argno>
  uval -> Us<argno>
  ref  -> Rs<argno>

Differential Revision: https://reviews.llvm.org/D125330
2022-05-10 14:12:44 -07:00
LLVM GN Syncbot
a0f3ef42b0 [gn build] Port f822db7670d4 2022-05-10 21:06:25 +00:00
Mehdi Amini
3ffb08844c Remove unused variable (fix -Werror build on MSVC) 2022-05-10 21:04:52 +00:00
Jan Korous
0376c0f271 Revert "[utils] Avoid hardcoding metadata ids in update_cc_test_checks"
This reverts commit ce583b14b2ec37b1c168bb92020680cb452502b3.
2022-05-10 14:04:19 -07:00
Mingming Liu
1555c41abb Revert "Enhance peephole optimization."
This reverts commit d84ca05ef7f897fdd51900ea07e3c5344632130a.

Will revert, update commit message and re-commit.
2022-05-10 13:59:05 -07:00
Vasileios Porpodas
035aee725c [SLP][NFC] Precommit a lit test for a followup patch that improves tree reordering for external users.
Differential Revision: https://reviews.llvm.org/D125110
2022-05-10 13:47:17 -07:00
Erich Keane
eadeabbe10 [NFC] Replace not-null and not-isa check with a not-isa_and_nonnull 2022-05-10 13:34:07 -07:00
Jim Ingham
63865e1fce Add the "sent break" message to the "gdb-remote packets" channel
It was originally only in "gdb-remote process" but it is convenient to
also have it come as part of gdb-remote packets.
2022-05-10 13:28:50 -07:00
Matthias Braun
3bf643eb12 Update test for changes in f0ea9c9cec7f7b632ef7894ff7b3859269de611b / D124552 2022-05-10 13:25:38 -07:00
Nathan James
a308a55720 [clang-tidy] Fix unintended change left in 12cb540529e 2022-05-10 21:07:31 +01:00
jeff
f822db7670 [AMDGPU] Allow for MFMA Inst Clustering
This patch adds cluster edges between independent MFMA instructions. Additionally, it propogates all predecessors of cluster insts to the root of the cluster(s), and all successors to the leaf(ves) of the cluster(s) -- this is done to remove the possibility that those insts will be interspersed within the cluster.

Reviewed By: kerbowa

Differential Revision: https://reviews.llvm.org/D124678
2022-05-10 12:57:40 -07:00
Erich Keane
b6572ad504 [NFC] Add missing 'break' in a switch case 2022-05-10 12:48:08 -07:00
Mingming Liu
d84ca05ef7 Enhance peephole optimization.
Differential Revision: https://reviews.llvm.org/D124118
2022-05-10 12:35:35 -07:00
Erich Keane
508d2b4e13 [NFC]Add Missing Break in switch that we didn't notice because it was
last.
2022-05-10 12:27:45 -07:00
jeff
3ff8ee2447 [NFC] Fix typo
Reviewed By: kerbowa

Differential Revision: https://reviews.llvm.org/D124647
2022-05-10 12:11:21 -07:00
Arthur Eubanks
7e0802aeb5 [BasicAA] Fix order in which we pass MemoryLocations to alias()
D98718 caused the order of Values/MemoryLocations we pass to alias() to
be significant due to storing the offset in the PartialAlias case. But
some callers weren't audited and were still passing swapped arguments,
causing the returned PartialAlias offset to be negative in some
cases. For example, the newly added unittests would return -1
instead of 1.

Fixes #55343, a miscompile.

Reviewed By: asbirlea, nikic

Differential Revision: https://reviews.llvm.org/D125328
2022-05-10 12:05:38 -07:00
Florian Hahn
17a73992dd
[AArch64] Remove redundant f{min,max}nm intrinsics.
The patch extends AArch64TTIImpl::instCombineIntrinsic to simplify
llvm.aarch64.neon.f{min,max}nm(a, a) -> a.

This helps with simplifying code written using the ACLE, e.g.
see https://godbolt.org/z/jYxsoc89c

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D125234
2022-05-10 19:57:43 +01:00
Yaxun (Sam) Liu
180a8536ce Fix indentation in ReleaseNotes.rst 2022-05-10 14:56:28 -04:00
Nicolas Vasilache
1f23211cb1 [mlir][SCF] Retire cloneWithNewYields helper function.
This is now subsumed by `replaceLoopWithNewYields`.

Differential Revision: https://reviews.llvm.org/D125309
2022-05-10 18:44:11 +00:00
Mahesh Ravishankar
567fd523bf [mlir][SCF] Add utility method to add new yield values to a loop.
The current implementation of `cloneWithNewYields` has a few issues
- It clones the loop body of the original loop to create a new
  loop. This is very expensive.
- It performs `erase` operations which are incompatible when this
  method is called from within a pattern rewrite. All erases need to
  go through `PatternRewriter`.

To address these a new utility method `replaceLoopWithNewYields` is added
which
- moves the operations from the original loop into the new loop.
- replaces all uses of the original loop with the corresponding
  results of the new loop
- use a call back to allow caller to generate the new yield values.
- the original loop is modified to just yield the basic block
  arguments corresponding to the iter_args of the loop. This
  represents a no-op loop. The loop itself is dead (since all its uses
  are replaced), but is not removed. The caller is expected to erase
  the op. Consequently, this method can be called from within a
  `matchAndRewrite` method of a `PatternRewriter`.

The `cloneWithNewYields` could be replaces with
`replaceLoopWithNewYields`, but that seems to trigger a failure during
walks, potentially due to the operations being moved. That is left as
a TODO.

Differential Revision: https://reviews.llvm.org/D125147
2022-05-10 18:44:11 +00:00
Alan Zhao
82c5e302f9 [llvm-ml] Implement support for MASM's extern directive
The EXTERN keyword defines external symbols in MASM.

Credit goes to epastor@ for implementing most of the logic; I (ayzhao@)
added some bugfixes and tests.

[0]: https://docs.microsoft.com/en-us/cpp/assembler/masm/extern-masm?view=msvc-170

Reviewed By: epastor

Submitted By: epastor

Differential Revision: https://reviews.llvm.org/D125273
2022-05-10 14:36:06 -04:00
Yaxun (Sam) Liu
afc9d674fe [CUDA][HIP] support __noinline__ as keyword
CUDA/HIP programs use __noinline__ like a keyword e.g.
__noinline__ void foo() {} since __noinline__ is defined
as a macro __attribute__((noinline)) in CUDA/HIP runtime
header files.

However, gcc and clang supports __attribute__((__noinline__))
the same as __attribute__((noinline)). Some C++ libraries
use __attribute__((__noinline__)) in their header files.
When CUDA/HIP programs include such header files,
clang will emit error about invalid attributes.

This patch fixes this issue by supporting __noinline__ as
a keyword, so that CUDA/HIP runtime could remove
the macro definition.

Reviewed by: Aaron Ballman, Artem Belevich

Differential Revision: https://reviews.llvm.org/D124866
2022-05-10 14:32:27 -04:00
Sanjay Patel
0353c2c996 [InstCombine] fold shuffles with FP<->Int cast operands
shuffle (cast X), (cast Y), Mask --> cast (shuffle X, Y, Mask)

This is similar to a recent transform with fneg ( b331a7ebc1e0 ),
but this is intentionally the most conservative first step to
try to avoid regressions in codegen. There are several
restrictions that could be removed as follow-up enhancements.

Note that a cast with a unary shuffle is currently canonicalized
in the other direction (shuffle after cast - D103038 ). We might
want to invert that to be consistent with this patch.
2022-05-10 14:20:43 -04:00
Sanjay Patel
aca33294de [InstCombine] add tests for shuffles with FP<->int cast operands; NFC 2022-05-10 13:45:32 -04:00
Joseph Huber
045665423e [OpenMP] Fix embedding offload code when there is no offloading toolchain
Summary:
We use the `--offload-new-driver` option to enable offload code
embedding. The check for when to do this was flawed and was enabling it
too early in the case of OpenMP, causing a segfault when dereferencing
the offloading toolchain.
2022-05-10 13:33:20 -04:00
Jan Korous
ce583b14b2 [utils] Avoid hardcoding metadata ids in update_cc_test_checks
Specifically for: !tbaa, !tbaa.struct, !annotation, !srcloc, !nosanitize.

The goal is to avoid test brittleness caused by hardcoded values.

Differential Revision: https://reviews.llvm.org/D123273
2022-05-10 10:17:45 -07:00