Hongtao Yu [Thu, 25 Feb 2021 08:52:58 +0000 (00:52 -0800)]
[CSSPGO] Unblocking optimizations by dangling pseudo probes.
This change fixes a couple places where the pseudo probe intrinsic blocks optimizations because they are not naturally removable. To unblock those optimizations, the blocking pseudo probes are moved out of the original blocks and tagged dangling, instead of allowing pseudo probes to be literally removed. The reason is that when the original block is removed, we won't be able to sample it. Instead of assigning it a zero weight, moving all its pseudo probes into another block and marking them dangling should allow the counts inference a chance to assign them a more reasonable weight. We have not seen counts quality degradation from our experiments.
The optimizations being unblocked are:
1. Removing conditional probes for if-converted branches. Conditional probes are tagged dangling when their homing branch arms are folded so that they will not be over-counted.
2. Unblocking jump threading from removing empty blocks. Pseudo probe prevents jump threading from removing logically empty blocks that only has one unconditional jump instructions.
3. Unblocking SimplifyCFG and MIR tail duplicate to thread empty blocks and blocks with redundant branch checks.
Since dangling probes are logically deleted, they should not consume any samples in LTO postLink. This can be achieved by setting their distribution factors to zero when dangled.
Reviewed By: wmi
Differential Revision: https://reviews.llvm.org/D97481
Hongtao Yu [Thu, 25 Feb 2021 08:43:17 +0000 (00:43 -0800)]
[CSSPGO] Introducing dangling pseudo probes.
Dangling probes are the probes associated to an empty block. This usually happens when all real instructions are optimized away from the block. There is a problem with dangling probes during the offline counts processing. The way the sample profiler works is that samples collected on the first physical instruction following a probe will be counted towards the probe. This logically equals to treating the instruction next to a probe as if it is from the same block of the probe. In the dangling probe case, the real instruction following a dangling probe actually starts a new block, and samples collected on the new block may cause issues when counted towards the empty block.
To mitigate this issue, we first try to move around a dangling probe inside its owning block. If there are still native instructions preceding the probe in the same block, we can then use them as a place holder to collect samples for the probe. A pass is added to walk each block backwards looking for probes not followed by any real instruction and moving them before the first real instruction. This is done right before the object emission.
If we are unlucky to find such in-block preceding instructions for a probe, the solution we are taking is to tag such probe as dangling so that the samples reported for them will not be trusted by the compiler. We leave it up to the counts inference algorithm to get such probes a reasonable count. The number `UINT64_MAX` is used to mark sample count as collected for a dangling probe.
Reviewed By: wmi
Differential Revision: https://reviews.llvm.org/D95962
Christopher Di Bella [Thu, 4 Mar 2021 06:27:21 +0000 (22:27 -0800)]
[libcxx] adds concept `std::assignable_from`
Implements parts of:
- P0898R3 Standard Library Concepts
- P1754 Rename concepts to standard_case for C++20, while we still can
Depends on D96660
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D96742
Johannes Doerfert [Mon, 25 Jan 2021 21:45:53 +0000 (15:45 -0600)]
[Docs] Remove `no-aa` from the alias analysis documentation
The `no-aa` pass has been removed with
7b560d40bddf.
Differential Revision: https://reviews.llvm.org/D95416
Johannes Doerfert [Tue, 2 Mar 2021 01:31:42 +0000 (19:31 -0600)]
[Attributor] Make DepClass a required argument
We often used a sub-optimal dependence class in the past because we
didn't see the argument. Let's make it explicit so we remember to think
about it.
Johannes Doerfert [Mon, 1 Mar 2021 23:04:49 +0000 (17:04 -0600)]
[Attributor] Fold "TrackDependence" into the DepClassTy enum
We don't need a bool and an enum to express the three options we
currently have. This makes the interface nicer and much easier to
use optional dependencies. Also avoids mistakes where the bool is
false and enum ignored.
Johannes Doerfert [Mon, 1 Mar 2021 23:16:08 +0000 (17:16 -0600)]
[Attributor] Avoid work for GEPs and wait till the users are visited
Johannes Doerfert [Mon, 1 Mar 2021 23:10:01 +0000 (17:10 -0600)]
[Attributor] Use known alignment as lower bound to avoid work
If we know already more than available from a use, we don't need to
invest time on it.
Johannes Doerfert [Mon, 1 Mar 2021 23:15:26 +0000 (17:15 -0600)]
[Attributor][NFC] Move some trivial checks up
Johannes Doerfert [Tue, 2 Mar 2021 02:21:21 +0000 (20:21 -0600)]
[Attributor] Use sensible initialization in AANoCaptureCallSiteReturned
Kito Cheng [Tue, 2 Mar 2021 09:24:08 +0000 (17:24 +0800)]
[doc] Fix description of _Float16
According to ISO/IEC TS 18661-3:2015 _FloatN is interchange floating
point type, extended floating-point type is _FloatNx.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2342.pdf
Reviewed By: SjoerdMeijer
Differential revision: https://reviews.llvm.org/D97759
Siva Chandra Reddy [Thu, 4 Mar 2021 05:29:46 +0000 (21:29 -0800)]
[libc] Remove redundant header files included from internal paths.
Evgeniy Brevnov [Fri, 4 Dec 2020 09:57:35 +0000 (16:57 +0700)]
[DSE] Add support for not aligned begin/end
This is an attempt to improve handling of partial overlaps in case of unaligned begin\end.
Existing implementation just bails out if it encounters such cases. Even when it doesn't I believe existing code checking alignment constraints is not quite correct. It tries to ensure alignment of the "later" start/end offset while should be preserving relative alignment between earlier and later start/end.
The idea behind the change is simple. When start/end is not aligned as we wish instead of bailing out let's adjust it as necessary to get desired alignment.
I'll update with performance results as measured by the test-suite...it's still running...
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D93530
Alan Baker [Mon, 7 Dec 2020 20:54:14 +0000 (15:54 -0500)]
libclc: Add clspv target to libclc
Add clspv as a new target for libclc. clspv is an open-source compiler that compiles OpenCL C to Vulkan SPIR-V. Compiles for the spir target.
The clspv target differs from the the spirv target in the following ways:
* fma is modified to use uint2 instead of ulong for mantissas. This results in lower performance fma, but provides a implementation that can be used on more Vulkan devices where 64-bit integer support is less common.
* Use of a software implementation of nextafter because the generic implementation depends on nextafter being a defined builtin function for which clspv has no definition.
* Full optimization of the library (-O3) and no conversion to SPIR-V
This library is close to what would be produced by running opt -O3 < builtins.opt.spirv-mesa3d-.bc > builtins.opt.clspv--.bc and continuing the build from that point.
Reviewer: jvesely
Differential Revision: https://reviews.llvm.org/D94013
Siva Chandra Reddy [Mon, 1 Mar 2021 22:58:14 +0000 (14:58 -0800)]
[compiler-rt | interceptors] Provide an intercept override knob.
This knob is useful for downstream users who want that some of their
libc functions to not be intercepted.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D97740
Christopher Di Bella [Tue, 2 Mar 2021 21:52:30 +0000 (13:52 -0800)]
[libcxx] adds concept `std::common_with`
Implements parts of:
- P0898R3 Standard Library Concepts
- P1754 Rename concepts to standard_case for C++20, while we still can
Depends on D96660
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D96683
Serguei Katkov [Wed, 3 Mar 2021 05:41:00 +0000 (12:41 +0700)]
[InstCombine] Move statepoint intrinsic handling from visitCall to visitCallBase
statepoint intrinsic can be used in invoke context,
so it should be handled in visitCallBase to cover both call and invoke.
Reviewers: reames, dantrushin
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D97833
Wang, Pengfei [Wed, 3 Mar 2021 02:38:21 +0000 (10:38 +0800)]
Add Windows ehcont section support (/guard:ehcont).
Add option /guard:ehcont
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D96709
Jason Molenda [Thu, 4 Mar 2021 03:25:30 +0000 (19:25 -0800)]
LanguageRuntime for 0th frame unwind, simplify getting pc-for-symbolication
Add calls into LanguageRuntime when finding the unwind method to
use out of the 0th (currently executing) stack frame.
Allow for the LanguageRuntimes to indicate if this stack frames
should be treated like a zeroth-frame -- symbolication should be
done based on the saved pc address, not decremented like normal ABI
function calls.
Add methods to RegisterContext and StackFrame to get a pc value
suitable for symbolication, to reduce the number of places in lldb
where we decrement the saved pc values before symbolication.
<rdar://problem/
70398009>
Differential Revision: https://reviews.llvm.org/D97644
Arthur O'Dwyer [Wed, 3 Mar 2021 16:10:49 +0000 (11:10 -0500)]
[libc++] Introduce __identity_t<T>. NFCI.
This is just a shorter synonym for `__identity<T>::type`.
Use it consistently throughout, where possible.
There is still some metaprogramming in <memory> and <variant>
where `__identity` is being used _without_ immediately calling
`::type` on it; but this is the unusual case, and it will become
even less usual as we start deliberately protecting certain types
against deduction (e.g. D97742).
Differential Revision: https://reviews.llvm.org/D97862
Christopher Di Bella [Tue, 2 Mar 2021 21:48:06 +0000 (13:48 -0800)]
[libcxx] adds concept `std::common_reference_with`
Implements parts of:
- P0898R3 Standard Library Concepts
- P1754 Rename concepts to standard_case for C++20, while we still can
Depends on D96657
Reviewed By: ldionne, Mordante, #libc
Differential Revision: https://reviews.llvm.org/D96660
Aart Bik [Wed, 3 Mar 2021 20:37:19 +0000 (12:37 -0800)]
[mlir][sparse] fix bug in reduction chain
Found with exhaustive testing, it is possible that a while loop
appears in between chainable for loops. As long as we don't
scalarize reductions in while loops, this means we need to
terminate the chain at the while. This also refactors the
reduction code into more readable helper methods.
Reviewed By: bixia
Differential Revision: https://reviews.llvm.org/D97886
Juneyoung Lee [Thu, 4 Mar 2021 01:12:57 +0000 (10:12 +0900)]
[LangRef] fix undefined label
Juneyoung Lee [Thu, 4 Mar 2021 00:57:50 +0000 (09:57 +0900)]
[LangRef] Make lifetime intrinsic's semantics consistent with StackColoring's comment
This patch is an update to LangRef by describing lifetime intrinsics' behavior
by following the description of MIR's LIFETIME_START/LIFETIME_END markers
at StackColoring.cpp (https://github.com/llvm/llvm-project/blob/
eb44682d671d66e422b02595a636050582a4d84a/llvm/lib/CodeGen/StackColoring.cpp#L163) and the discussion in llvm-dev.
In order to explicitly define the meaning of an object lifetime, I added 'Object Lifetime' subsection.
Reviewed By: nlopes
Differential Revision: https://reviews.llvm.org/D94002
River Riddle [Thu, 4 Mar 2021 00:37:32 +0000 (16:37 -0800)]
[mlir] Add support for generating Attribute classes for ODS
The support for attributes closely maps that of Types (basically 1-1) given that Attributes are defined in exactly the same way as Types. All of the current ODS TypeDef classes get an Attr equivalent. The generation of the attribute classes themselves share the same generator as types.
Differential Revision: https://reviews.llvm.org/D97589
Craig Topper [Thu, 4 Mar 2021 00:21:23 +0000 (16:21 -0800)]
[RISCV] Make use of the required features in BuiltinInfo to store that V extension builtins require 'experimental-v'.
Use that to print the diagnostic in SemaChecking instead of
listing all of the builtins in a switch.
With the required features, IR generation will also be able
to error on this. Checking this here allows us to have a RISCV
focused error message.
Reviewed By: HsiangKai
Differential Revision: https://reviews.llvm.org/D97826
Fangrui Song [Thu, 4 Mar 2021 00:22:30 +0000 (16:22 -0800)]
[IRSymTab] Set FB_used on llvm.compiler.used symbols
IR symbol table does not parse inline asm. A symbol only referenced by inline
asm is not in the IR symbol table, so LTO does not know that the definition (in
another translation unit) is referenced and may internalize it, even if that
definition has `__attribute__((used))` (which lowers to `llvm.compiler.used` on
ELF targets since D97446).
```
// cabac.c
__attribute__((used)) const uint8_t ff_h264_cabac_tables[...] = {...};
// h264_cabac.c
asm("lea ff_h264_cabac_tables(%rip), %0" : ...);
```
`__attribute__((used))` is the recommended way to tell the compiler there may
be inline asm references, so the usage is perfectly fine. This patch
conservatively sets the `FB_used` bit on `llvm.compiler.used` symbols to work
around the IR symbol table limitation. Note: before D97446, Clang never emitted
symbols in the `llvm.compiler.used` list, so this change does not punish any
Clang emitted global object.
Without the patch, `ff_h264_cabac_tables` may be assigned to a non-external
partition and get internalized. Then we will get a linker error because the
`cabac.c` definition is not exposed.
Differential Revision: https://reviews.llvm.org/D97755
Steven Wan [Thu, 4 Mar 2021 00:06:37 +0000 (19:06 -0500)]
[AIX] Update default arch on AIX
On AIX, the default arch level should match the minimum supported arch level of the OS version.
Differential Revision: https://reviews.llvm.org/D97823
River Riddle [Wed, 3 Mar 2021 23:34:18 +0000 (15:34 -0800)]
[mlir][pdl][NFC] Rename InputOp to OperandOp
This better matches the actual IR concept that is being modeled, and is consistent with how the rest of PDL is structured.
Differential Revision: https://reviews.llvm.org/D95718
River Riddle [Wed, 3 Mar 2021 23:33:15 +0000 (15:33 -0800)]
[mlir][pdl] Add a new !pdl.range<> type
This type represents a range of positional values. It will be used in followup revisions to add support for variadic constructs to PDL, such as operand and result ranges.
Differential Revision: https://reviews.llvm.org/D95717
Xun Li [Wed, 3 Mar 2021 23:21:57 +0000 (15:21 -0800)]
[LICM][Coroutine] Don't sink stores from loops with coro.suspend instructions
See pr46990(https://bugs.llvm.org/show_bug.cgi?id=46990). LICM should not sink store instructions to loop exit blocks which cross coro.suspend intrinsics. This breaks semantic of coro.suspend intrinsic which return to caller directly. Also this leads to use-after-free if the coroutine is freed before control returns to the caller in multithread environment.
This patch disable promotion by check whether loop contains coro.suspend intrinsics.
This is a resubmit of D86190.
Disabling LICM for loops with coroutine suspension is a better option not only for correctness purpose but also for performance purpose.
In most cases LICM sinks memory operations. In the case of coroutine, sinking memory operation out of the loop does not improve performance since coroutien needs to get data from the frame anyway. In fact LICM would hurt coroutine performance since it adds more entries to the frame.
Differential Revision: https://reviews.llvm.org/D96928
Fangrui Song [Wed, 3 Mar 2021 23:18:44 +0000 (15:18 -0800)]
[test] Fix profiling.ll
`__llvm_prf_nm` is compressed if zlib is available. In addition, its size may not be that stable.
Jin Lin [Wed, 3 Mar 2021 20:06:42 +0000 (12:06 -0800)]
Add the use of register r for outlined function when register r is live in and defined later.
The compiler needs to mark register $x0 as live in for the following case.
$x1 = ADDXri $sp, 16, 0
BL @spam, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit killed $x1, implicit-def $sp, implicit-def dead $x0
Reviewed By: paquette
Differential Revision: https://reviews.llvm.org/D95267
River Riddle [Wed, 3 Mar 2021 23:06:42 +0000 (15:06 -0800)]
Fix flang build after D97804
George Balatsouras [Wed, 3 Mar 2021 20:30:20 +0000 (12:30 -0800)]
[dfsan] Remove hard-coded shadow width in more tests
As a preparation step for fast8 support, we need to update the tests
to pass in both modes. That requires generalizing the shadow width
and remove any hard coded references that assume it's always 2 bytes.
Reviewed By: stephan.yichao.zhao
Differential Revision: https://reviews.llvm.org/D97884
Zequan Wu [Sat, 27 Feb 2021 00:38:24 +0000 (16:38 -0800)]
[lld-link] Add safe icf mode to lld-link, which does safe icf for all sections.
Differential Revision: https://reviews.llvm.org/D97436
River Riddle [Wed, 3 Mar 2021 22:23:14 +0000 (14:23 -0800)]
[mlir][IR] Refactor the internal implementation of Value
The current implementation of Value involves a pointer int pair with several different kinds of owners, i.e. BlockArgumentImpl*, Operation *, TrailingOpResult*. This design arose from the desire to save memory overhead for operations that have a very small number of results (generally 0-2). There are, unfortunately, many problematic aspects of the current implementation that make Values difficult to work with or just inefficient.
Operation result types are stored as a separate array on the Operation. This is very inefficient for many reasons: we use TupleType for multiple results, which can lead to huge amounts of memory usage if multi-result operations change types frequently(they do). It also means that simple methods like Value::getType/Value::setType now require complex logic to get to the desired type.
Value only has one pointer bit free, severely limiting the ability to use it in things like PointerUnion/PointerIntPair. Given that we store the kind of a Value along with the "owner" pointer, we only leave one bit free for users of Value. This creates situations where we end up nesting PointerUnions to be able to use Value in one.
As noted above, most of the methods in Value need to branch on at least 3 different cases which is both inefficient, possibly error prone, and verbose. The current storage of results also creates problems for utilities like ValueRange/TypeRange, which want to efficiently store base pointers to ranges (of which Operation* isn't really useful as one).
This revision greatly simplifies the implementation of Value by the introduction of a new ValueImpl class. This class contains all of the state shared between all of the various derived value classes; i.e. the use list, the type, and the kind. This shared implementation class provides several large benefits:
* Most of the methods on value are now branchless, and often one-liners.
* The "kind" of the value is now stored in ValueImpl instead of Value
This frees up all of Value's pointer bits, allowing for users to take full advantage of PointerUnion/PointerIntPair/etc. It also allows for storing more operation results as "inline", 6 now instead of 2, freeing up 1 word per new inline result.
* Operation result types are now stored in the result, instead of a side array
This drops the size of zero-result operations by 1 word. It also removes the memory crushing use of TupleType for operations results (which could lead up to hundreds of megabytes of "dead" TupleTypes in the context). This also allowed restructured ValueRange, making it simpler and one word smaller.
This revision does come with two conceptual downsides:
* Operation::getResultTypes no longer returns an ArrayRef<Type>
This conceptually makes some usages slower, as the iterator increment is slightly more complex.
* OpResult::getOwner is slightly more expensive, as it now requires a little bit of arithmetic
From profiling, neither of the conceptual downsides have resulted in any perceivable hit to performance. Given the advantages of the new design, most compiles are slightly faster.
Differential Revision: https://reviews.llvm.org/D97804
Jez Ng [Wed, 3 Mar 2021 22:31:03 +0000 (17:31 -0500)]
[lld-macho] Fix test breakage introduced by D97799
Sanjay Patel [Wed, 3 Mar 2021 21:53:49 +0000 (16:53 -0500)]
[Analysis] simplify propagation of FMF in recurrences; NFC
This is a mess, but this is hopefully no-functional-change.
The 'Prev' descriptor is only used for min/max recurrences
or when starting a match from a phi, so it should not be a
factor when propagating FMF for fmul/fadd.
The API is confusing (and should be reduced in subsequent steps)
because the "UnsafeAlgebraInst" appears to actually be a placeholder
for a recurrence that does NOT have FMF, but we still want to
treat it as reassociative.
Stefan Gränitz [Wed, 3 Mar 2021 22:14:21 +0000 (23:14 +0100)]
[lli] Add JITLink link component after
99a6d003edbe
David Blaikie [Wed, 3 Mar 2021 22:07:28 +0000 (14:07 -0800)]
Fix use of deprecated API
Louis Dionne [Wed, 3 Mar 2021 22:01:15 +0000 (17:01 -0500)]
[libc++] Temporary hack: disable Apple back-deployment testing
Apple back-deployment testing is currently failing because Green Dragon
is down. To avoid stalling the whole CI pipeline because of that, I am
temporarily disabling those jobs until Green Dragon is back, or even
better we have found a different way to store those small artifacts.
MaheshRavishankar [Wed, 3 Mar 2021 21:56:09 +0000 (13:56 -0800)]
[mlir] Remove incorrect folding for SubTensorInsertOp
The SubTensorInsertOp has a requirement that dest type and result
type match. Just folding the tensor.cast operation violates this and
creates verification errors during canonicalization. Also fix other
canonicalization methods that werent inserting casts properly.
Differential Revision: https://reviews.llvm.org/D97800
Florian Hahn [Wed, 3 Mar 2021 19:44:43 +0000 (19:44 +0000)]
[AArch64] Add implicit uses for operands when expanding BLR_RVMARKER.
Make sure we preserve info about passed arguments as implicit uses, to
make sure later passes still have access to this information.
This fixes a mis-compile where the machine-combiner would pick an
incorrect free register.
Stefan Gränitz [Wed, 3 Mar 2021 21:29:43 +0000 (22:29 +0100)]
Revert "hack to unbreak check-llvm on win after D97335" in attempt for actual fix
This reverts commit
900f076113302e26e1939541b546b0075e3e9721 and attempts an actual fix: All failing tests for llvm-jitlink use the `-noexec` flag. The inputs they operate on are not meant for execution on the host system. Looking e.g. at the MachO_test_harness_harnesss.s test, llvm-mc generates input machine code with "x86_64-apple-macosx10.9".
My previous attempt in
bbdb4c8c9bcef0e8db751630accc04ad874f54e7 disabled the debug support plugin for Windows targets, but what we would actually want is to disable it on Windows HOSTS.
With the new patch here, I don't do exactly that, but instead follow the approach for the EH frame plugin and include the `-noexec` flag in the condition. It should have the desired effect when it comes to the test suite. It appears a little workaround'ish, but should work reliably for now. I will discuss the issue with Lang and see if we can do better. Thanks @thakis again for the temporary fix.
Soumi Manna [Wed, 3 Mar 2021 21:15:23 +0000 (13:15 -0800)]
[WebAssembly] Add missing default cases in switch statements
unsigned variable 'IntNo' has been declared but not been defined inside function
EmitWebAssemblyBuiltinExpr().
static code analysis tool complains about uninitialized variable "IntNo" since
this enters to default branch without setting any intrinsics and calls Function
*Callee = CGM.getIntrinsic(IntNo).
This patch fixes the problem by adding default cases in switch statements.
Jez Ng [Wed, 3 Mar 2021 20:52:10 +0000 (15:52 -0500)]
[lld-macho] Require -arch and -platform_version to always be specified
We previously defaulted to x86_64 and an unknown platform, which was fine when
we only supported one arch and did no platform checks, but that will no longer
be true going ahead. Therefore, we should require those flags to be specified
whenever the linker is invoked.
Note that LLD-ELF and ld64 both infer the arch from their input object files,
but the usefulness of that is questionable since clang will always specify these
flags, and most of the time `lld` will be invoked via clang.
Reviewed By: #lld-macho, thakis
Differential Revision: https://reviews.llvm.org/D97799
Jez Ng [Wed, 3 Mar 2021 20:52:06 +0000 (15:52 -0500)]
[lld-macho][nfc] Parse more options using getLastArg{Value}
The option-iterating loop should be reserved for options whose command-line
order is important. I think LLD-ELF follows a similar design.
Reviewed By: #lld-macho, smeenai
Differential Revision: https://reviews.llvm.org/D97797
Whitney Tsang [Wed, 3 Mar 2021 20:41:41 +0000 (20:41 +0000)]
[LoopUnrollRuntime] Add option to assume the non latch exit block to be
predictable.
Reviewed By: Meinersbur, bmahjour
Differential Revision: https://reviews.llvm.org/D97747
Alexey Bataev [Tue, 2 Mar 2021 19:30:52 +0000 (11:30 -0800)]
[Cost]Add tests for boolean and/or reductions, NFC.
Tests with the default costs for boolean and/or reductions.
Differential Revision: https://reviews.llvm.org/D97793
Philip Reames [Wed, 3 Mar 2021 20:20:27 +0000 (12:20 -0800)]
Address review comment from D97219 (follow up to 8051156)
Probably should have done this before landing, but I forgot.
Basic idea is to avoid using the SCEV predicate when it doesn't buy us anything. Also happens to set us up for handling non-add recurrences in the future if desired.
Philip Reames [Wed, 3 Mar 2021 20:07:00 +0000 (12:07 -0800)]
Sink routine for replacing a operand bundle to CallBase [NFC]
We had equivalent code for both CallInst and InvokeInst, but never cared about the result type.
Philip Reames [Wed, 3 Mar 2021 19:49:46 +0000 (11:49 -0800)]
[LSR] Unify scheduling of existing and inserted addrecs
LSR goes to some lengths to schedule IV increments such that %iv and %iv.next never need to overlap. This is fairly fundamental to LSRs cost model. LSR assumes that an addrec can be represented with a single register. If %iv and %iv.next have to overlap, then that assumption does not hold.
The bug - which this patch is fixing - is that LSR only does this scheduling for IVs which it inserts, but it's cost model assumes the same for existing IVs that it reuses. It will rewrite existing IV users such that the no-overlap property holds, but will not actually reschedule said IV increment.
As you can see from the relatively lack of test updates, this doesn't actually impact codegen much. The main reason for doing it is to make a follow up patch series which improves post-increment use and scheduling easier to follow.
Differential Revision: https://reviews.llvm.org/D97219
Jonas Paulsson [Sat, 27 Feb 2021 00:55:44 +0000 (18:55 -0600)]
[SystemZ] Reimplement the i8/i16 compare-and-swap logic.
Even though the implementation in emitAtomicCmpSwapW() was correct, it made
Valgrind report an error. Instead of using a RISBG on CmpVal, an LL[CH]R can
be made on the OldVal, and the problem is avoided.
Review: Ulrich Weigand
Differential Revision: https://reviews.llvm.org/D97604
Peter Steinfeld [Wed, 3 Mar 2021 18:52:40 +0000 (10:52 -0800)]
[flang] Prohibit MODULE procedures in the global scope
We were allowing procedures with the MODULE prefix to be declared at the global
scope. This is prohibited by C1547 and was causing an internal check of the
compiler to fail.
I fixed this by adding a check. I also added a test that would trigger a crash
without this change.
Differential Revision: https://reviews.llvm.org/D97875
Hanhan Wang [Wed, 3 Mar 2021 19:46:50 +0000 (11:46 -0800)]
[mlir][linalg] Add depthwise_conv_2d_input_nhwc_filter_hwcf to Linalg TC ops.
Different from the definition in Tensorflow and TOSA, the output is [N,H,W,C,M]. This can make transforms easier in LinAlg because the indexing maps are plain. E.g., to determine if the fill op has dependency between the depthwise conv op, the current pipeline only recognizes the dep if they are all projected affine map.
Reviewed By: asaadaldien
Differential Revision: https://reviews.llvm.org/D97798
Florian Hahn [Wed, 3 Mar 2021 18:58:05 +0000 (18:58 +0000)]
[AArch64] Move CALL_RVMARKER definition after CALL.
This is a NFC with respect to the generated code. But it fixes a crash
when using -debug, because of the position in the enum CALL_RVMARKER
nodes were treated as memops. That caused a crash when printing
CALL_RVMARKER nodes.
Fangrui Song [Wed, 3 Mar 2021 19:32:24 +0000 (11:32 -0800)]
[InstrProfiling] Place __llvm_prf_vnodes and __llvm_prf_names in llvm.used on ELF
`__llvm_prf_vnodes` and `__llvm_prf_names` are used by runtime but not
referenced via relocation in the translation unit.
With `-z start-stop-gc` (LLD 13 (D96914); GNU ld 2.37 https://sourceware.org/bugzilla/show_bug.cgi?id=27451),
the linker does not let `__start_/__stop_` references retain their sections.
Place `__llvm_prf_vnodes` and `__llvm_prf_names` in `llvm.used` to make
them retained by the linker.
This patch changes most existing `UsedVars` cases to `CompilerUsedVars`
to reflect the ideal state - if the binary format properly supports
section based GC (dead stripping), `llvm.compiler.used` should be sufficient.
`__llvm_prf_vnodes` and `__llvm_prf_names` are switched to `UsedVars`
since we want them to be unconditionally retained by both compiler and linker.
Behaviors on COFF/Mach-O are not affected.
Reviewed By: davidxl
Differential Revision: https://reviews.llvm.org/D97649
Fangrui Song [Wed, 3 Mar 2021 19:29:19 +0000 (11:29 -0800)]
[test] Improve PGO tests
Zequan Wu [Wed, 3 Mar 2021 04:35:19 +0000 (20:35 -0800)]
[Coverage] Emit gap region between statements if first statements contains terminate statements.
Differential Revision: https://reviews.llvm.org/D97101
Sam McCall [Sat, 27 Feb 2021 21:08:07 +0000 (22:08 +0100)]
[clangd] ObjC fixes for semantic highlighting and xref highlights
- highlight references to protocols in class/protocol/extension decls
- support multi-token selector highlights in semantic + xref highlights
(method calls and declarations only)
- In `@interface I(C)`, I now references the interface and C the category
- highlight uses of interfaces as types
- added semantic highlightings of protocol names (as "interface") and
category names (as "namespace").
These are both standard kinds, maybe "extension" will be standardized...
- highlight `auto` as "class" when it resolves to an ObjC pointer
- don't highlight `self` as a variable even though the AST models it as one
Not fixed: uses of protocols in type names (needs some refactoring of
unrelated code first)
Differential Revision: https://reviews.llvm.org/D97617
George Balatsouras [Wed, 3 Mar 2021 01:52:58 +0000 (17:52 -0800)]
[dfsan] Remove hardcoded shadow width in abilist_aggregate.ll
As a preparation step for fast8 support, we need to update the tests
to pass in both modes. That requires generalizing the shadow width
and remove any hard coded references that assume it's always 2 bytes.
Reviewed By: stephan.yichao.zhao
Differential Revision: https://reviews.llvm.org/D97723
Petr Hosek [Wed, 3 Mar 2021 08:39:50 +0000 (00:39 -0800)]
[CMake] Rename RUNTIMES_BUILD to LLVM_RUNTIMES_BUILD
This avoid potential conflict with other internal variables.
Differential Revision: https://reviews.llvm.org/D97838
Louis Dionne [Wed, 3 Mar 2021 18:45:06 +0000 (13:45 -0500)]
[libc++] NFC: Normalize links to bug reports
Stanislav Mekhanoshin [Tue, 2 Mar 2021 19:06:30 +0000 (11:06 -0800)]
[AMDGPU] Exclude always_inline from max bb threshold
Honor always_inline attribute when processing -amdgpu-inline-max-bb.
It was lost during the ports of the heuristic. There is no reason
to honor inline hint, but not always inline.
Differential Revision: https://reviews.llvm.org/D97790
Mehdi Amini [Tue, 23 Feb 2021 01:56:01 +0000 (01:56 +0000)]
Add basic JIT Python Bindings
This offers the ability to create a JIT and invoke a function by passing
ctypes pointers to the argument and the result.
Differential Revision: https://reviews.llvm.org/D97523
Mehdi Amini [Sat, 13 Feb 2021 19:23:06 +0000 (19:23 +0000)]
Add C bindings for mlir::ExecutionEngine
This adds minimalistic bindings for the execution engine, allowing to
invoke the JIT from the C API. This is still quite early and
experimental and shouldn't be considered stable in any way.
Differential Revision: https://reviews.llvm.org/D96651
Hongtao Yu [Tue, 2 Mar 2021 06:34:30 +0000 (22:34 -0800)]
[CSSPGO][llvm-profgen] Continue disassembling after illegal instruction is seen.
Previously we errored out when disassembling illegal instructions and there would be no profile generated. In fact illegal instructions are not uncommon and we'd better skip them and print "unknown" instead of erroring out. This matches the behavior of llvm-objdump (see disassembleObject in llvm-objdump.cpp).
Reviewed By: wlei, wenlei
Differential Revision: https://reviews.llvm.org/D97776
Choongwoo Han [Wed, 3 Mar 2021 17:53:09 +0000 (09:53 -0800)]
[llvm-cov] Cache file status information
Currently, getSourceFile accesses file system to check if two paths are
the same file with a thread lock, which is a huge performance bottleneck
in some cases. Currently, it's accessing file system size(files) * size(files) times.
Thus, cache file status information, which reduces file system access to size(files) times.
When I tested it with two binaries and 16 cpu cores,
it saved over 70% of time.
Binary 1: 56 secs -> 3 secs
Binary 2: 17 hours -> 4 hours
Differential Revision: https://reviews.llvm.org/D97061
Elia Geretto [Wed, 3 Mar 2021 18:01:27 +0000 (10:01 -0800)]
[XRay][x86_64] Fix CFI directives in assembly trampolines
This patch modifies the x86_64 XRay trampolines to fix the CFI information
generated by the assembler. One of the main issues in correcting the CFI
directives is the `ALIGNED_CALL_RAX` macro, which makes the CFA dependent on
the alignment of the stack. However, this macro is not really necessary because
some additional assumptions can be made on the alignment of the stack when the
trampolines are called. The code has been written as if the stack is guaranteed
to be 8-bytes aligned; however, it is instead guaranteed to be misaligned by 8
bytes with respect to a 16-bytes alignment. For this reason, always moving the
stack pointer by 8 bytes is sufficient to restore the appropriate alignment.
Trampolines that are called from within a function as a result of the builtins
`__xray_typedevent` and `__xray_customevent` are necessarely called with the
stack properly aligned so, in this case too, `ALIGNED_CALL_RAX` can be
eliminated.
Fixes: https://bugs.llvm.org/show_bug.cgi?id=49060
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D96785
Louis Dionne [Tue, 23 Feb 2021 23:26:15 +0000 (18:26 -0500)]
[libc++] Use generator expression to simplify the CMake code
A comment was left for when we would require CMake >= 3, which we do now.
I expect this should be a NFC.
Differential Revision: https://reviews.llvm.org/D97341
Louis Dionne [Mon, 1 Mar 2021 17:09:45 +0000 (12:09 -0500)]
[libc++/abi] Replace uses of _NOEXCEPT in src/ by noexcept
We always build the libraries in a Standard mode that supports noexcept,
so there's no need to use the _NOEXCEPT macro.
Differential Revision: https://reviews.llvm.org/D97700
Hanhan Wang [Wed, 3 Mar 2021 17:35:54 +0000 (09:35 -0800)]
[mlir][linalg] Delete unused vars if there are shaped-only operands.
Reviewed By: stella.stamenova
Differential Revision: https://reviews.llvm.org/D97851
MaheshRavishankar [Wed, 3 Mar 2021 17:24:29 +0000 (09:24 -0800)]
[mlir] Add LinalgInterface method to clone with a given BlockAndValueMapping.
Since Linalg operations have regions by default which are not isolated
from above, add an another method to the interface that will take a
BlockAndValueMapping to remap the values within the region as well.
Differential Revision: https://reviews.llvm.org/D97709
Philip Reames [Wed, 3 Mar 2021 17:16:56 +0000 (09:16 -0800)]
Fix a build warning from ea7d208
Philip Reames [Wed, 3 Mar 2021 16:58:53 +0000 (08:58 -0800)]
[basicaa] Rewrite isGEPBaseAtNegativeOffset in terms of index difference [mostly NFC]
This is almost purely NFC, it just fits more obviously in the flow of the code now that we've standardized on the index different approach. The non-NFC bit is that because of canceling the VariableOffsets in the subtract, we can now handle the case where both sides involve a common variable offset. This isn't an "interesting" improvement; it just happens to fall out of the natural code structure.
One subtle point - the placement of this above the BaseAlias check is important in the original code as this can return NoAlias even when we can't find a relation between the bases otherwise.
Also added some enhancement TODOs noticed while understanding the existing code.
Note: This is slightly different than the LGTMed version. I fixed the "inbounds" issue Nikita noticed with the original code in e6e5ef4 and rebased this to include the same fix.
Differential Revision: https://reviews.llvm.org/D97520
Baptiste Saleil [Wed, 3 Mar 2021 16:57:42 +0000 (11:57 -0500)]
[VirtRegRewriter] Insert missing killed flags when tracking subregister liveness
VirtRegRewriter may sometimes fail to correctly apply the kill flag where necessary,
which causes unecessary code gen on PowerPC. This patch fixes the way masks for
defined lanes are computed and the way mask for used lanes is computed.
Contact albion.fung@ibm.com instead of author for problems related to this commit.
Differential Revision: https://reviews.llvm.org/D92405
Philip Reames [Wed, 3 Mar 2021 16:43:32 +0000 (08:43 -0800)]
[basicaa] Fix a latent bug in isGEPBaseAtNegativeOffset
This was pointed out in review of D97520 by Nikita, but existed in the original code as well.
The basic issue is that a decomposed GEP expression describes (potentially) more than one getelementptr. The "inbounds" derived UB which justifies this aliasing rule requires that the entire offset be composed of "inbounds" geps. Otherwise, as can be seen in the recently added and changes in this patch test, we can end up with a large commulative offset with only a small sub-offset actually being "inbounds". If that small sub-offset lies within the object, the result was unsound.
We could potentially be fancier here, but for the moment, simply be conservative when any of the GEPs parsed aren't inbounds.
Philip Reames [Wed, 3 Mar 2021 16:31:52 +0000 (08:31 -0800)]
[basicaa] Minor indentation fix
Louis Dionne [Tue, 2 Mar 2021 21:53:07 +0000 (16:53 -0500)]
[pstl] Fix broken policy_traits and clean up unused code
https://llvm.org/PR47602
https://llvm.org/PR47601
Differential Revision: https://reviews.llvm.org/D97808
Philip Reames [Wed, 3 Mar 2021 16:30:36 +0000 (08:30 -0800)]
[tests] Add tests for cases brought up during review of D97520
Arnold Schwaighofer [Tue, 23 Feb 2021 18:01:35 +0000 (10:01 -0800)]
[coro async] Allow a coro.suspend.async to specify which argument is the context argument
Before we used the same argument as the entry point. The resume partial
function might want to use a different ABI for its context argument
Differential Revision: https://reviews.llvm.org/D97333
Benjamin Kramer [Mon, 1 Mar 2021 19:41:12 +0000 (20:41 +0100)]
[mlir][Shape] Lower cstr_eq to shape_eq + assert
Differential Revision: https://reviews.llvm.org/D97860
Nathan James [Wed, 3 Mar 2021 16:01:12 +0000 (16:01 +0000)]
[clang-tidy] Deprecate readability-deleted-default check
... For removal in next release cycle.
The clang warning that does the same thing is enabled by default and typically emits better diagnostics making this check surplus to requirements.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D97491
Nathan James [Wed, 3 Mar 2021 15:57:49 +0000 (15:57 +0000)]
[clang-query] Fix help text after D91918
After rG5e1801813d93210acae84ff3c68a01512c2df9bc The help command still lists IgnoreImplicitCastsAndParentheses as a valid option.
Reviewed By: aaron.ballman, rsmith
Differential Revision: https://reviews.llvm.org/D97806
Simon Pilgrim [Wed, 3 Mar 2021 15:30:32 +0000 (15:30 +0000)]
[X86] Fold scalar_to_vector(x) -> extract_subvector(broadcast(x),0) iff broadcast(x) exists
Add handling for reusing an existing broadcast(x) to a wider vector.
David Tenty [Thu, 25 Feb 2021 04:41:53 +0000 (23:41 -0500)]
[AIX][clang][driver] Restrict /usr/lib to internal library search paths
Adding it to the general filepaths results in it being added to the
linker arguments. The AIX linker always looks in this path anyway
and adds it as a default library path component. Adding this duplicate
explicitly results in duplicate entries in path in the loader section
of executables and messes up tools like CMake that parse the default
library flags.
Reviewed By: ZarkoCA
Differential Revision: https://reviews.llvm.org/D97574
Daniel McIntosh [Wed, 3 Mar 2021 15:29:37 +0000 (10:29 -0500)]
[test] Fix apparent typo in clang/test/Driver/std.c
Currently the test on line 3 is identical to the test on line 1.
Looking at the rest of the file (particularily the use of FOVERRIDE
as the check-prefix), I think it's pretty clear that this line
was supposed to use `-ftrigraphs` instead of `-trigraphs`.
Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D97796
Benjamin Kramer [Mon, 1 Mar 2021 19:34:17 +0000 (20:34 +0100)]
[mlir][Shape] Make shape_eq nary
This gets rid of a dubious shape_eq %a, %a fold, that folds shape_eq
even if %a is not an Attribute.
Differential Revision: https://reviews.llvm.org/D97728
Nico Weber [Wed, 3 Mar 2021 15:17:31 +0000 (10:17 -0500)]
Revert "[InstrProfiling] Place __llvm_prf_vnodes and __llvm_prf_names in llvm.used on ELF"
This reverts commit
04c3040f417683e7c31b3ee3381a3263106f48c5.
Breaks instrprof-value-merge.c in bootstrap builds.
Benjamin Kramer [Mon, 1 Mar 2021 19:14:06 +0000 (20:14 +0100)]
[mlir][Shape] Make cstr_eq more like cstr_broadcastable
This includes allowing extents and not just shapes.
Differential Revision: https://reviews.llvm.org/D97716
Melanie Blower [Tue, 2 Mar 2021 12:58:42 +0000 (07:58 -0500)]
[clang][patch] To solve PR26413, x86 interrupt routines may only call routines with no_saved_reg
Reviewed By: Aaron Ballman
Differential Revision: https://reviews.llvm.org/D97764
Aaron Ballman [Wed, 3 Mar 2021 15:02:51 +0000 (10:02 -0500)]
Implement P2173 for attributes on lambdas
https://wg21.link/P2173 is making its way through WG21 currently and
has not been formally adopted yet. This feature provides very useful
functionality in that you can specify attributes on the various
function *declarations* generated by a lambda expression, where the
current C++ grammar only allows attributes which apply to the various
function *types* so generated.
This patch implements P2173 on the assumption that it will be adopted
by WG21 with this syntax for C++23.
Anastasia Stulova [Wed, 3 Mar 2021 12:05:38 +0000 (12:05 +0000)]
[OpenCL] Prevent adding extension pragma by default.
This commit refactors extension support to allow
specifying whether pragma is needed or not explicitly.
For backward compatibility pragmas are set to required
for all extensions that were added prior to this but
not for OpenCL 3.0 features.
Differential Revision: https://reviews.llvm.org/D97052
Hans Wennborg [Wed, 3 Mar 2021 14:50:08 +0000 (15:50 +0100)]
Revert "[ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of explicitly emitting retainRV or claimRV calls in the IR"
This caused miscompiles of Chromium tests for iOS due clobbering of live
registers. See discussion on the code review for details.
> Background:
>
> This fixes a longstanding problem where llvm breaks ARC's autorelease
> optimization (see the link below) by separating calls from the marker
> instructions or retainRV/claimRV calls. The backend changes are in
> https://reviews.llvm.org/D92569.
>
> https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autoreleasereturnvalue
>
> What this patch does to fix the problem:
>
> - The front-end adds operand bundle "clang.arc.attachedcall" to calls,
> which indicates the call is implicitly followed by a marker
> instruction and an implicit retainRV/claimRV call that consumes the
> call result. In addition, it emits a call to
> @llvm.objc.clang.arc.noop.use, which consumes the call result, to
> prevent the middle-end passes from changing the return type of the
> called function. This is currently done only when the target is arm64
> and the optimization level is higher than -O0.
>
> - ARC optimizer temporarily emits retainRV/claimRV calls after the calls
> with the operand bundle in the IR and removes the inserted calls after
> processing the function.
>
> - ARC contract pass emits retainRV/claimRV calls after the call with the
> operand bundle. It doesn't remove the operand bundle on the call since
> the backend needs it to emit the marker instruction. The retainRV and
> claimRV calls are emitted late in the pipeline to prevent optimization
> passes from transforming the IR in a way that makes it harder for the
> ARC middle-end passes to figure out the def-use relationship between
> the call and the retainRV/claimRV calls (which is the cause of
> PR31925).
>
> - The function inliner removes an autoreleaseRV call in the callee if
> nothing in the callee prevents it from being paired up with the
> retainRV/claimRV call in the caller. It then inserts a release call if
> claimRV is attached to the call since autoreleaseRV+claimRV is
> equivalent to a release. If it cannot find an autoreleaseRV call, it
> tries to transfer the operand bundle to a function call in the callee.
> This is important since the ARC optimizer can remove the autoreleaseRV
> returning the callee result, which makes it impossible to pair it up
> with the retainRV/claimRV call in the caller. If that fails, it simply
> emits a retain call in the IR if retainRV is attached to the call and
> does nothing if claimRV is attached to it.
>
> - SCCP refrains from replacing the return value of a call with a
> constant value if the call has the operand bundle. This ensures the
> call always has at least one user (the call to
> @llvm.objc.clang.arc.noop.use).
>
> - This patch also fixes a bug in replaceUsesOfNonProtoConstant where
> multiple operand bundles of the same kind were being added to a call.
>
> Future work:
>
> - Use the operand bundle on x86-64.
>
> - Fix the auto upgrader to convert call+retainRV/claimRV pairs into
> calls with the operand bundles.
>
> rdar://
71443534
>
> Differential Revision: https://reviews.llvm.org/D92808
This reverts commit
ed4718eccb12bd42214ca4fb17d196d49561c0c7.
Hans Wennborg [Wed, 3 Mar 2021 14:50:02 +0000 (15:50 +0100)]
revert llvm/include/llvm/Analysis/ObjCARCUtil.h part of
1cc558bd4fa1acd1462226ef4796c712f80ea8e8
Kadir Cetinkaya [Tue, 2 Mar 2021 15:43:21 +0000 (16:43 +0100)]
[clangd] Make WorkspaceSymbols request work with empty queries
Clangd uses codecompletion limit as the limit for workspacesymbols, so
in theory this should only be an order of magnitude slower than a
codecompletion request with empty identifier (as code completion limits
the available symbols).
This is also what LSP suggests "Clients may send an empty string here to request all symbols.".
Clangd doesn't really fulfill the "all" part of that statement, but we
never do unless user set the index query limit to zero explicitly.
Differential Revision: https://reviews.llvm.org/D97773
Ayke van Laethem [Sun, 21 Feb 2021 19:23:46 +0000 (20:23 +0100)]
[AVR] Fix def state of operands
Some instructions (especially mov+pop instructions) were setting the
wrong operands. For example, the pop instruction had the register set as
a source operand while it is a destination operand (the value is loaded
into the register).
I have found these issues using the machine verifier and using manual
code inspection.
Differential Revision: https://reviews.llvm.org/D97159
Ayke van Laethem [Sun, 21 Feb 2021 00:23:02 +0000 (01:23 +0100)]
[AVR] Fix expansion of NEGW
The previous expansion used SBCI, which is incorrect because the NEGW
pseudo instruction accepts a DREGS operand (2xGPR8) and SBCI only allows
LD8 registers. One solution could be to correct the NEGW pseudo
instruction, but another solution is to use a different instruction
(sbc) that does accept a GPR8 register and therefore allows more freedom
to the register allocator.
The output now matches avr-gcc for the following code:
int foo(int n) {
return -n;
}
I've found this issue using the machine instruction verifier: it was
complaining about the wrong register class in NEGWRd.mir.
Differential Revision: https://reviews.llvm.org/D97131
Ayke van Laethem [Thu, 11 Feb 2021 13:07:53 +0000 (14:07 +0100)]
[AVR] Add register aliases XL, YH, etc
These aliases are sometimes used in assembly code and make the code more
readable. They are supported by avr-gcc too.
Differential Revision: https://reviews.llvm.org/D96492