peter klausler [Mon, 17 May 2021 21:06:44 +0000 (14:06 -0700)]
[flang] Implement MATMUL in the runtime
Define an API for the transformational intrinsic function MATMUL,
implement it, and add some basic unit tests. The large number of
possible argument type combinations are covered by a set of
generalized templates that are instantiated for each valid
pair of possible argument types.
Places where BLAS-2/3 routines could be called for acceleration
are marked with TODOs. Handling for other special cases (e.g.,
known-shape 3x3 matrices and vectors) are deferred.
Some minor tweaks were made to the recent related implementation
of DOT_PRODUCT to reflect lessons learned.
Differential Revision: https://reviews.llvm.org/D102652
Fangrui Song [Tue, 18 May 2021 17:57:24 +0000 (10:57 -0700)]
[Driver] Delete -mimplicit-it=
This is a GNU as and Clang cc1as option, not a GCC option.
Users should specify `-Wa,-mimplicit-it=` instead.
Note: mixing the -m option and the -Wa, option doesn't work
`-Wa,-mimplicit-it=never -mimplicit-it=always` =>
`clang (LLVM option parsing): for the --arm-implicit-it option: may only occur zero or one times!`
Reviewed By: nickdesaulniers, raj.khem
Differential Revision: https://reviews.llvm.org/D102568
Nico Weber [Mon, 17 May 2021 17:49:17 +0000 (13:49 -0400)]
[lld/mac] Correctly set nextdefsym
In LC_DYSYMTAB, private externs were still emitted as exported symbols instead
of as locals.
Fixes PR50373. See bug for details.
Differential Revision: https://reviews.llvm.org/D102662
Chris Lattner [Tue, 18 May 2021 17:23:01 +0000 (10:23 -0700)]
[IntegerAttr] Add helpers for working with LLVM's APSInt type.
The FIRRTL dialect in CIRCT uses inherently signful types, and APSInt
is the best way to model that. Add a couple of helpers that make it
easier to work with an IntegerAttr that carries a sign.
This follows the example of getZExt() and getSExt() which assert when
the underlying type of the attribute is unexpected. In this case
we assert fail when the underlying type of the attribute is signless.
This is strictly additive, so it is NFC. It is tested in the CIRCT
repo.
Differential Revision: https://reviews.llvm.org/D102701
Arthur Eubanks [Tue, 18 May 2021 17:39:12 +0000 (10:39 -0700)]
[NFC] Format PassesBindingsTests CMake like other unittests
Sanjay Patel [Tue, 18 May 2021 17:28:31 +0000 (13:28 -0400)]
[InstCombine] restrict funnel shift match to avoid miscompile
As noted in the post-commit discussion for:
https://reviews.llvm.org/rGabd7529625a73f405e40a63dcc446c41d51a219e
...that change exposed a logic hole that allows a miscompile
if the shift amount could exceed the narrow width:
https://alive2.llvm.org/ce/z/-i_CiM
https://alive2.llvm.org/ce/z/NaYz28
The restriction isn't necessary for a rotate (same operand for
both shifts), so we should adjust the matching for the shift
value as a follow-up enhancement:
https://alive2.llvm.org/ce/z/ahuuQb
Arthur Eubanks [Tue, 18 May 2021 16:33:50 +0000 (09:33 -0700)]
[test] Speculative fix for bots (round 2)
Bot has error "Failed to create target from default triple: Unable to
find target for this triple (no targets are registered)", likely because
we only initialized the native target, not the registered target if it's
different.
https://lab.llvm.org/buildbot/#/builders/86/builds/13664
Arthur Eubanks [Tue, 18 May 2021 17:25:35 +0000 (10:25 -0700)]
[gn build] Rename PassesBindingsTests and add it to unittests
Sanjay Patel [Tue, 18 May 2021 12:01:10 +0000 (08:01 -0400)]
[InstCombine] add tests for funnel shift miscompile; NFC
Chris Lattner [Sun, 16 May 2021 05:18:16 +0000 (22:18 -0700)]
[IR] Add a Location to BlockArgument.
This adds the ability to specify a location when creating BlockArguments.
Notably Value::getLoc() will return this correctly, which makes diagnostics
more precise (e.g. the example in test-legalize-type-conversion.mlir).
This is currently optional to avoid breaking any existing code - if
absent, the BlockArgument defaults to using the location of its enclosing
operation (preserving existing behavior).
The bulk of this change is plumbing location tracking through the parser
and printer to make sure it can round trip (in -mlir-print-debuginfo
mode). This is complete for generic operations, but requires manual
adoption for custom ops.
I added support for function-like ops to round trip their argument
locations - they print correctly, but when parsing the locations are
dropped on the floor. I intend to fix this, but it will require more
invasive plumbing through "function_like_impl" stuff so I think it
best to split it out to its own patch.
Differential Revision: https://reviews.llvm.org/D102567
Arthur Eubanks [Tue, 18 May 2021 17:12:51 +0000 (10:12 -0700)]
Revert "[test] Speculative fix for bots"
This reverts commit
5c291482ec8bcd686044ebc0d4cffe7bf769521c.
unittests/Passes/CMakeFiles/PassesBindingsTests.dir/PassBuilderBindingsTest.cpp.o: In function `PassBuilderCTest::SetUp()':
PassBuilderBindingsTest.cpp:(.text._ZN16PassBuilderCTest5SetUpEv[_ZN16PassBuilderCTest5SetUpEv]+0x28): undefined reference to `LLVMInitializeARMTargetInfo'
Simon Pilgrim [Tue, 18 May 2021 17:06:14 +0000 (18:06 +0100)]
[X86] Use Skylake Server model for x86-64-v4 so we have full instruction coverage
The x86-64-v4 generic cpu arch supports AVX512BW/DQ/CD/VLX which isn't covered by the Haswell model, use the SkylakeServer model instead which is a lot closer to what the arch represents.
Differential Revision: https://reviews.llvm.org/D102553
Arthur Eubanks [Tue, 18 May 2021 16:33:50 +0000 (09:33 -0700)]
[test] Speculative fix for bots
Bot has error "Failed to create target from default triple: Unable to
find target for this triple (no targets are registered)", likely because
we only initialized the native target, not the registered target if it's
different.
https://lab.llvm.org/buildbot/#/builders/86/builds/13664
Arthur Eubanks [Tue, 18 May 2021 17:00:54 +0000 (10:00 -0700)]
[gn build] Add target for PassesBindingsTest
Jessica Paquette [Mon, 17 May 2021 23:00:53 +0000 (16:00 -0700)]
[AArch64][GlobalISel] Prefer mov for s32->s64 G_ZEXT
We can use an ORRWrs (mov) + SUBREG_TO_REG rather than a UBFX for G_ZEXT on
s32->s64.
This closer matches what SDAG does, and is likely more power efficient etc.
(Also fixed up arm64-rev.ll which had a fallback check line which was entirely
useless.)
Simple example: https://godbolt.org/z/h1jKKdx5c
Differential Revision: https://reviews.llvm.org/D102656
Roman Lebedev [Tue, 18 May 2021 16:53:02 +0000 (19:53 +0300)]
[X86] AMD Zen 3: fix MULX modelling - don't forget about WriteIMulH (PR50387)
Otherwise lack thereof will be caught by a defensive check during
scheduling, and we'll crash.
I've literally never seen this syntax before..
Vinayaka Bandishti [Tue, 18 May 2021 12:28:27 +0000 (17:58 +0530)]
[MLIR][Affine] Privatize certain escaping memrefs
During affine loop fusion, create private memrefs for escaping memrefs
too under the conditions that:
-- the source is not removed after fusion, and
-- the destination does not write to the memref.
This creates more fusion opportunities as illustrated in the test case.
Reviewed By: bondhugula, ayzhuang
Differential Revision: https://reviews.llvm.org/D102604
Aaron Ballman [Tue, 18 May 2021 16:42:52 +0000 (12:42 -0400)]
Speculatively fix failing tests from
6381664580080f015bc0c2ec647853f697cf744a
This was causing some Mac-specific build failures:
http://45.33.8.238/macm1/9739/step_7.txt
http://45.33.8.238/mac/31615/step_7.txt
As best I can tell with psychic debugging, the /Users/blah path to the
source file is being treated as a macro undef with the clang-cl driver.
This splits the filename off explicitly so hopefully the rest of the
command line arguments will be read properly.
Jessica Paquette [Fri, 14 May 2021 23:53:52 +0000 (16:53 -0700)]
[GlobalISel] Simplify G_ICMP to true/false when the result is known
Use existing KnownBits helpers from KnownBits.h to simplify G_ICMPs.
E.g.
x == x -> true
x != x -> false
load(x) > 1 -> true (when the load is known to be greater than 1)
And so on.
Differential Revision: https://reviews.llvm.org/D102542
Sergey Dmitriev [Tue, 18 May 2021 15:43:51 +0000 (08:43 -0700)]
[clang-offload-bundler] Add sections and set section flags using one llvm-objcopy invocation
llvm-objcopy has been changed to support adding a section and updating section flags
in one run (D90438), so we can now change clang-offload-bundler to run llvm-objcopy
tool only once when creating fat object.
Reviewed By: ABataev
Differential Revision: https://reviews.llvm.org/D102670
Lang Hames [Tue, 18 May 2021 04:38:17 +0000 (21:38 -0700)]
[ORC-RT] Add apply_tuple utility.
This is a substitute for std::apply, which we can't use until we move to c++17.
apply_tuple will be used in upcoming the upcoming wrapper-function utils code.
Lang Hames [Tue, 18 May 2021 02:51:42 +0000 (19:51 -0700)]
[ORC-RT] Add compiler abstraction header for the ORC runtime.
This header provides helper macros to insulate the rest of the ORC runtime from
compiler specifics.
Lang Hames [Mon, 17 May 2021 19:28:46 +0000 (12:28 -0700)]
[ORC] Don't try to obtain a ref to a non-existent buffer.
Aaron Ballman [Tue, 18 May 2021 14:32:22 +0000 (10:32 -0400)]
Introduce SYCL 2020 mode
Currently, we have support for SYCL 1.2.1 (also known as SYCL 2017).
This patch introduces the start of support for SYCL 2020 mode, which is
the latest SYCL standard available at (https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html).
This sets the default SYCL to be 2020 in the driver, and introduces the
notion of a "default" version (set to 2020) when cc1 is in SYCL mode
but there was no explicit -sycl-std= specified on the command line.
Tim Northover [Tue, 12 Jan 2021 13:12:40 +0000 (13:12 +0000)]
Recommit X86: support Swift Async context
This adds support to the X86 backend for the newly committed swiftasync
function parameter. If such a (pointer) parameter is present it gets stored
into an augmented frame record (populated in IR, but generally containing
enhanced backtrace for coroutines using lots of tail calls back and forth).
The context frame is identical to AArch64 (primarily so that unwinders etc
don't get extra complexity). Specfically, the new frame record is [AsyncCtx,
%rbp, ReturnAddr], and its presence is signalled by bit 60 of the stored %rbp
being set to 1. %rbp still points to the frame pointer in memory for backwards
compatibility (only partial on x86, but OTOH the weird AsyncCtx before the rest
of the record is because of x86).
Recommited with a fix for unwind info when i386 pc-rel thunks are
adjacent to a prologue.
Jinsong Ji [Tue, 18 May 2021 14:03:26 +0000 (14:03 +0000)]
[DebugInfo][test] Check specific func name to ignore codegen differences
We use `CHECK-LABEL: define` to divide input stream into functions,
this works well on most platforms.
But there are cases that some platforms (eg: AIX) may have different
codegen , especially for global constructor and descructors.
On AIX, the codegen will have two more functions: __dtor_b,
__finalize_b, which will fail the test.
The fix is to use specific function name so that we can safely ignore
those unrelated codegen differences.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D102654
Raphael Isemann [Tue, 18 May 2021 08:30:54 +0000 (10:30 +0200)]
[ADT] Remove StringRef::withNullAsEmpty
A long time ago LLDB wanted to start using StringRef instead of
C-Strings/ConstString but was blocked by the StringRef(const char *) ctor
asserting that the C-string isn't a nullptr. To workaround this, D24697
introduced a special function called withNullAsEmpty and that's what LLDB (and
only LLDB) started to use to build StringRefs from C-strings.
A bit later it seems that withNullAsEmpty was declared too awkward to use and
instead the assert in the StringRef constructor got removed (see D24904). The
rest of LLDB was then converted to StringRef by just calling the now perfectly
usable implicit constructor.
However, it seems that the original approach with withNullAsEmpty was never
touched again since then and now just exists as a function in StringRef that
is only used in a few places in LLDB.
I removed the few uses of withNullAsEmpty in D102597 and this patch removes
the function itself. Calling the implicit StringRef(const char *) constructor
is the preferred way of doing this today.
Reviewed By: lattner
Differential Revision: https://reviews.llvm.org/D102599
Roman Lebedev [Tue, 18 May 2021 12:55:02 +0000 (15:55 +0300)]
[X86] AMD Zen 3: cap LoopMicroOpBufferSize to workaround PR50384 (quadratic IndVars runtime)
While i would like to keep the right value here,
i would also like to be able to actually compile
e.g. vanilla test-suite.
256 is a pretty random guess, it should be pretty good enough
for serious loops, but small enough to result in tolerant
compile times for certain edge cases.
https://bugs.llvm.org/show_bug.cgi?id=50384
Kristina Bessonova [Sun, 18 Apr 2021 16:46:46 +0000 (18:46 +0200)]
[libcxx][test] Attempt to make debug mode tests more bulletproof
The problem with debug mode tests is that it isn't known which particular
_LIBCPP_ASSERT causes the test to exit, and as shown by
https://reviews.llvm.org/D100029 and
2908eb20ba7 it might be not the
expected one.
The patch adds TEST_LIBCPP_ASSERT_FAILURE macro that allows checking
_LIBCPP_ASSERT message to ensure we caught an expected failure.
Reviewed By: Quuxplusone, ldionne
Differential Revision: https://reviews.llvm.org/D100595
David Sherwood [Tue, 18 May 2021 10:42:48 +0000 (11:42 +0100)]
[NFC] Removed unused VFInfo comparison operator
Martin Storsjö [Tue, 18 May 2021 12:05:53 +0000 (15:05 +0300)]
[LLD] [MinGW] Pass the canExitEarly parameter through properly
The MinGW driver passed a hardcoded true to this parameter
since
6f4e255219f2a7878d3, but when the MinGW driver got the
canExitEarly parameter for consistency in
b11386f9be9b2dc7276, this
call was missed so it wasn't passed on properly.
Simon Pilgrim [Tue, 18 May 2021 12:06:57 +0000 (13:06 +0100)]
[X86][AVX] Cleanup AVX2 vector integer truncation costs
Noticed while investigating PR50364, the truncation costs for v4i64->v4i16/v4i8 and v8i32->v8i8 were way too optimistic for a shuffle sequence that usually matches the AVX1 codegen (they matched AVX512 numbers which have actual truncation instructions!).
Nico Weber [Tue, 18 May 2021 00:53:55 +0000 (20:53 -0400)]
[lld/mac] Propagate -(un)exported_symbol(s_list) to privateExtern in Driver
That way, it's done only once instead of every time shouldExportSymbol() is
called.
Possibly a bit faster:
% ministat at_main at_symtodo
x at_main
+ at_symtodo
N Min Max Median Avg Stddev
x 30 3.9732189 4.114846 4.024621 4.0304692 0.
037022865
+ 30 3.93766 4.0510042 3.9973931 3.991469 0.
028472565
Difference at 95.0% confidence
-0.0390002 +/- 0.0170714
-0.967635% +/- 0.423559%
(Student's t, pooled s = 0.0330256)
In other runs with n=30 it makes no perf difference, so maybe it's just noise.
But being able to quickly and conveniently answer "is this symbol exported?"
is useful for fixing PR50373 and for implementing -dead_strip, so this seems
like a good change regardless.
No behavior change.
Differential Revision: https://reviews.llvm.org/D102661
Florian Hahn [Fri, 14 May 2021 22:33:27 +0000 (23:33 +0100)]
[LV] Add test which sinks a load a across an aliasing store.
Simon Pilgrim [Tue, 18 May 2021 11:24:59 +0000 (12:24 +0100)]
[CostModel][X86] Add scalar truncation cost checks
Ensure these are all zero
Simon Pilgrim [Tue, 18 May 2021 11:20:19 +0000 (12:20 +0100)]
[CostModel][X86] Add missing check prefixes from cast.ll
We have checks for these but no actual RUNs were using them
Simon Pilgrim [Tue, 18 May 2021 11:15:38 +0000 (12:15 +0100)]
Revert rGd70cbd1ce9b426f2c7e0e0f900769bbcbb300a95 "[AMDGPU] Regenerate wave32.ll tests"
This is failing on buildbots but not locally - not sure why
Simon Pilgrim [Tue, 18 May 2021 11:03:13 +0000 (12:03 +0100)]
[AMDGPU] Regenerate wave32.ll tests
Keep the manual GFX10DEFWAVE checks for VGPRBlocks
Alexey Bader [Tue, 13 Apr 2021 14:10:15 +0000 (17:10 +0300)]
[SYCL] Enable `opencl_global_[host,device]` attributes for SYCL
Differential Revision: https://reviews.llvm.org/D100396
Nicolas Vasilache [Tue, 18 May 2021 10:07:03 +0000 (10:07 +0000)]
[mlir][Linalg] Drop spuriously long matmul_column_major benchmark
Ole Strohm [Mon, 17 May 2021 14:25:52 +0000 (15:25 +0100)]
[OpenCL] Fix initialization of __constant constructors without arguments
This fixes the initialization of objects in the __constant
address space that occurs when declaring the object.
Fixes part of PR42566
Reviewed By: Anastasia
Differential Revision: https://reviews.llvm.org/D102248
James Henderson [Thu, 6 May 2021 14:44:46 +0000 (15:44 +0100)]
[lld] Add a feature for each lld variant when use_lld is called
This allows tests to detect whether to run or not, dependent on which
LLD version is required for the test.
Reviewed by: thopre
Differential Revision: https://reviews.llvm.org/D101997
James Henderson [Mon, 17 May 2021 14:02:29 +0000 (15:02 +0100)]
[lit] Stop using PATH to lookup clang/lld/lldb unless requested
This patch stops lit from looking on the PATH for clang, lld and other
users of use_llvm_tool (currently only the debuginfo-tests) unless the
call explicitly requests to opt into using the PATH. When not opting in,
tests will only look in the build directory.
See the mailing list thread starting from
https://lists.llvm.org/pipermail/llvm-dev/2021-May/150421.html.
See the review for details of why decisions were made about when still
to use the PATH.
Reviewed by: thopre
Differential Revision: https://reviews.llvm.org/D102630
Adrian Kuegel [Tue, 18 May 2021 08:40:49 +0000 (10:40 +0200)]
[mlir] Add folder for complex.ReOp and complex.ImOp.
Now that complex constants are supported, we can also fold.
Differential Revision: https://reviews.llvm.org/D102616
Jay Foad [Tue, 18 May 2021 09:15:49 +0000 (10:15 +0100)]
[AMDGPU] Fix typo in comment
Benjamin Kramer [Tue, 18 May 2021 09:09:12 +0000 (11:09 +0200)]
[CodeGen] Avoid unused variable warning in Release builds. NFCI.
Neal (nealsid) [Tue, 18 May 2021 09:03:30 +0000 (10:03 +0100)]
Update MSVC version number in preprocessor check
Passing template parameter packs to std::map doesn't work in VS 2017/2019, so this updates the preprocessor version check to use an alternate version in VS2019, as well.
Reviewed By: DavidSpickett
Differential Revision: https://reviews.llvm.org/D102260
Raphael Isemann [Tue, 18 May 2021 07:29:20 +0000 (09:29 +0200)]
[lldb][NFC] Cleanup IRForTarget member initializers
Note that the FunctionCallee members aren't pointer, so the nullptr was just
an alternative way to call the default constructor.
Fraser Cormack [Mon, 17 May 2021 10:13:19 +0000 (11:13 +0100)]
[RISCV] Fix operand order in fixed-length VM(OR|AND)NOT patterns
Where the RVV specification writes `vs2, vs1`, our TableGen patterns use
`rs1, rs2`. These differences can easily cause confusion. The VMANDNOT
instruction performs `LHS && !RHS`, and similarly for VMORNOT.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D102606
Florian Hahn [Tue, 18 May 2021 07:47:17 +0000 (08:47 +0100)]
[VPlan] Add VPUserID to distinguish between recipes and others.
This allows cast/dyn_cast'ing from VPUser to recipes. This is needed
because there are VPUsers that are not recipes.
Reviewed By: gilr, a.elovikov
Differential Revision: https://reviews.llvm.org/D100257
Marius Brehler [Tue, 18 May 2021 07:46:23 +0000 (07:46 +0000)]
[mlir][docs] Fix broken link to Toy example
Balazs Benics [Tue, 18 May 2021 07:43:20 +0000 (09:43 +0200)]
[ASTimporter] Remove decl from lookup only if it has decl context
In the case of TypedefDecls we set the DeclContext after we imported it.
It turns out, it could lead to null pointer dereferences during the
cleanup part of a failed import.
This patch demonstrates this issue and fixes it by checking if the
DeclContext is available or not.
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/D102640
Raphael Isemann [Tue, 18 May 2021 07:03:28 +0000 (09:03 +0200)]
[lldb][NFC] Remove all uses of StringRef::withNullAsEmpty in LLDB
A long time ago LLDB wanted to start using StringRef instead of
C-Strings/ConstString but was blocked by the fact that the StringRef constructor
that takes a C-string was asserting that the C-string isn't a nullptr. To
workaround this, D24697 introduced a special function called `withNullAsEmpty`
and that's what LLDB (and only LLDB) started to use to build StringRefs from
C-strings.
A bit later it seems that `withNullAsEmpty` was declared too awkward to use and
instead the assert in the StringRef constructor got removed (see D24904). The
rest of LLDB was then converted to StringRef by just calling the now perfectly
usable implicit constructor.
However, all the calls to `withNullAsEmpty` just remained and are now just
strange artefacts in the code base that just look out of place. It's also
curiously a LLDB-exclusive function and no other project ever called it since
it's introduction half a decade ago.
This patch removes all uses of `withNullAsEmpty`. The follow up will be to
remove the function from StringRef.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D102597
Vitaly Buka [Tue, 18 May 2021 07:11:20 +0000 (00:11 -0700)]
[NFC][scudo] Reduce test region size on MIPS32
David Green [Tue, 18 May 2021 07:07:30 +0000 (08:07 +0100)]
[RDA] Fix printing of regs / reg units. NFC
It was printing RegUnits as Regs, leading to much confusion in the debug
logs.
Sander de Smalen [Tue, 18 May 2021 06:37:31 +0000 (07:37 +0100)]
[LV] Return both fixed and scalable Max VF from computeMaxVF.
This patch introduces a new class, MaxVFCandidates, that holds the
maximum vectorization factors that have been computed for both scalable
and fixed-width vectors.
This patch is intended to be NFC for fixed-width vectors, although
considering a scalable max VF (which is disabled by default) pessimises
tail-loop elimination, since it can no longer determine if any chosen VF
(less than fixed/scalable MaxVFs) is guaranteed to handle all vector
iterations if the trip-count is known. This issue will be addressed in
a future patch.
Reviewed By: fhahn, david-arm
Differential Revision: https://reviews.llvm.org/D98721
Dmitry Vyukov [Fri, 14 May 2021 07:26:15 +0000 (09:26 +0200)]
sanitizer_common/symbolizer: fix crashes during exit
Override __cxa_atexit and ignore callbacks.
This prevents crashes in a configuration when the symbolizer
is built into sanitizer runtime and consequently into the test process.
LLVM libraries have some global objects destroyed during exit,
so if the test process triggers any bugs after that, the symbolizer crashes.
An example stack trace of such crash:
For the standalone llvm-symbolizer this does not hurt,
we just don't destroy few global objects on exit.
Reviewed By: kda
Differential Revision: https://reviews.llvm.org/D102470
Pushpinder Singh [Mon, 17 May 2021 08:22:36 +0000 (08:22 +0000)]
[AMDGPU][Libomptarget] Rename & move g_executables to private
This patch moves g_executables to private member of Runtime class
and is renamed to HSAExecutables following LLVM naming convention.
This movement required making Runtime::Initialize and Runtime::Finalize
non-static. Verified the correctness of this change by running
libomptarget tests on gfx906.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D102600
Ten Tzen [Tue, 18 May 2021 05:06:32 +0000 (22:06 -0700)]
[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1
This patch is the Part-1 (FE Clang) implementation of HW Exception handling.
This new feature adds the support of Hardware Exception for Microsoft Windows
SEH (Structured Exception Handling).
This is the first step of this project; only X86_64 target is enabled in this patch.
Compiler options:
For clang-cl.exe, the option is -EHa, the same as MSVC.
For clang.exe, the extra option is -fasync-exceptions,
plus -triple x86_64-windows -fexceptions and -fcxx-exceptions as usual.
NOTE:: Without the -EHa or -fasync-exceptions, this patch is a NO-DIFF change.
The rules for C code:
For C-code, one way (MSVC approach) to achieve SEH -EHa semantic is to follow
three rules:
* First, no exception can move in or out of _try region., i.e., no "potential
faulty instruction can be moved across _try boundary.
* Second, the order of exceptions for instructions 'directly' under a _try
must be preserved (not applied to those in callees).
* Finally, global states (local/global/heap variables) that can be read
outside of _try region must be updated in memory (not just in register)
before the subsequent exception occurs.
The impact to C++ code:
Although SEH is a feature for C code, -EHa does have a profound effect on C++
side. When a C++ function (in the same compilation unit with option -EHa ) is
called by a SEH C function, a hardware exception occurs in C++ code can also
be handled properly by an upstream SEH _try-handler or a C++ catch(...).
As such, when that happens in the middle of an object's life scope, the dtor
must be invoked the same way as C++ Synchronous Exception during unwinding
process.
Design:
A natural way to achieve the rules above in LLVM today is to allow an EH edge
added on memory/computation instruction (previous iload/istore idea) so that
exception path is modeled in Flow graph preciously. However, tracking every
single memory instruction and potential faulty instruction can create many
Invokes, complicate flow graph and possibly result in negative performance
impact for downstream optimization and code generation. Making all
optimizations be aware of the new semantic is also substantial.
This design does not intend to model exception path at instruction level.
Instead, the proposed design tracks and reports EH state at BLOCK-level to
reduce the complexity of flow graph and minimize the performance-impact on CPP
code under -EHa option.
One key element of this design is the ability to compute State number at
block-level. Our algorithm is based on the following rationales:
A _try scope is always a SEME (Single Entry Multiple Exits) region as jumping
into a _try is not allowed. The single entry must start with a seh_try_begin()
invoke with a correct State number that is the initial state of the SEME.
Through control-flow, state number is propagated into all blocks. Side exits
marked by seh_try_end() will unwind to parent state based on existing
SEHUnwindMap[].
Note side exits can ONLY jump into parent scopes (lower state number).
Thus, when a block succeeds various states from its predecessors, the lowest
State triumphs others. If some exits flow to unreachable, propagation on those
paths terminate, not affecting remaining blocks.
For CPP code, object lifetime region is usually a SEME as SEH _try.
However there is one rare exception: jumping into a lifetime that has Dtor but
has no Ctor is warned, but allowed:
Warning: jump bypasses variable with a non-trivial destructor
In that case, the region is actually a MEME (multiple entry multiple exits).
Our solution is to inject a eha_scope_begin() invoke in the side entry block to
ensure a correct State.
Implementation:
Part-1: Clang implementation described below.
Two intrinsic are created to track CPP object scopes; eha_scope_begin() and eha_scope_end().
_scope_begin() is immediately added after ctor() is called and EHStack is pushed.
So it must be an invoke, not a call. With that it's also guaranteed an
EH-cleanup-pad is created regardless whether there exists a call in this scope.
_scope_end is added before dtor(). These two intrinsics make the computation of
Block-State possible in downstream code gen pass, even in the presence of
ctor/dtor inlining.
Two intrinsic, seh_try_begin() and seh_try_end(), are added for C-code to mark
_try boundary and to prevent from exceptions being moved across _try boundary.
All memory instructions inside a _try are considered as 'volatile' to assure
2nd and 3rd rules for C-code above. This is a little sub-optimized. But it's
acceptable as the amount of code directly under _try is very small.
Part-2 (will be in Part-2 patch): LLVM implementation described below.
For both C++ & C-code, the state of each block is computed at the same place in
BE (WinEHPreparing pass) where all other EH tables/maps are calculated.
In addition to _scope_begin & _scope_end, the computation of block state also
rely on the existing State tracking code (UnwindMap and InvokeStateMap).
For both C++ & C-code, the state of each block with potential trap instruction
is marked and reported in DAG Instruction Selection pass, the same place where
the state for -EHsc (synchronous exceptions) is done.
If the first instruction in a reported block scope can trap, a Nop is injected
before this instruction. This nop is needed to accommodate LLVM Windows EH
implementation, in which the address in IPToState table is offset by +1.
(note the purpose of that is to ensure the return address of a call is in the
same scope as the call address.
The handler for catch(...) for -EHa must handle HW exception. So it is
'adjective' flag is reset (it cannot be IsStdDotDot (0x40) that only catches
C++ exceptions).
Suppress push/popTerminate() scope (from noexcept/noTHrow) so that HW
exceptions can be passed through.
Original llvm-dev [RFC] discussions can be found in these two threads below:
https://lists.llvm.org/pipermail/llvm-dev/2020-March/140541.html
https://lists.llvm.org/pipermail/llvm-dev/2020-April/141338.html
Differential Revision: https://reviews.llvm.org/D80344/new/
Pushpinder Singh [Mon, 17 May 2021 07:11:13 +0000 (07:11 +0000)]
[AMDGPU][libomptarget] Remove unused global variables
This initial patch removes some unused variables from global namespace.
There will more incoming patches for moving global variables to classes
or static members.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D102598
Serguei Katkov [Tue, 18 May 2021 04:35:32 +0000 (11:35 +0700)]
[Statepoint Lowering] Cleanup: remove unused option statepoint-always-spill-base.
Alexander Shaposhnikov [Tue, 18 May 2021 05:09:06 +0000 (22:09 -0700)]
[lld][MachO] Adjust isCodeSection signature
This diff changes the type of the argument of isCodeSection to const InputSection *.
NFC.
Test plan: make check-lld-macho
Differential revision: https://reviews.llvm.org/D102664
Adam Nemet [Tue, 18 May 2021 03:53:41 +0000 (20:53 -0700)]
[GVN] Improve analysis for missed optimization remark
This change tries to handle multiple dominating users of the pointer operand
by choosing the most immediately dominating one, if possible. While making
this change I also found that the previous implementation had a missing break
statement, making all loads with an odd number of dominating users emit an
OtherAccess value, so that has also been fixed.
Patch by Henrik G Olsson!
Differential Revision: https://reviews.llvm.org/D79097
Chen Zheng [Mon, 17 May 2021 07:16:55 +0000 (03:16 -0400)]
[PowerPC] only check the load instruction result number 0.
Reviewed By: nemanjai
Differential Revision: https://reviews.llvm.org/D102596
Sam Clegg [Fri, 14 May 2021 23:25:04 +0000 (16:25 -0700)]
[lld][WebAssembly] Refactor input chunk class hierarchy. NFC
The main motivation for this refactor is to remove the subclass
relationship between the InputSegment and MergeInputSegment and
SyntenticMergedInputSegment so that we can use the merging classes for
debug sections which are not data segments.
In the process of refactoring I also remove all the virtual functions
from the class hierarchy and try to reuse techniques used in the ELF
linker (see `lld/ELF/InputSections.h`).
Differential Revision: https://reviews.llvm.org/D102546
Philip Reames [Tue, 18 May 2021 03:52:46 +0000 (20:52 -0700)]
Revert "[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute (try 3)"
This reverts commit
6d3e3ae8a9ca10e063d541a959f4fe4cdb003dba.
Still seeing PPC build bot failures, and one arm self host bot failing. I'm officially stumped, and need help from a bot owner to reduce.
Stella Stamenova [Tue, 18 May 2021 03:26:59 +0000 (20:26 -0700)]
Revert "[ADT] Add new type traits for type pack indexes"
This reverts commit
a6d3987b8ef3b7616f0835b89515c4264f2a7a64.
Michael Kruse [Tue, 18 May 2021 03:15:46 +0000 (22:15 -0500)]
[Polly] Add support for -polly-dump-after(-file) with the NPM.
For the same reason as with -polly-dump-before, it is only supported
with -polly-position=early.
Serguei Katkov [Mon, 17 May 2021 06:40:38 +0000 (13:40 +0700)]
[Inliner] Copy attributes when deoptimize intrinsic is inlined
During inlining of call-site with deoptimize intrinsic callee we miss
attributes set on this call site. As a result attributes like deopt-lowering are
disappeared resulting in inefficient behavior of register allocator in codegen.
Just copy attributes for deoptimize call like we do for others calls.
Reviewers: reames, apilipenko
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D102602
Michael Kruse [Tue, 18 May 2021 00:31:09 +0000 (19:31 -0500)]
[Polly] Add support for -polly-dump-before(-file) with the NPM.
Only supported with -polly-position=early. Unfortunately, the
extension point callpack for VectorizerStart only passes a
FunctionPassManager, making it impossible to add a module pass.
Arthur Eubanks [Mon, 17 May 2021 17:07:28 +0000 (10:07 -0700)]
[NFC] Pass GV value type instead of pointer type to GetOrCreateLLVMGlobal
For opaque pointers, to avoid PointerType::getElementType().
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D102638
Arthur Eubanks [Fri, 14 May 2021 21:01:05 +0000 (14:01 -0700)]
[NFC][OpaquePtr] Avoid using PointerType::getElementType() in VectorUtils.cpp
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D102533
Adam Nemet [Fri, 11 Dec 2020 17:39:15 +0000 (09:39 -0800)]
[Matrix] Fold the transpose into the matmul operand used to fetch scalars
For column-major this is:
A * B^t
whereas for row-major:
A^t * B
Differential Revision: https://reviews.llvm.org/D101762
Rob Suderman [Tue, 18 May 2021 00:25:34 +0000 (17:25 -0700)]
[mlir][tosa] Cleanup of tosa.rescale lowering to linalg
Comment was poorly written. Changed to bail on contradictory information in
the double round.
Reviewed By: NatashaKnk
Differential Revision: https://reviews.llvm.org/D102651
Med Ismail Bennani [Tue, 18 May 2021 00:27:55 +0000 (01:27 +0100)]
[lldb/API] Use a valid LineEntry object in SBCompileUnit::FindLineEntryIndex
This patch updates `SBCompileUnit::FindLineEntryIndex` to pass a valid
`LineEntry` pointer to `CompileUnit::FindLineEntry`.
This caused `LineTable::FindLineEntryIndexByFileIndexImpl` to return its
`best_match` initial value (UINT32_MAX).
rdar://
78115426
Differential Revision: https://reviews.llvm.org/D102658
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Nico Weber [Mon, 17 May 2021 22:17:18 +0000 (18:17 -0400)]
[lld/mac] Inline a check
`match()` can only return for non-empty vectors, but at least in
non-LTO builds that isn't clear to the compiler. Help it out.
This is a minor but measurable speedup on my machine (but less
than what we might've lost in https://reviews.llvm.org/D100818#2764272 --
bot note higher N on this measurement here, so higher confidence here):
% ministat at_main at_branch
x at_main
+ at_branch
N Min Max Median Avg Stddev
x 30 3.9243979 4.0395119 3.987375 3.9826236 0.
027567796
+ 30 3.8495831 4.0009291 3.931325 3.9347135 0.
037832878
Difference at 95.0% confidence
-0.0479101 +/- 0.0171102
-1.20298% +/- 0.429622%
(Student's t, pooled s = 0.0331007)
No behavior change.
Eventually we should apply these lists at symbol parse time instead of
every time shouldExportSymbol() though :)
Differential Revision: https://reviews.llvm.org/D102655
Philip Reames [Mon, 17 May 2021 23:52:41 +0000 (16:52 -0700)]
[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute (try 3)
Resubmit after fixing test/Transforms/LoopVectorize/ARM/mve-gather-scatter-tailpred.ll
Previous commit message...
This is a resubmit of 3e5ce4 (which was reverted by 7fe41ac). The original commit caused a PPC build bot failure we never really got to the bottom of. I can't reproduce the issue, and the bot owner was non-responsive. In the meantime, we stumbled across an issue which seems possibly related, and worked around a latent bug in 80e8025. My best guess is that the original patch exposed that latent issue at higher frequency, but it really is just a guess.
Original commit message follows...
If we know that the scalar epilogue is required to run, modify the CFG to end the middle block with an unconditional branch to scalar preheader. This is instead of a conditional branch to either the preheader or the exit block.
The motivation to do this is to support multiple exit blocks. Specifically, the current structure forces us to identify immediate dominators and *which* exit block to branch from in the middle terminator. For the multiple exit case - where we know require scalar will hold - these questions are ill formed.
This is the last change needed to support multiple exit loops, but since the diffs are already large enough, I'm going to land this, and then enable separately. You can think of this as being NFCIish prep work, but the changes are a bit too involved for me to feel comfortable tagging the review that way.
Differential Revision: https://reviews.llvm.org/D94892
Stanislav Mekhanoshin [Wed, 12 May 2021 20:25:08 +0000 (13:25 -0700)]
[AMDGPU] Do not check denorm for LDS FP atomic with unsafe flag
This is already how it is handled for global and flat atomics.
Differential Revision: https://reviews.llvm.org/D102366
Philip Reames [Mon, 17 May 2021 23:49:32 +0000 (16:49 -0700)]
Revert "[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute"
This reverts commit
c23ce54b36b1a52eb280ea1d59802b56d6dd9800. I apparently missed some newly added non-x86 tests.
Philip Reames [Mon, 17 May 2021 23:08:19 +0000 (16:08 -0700)]
[LV] Unconditionally branch from middle to scalar preheader if the scalar loop must execute
This is a resubmit of 3e5ce4 (which was reverted by 7fe41ac). The original commit caused a PPC build bot failure we never really got to the bottom of. I can't reproduce the issue, and the bot owner was non-responsive. In the meantime, we stumbled across an issue which seems possibly related, and worked around a latent bug in 80e8025. My best guess is that the original patch exposed that latent issue at higher frequency, but it really is just a guess.
Original commit message follows...
If we know that the scalar epilogue is required to run, modify the CFG to end the middle block with an unconditional branch to scalar preheader. This is instead of a conditional branch to either the preheader or the exit block.
The motivation to do this is to support multiple exit blocks. Specifically, the current structure forces us to identify immediate dominators and *which* exit block to branch from in the middle terminator. For the multiple exit case - where we know require scalar will hold - these questions are ill formed.
This is the last change needed to support multiple exit loops, but since the diffs are already large enough, I'm going to land this, and then enable separately. You can think of this as being NFCIish prep work, but the changes are a bit too involved for me to feel comfortable tagging the review that way.
Differential Revision: https://reviews.llvm.org/D94892
Ben Shi [Mon, 17 May 2021 23:10:17 +0000 (07:10 +0800)]
[RISCV][test] Add new tests of or/xor in the zbs extension
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D102625
Ben Shi [Mon, 17 May 2021 23:06:12 +0000 (07:06 +0800)]
[clang][AVR] Redefine [u]int16_t to be compatible with avr-gcc
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D102547
Jim Ingham [Mon, 17 May 2021 22:31:54 +0000 (15:31 -0700)]
Revert "Reset the wakeup timeout when we re-enter the continue wait."
This reverts commit
bd5751f3d249ec0798060bd98c07272174c52af0.
This patch series is causing us to every so often miss switching
the state from eStateRunning to eStateStopped when we get the stop
packet from the debug server.
Reverting till I can figure out how that could be happening.
Scott Linder [Wed, 14 Apr 2021 17:25:11 +0000 (17:25 +0000)]
[ADT] Add new type traits for type pack indexes
Similar versions of these already exist, this effectively just just
factors them out into STLExtras. I plan to use these in future patches.
Differential Revision: https://reviews.llvm.org/D100672
Scott Linder [Mon, 5 Apr 2021 22:59:09 +0000 (22:59 +0000)]
[ADT] Factor out in_place_t and expose in Optional ctor
Differential Revision: https://reviews.llvm.org/D100671
Eli Friedman [Mon, 14 Sep 2020 23:13:37 +0000 (16:13 -0700)]
[AArch64][SVE] Implement extractelement of i1 vectors.
The implementation just extends the vector to a larger element type, and
extracts from that. Not fancy, but generates reasonable code.
There was discussion in the review of doing the promotion in
target-independent code, but I'm sticking with this to avoid making
LegalizeDAG infrastructure more complicated.
Differential Revision: https://reviews.llvm.org/D87651
Philip Reames [Mon, 17 May 2021 21:10:00 +0000 (14:10 -0700)]
Do actual DCE in LoopUnroll (try 3)
Recommitting after fixing a bug found post commit. Amusingly, try 1 had been correct, and by reverting to incorporate last minute review feedback, I introduce the bug. Oops. :)
The problem was that recursively deleting an instruction can delete instructions beyond the current iterator (via a dead phi), thus invalidating iteration. Test case added in LoopUnroll/dce.ll to cover this case.
LoopUnroll does a limited DCE pass after unrolling, but if you have a chain of dead instructions, it only deletes the last one. Improve the code to recursively delete all trivially dead instructions.
Differential Revision: https://reviews.llvm.org/D102511
Arthur Eubanks [Mon, 17 May 2021 20:56:49 +0000 (13:56 -0700)]
[test] Free triple in PassBuilderBindingsTest
Heejin Ahn [Sun, 16 May 2021 10:17:16 +0000 (03:17 -0700)]
[WebAssembly] Nullify DBG_VALUE_LISTs in DebugValueManager
WebAssemblyDebugValueManager class currently does not handle
DBG_VALUE_LIST instructions correctly for two reasons, which are
explained in https://bugs.llvm.org/show_bug.cgi?id=50361.
This effectively nullifies DBG_VALUE_LISTs in
WebAssemblyDebugValueManager so that the info will appear as "optimized
out" in debuggers but still be at least correct in the meantime.
Reviewed By: dschuff, jmorse
Differential Revision: https://reviews.llvm.org/D102589
River Riddle [Mon, 17 May 2021 20:25:00 +0000 (13:25 -0700)]
[mlir][NFC] Remove stale `createLowerAffinePass` declaration
This pass isn't defined in the Transforms/ library anymore.
Jinsong Ji [Mon, 17 May 2021 19:57:30 +0000 (19:57 +0000)]
[Driver][test] Don't assume integrated-as
The tests of fdebug-compilation-dir and -ffile-compilation-dir for `-x
assembler` are assuming integrated-as.
If the platform set the no-itegrated-as by default (eg: AIX for now), then this test will
fail.
Add the -integrated-as to aviod relying on the platform defaults.
Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D102647
Eli Friedman [Thu, 6 May 2021 19:27:01 +0000 (12:27 -0700)]
[clang CodeGen] Don't crash on large atomic function parameter.
I wouldn't recommend writing code like the testcase; a function
parameter isn't atomic, so using an atomic type doesn't really make
sense. But it's valid, so clang shouldn't crash on it.
The code was assuming hasAggregateEvaluationKind(Ty) implies Ty is a
RecordType, which isn't true. Just use isRecordType() instead.
Differential Revision: https://reviews.llvm.org/D102015
Markus Böck [Mon, 17 May 2021 20:12:22 +0000 (22:12 +0200)]
[lld][MinGW] Introduce aliases for -Bdynamic and -Bstatic
Besides -Bdynamic and -Bstatic, ld documents additional aliases for both of these options. Instead of -Bstatic, one may write -dn, -non_shared or -static. Instead of -Bdynamic one may write -dy or -call_shared. Source: https://sourceware.org/binutils/docs-2.36/ld/Options.html
This patch adds those aliases to the MinGW driver of lld for the sake of ld compatibility.
Encountered this case while compiling a static Qt 6.1 distribution and got build failures as -static was passed directly to the linker, instead of through the compiler driver.
Differential Revision: https://reviews.llvm.org/D102637
Dave Lee [Sat, 15 May 2021 01:11:29 +0000 (18:11 -0700)]
[lldb] Document ctrl-f for completing show-autosuggestion
Document how to complete command line suggestions provided by `show-autosuggestion`.
Differential Revision: https://reviews.llvm.org/D102544
Mitch Phillips [Mon, 17 May 2021 19:36:37 +0000 (12:36 -0700)]
Revert "X86: support Swift Async context"
This reverts commit
747e5cfb9f5d944b47fe014925b0d5dc2fda74d7.
Reason: New frame layout broke the sanitizer unwinder. Not clear why,
but seems like some of the changes aren't always guarded by Swyft
checks. See
https://reviews.llvm.org/rG747e5cfb9f5d944b47fe014925b0d5dc2fda74d7 for
more information.
Vitaly Buka [Mon, 17 May 2021 19:24:06 +0000 (12:24 -0700)]
[NFC][scudo] Clang-format tests
Arthur Eubanks [Mon, 17 May 2021 19:16:10 +0000 (12:16 -0700)]
Revert "[Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable"
This reverts commit
14dfb3831c425c7f22540a2160424224008c257e.
More false positives, see D100581.
LLVM GN Syncbot [Mon, 17 May 2021 18:56:03 +0000 (18:56 +0000)]
[gn build] Port
0c557db61711
Sanjay Patel [Mon, 17 May 2021 18:27:32 +0000 (14:27 -0400)]
[InstCombine] fold fnegs around select
This is one of the folds requested in:
https://llvm.org/PR39480
https://alive2.llvm.org/ce/z/NczU3V
Note - this uses the normal FMF propagation logic
(flags transfer from the final value to new/intermediate ops).
It's not clear if this matches what Alive2 implements,
so we may want to adjust one or the other.
Sanjay Patel [Mon, 17 May 2021 16:41:57 +0000 (12:41 -0400)]
[InstCombine] add tests for fneg-of-select; NFC