platform/upstream/llvm.git
2 years ago[ConstantFolding] Eliminate atan and atan2 calls
Mohammed Nurul Hoque [Wed, 10 Aug 2022 14:59:23 +0000 (10:59 -0400)]
[ConstantFolding] Eliminate atan and atan2 calls

From the opengroup specifications, atan2 may fail if the result
underflows and atan may fail if the argument is subnormal, but
we assume that does not happen and eliminate the calls if we
can constant fold the result at compile-time.

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

2 years ago[libc++] Make __libcpp_verbose_abort [[noreturn]]
Louis Dionne [Mon, 8 Aug 2022 15:53:34 +0000 (11:53 -0400)]
[libc++] Make __libcpp_verbose_abort [[noreturn]]

This will allow using it in functions that are [[noreturn]] themselves.

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

2 years agoRevert rGa772f775a2ba401e95a0bbe73deb6300f1dc12c0 "[clang-tidy] Support C++14 in...
Simon Pilgrim [Wed, 10 Aug 2022 14:25:04 +0000 (15:25 +0100)]
Revert rGa772f775a2ba401e95a0bbe73deb6300f1dc12c0 "[clang-tidy] Support C++14 in bugprone-signal-handler."

This was breaking a number of buildbots: https://lab.llvm.org/buildbot/#/builders/139/builds/26335

2 years ago[clang] Correct documentation for NEON and SVE operator support
David Truby [Wed, 10 Aug 2022 14:02:55 +0000 (15:02 +0100)]
[clang] Correct documentation for NEON and SVE operator support

Previously the language extension documentation didn't mention SVE and
was incomplete in listing the C/C++ operators supported on NEON. This
corrects the documentation to be in line with the implementation.

2 years ago[X86] Use DAG.getFreeze() to create freeze node. NFC.
Simon Pilgrim [Wed, 10 Aug 2022 13:35:50 +0000 (14:35 +0100)]
[X86] Use DAG.getFreeze() to create freeze node. NFC.

2 years ago[clang][dataflow] Analyze constructor bodies
Sam Estep [Wed, 10 Aug 2022 14:01:18 +0000 (14:01 +0000)]
[clang][dataflow] Analyze constructor bodies

This patch adds the ability to context-sensitively analyze constructor bodies, by changing `pushCall` to allow both `CallExpr` and `CXXConstructExpr`, and extracting the main context-sensitive logic out of `VisitCallExpr` into a new `transferInlineCall` method which is now also called at the end of `VisitCXXConstructExpr`.

Reviewed By: ymandel, sgatev, xazax.hun

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

2 years ago[mlir] Extract offsets-sizes-strides computation from `makeTiledShape(s)`.
Alexander Belyaev [Wed, 10 Aug 2022 13:26:49 +0000 (15:26 +0200)]
[mlir] Extract offsets-sizes-strides computation from `makeTiledShape(s)`.

This change separates computation of the actual parameters of the subset and
the materialization of subview/extract_slice. That way the users can still use
Linalg tiling logic even if they use different operations to materialize the
subsets.

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

2 years ago[LLDB] Add basic floating point ops to IR interpreter
Pavel Kosov [Wed, 10 Aug 2022 13:34:52 +0000 (16:34 +0300)]
[LLDB] Add basic floating point ops to IR interpreter

Patch adds support for fadd, fsub, fdiv, fmul and fcmp to IR interpreter.

~~~

OS Laboratory. Huawei RRI. Saint-Petersburg

Reviewed By: clayborg

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

2 years ago[AIX][tests] XFAIL for system-aix instead
Jake Egan [Wed, 10 Aug 2022 13:31:04 +0000 (09:31 -0400)]
[AIX][tests] XFAIL for system-aix instead

The Clang folding for floating-point sometimes calls out to the host.

2 years ago[mlir] Generate C++ doc comments for interfaces
Alex Zinenko [Wed, 10 Aug 2022 13:11:26 +0000 (15:11 +0200)]
[mlir] Generate C++ doc comments for interfaces

When emitting the declarations for interface methods defined in ODS,
also emit their descriptions as C++ comments. This makes the
documentation accessible to C++ tooling such as IDEs that offers better
usability than reading it form the .td or the website.

Reviewed By: jpienaar

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

2 years agoMigrate llvm.experimental.patchpoint() to ptr.
Edd Barrett [Wed, 10 Aug 2022 12:13:28 +0000 (13:13 +0100)]
Migrate llvm.experimental.patchpoint() to ptr.

This intrinsic used a typed pointer for a call target operand. This
change updates the operand to be an opaque pointer and updates all
pointers in all test files that use the intrinsic.

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

2 years ago[DAG] visitFREEZE - generalize freeze(op()) -> op(freeze()) to any number of operands
Simon Pilgrim [Wed, 10 Aug 2022 12:12:04 +0000 (13:12 +0100)]
[DAG] visitFREEZE - generalize freeze(op()) -> op(freeze()) to any number of operands

canCreateUndefOrPoison currently only handles unary ops, but we intend to change that soon - this more closely matches the pushFreezeToPreventPoisonFromPropagating behaviour where the freeze is pushed up to a single operand value, as long as all others are guaranteed not to be poison/undef.

However, pushFreezeToPreventPoisonFromPropagating would freeze all uses of the value - whilst this variant requires the frozen value to be only used in the op - we can look at generalize multiple uses later if the need arises.

2 years ago[mlir][shape] Update meet to handle all size & shape types
Jacques Pienaar [Wed, 10 Aug 2022 12:08:24 +0000 (05:08 -0700)]
[mlir][shape] Update meet to handle all size & shape types

