- Dec 17, 2022
-
-
Craig Topper authored
-
Kazu Hirata authored
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
-
Uday Bondhugula authored
The largest known divisor for expressions like (32 * d0 + 32, 128) ceildiv 8 wasn't being computed tightly; a conservative value of 1 was being returned. Address this. This leads to a broad improvement for several affine analyses and rewrites that depend on knowing whether something is a multiple of a specific constant or such largest known constant. Differential Revision: https://reviews.llvm.org/D140185
-
Kazu Hirata authored
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
-
Craig Topper authored
sifive-7-series can predicate ALU instructions in the shadow of a branch not just move instructions. This patch implements analyzeSelect/optimizeSelect to predicate these operations. This is based on ARM's implementation which can predicate using flags and condition codes. I've restricted it to just the instructions we have test cases for, but it can be extended in the future. Reviewed By: reames Differential Revision: https://reviews.llvm.org/D140053
-
Fangrui Song authored
-
Fangrui Song authored
std::optional::value() has undesired exception checking semantics and is unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The call sites block std::optional migration. This makes `ninja clang` work in the absence of llvm::Optional::value.
-
Christudasan Devadasan authored
Currently, the custom SGPR spill lowering pass spills SGPRs into physical VGPR lanes and the remaining VGPRs are used by regalloc for vector regclass allocation. This imposes many restrictions that we ended up with unsuccessful SGPR spilling when there won't be enough VGPRs and we are forced to spill the leftover into memory during PEI. The custom spill handling during PEI has many edge cases and often breaks the compiler time to time. This patch implements spilling SGPRs into virtual VGPR lanes. Since we now split the register allocation for SGPRs and VGPRs, the virtual registers introduced for the spill lanes would get allocated automatically in the subsequent regalloc invocation for VGPRs. Spill to virtual registers will always be successful, even in the high-pressure situations, and hence it avoids most of the edge cases during PEI. We are now left with only the custom SGPR spills during PEI for special registers like the frame pointer which isn an unproblematic case. This patch also implements the whole wave spills which might occur if RA spills any live range of virtual registers involved in the whole wave operations. Earlier, we had been hand-picking registers for such machine operands. But now with SGPR spills into virtual VGPR lanes, we are exposing them to the allocator. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D124196
-
Christudasan Devadasan authored
With D134950, targets get notified when a virtual register is created and/or cloned. Targets can do the needful with the delegate callback. AMDGPU propagates the virtual register flags maintained in the target file itself. They are useful to identify a certain type of machine operands while inserting spill stores and reloads. Since RegAllocFast spills the physical register itself, there is no way its virtual register can be mapped back to retrieve the flags. It can be solved by passing the virtual register as an additional argument. This argument has no use when the spill interfaces are called during the greedy allocator or even the PrologEpilogInserter and can pass a null register in such cases. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D138656
-
Christudasan Devadasan authored
It is needed to invoke the delegate methods effectively whenever a virtual register is cloned from an existing register of the same class. Reviewed By: qcolombet Differential Revision: https://reviews.llvm.org/D138517
-
Christudasan Devadasan authored
This will help targets to customize certain codegen decisions based on the virtual registers involved in special operations. This patch also extends the existing delegate in MRI to start support multicast. Reviewed By: qcolombet Differential Revision: https://reviews.llvm.org/D134950
-
Christudasan Devadasan authored
Unlike the callee-saved VGPR spill instructions emitted by `PEI::spillCalleeSavedRegs`, the CS VGPR spills inserted during emitPrologue/emitEpilogue require the exec bits flipping to avoid clobbering the inactive lanes of VGPRs used for SGPR spilling. Currently, these spill instructions are referenced from the SP at function entry and when the callee performs a stack realignment, they ended up getting incorrect stack offsets. Even if we try to adjust the offsets, the FP-SP becomes a runtime entity with dynamic stack realignment and the offsets would still be inaccurate. To fix it, use FP as the frame base in the spill instructions whenever the function has FP. The offsets obtained for the CS objects would always be the right values from FP. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D134949
-
Christudasan Devadasan authored
In general, a callee is free to use a scratch register without preserving its previous state. However, the VGPR used for SGPR spilling can potentially have its inactive lanes overwritten by the writelane instructions. When the function returns, it can cause unexpected behavior if the VGPR value is not preserved appropriately. The current scheme to preserve the inactive lanes of such scratch VGPRs is not done rightly. It preserves all lanes and causes the outgoing values (if any) getting overwritten by the epilog restores. It then corrupts the return value. To avoid such situation with scratch VGPRs, this patch ensures we preserve only their inactive lanes. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D134526
-
Christudasan Devadasan authored
There is a lot of customization and eventually code duplication in the frame lowering that handles special SGPR spills like the one needed for the Frame Pointer. Incorporating any additional SGPR spill currently makes it difficult during PEI. This patch introduces a new spill builder to efficiently handle such spill requirements. Various spill methods are special handled using a separate class. Reviewed By: sebastian-ne, scott.linder Differential Revision: https://reviews.llvm.org/D132436
-
Christudasan Devadasan authored
SILowerSGPRSpills pass handles the lowering of SGPR spills into VGPR lanes. Some SGPR spills are handled later during PEI. There is a common function used in both places to find the free VGPR lane. This patch eliminates that dependency to find the free VGPR by handling it separately for PEI. It is a prerequisite patch for a future work to allow SGPR spills to virtual VGPR lanes during SILowerSGPRSpills. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D124195
-
Christudasan Devadasan authored
We always assume the vector register is dead or killed while inserting the VGPR spills in the prolog. It is not always true. Used the entry block liveIn data while setting the flag. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D124194
-
Christudasan Devadasan authored
The custom VGPR spills inserted during frame lowering maintain a separate list for WWM reserved registers. Added them into WWMSpills that already tracks such reserved registers. It unifies the spill insertion. Reviewed By: nhaehnle, arsenm Differential Revision: https://reviews.llvm.org/D124193
-
Christudasan Devadasan authored
Since the writelane instruction used for SGPR spills can modify inactive lanes, the callee must preserve the VGPR this instruction modifies even if it was marked Caller-saved. Reviewed By: arsenm, nhaehnle Differential Revision: https://reviews.llvm.org/D124192
-
Fangrui Song authored
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
-
Fangrui Song authored
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
-
Fangrui Song authored
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
-
Fangrui Song authored
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
-
ziqingluo-90 authored
Unsafe Buffer Usage analysis only warns unsafe buffer accesses but not pointer dereferences. An array subscript on a literal zero is equivalent to dereference a pointer thus we do not want to warn it. Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D138321
-
Fangrui Song authored
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
-
Fangrui Song authored
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
-
Fangrui Song authored
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
-
ziqingluo-90 authored
Generalize the pointer expression AST matcher in Unsafe Buffer Usage analysis. Add test cases for various kinds of pointer usages. Reviewed By: NoQ, aaron.ballman, xazax.hun Differential Revision: https://reviews.llvm.org/D138318
-
Fangrui Song authored
value() has undesired exception checking semantics and calls __throw_bad_optional_access in libc++. Moreover, the API is unavailable without _LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS).
-
Fangrui Song authored
-
Fangrui Song authored
-
Wenzel Jakob authored
This example shows how to use the newly added LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks API.
-
Lang Hames authored
Adds a LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks function that can be used to create an RTDyldObjectLinkingLayer using callbacks that are similar (but not identical) to those used in LLVMCreateSimpleMCJITMemoryManager. This is intended to ease the transition to ORC for MCJIT C-API clients. Differential Revision: https://reviews.llvm.org/D139393
-
Fangrui Song authored
value() has undesired exception checking semantics and calls __throw_bad_optional_access in libc++. Moreover, the API is unavailable without _LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). This fixes check-clang-tools.
-
Vy Nguyen authored
This reverts commit 52a118d0. New changes: Fix tests to dump both slices in the fat-archive because otool isn't deterministic about which slice it prints across different archs. (It printed x86 on x86 machines but arm64 on arm64, this was why the test failed on arm64) Differential Revision: https://reviews.llvm.org/D139572
-
Yingchi Long authored
Most of VP intrinsics are implemented in RISC-V backends, but vp.reduce.mul (element length > 1) does not yet. Legalizes vp.reduce.mul using ExpandVectorPredication Pass. Reviewed By: reames Differential Revision: https://reviews.llvm.org/D139721
-
Artem Dergachev authored
This patch adds more abstractions that we'll need later for emitting -Wunsafe-buffer-usage fixits. It doesn't emit any actual fixits, so no change is observed behavior, but it introduces a way to emit fixits, and existing tests now verify that the compiler still emits no fixits, despite knowing how to do so. The purpose of our code transformation analysis is to fix variable types in the code from raw pointer types to C++ standard collection/view types. The analysis has to decide on its own which specific type is the most appropriate for every variable. This patch introduces the Strategy class that maps variables to their most appropriate types. In D137348 we've introduced the Gadget abstraction, which describes a rigid AST pattern that the analysis "fully understands" and may need to fix. Which specific fix is actually necessary for a given Gadget, and whether it's necessary at all, and whether it's possible in the first place, depends on the Strategy. So, this patch adds a virtual method which every gadget can implement in order to teach the analysis how to fix that gadget: Gadget->getFixits(Strategy) However, even if the analysis knows how to fix every Gadget, doesn't necessarily mean it can fix the variable. Some uses of the variable may have never been covered by Gadgets, which corresponds to the situation that the analysis doesn't fully understand how the variable is used. This patch introduces a Tracker class that tracks all variable uses (i.e. DeclRefExprs) in the function. Additionally, each Gadget now provides a new virtual method Gadget->getClaimedVarUseSites() that the Tracker can call to see which DeclRefExprs are "claimed" by the Gadget. In order to fix the variable with a certain Strategy, the Tracker needs to confirm that there are no unclaimed uses, and every Gadget has to provide a fix for that Strategy. This "conservative" behavior guarantees that fixes emitted by our analysis are correct by construction. We can now be sure that the analysis won't attempt to emit a fix if it doesn't understand the code. Later, as we implement more getFixits() methods in individual Gadget classes, we'll start progressively emitting more and more fixits. Differential Revision: https://reviews.llvm.org/D138253
-
Benoit Jacob authored
The requirement that divisor>0 is not enforced here outside of the constant case, but how to enforce it? If I understand correctly, it is UB and while it is nice to be able to deterministically intercept UB, that isn't always feasible. Hopefully, keeping the existing enforcement in the constant case is enough. Differential Revision: https://reviews.llvm.org/D140079
-
Roman Lebedev authored
Reland "[SimplifyCFG] `FoldBranchToCommonDest()`: deal with mismatched IV's in PHI's in common successor block" This reverts commit 37b8f09a, and returns commit 1bd0b82e. The miscompile was in InstCombine, and it has been addressed. This tries to approach the problem noted by @arsenm: terrible codegen for `__builtin_fpclassify()`: https://godbolt.org/z/388zqdE37 Just because the PHI in the common successor happens to have different incoming values for these two blocks, doesn't mean we have to give up. It's quite easy to deal with this, we just need to produce a select: https://alive2.llvm.org/ce/z/000srb Now, the cost model for this transform is rather overly strict, so this will basically never fire. We tally all (over all preds) the selects needed to the NumBonusInsts Differential Revision: https://reviews.llvm.org/D139275
-
Roman Lebedev authored
This is consistent with how other commutative matchers operate, and i assumed that is how this one worked, alas it did not, and thus `foldNestedSelects()` was miscompiling stuff.
-
Roman Lebedev authored
-