Also tighten up return type inference & compatibility functions.

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

2 years ago[clang][dataflow] Store DeclContext of block being analysed in Environment if available.
Wei Yi Tee [Wed, 3 Aug 2022 14:48:49 +0000 (14:48 +0000)]
[clang][dataflow] Store DeclContext of block being analysed in Environment if available.

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

2 years ago[clang][AArch64][SVE] Add unary +/- operators for SVE types
David Truby [Tue, 2 Aug 2022 11:54:05 +0000 (11:54 +0000)]
[clang][AArch64][SVE] Add unary +/- operators for SVE types

This patch enables the unary promotion and negation operators on
SVE types.

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

2 years ago[DAG] canCreateUndefOrPoison - add freeze(truncate(x)) -> truncate(freeze(x)) support
Simon Pilgrim [Wed, 10 Aug 2022 10:27:08 +0000 (11:27 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(truncate(x)) -> truncate(freeze(x)) support

2 years ago[LLDB][AArch64][NFC] Fix some clang-format annotations
David Spickett [Wed, 10 Aug 2022 10:20:15 +0000 (10:20 +0000)]
[LLDB][AArch64][NFC] Fix some clang-format annotations

We don't want the DEFINE_ macros or the array registers
being clang formatted.

RegisterInfos_arm64.h was missing the off annotation and
RegisterInfos_arm64_sve.h needed the off moving to before
the macro definitions.

2 years ago[AArch64][SVE] Use SVE for VLS fcopysign for wide vectors
David Truby [Thu, 4 Aug 2022 12:40:12 +0000 (12:40 +0000)]
[AArch64][SVE] Use SVE for VLS fcopysign for wide vectors

Currently fcopysign for VLS vectors lowers through NEON even when the
vector width is wider than a NEON vector, causing bad codegen as the
vectors are split. This patch causes SVE to be used for these vectors
instead, giving much better codegen on wide VLS vectors.

Reviewed By: paulwalker-arm

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

2 years ago[clang-tidy] Support C++14 in bugprone-signal-handler.
Balázs Kéri [Wed, 10 Aug 2022 09:07:38 +0000 (11:07 +0200)]
[clang-tidy] Support C++14 in bugprone-signal-handler.

Check `bugprone-signal-handler` is improved to check for
C++-specific constructs in signal handlers. This check is
valid until C++17.

Reviewed By: whisperity

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

2 years ago[RISCV] Implement isUsedByReturnOnly TargetLowering hook in order to tailcall more...
Alex Bradbury [Wed, 10 Aug 2022 09:50:29 +0000 (10:50 +0100)]
[RISCV] Implement isUsedByReturnOnly TargetLowering hook in order to tailcall more libcalls

Prior to this patch, libcalls inserted by the SelectionDAG legalizer
could never be tailcalled. The eligibility of libcalls for tail calling
is is partly determined by checking TargetLowering::isInTailCallPosition
and comparing the return type of the libcall and the calleer.
isInTailCallPosition in turn calls TargetLowering::isUsedByReturnOnly
(which always returns false if not implemented by the target).

This patch provides a minimal implementation of
TargetLowering::isUsedByReturnOnly - enough to support tail calling
libcalls on hard float ABIs. Soft-float ABIs are left for a follow on
patch. libcall-tail-calls.ll also shows missed opportunities to tail
call integer libcalls, but this is due to issues outside of
the isUsedByReturnOnly hook.

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

2 years agoRevert "[Flang] Use find_program() to find clang-tblgen"
Nikita Popov [Wed, 10 Aug 2022 09:38:41 +0000 (11:38 +0200)]
Revert "[Flang] Use find_program() to find clang-tblgen"

This reverts commit 3bba12a81e242359580fa322cf1a9a0a43b461e6.

While this fixes doc generation in standalone flang builds, it
breaks them for combined builds of clang and flang.

2 years ago[X86][NFCI] Remove target-specific branch optimisation that's handled in BranchFolding
Alex Bradbury [Wed, 10 Aug 2022 09:35:31 +0000 (10:35 +0100)]
[X86][NFCI] Remove target-specific branch optimisation that's handled in BranchFolding

This specific optimisation is handled in OptimizeBlock in BranchFolding
so is redundant. As discussed on the review thread, I've verified that
we have test coverage for that optimisation within test/CodeGen/X86 by
disabling the BranchFolding version of this transform after applying
this patch and rerunning the test suite.

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

2 years ago[WebAssembly] Produce error when encountering unlowerable Wasm global accesses
Alex Bradbury [Wed, 10 Aug 2022 09:34:10 +0000 (10:34 +0100)]
[WebAssembly] Produce error when encountering unlowerable Wasm global accesses

WebAssembly globals are represented as IR globals with the wasm_var
address space (AS1). Prior to this patch, a wasm global load that isn't
lowerable will produce a failure to select, while a wasm global store
will produced incorrect code. This patch ensures we consistently produce
a clear error.

As noted in the test cases, it's conceivable that a frontend or an
optimisation pass could produce similar IR even in the presence of the
semantic restrictions on pointers to Wasm globals in the frontend, which
is a separate problem to address.

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

2 years agoRevert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""
Phoebe Wang [Wed, 10 Aug 2022 09:26:11 +0000 (17:26 +0800)]
Revert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""

This reverts commit 0729d00135ccbe1514a49168bbf26986823235c2.

Buildbot https://lab.llvm.org/buildbot/#/builders/19/builds/11989 failed
with "error: ISO C requires a translation unit to contain at least one declaration [-Werror,-Wempty-translation-unit]"

2 years ago[DAG] Use DAG.getFreeze() to create freeze node. NFC.
Simon Pilgrim [Wed, 10 Aug 2022 09:26:11 +0000 (10:26 +0100)]
[DAG] Use DAG.getFreeze() to create freeze node. NFC.

2 years ago[RISCV] Add cost model for fp-mask cast op.
jacquesguan [Thu, 4 Aug 2022 09:24:45 +0000 (17:24 +0800)]
[RISCV] Add cost model for fp-mask cast op.

The cost of convert from or to mask vector is different from other cases. We could not use PowDiff to calculate it. This patch set it to 3 as we use 3 instruction to make it.

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

2 years ago[Flang][OpenMP] Fix conversion of nested loops for SIMD directive
Dominik Adamski [Mon, 8 Aug 2022 09:51:54 +0000 (04:51 -0500)]
[Flang][OpenMP] Fix conversion of nested loops for SIMD directive

Flang was not able to convert simd directive which contains nested
Fortran loops. The nested Fortran loops inside SIMD directive
are modelled as FIR loops and they need to be translated into LLVM
MLIR dialect.

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

Reviewed by: peixin

Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
2 years ago[LLDB] Add multi value test for const static enum
David Spickett [Tue, 9 Aug 2022 08:38:17 +0000 (08:38 +0000)]
[LLDB] Add multi value test for const static enum

1438639a2f7eb9e9cba01454d3a9b1b16d179c9a removed a test
that was using undefined behaviour setting a non-typed enum
to a value outside its known range.

That test also checked if we formatted the value properly
when it could contain >1 valid enum value.

I don't think there's anything special about how we format
typed vs non-typed enums so I'm adding a test for ScopedEnum
that will expect to see 2 enum values plus extra.

Reviewed By: labath, Michael137, shafik

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

2 years ago[Attributor] Check for noalias call in AAInstanceInfo
Nikita Popov [Thu, 21 Jul 2022 07:53:26 +0000 (09:53 +0200)]
[Attributor] Check for noalias call in AAInstanceInfo

The relevant property of allocation functions of interest here is
their uniqueness (in the sense of disjoint provenance), which is
encoded by the noalias return attribute.

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

2 years ago[Flang] Use find_program() to find clang-tblgen
Nikita Popov [Mon, 8 Aug 2022 10:40:49 +0000 (12:40 +0200)]
[Flang] Use find_program() to find clang-tblgen

Use find_program() to find the clang-tblgen executable. The current
code ends up using docs/clang-tblgen for me...

This is the same way that mlir-tblgen is obtained in:
https://github.com/llvm/llvm-project/blob/27241435515554bc21105713c9d34cf886c5bced/flang/CMakeLists.txt#L95-L96.

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

2 years ago[workflow] Run release tasks for me (tru) as well.
Tobias Hieta [Wed, 10 Aug 2022 08:02:12 +0000 (10:02 +0200)]
[workflow] Run release tasks for me (tru) as well.

Reviewed By: tstellar

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

2 years ago[release] Use threaded compression with xz
Tobias Hieta [Wed, 10 Aug 2022 08:01:13 +0000 (10:01 +0200)]
[release] Use threaded compression with xz

Use xz -T0 to use your threads

Reviewed By: tstellar

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

2 years agotsan: update Go rules to use -std=c++17
Fangrui Song [Wed, 10 Aug 2022 07:32:40 +0000 (00:32 -0700)]
tsan: update Go rules to use -std=c++17

llvm-project has switched to require C++17.

Reviewed By: dvyukov

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

2 years ago[clang][transformer] Fix crash on replacement-less ASTEdit.
Clement Courbet [Thu, 30 Jun 2022 07:34:20 +0000 (09:34 +0200)]
[clang][transformer] Fix crash on replacement-less ASTEdit.

Given that we provide an EditGenerator edit(ASTEdit), we can't ever be
sure that the user won't give us an empty replacement.

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

2 years ago[libc] Add implementation of pthread_exit and thrd_exit.
Siva Chandra Reddy [Fri, 5 Aug 2022 20:53:46 +0000 (20:53 +0000)]
[libc] Add implementation of pthread_exit and thrd_exit.

Reviewed By: michaelrj

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

2 years agoReland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
Phoebe Wang [Wed, 10 Aug 2022 01:13:27 +0000 (09:13 +0800)]
Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"

Disable the build on macOS due to the bot fail.

Reviewed By: bkramer

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

2 years ago[ELF] Simplify llvm::enumerate with structured binding. NFC
Fangrui Song [Wed, 10 Aug 2022 04:52:08 +0000 (21:52 -0700)]
[ELF] Simplify llvm::enumerate with structured binding. NFC

2 years ago[ELF] De-template BitcodeFile::parse. NFC
Fangrui Song [Wed, 10 Aug 2022 04:46:28 +0000 (21:46 -0700)]
[ELF] De-template BitcodeFile::parse. NFC

2 years agoRevert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""
Med Ismail Bennani [Wed, 10 Aug 2022 04:44:20 +0000 (21:44 -0700)]
Revert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""

This reverts commit ab4e5ed441d475ead43bc4ce1cdef842688292f4 since it
causes a build failure on macOS:

https://green.lab.llvm.org/green/job/lldb-cmake/45984/

2 years ago[ELF] De-template createBitcodeSymbol. NFC
Fangrui Song [Wed, 10 Aug 2022 04:43:35 +0000 (21:43 -0700)]
[ELF] De-template createBitcodeSymbol. NFC

2 years ago[lldb/crashlog] Refactor the CrashLogParser logic
Med Ismail Bennani [Tue, 9 Aug 2022 23:36:47 +0000 (16:36 -0700)]
[lldb/crashlog] Refactor the CrashLogParser logic

This patch changes the CrashLogParser class to be both the base class
and a Factory for the JSONCrashLogParser & TextCrashLogParser.

That should help remove some code duplication and ensure both class
have a parse method.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Skip null image dsym fetching on interactive mode
Med Ismail Bennani [Wed, 10 Aug 2022 00:31:31 +0000 (17:31 -0700)]
[lldb/crashlog] Skip null image dsym fetching on interactive mode

Sometimes, it can happen that a crash report has null images in its list
of used binaries. This manifests like such:

```
    0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
```

When fetching debug symbols to symbolicate the crashlog stackframe,
having null images causes `dsymForUUID` to hang for few seconds.

This patch addresses that by skipping null images from being load by the
scripted process.

rdar://97419487

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Add `-s|--skip-status` option to interactive mode
Med Ismail Bennani [Wed, 3 Aug 2022 00:29:01 +0000 (17:29 -0700)]
[lldb/crashlog] Add `-s|--skip-status` option to interactive mode

This patch introduces a new option for the interactive crashlog mode,
that will prevent it from dumping the `process status` & `thread backtrace`
output to the debugger console.

This is necessary when lldb in running from an IDE, to prevent flooding
the console with information that should be already present in the UI.

rdar://96813296

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Remove 'process_path' parsing logic
Med Ismail Bennani [Wed, 3 Aug 2022 23:36:56 +0000 (16:36 -0700)]
[lldb/crashlog] Remove 'process_path' parsing logic

In can happen when creating stackshot crash report that that key is missing.

Moreover, we try to parse that key but don't use it, or need it, since we
fetch images and symbolicate the stackframes using the binaries UUIDs.

This is why this patch removes everything that is related to the
`process_path`/`procPath` parsing.

rdar://95054188

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Update frame regex matcher
Med Ismail Bennani [Thu, 4 Aug 2022 17:34:41 +0000 (10:34 -0700)]
[lldb/crashlog] Update frame regex matcher

This patch updates the regular expression matching stackframes in
crashlog to allow addresses that are 7 characters long and more (vs. 8
characters previously).

It changes the `0x[0-9a-fA-F]{7}[0-9a-fA-F]+` by `0x[0-9a-fA-F]{7,}`.

rdar://97684839

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Surface error using SBCommandReturnObject argument
Med Ismail Bennani [Wed, 3 Aug 2022 23:45:48 +0000 (16:45 -0700)]
[lldb/crashlog] Surface error using SBCommandReturnObject argument

This patch allows the crashlog script to surface its errors to lldb by
using the provided SBCommandReturnObject argument.

rdar://95048193

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[lldb/crashlog] Add '-t|--target' option to interactive mode
Med Ismail Bennani [Wed, 3 Aug 2022 21:11:43 +0000 (14:11 -0700)]
[lldb/crashlog] Add '-t|--target' option to interactive mode

This patch introduces a new flag for the interactive crashlog mode, that
allow the user to specify, which target to use to create the scripted
process.

This can be very useful when lldb already have few targets created:
Instead of taking the first one (zeroth index), we will use that flag to
create a new target. If the user didn't provide a target path, we will rely
on the symbolicator to create a targer.If that fails and there are already
some targets loaded in lldb, we use the first one.

rdar://94682869

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[MLIR] [Python] Fix the Windows build broken by d747a17
John Demme [Wed, 10 Aug 2022 03:07:33 +0000 (20:07 -0700)]
[MLIR] [Python] Fix the Windows build broken by d747a17

Windows builds require all control paths return. Since we don't have
`llvm_unreachable` in the Python bindings, just return `None`.

2 years ago[MLIR] [Python] Fix `Value.owner` to handle BlockArgs
John Demme [Wed, 10 Aug 2022 02:37:04 +0000 (19:37 -0700)]
[MLIR] [Python] Fix `Value.owner` to handle BlockArgs

Previously, calling `Value.owner()` would C++ assert in debug builds if
`Value` was a block argument. Additionally, the behavior was just wrong
in release builds. This patch adds support for BlockArg Values.

2 years agoReland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
Phoebe Wang [Wed, 10 Aug 2022 01:13:27 +0000 (09:13 +0800)]
Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"

Fix the mising change for truncdfbf2.c

Reviewed By: bkramer

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

2 years agoRevert "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
Phoebe Wang [Wed, 10 Aug 2022 02:05:12 +0000 (10:05 +0800)]
Revert "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"

This reverts commit 0ae2a41d803d715975d710ec289a4bd90ca534e2.

Revert due to buildbot fail.

2 years ago[sanitizer] Let internal symbolizer to use posix_memalign
Vitaly Buka [Wed, 10 Aug 2022 01:44:00 +0000 (18:44 -0700)]
[sanitizer] Let internal symbolizer to use posix_memalign

2 years ago[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available
Phoebe Wang [Wed, 10 Aug 2022 01:13:27 +0000 (09:13 +0800)]
[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available

#56854 shows a backwards compatibility problem when builtins of compiler-rt don't follow ABI. We need to prevent to fall into the trap again for BF16.

Reviewed By: bkramer

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

2 years ago[X86][BF16] Enable __bf16 for x86 targets.
Freddy Ye [Wed, 10 Aug 2022 00:59:21 +0000 (08:59 +0800)]
[X86][BF16] Enable __bf16 for x86 targets.

X86 psABI has updated to support __bf16 type, the ABI of which is the
same as FP16. See https://discourse.llvm.org/t/patch-add-optional-bfloat16-support/63149

Reviewed By: pengfei

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

2 years ago[X86][BF16] Make backend type bf16 to follow the psABI
Phoebe Wang [Wed, 10 Aug 2022 00:58:41 +0000 (08:58 +0800)]
[X86][BF16] Make backend type bf16 to follow the psABI

X86 psABI has updated to support __bf16 type, the ABI of which is the
same as FP16. See https://discourse.llvm.org/t/patch-add-optional-bfloat16-support/63149

This is an alternative of D129858, which has less code modification and
supports the vector type as well.

Reviewed By: LuoYuanke

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

2 years ago[COFF] Change a llvm::StringSet<> to llvm::DenseSet<StringRef>. NFC
Fangrui Song [Wed, 10 Aug 2022 00:50:42 +0000 (17:50 -0700)]
[COFF] Change a llvm::StringSet<> to llvm::DenseSet<StringRef>. NFC

The former stores strings and is therefore more expensive.

2 years ago[clang] add APValue type check in `TryPrintAsStringLiteral`
YingChi Long [Tue, 9 Aug 2022 17:11:41 +0000 (01:11 +0800)]
[clang] add APValue type check in `TryPrintAsStringLiteral`

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

https://reviews.llvm.org/D115031 improved printing of non-type template
parameter args. But checking if the end of Inits is 0 without checking
if APValue is an integer, causes clang to segfault. This patch adds
the code to check the type. (May not be a proper bugfix.)

Reviewed By: aaron.ballman, lichray

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

2 years ago[analyzer] Fix false positive in use-after-move checker
malavikasamak [Wed, 10 Aug 2022 00:25:19 +0000 (17:25 -0700)]
[analyzer] Fix false positive in use-after-move checker

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

2 years ago[mlir][sparse] fix doc
Aart Bik [Tue, 9 Aug 2022 22:48:00 +0000 (15:48 -0700)]
[mlir][sparse] fix doc

Reviewed By: Peiming

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

2 years agoFix modeline
Adrian Prantl [Tue, 9 Aug 2022 23:35:10 +0000 (16:35 -0700)]
Fix modeline

2 years ago[libc++] Implement `operator<=>` for `type_index`
Adrian Vogelsgesang [Sun, 7 Aug 2022 15:01:04 +0000 (08:01 -0700)]
[libc++] Implement `operator<=>` for `type_index`

Implements part of P1614R2 "The Mothership has Landed"

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

2 years ago[lldb/crashlog] Fix interactive crashlog test
Med Ismail Bennani [Thu, 28 Jul 2022 18:29:49 +0000 (11:29 -0700)]
[lldb/crashlog] Fix interactive crashlog test

This patch should fix the interactive crashlog test by checking in the
binary as a yaml to regeneate the binary with the addresses and offsets
when running the test.

rdar://93655633

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[libc++][NFC] Remove TEST_HAS_NO_SPACESHIP_OPERATOR
Adrian Vogelsgesang [Thu, 4 Aug 2022 22:43:59 +0000 (15:43 -0700)]
[libc++][NFC] Remove TEST_HAS_NO_SPACESHIP_OPERATOR

The corresponding _LIBCPP_HAS_NO_SPACESHIP_OPERATOR macro was already
removed in commit c0f87e8382

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

2 years ago[llvm-profdata] Support JSON as as an output-only format
Kazu Hirata [Tue, 9 Aug 2022 23:24:53 +0000 (16:24 -0700)]
[llvm-profdata] Support JSON as as an output-only format

This patch teaches llvm-profdata to output the sample profile in the
JSON format.  The new option is intended to be used for research and
development purposes.  For example, one can write a Python script to
take a JSON file and analyze how similar different inline instances of
a given function are to each other.

I've chosen JSON because Python can parse it reasonably fast, and it
just takes a couple of lines to read the whole data:

  import json
  with open ('profile.json') as f:
    profile = json.load(f)

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

2 years ago[libunwind] Use `_dl_find_object` if available
Adrian Vogelsgesang [Wed, 27 Jul 2022 20:55:58 +0000 (13:55 -0700)]
[libunwind] Use `_dl_find_object` if available

As shown in P2544R0 [1] and the accompanying benchmark [2], the
current unwinding logic does not scale for multi-threaded programs.
This is because `dl_iterate_phdr` takes a global lock.

glibc 2.35 added `_dl_find_object` which directly returns the unwind
info for a given target address. `_dl_find_object` is fully lock-free
and hence allows parallel exception unwinding on multiple threads.

With this commit, libunwind now takes advantage of `_dl_find_object`.
Thereby, this commit improves libunwind's performance on benchmark [2]
for unwinding exception on 20 threads from 1103ms to 78ms.
(measured on Intel Xeon Silver 4114 with 20 physical cores)

[1] https://isocpp.org/files/papers/P2544R0.html
[2] https://github.com/neumannt/exceptionperformance

Detailed performance numbers from the benchmark:

Before:
> Testing unwinding performance: sqrt computation with occasional errors
>
> testing baseline using 1 2 4 8 16 20 threads
> failure rate 0%: 34 35 34 35 35 36
> testing exceptions using 1 2 4 8 16 20 threads
> failure rate 0%: 16 32 33 34 35 36
> failure rate 0.1%: 16 32 34 36 35 36
> failure rate 1%: 20 40 40 43 90 113
> failure rate 10%: 59 92 140 304 880 1103
> [...]
>
> Testing invocation overhead: recursive fib with occasional errors
>
> testing exceptions using 1 2 4 8 16 20 threads
> failure rate 0%: 19 32 37 38 39 36
> failure rate 0.1%: 22 32 40 40 39 34
> failure rate 1%: 20 28 38 39 48 40
> failure rate 10%: 25 39 44 50 92 113

After:
> Testing unwinding performance: sqrt computation with occasional errors
>
> testing baseline using 1 2 4 8 16 20 threads
> failure rate 0%: 19 30 35 38 39 35
> testing baseline using 1 2 4 8 16 20 threads
> failure rate 0%: 32 35 33 34 34 36
> testing exceptions using 1 2 4 8 16 20 threads
> failure rate 0%: 16 35 33 37 35 35
> failure rate 0.1%: 16 32 36 33 34 37
> failure rate 1%: 21 37 39 40 40 41
> failure rate 10%: 72 75 76 80 80 78
> [...]
>
> Testing invocation overhead: recursive fib with occasional errors
>
> testing baseline using 1 2 4 8 16 20 threads
> failure rate 0%: 18 35 37 34 38 37
> testing exceptions using 1 2 4 8 16 20 threads
> failure rate 0%: 19 33 40 40 41 39
> failure rate 0.1%: 21 33 39 38 39 38
> failure rate 1%: 20 36 39 40 41 40
> failure rate 10%: 25 45 41 42 44 43

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

2 years ago[AMDGPU] SIFixSGPRCopies refactoring
alex-t [Sat, 6 Aug 2022 23:47:35 +0000 (01:47 +0200)]
[AMDGPU] SIFixSGPRCopies refactoring

This change finalizes the series of patches aiming to replace old
strategy of VGPR to SGPR copies loweriong.  Following the
https://reviews.llvm.org/D128252 and https://reviews.llvm.org/D130367 code
parts that are no longer used were removed.  Pass main loop is no longer used
for the MIR changes but collect information for further analysis.  Actual MIR
lowering happens further according the analysys result in the set of separate
functions. Another important change concerns the order of lowering: VGPR to
SGPR copies lowering is done first to have priority on the rest of the MIR
changes.

Reviewed By: rampitec

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

2 years ago[sanitizer] Use C++17 to build the symbolizer.
Evgenii Stepanov [Tue, 9 Aug 2022 22:31:52 +0000 (15:31 -0700)]
[sanitizer] Use C++17 to build the symbolizer.

2 years ago[libc][NFC] Fix a few compiler warnings.
Siva Chandra Reddy [Tue, 9 Aug 2022 22:27:46 +0000 (22:27 +0000)]
[libc][NFC] Fix a few compiler warnings.

2 years ago[RISCV] Split check lines for fpclamptosat_vec test
Philip Reames [Tue, 9 Aug 2022 21:58:26 +0000 (14:58 -0700)]
[RISCV] Split check lines for fpclamptosat_vec test

This is currently exercising scalarization code path; with vectors enabled, we hit a different code path.  Explicitly exercise both so that both configurations have testing.

2 years ago[ARM] Do not use LOAD_STACK_GUARD with ROPI/RWPI
Pengxuan Zheng [Mon, 8 Aug 2022 19:43:30 +0000 (12:43 -0700)]
[ARM] Do not use LOAD_STACK_GUARD with ROPI/RWPI

ROPI/RWPI are not supported with LOAD_STACK_GUARD currently.

Reviewed By: nickdesaulniers, rengolin

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

2 years ago@skipIfAsan for the other long test in TestMemoryRegion.py
Jim Ingham [Tue, 9 Aug 2022 21:54:18 +0000 (14:54 -0700)]
@skipIfAsan for the other long test in TestMemoryRegion.py

These two tests were each of them too long when running under ASAN,
so we have to skip both to get a clean ASAN bot run.

2 years ago[libc] Add __cxa_atexit support to the atexit function.
Siva Chandra Reddy [Tue, 2 Aug 2022 07:14:12 +0000 (07:14 +0000)]
[libc] Add __cxa_atexit support to the atexit function.

Reviewed By: abrachet

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

2 years ago[libc] Add a utility data structure named FixedVector.
Siva Chandra Reddy [Sat, 6 Aug 2022 00:19:51 +0000 (00:19 +0000)]
[libc] Add a utility data structure named FixedVector.

This data structure uses a backing cpp::array object and supports a
vector like push_back API. In comparison with a traditional vector
data structure, it is of a fixed capacity and cannot be resized.

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

2 years ago[AArch64][LoopVectorize] Introduce trip count minimal value threshold to ignore tail...
Dinar Temirbulatov [Tue, 9 Aug 2022 21:10:17 +0000 (22:10 +0100)]
[AArch64][LoopVectorize] Introduce trip count minimal value threshold to ignore tail-folding.

After D121595 was commited, I noticed regressions assosicated with small trip
count numbersvectorisation by tail folding with scalable vectors. As a solution
for those issues I propose to introduce the minimal trip count threshold value.

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

2 years ago[flang] Revert changes (NFC)
Jeff Niu [Tue, 9 Aug 2022 20:10:21 +0000 (16:10 -0400)]
[flang] Revert changes (NFC)

2 years ago[mlir] Fix build of toyc-ch6 (NFC)
Jeff Niu [Tue, 9 Aug 2022 19:58:49 +0000 (15:58 -0400)]
[mlir] Fix build of toyc-ch6 (NFC)

2 years agoThe memory region tests have been consistently timing on the ASAN
Jim Ingham [Tue, 9 Aug 2022 19:49:43 +0000 (12:49 -0700)]
The memory region tests have been consistently timing on the ASAN
bot.  This happens because they are building a long result into
a Python string, and the asan checker is making that very slow.

The last two tests here are both slow, but the 'test_command' is the
really slow one.  I'm going to start disabling just that one and see
if that gets the ASAN bots clean.

2 years ago[pseudo] Fix a suspicious usage of `sizeof(this)`.
Haojian Wu [Tue, 9 Aug 2022 19:46:56 +0000 (21:46 +0200)]
[pseudo] Fix a suspicious usage of `sizeof(this)`.

It should be `sizeof(*this)`.

2 years ago[mlir] Cleanup DenseArrayAttrBase definition and expose raw API
Jeff Niu [Mon, 8 Aug 2022 22:04:05 +0000 (18:04 -0400)]
[mlir] Cleanup DenseArrayAttrBase definition and expose raw API

This patch cleans up the definition of `DenseArrayAttrBase` by relying
more on ODS-generated methods. It also exposes an API for using the raw
data of a dense array, similar to `DenseIntOrFPElementsAttr::getRaw`.

Reviewed By: lattner, mehdi_amini

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

2 years agofix mlgo regalloc test model generation for tflite
yundiqian [Tue, 9 Aug 2022 19:10:08 +0000 (12:10 -0700)]
fix mlgo regalloc test model generation for tflite

To move from TF C API to TFLite, we found that the argmax op in TFLite does not work for int64 inputs, so cast the int64 inputs to int32 inputs to make TFLite argmax op work

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

2 years ago[mlir][LLVMIR] (NFC) Add convenience builders for ConstantOp
Jeff Niu [Tue, 9 Aug 2022 18:40:07 +0000 (14:40 -0400)]
[mlir][LLVMIR] (NFC) Add convenience builders for ConstantOp

And clean up some of the user code

2 years ago[LLD][COFF] Identify /GL object files which are inside libraries
Pengxuan Zheng [Tue, 9 Aug 2022 00:49:08 +0000 (17:49 -0700)]
[LLD][COFF] Identify /GL object files which are inside libraries

With D26647, we can already identify input object files compiled by cl.exe with
/GL. It seems to be helpful to do the same and print an error message for those
object files compiled with /GL but are inside libraries/archives too.

Reviewed By: rnk, thieta

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

2 years ago[Flang][OpenMP] Add support for integer multiplication reduction in worksharing-loop
Dylan Fleming [Tue, 9 Aug 2022 19:22:16 +0000 (19:22 +0000)]
[Flang][OpenMP] Add support for integer multiplication reduction in worksharing-loop

Adds support for reduction of multiplcation
by extending OpenMP.cpp::genOpenMPReduction()
and altering the identity constant emitted in
OpenMP.cpp::createReductionDelc()

This patch builds D130077 and as such,
only supports reductions for interger types in
worksharping loops.

Reviewed By: awarzynski

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

2 years ago[flang] Extend characterization & checking for procedure bindings
Peter Klausler [Tue, 9 Aug 2022 16:01:50 +0000 (09:01 -0700)]
[flang] Extend characterization & checking for procedure bindings

Procedure bindings with explicit interfaces don't work when the
interface is shadowed by a generic interface of the same name,
and can produce spurious semantic error messages.  Extend the
characterization and checking code for such things, and the utility
functionns on which they depend, to dig through generics when they
occlude interface-defining subprograms.  This is done on demand in
checking code, not once during name resolution, because the
procedures in question may also be forward-referenced.

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

diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index e79f8ab6503e..0b03bf06eb73 100644
--- a/flang/include/flang/Semantics/symbol.h

2 years ago[mlir][sparse] fix switch statement bug on two binary ops
Aart Bik [Tue, 9 Aug 2022 16:39:58 +0000 (09:39 -0700)]
[mlir][sparse] fix switch statement bug on two binary ops

They appeared at the wrong place in the switch, treating
them as unary op rather than binary op.

Reviewed By: bixia

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

2 years ago[mlir][sparse] update bibliography of sparse tensor dialect
Aart Bik [Tue, 9 Aug 2022 18:00:07 +0000 (11:00 -0700)]
[mlir][sparse] update bibliography of sparse tensor dialect

Reviewed By: Peiming

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

2 years ago[mlir][spirv] Use functors for default memory space mappings
Lei Zhang [Tue, 9 Aug 2022 18:32:22 +0000 (14:32 -0400)]
[mlir][spirv] Use functors for default memory space mappings

This makes it easier to use as a utility function to query the
mappings, including the reverse.

This commit also drops some storage classes that aren't needed
for now.

Reviewed By: kuhar

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

2 years ago[mlir][spirv] Detach memory space mapping from type conversion
Lei Zhang [Tue, 9 Aug 2022 18:25:38 +0000 (14:25 -0400)]
[mlir][spirv] Detach memory space mapping from type conversion

This commit moves MemRef memory space to SPIR-V storage class
conversion out of the main SPIR-V type converter. Now the mapping
should happen as a prelimiary step before performing the final
conversion to SPIR-V. Flows are expect to write their own memory
space mappings like the `MapMemRefStorageClassPass` to handle
memory space mappings according to their needs.

This is needed because SPIR-V is serving multiple client APIs,
including Vulkan and OpenCL. Different client APIs might want
to use different storage classes for buffers in a particular
memory space, e.g., `StorageBuffer` for Vulkan vs. `CrossWorkgroup`
for OpenCL when converting the default 0 memory space.  Hardcoding
a specific mapping makes that hard. While it's possible to embed
selection logic further inside the main type converter, it will
make the main type converter even complicated. So it's better to
separate the concerns, as mapping the memory space is really
concretizing the meaning of those numeric memory spaces in the
particular context of SPIR-V lowering.

Reviewed By: kuhar

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

2 years ago[RISCV] Refresh two autogened tests to avoid future whitespace diffs [nfc]
Philip Reames [Tue, 9 Aug 2022 18:23:09 +0000 (11:23 -0700)]
[RISCV] Refresh two autogened tests to avoid future whitespace diffs [nfc]

2 years ago[mlir][spirv] Make MemRef memory space mapping pass more flexible
Lei Zhang [Tue, 9 Aug 2022 18:15:55 +0000 (14:15 -0400)]
[mlir][spirv] Make MemRef memory space mapping pass more flexible

* Avoid restricting the pass to to builtin module ops. The pass
  should be able to run on any region ops.
* Avoid hardcoding func FuncOp when handling functions. Instead,
  use the function op interface.
* Assigns the default mapping in the constructor. So for cases
  where we are using the pass in a pipeline, we still have a
  meaningful default.

Along the way, dropped uncessary unrealized conversion casts and
use full conversion. The pass should be able to convert all sorts
of ops; there is really no need to have such bridages.

Reviewed By: kuhar

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

2 years ago[MLIR] Extend vector.gather to accept tensor as base
Jerry Wu [Tue, 9 Aug 2022 18:19:05 +0000 (11:19 -0700)]
[MLIR] Extend vector.gather to accept tensor as base

In addition to memref, accept ranked tensor as the base operand of vector.gather, similar to vector.trasnfer_read.

This will allow us to vectorize noncontiguous tensor.extract into vector.gather. Full discussion can be found here: https://github.com/iree-org/iree/issues/9198

Reviewed By: hanchung, dcaballe

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

2 years ago[MLIR] Support lowering n-D arith.index_cast to LLVM
Jerry Wu [Tue, 9 Aug 2022 18:12:00 +0000 (11:12 -0700)]
[MLIR] Support lowering n-D arith.index_cast to LLVM

Previously we can only lower arith.index_cast with 1-D vectors to LLVM. This change added the support for n-D vectors.

Reviewed By: ftynse, hanchung

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

2 years ago[mlir][spirv] Migrate to use specalized enum attributes
Lei Zhang [Tue, 9 Aug 2022 18:03:54 +0000 (14:03 -0400)]
[mlir][spirv] Migrate to use specalized enum attributes

Previously we are using IntegerAttr to back all SPIR-V enum
attributes. Therefore we all such attributes are showed like
IntegerAttr in IRs, which is barely readable and breaks
roundtripability of the IR. This commit changes to use
`EnumAttr` as the base directly so that we can have separate
attribute definitions and better IR printing.

Reviewed By: kuhar

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

2 years ago[mlir][sparse] improve semi-ring doc
Aart Bik [Tue, 9 Aug 2022 17:29:42 +0000 (10:29 -0700)]
[mlir][sparse] improve semi-ring doc

Spell out SparseVector instead of just using SparseVec

Reviewed By: jim22k, bixia

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

2 years ago[X86][ARM] Update tests for bitwise logic trees of shifts; NFC
Filipp Zhinkin [Tue, 9 Aug 2022 17:55:50 +0000 (20:55 +0300)]
[X86][ARM] Update tests for bitwise logic trees of shifts; NFC

Baseline tests for D131189.

2 years agoMove FormattersMatchCandidate flags to a struct.
Jorge Gorbe Moya [Tue, 9 Aug 2022 17:44:09 +0000 (10:44 -0700)]
Move FormattersMatchCandidate flags to a struct.

This removes some error-prone repetition in
FormatManager::GetPossibleMatches, where the same three boolean flags
are passed in a row multiple times as arguments to recursive calls to
GetPossibleMatches.

Instead of:
```
  // same flags, but with did_strip_typedef set to true.
  GetPossibleMatches(..., did_strip_ptr, did_strip_ref, true);
```
we can now say
```
  GetPossibleMatches(..., current_flags.WithStrippedTypedef());
```
which hopefully makes the intent clearer, and more readable in case we
add another flag.

Reviewed by: DavidSpickett, labath

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

2 years ago[docs][AArch64] Label Features with Arm ARM Names
Archibald Elliott [Mon, 8 Aug 2022 10:44:26 +0000 (11:44 +0100)]
[docs][AArch64] Label Features with Arm ARM Names

This patch adds the names of the Arm Architecture Reference Manual (ARM)
features to the corresponding Subtarget Features in the AArch64 backend
and target parser.

The aim of this is to make it clearer what architectural features a
subtarget feature might enable (so, which features a CPU must provide to
support that subtarget feature), and so make it easier to add new CPUs
in the future.

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

2 years agoLiveDebugValues: Fix another crash related to unreachable blocks
Adrian Prantl [Tue, 9 Aug 2022 17:34:57 +0000 (10:34 -0700)]
LiveDebugValues: Fix another crash related to unreachable blocks

This is a follow-up patch to D130999. In the test, the MIR contains an
unreachable MBB but the code attempts to look it up in MLocs. This
patch fixes this issue by checking for the default-constructed value.

rdar://97226240

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

2 years ago[InstCombine] fold usub.with.overflow to icmp when there's no use of the math value
Sanjay Patel [Tue, 9 Aug 2022 17:03:23 +0000 (13:03 -0400)]
[InstCombine] fold usub.with.overflow to icmp when there's no use of the math value

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

This is part of solving issue #56926.

2 years ago[RISCV] Pin a test to scalar lowering to preserve test intent [nfc]
Philip Reames [Tue, 9 Aug 2022 16:58:56 +0000 (09:58 -0700)]
[RISCV] Pin a test to scalar lowering to preserve test intent [nfc]

In an upcoming change to enable fixed length vector lowering via vector registers, the codepath exercised would change.  Pin this to the old lowering.