aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen
AgeCommit message (Collapse)AuthorFilesLines
2020-03-12[SVE] Update API ConstantVector::getSplat() to use ElementCount.Huihui Zhang1-12/+16
Summary: Support ConstantInt::get() and Constant::getAllOnesValue() for scalable vector type, this requires ConstantVector::getSplat() to take in 'ElementCount', instead of 'unsigned' number of element count. This change is needed for D73753. Reviewers: sdesmalen, efriedma, apazos, spatel, huntergr, willlovett Reviewed By: efriedma Subscribers: tschuett, hiraditya, rkruppe, psnobl, cfe-commits, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74386
2020-03-12[DAGCombine] foldVSelectOfConstants - ensure constants are same typeSimon Pilgrim1-0/+2
Fix bug identified by https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21167, foldVSelectOfConstants must ensure that the 2 build vectors have scalars of the same type before trying to compare APInt values.
2020-03-12[WebAssembly] Fix SIMD shift unrolling to avoid assertion failureThomas Lively1-3/+4
Summary: Using the default DAG.UnrollVectorOp on v16i8 and v8i16 vectors results in i8 or i16 nodes being inserted into the SelectionDAG. Since those are illegal types, this causes a legalization assertion failure for some code patterns, as uncovered by PR45178. This change unrolls shifts manually to avoid this issue by adding and using a new optional EVT argument to DAG.ExtractVectorElements to control the type of the extract_element nodes. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, zzheng, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76043
2020-03-12[RAGreedy] Fix minor typo in comment. NFCMarcello Maggioni1-1/+1
2020-03-12[AArch64][SVE] Add intrinsics for non-temporal scatters/gathersAndrzej Warzynski1-1/+2
Summary: This patch adds the following intrinsics for non-temporal gather loads and scatter stores: * aarch64_sve_ldnt1_gather_index * aarch64_sve_stnt1_scatter_index These intrinsics implement the "scalar + vector of indices" addressing mode. As opposed to regular and first-faulting gathers/scatters, there's no instruction that would take indices and then scale them. Instead, the indices for non-temporal gathers/scatters are scaled before the intrinsics are lowered to `ldnt1` instructions. The new ISD nodes, GLDNT1_INDEX and SSTNT1_INDEX, are only used as placeholders so that we can easily identify the cases implemented in this patch in performGatherLoadCombine and performScatterStoreCombined. Once encountered, they are replaced with: * GLDNT1_INDEX -> SPLAT_VECTOR + SHL + GLDNT1 * SSTNT1_INDEX -> SPLAT_VECTOR + SHL + SSTNT1 The patterns for lowering ISD::SHL for scalable vectors (required by this patch) were missing, so these are added too. Reviewed By: sdesmalen Differential Revision: https://reviews.llvm.org/D75601
2020-03-12[GlobalISel] fix crash in narrowScalarExtract if DstRegs only has one registerDominik Montada1-2/+4
Summary: When narrowing a scalar G_EXTRACT where the destination lines up perfectly with a single result of the emitted G_UNMERGE_VALUES a COPY should be emitted instead of unconditionally trying to emit a G_MERGE_VALUES. Reviewers: arsenm, dsanders Reviewed By: arsenm Subscribers: wdng, rovka, hiraditya, volkan, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75743
2020-03-12Remove unused variable.Tres Popp1-1/+0
Delete dead code from 8fffa40400e8719222e7f67152c12738521fa9fb.
2020-03-11[GC] Remove redundant entiries in stackmap section (and test it this time)Philip Reames1-3/+22
This is a reimplementation of the optimization removed in D75964. The actual spill/fill optimization is handled by D76013, this one just worries about reducing the stackmap section size itself by eliminating redundant entries. As noted in the comments, we could go a lot further here, but avoiding the degenerate invoke case as we did before is probably "enough" in practice. Differential Revision: https://reviews.llvm.org/D76021
2020-03-11Specify branch probabilities for callbr destsBill Wendling1-2/+2
Summary: callbr's indirect branches aren't expected to be taken, so reduce their probabilities to 0 while increasing the default destination to 1. This allows some code improvements through block placement. Reviewers: nickdesaulniers Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72656
2020-03-11Add debug info support for Swift/Clang APINotes.Adrian Prantl1-0/+2
In order for dsymutil to collect .apinotes files (which capture attributes such as nullability, Swift import names, and availability), I want to propose adding an apinotes: field to DIModule that gets translated into a DW_AT_LLVM_apinotes (path) nested inside DW_TAG_module. This will be primarily used by LLDB to indirectly extract the Swift names of Clang declarations that were deserialized from DWARF. <rdar://problem/59514626> Differential Revision: https://reviews.llvm.org/D75585
2020-03-11Add an SDK attribute to DICompileUnitAdrian Prantl1-0/+3
This is part of PR44213 https://bugs.llvm.org/show_bug.cgi?id=44213 When importing (system) Clang modules, LLDB needs to know which SDK (e.g., MacOSX, iPhoneSimulator, ...) they came from. While the sysroot attribute contains the absolute path to the SDK, this doesn't work well when the debugger is run on a different machine than the compiler, and the SDKs are installed in different directories. It thus makes sense to just store the name of the SDK instead of the absolute path, so it can be found relative to LLDB. rdar://problem/51645582 Differential Revision: https://reviews.llvm.org/D75646
2020-03-11Fix conflict value for metadata "Objective-C Garbage Collection" in the mix ↵Jin Lin1-0/+9
of swift and Objective-C bitcode Summary: The change is to fix conflict value for metadata "Objective-C Garbage Collection" in the mix of swift and Objective-C bitcode. The purpose is to provide the support of LTO for swift and Objective-C mixed project. Reviewers: rjmccall, ahatanak, steven_wu Reviewed By: rjmccall, steven_wu Subscribers: manmanren, mehdi_amini, hiraditya, dexonsmith, llvm-commits, jinlin Tags: #llvm Differential Revision: https://reviews.llvm.org/D71219
2020-03-11[GC] Loosen ordering on statepoint reloads to allow CSEPhilip Reames1-6/+8
We just removed a broken duplicate elimination algorithm in D75964, and after landed that it occurred to me that duplicate elimination is simply CSE. SelectionDAG has a build in CSE, so why wasn't that triggering? Well, it turns out we were overly conservative in the memory states for our reloads and CSE (rightly) considers the incoming memory state for a load part of the identity of the load. By loosening the chain and allowing reordering, we also allow CSE. As shown in the test case, doing iterative CSE as we go is enough to eliminate duplicate stores in later statepoints as well. We key our (block local) slot map by SDValue, so commoning a previous pair of loads at construction time means we also common following stores. Differential Revision: https://reviews.llvm.org/D76013
2020-03-11[DAG] MatchRotate - Add funnel shift by immediate supportSimon Pilgrim1-10/+26
This patch reuses the existing MatchRotate ROTL/ROTR rotation pattern code to also recognize the more general FSHL/FSHR funnel shift patterns when we have constant shift amounts. Differential Revision: https://reviews.llvm.org/D75114
2020-03-12[CodeGenPrepare] Fold br(freeze(icmp x, const)) to br(icmp(freeze x, const))Juneyoung Lee1-0/+20
Summary: This patch helps CodeGenPrepare move freeze into the icmp when it is used by branch. It reenables generation of efficient conditional jumps. This is only done when at least one of icmp's operands is constant to prevent the transformation from increasing # of freeze instructions. Performance degradation of MultiSource/Benchmarks/Ptrdist/yacr2/yacr2.test is resolved with this patch. Checked with Alive2 Reviewers: reames, fhahn, nlopes Reviewed By: reames Subscribers: jdoerfert, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75859
2020-03-11[GC] Remove buggy untested optimization from statepoint loweringPhilip Reames1-52/+4
A downstream test case (see included reduced test) revealed that we have a bug in how we handle duplicate relocations. If we have the same SDValue relocated twice, and that value happens to be a constant (such as null), we only export one of the two llvm::Values. Exporting on a per llvm::Value basis is required to allow lowering of gc.relocates in following basic blocks (e.g. invokes). Without it, we end up with a use of an undefined vreg and bad things happen. Rather than fixing the optimization - which appears to be hard - I propose we simply remove it. There are no tests in tree that change with this code removed. If we find out later that this did matter for something, we can reimplement a variation of this in CodeGenPrepare to catch the easy cases without complicating the lowering code. Thanks to Denis and Serguei who did all the hard work of figuring out what went wrong here. The patch is by far the easy part. :) Differential Revision: https://reviews.llvm.org/D75964
2020-03-10GlobalISel: Don't try to narrow extending loads/trunc storeMatt Arsenault1-0/+6
If the loaded memory size was smaller than the result size, this would produce out of bounds memory accesses. I'm wondering if we need a distinct narrow memory legalize action type, since a case I care about is decomposing a 4-byte unaligned access into 4 extending loads, which would leave the original result register type. I'm currently awkwardly using narrowScalar to handle unaligned accesses that need to be split.
2020-03-10GlobalISel: Add missing add/sub with carries to MachineIRBuilderMatt Arsenault1-16/+0
2020-03-10GlobalISel: Implement fewerElementsVector for G_TRUNCMatt Arsenault1-7/+18
Extend fewerElementsVectorBasic to handle operands with different element types.
2020-03-10Give helpers internal linkage. NFC.Benjamin Kramer1-5/+5
2020-03-10[VE] Target-specific bit size for sjljehprepareKazushi (Jam) Marukawa3-13/+23
Summary: This patch extends the TargetMachine to let targets specify the integer size used by the sjljehprepare pass. This is 64bit for the VE target and otherwise defaults to 32bit for all targets, which was hard-wired before. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D71337
2020-03-10[TargetLowering] SimplifyDemandedVectorElts - add DemandedElts mask to ↵Simon Pilgrim1-1/+2
ISD::BITCAST SimplifyDemandedBits call. This fixes most of the regressions introduced in the rG4bc6f6332028 bugfix. The vector-trunc.ll issue should be fixed by D66004.
2020-03-10Reland "[DebugInfo] Enable the debug entry values feature by default"Djordje Todorovic4-5/+29
Differential Revision: https://reviews.llvm.org/D73534
2020-03-10[llvm][MIRVRegNamer] Avoid collisions across constant pool indices.Puyan Lotfi1-1/+1
When hashing on MachineOperand::MO_ConstantPoolIndex, now MIR-Canon and MIRVRegNamer will no longer result in a hash collision. Differential Revision: https://reviews.llvm.org/D74449
2020-03-09Move Spiller.h from lib/ directory path to include/CodeGen. NFCMarcello Maggioni6-48/+5
This allows Spiller.h to be used and included outside of the lib/CodeGen directory. For example to be used in the lib/Target directory or other places.
2020-03-09[CallSiteInfo] Enable the call site info only for -g + optimizationsDjordje Todorovic3-4/+4
Emit call site info only in the case of '-g' + 'O>0' level. Differential Revision: https://reviews.llvm.org/D75175
2020-03-09[ExpandMemCmp] Properly constant-fold all compares.Clement Courbet1-0/+4
Summary: This gets rid of duplicated code and diverging behaviour w.r.t. constants. Fixes PR45086. Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75519
2020-03-09[ExpandMemCmp] Properly constant-fold all compares.Clement Courbet1-98/+74
Summary: This gets rid of duplicated code and diverging behaviour w.r.t. constants. Fixes PR45086. Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75519
2020-03-07Assume ieee behavior without denormal-fp-math attributeMatt Arsenault1-9/+1
2020-03-06Revert "Revert "[GlobalISel][Localizer] Enable intra-block localization of ↵Amara Emerson1-1/+6
already-local uses."" This reverts commit 5583c2f2fba5be1df60f00cbc34a5098b5a49909. The lldb bot failure was a test that was fragile and sensitive to irrelevant changes in instruction ordering. Re-committing this as the test should have been skipped for AArch64 now. Differential Revision: https://reviews.llvm.org/D75555
2020-03-06Fix incorrect logic in maintaining the side-effect of compiler generated ↵Jin Lin1-18/+41
outliner functions Summary: Fix incorrect logic in maintaining the side-effect of compiler generated outliner functions by adding the up-exposed uses. Reviewers: paquette, tellenbach Reviewed By: paquette Subscribers: aemerson, lebedev.ri, hiraditya, llvm-commits, jinlin Tags: #llvm Differential Revision: https://reviews.llvm.org/D71217
2020-03-06[AIX] Handle LinkOnceODRLinkage and AppendingLinkage for static init gloabl ↵Xiangling Liao1-0/+4
arrays Handle LinkOnceODRLinkage; Handle AppendingLinkage type for llvm.global_ctors/dtors static init global arrays; Differential Revision: https://reviews.llvm.org/D75305
2020-03-06[DAG] Combine fshl/fshr(load1,load0,c) if we have consecutive loadsSimon Pilgrim1-0/+37
As noted on D75114, if both arguments of a funnel shift are consecutive loads we are missing the opportunity to combine them into a single load. Differential Revision: https://reviews.llvm.org/D75624
2020-03-06[GlobalISel] add missing libcalls and 128-bit support for floating pointsDominik Montada1-65/+54
Add libcall support for G_FMINNUM, G_FMAXNUM, G_FSQRT, G_FRINT, G_FNEARBYINT. Add 128-bit libcall support for all simple libcalls. Reviewers: arsenm, Petar.Avramovic, dsanders, petarj, paquette Subscribers: wdng, rovka, hiraditya, volkan, llvm-commits Differential Revision: https://reviews.llvm.org/D75516
2020-03-05[PGO][PGSO] Use IsColdXNthPercentile for sample PGO.Hiroshi Yamauchi1-0/+47
Summary: This performs better for sample PGO. NFC as PGSOColdCodeOnlyForSamplePGO is still true. Reviewers: davidxl Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75550
2020-03-05[DAGCombine] Check the uses of negated floating constant and remove the hackQingShan Zhang1-11/+15
PowerPC hits an assertion due to somewhat the same reason as https://reviews.llvm.org/D70975. Though there are already some hack, it still failed with some case, when the operand 0 is NOT a const fp, it is another fma that with const fp. And that const fp is negated which result in multi-uses. A better fix is to check the uses of the negated const fp. If there are already use of its negated value, we will have benefit as no extra Node is added. Differential revision: https://reviews.llvm.org/D75501
2020-03-05Revert "[GlobalISel][Localizer] Enable intra-block localization of ↵Muhammad Omair Javaid1-6/+1
already-local uses." This reverts commit e91e1df6ab74006e96b0cca94192e935542705a4.
2020-03-04GlobalISel: Move some legalizer functions to utilsMatt Arsenault2-52/+52
2020-03-04GlobalISel: Set alignment on function argument stack load/storeMatt Arsenault1-0/+11
2020-03-04Generate Callee Saved Register (CSR) related cfi directives like .cfi_restore.Wei Mi1-10/+66
https://reviews.llvm.org/D42848 only handled CFA related cfi directives but didn't handle CSR related cfi. The patch adds the CSR part. Basically it reuses the framework created in D42848. For each basicblock, the patch tracks which CSR set have been saved at its CFG predecessors's exits, and compare the CSR set with the set at its previous basicblock's exit (The previous block is the block laid before the current block). If the saved CSR set at its previous basicblock's exit is larger, .cfi_restore will be inserted. The patch also generates proper .cfi_restore in epilogue to make sure the saved CSR set is consistent for the incoming edges of each block. Differential Revision: https://reviews.llvm.org/D74303
2020-03-04[CodeGenPrepare] Handle ExtractValueInst in dupRetToEnableTailCallOptsGuozhi Wei1-1/+12
As the test case shows if there is an ExtractValueInst in the Ret block, function dupRetToEnableTailCallOpts can't duplicate it into the block containing call. So later no tail call is generated in CodeGen. This patch adds the ExtractValueInst handling code in function dupRetToEnableTailCallOpts and FoldReturnIntoUncondBranch, and later tail call can be generated for this case. Differential Revision: https://reviews.llvm.org/D74242
2020-03-04[ConstantFolding] Always return something from ConstantFoldConstantNikita Popov1-13/+12
Spin-off from D75407. As described there, ConstantFoldConstant() currently returns null for non-ConstantExpr/ConstantVector inputs, but otherwise always returns non-null, independently of whether any folding has happened or not. This is confusing and makes consumer code more complicated. I would expect either that ConstantFoldConstant() returns only if it actually folded something, or that it always returns non-null. I'm going to the latter possibility here, which appears to be more useful considering existing usage. Differential Revision: https://reviews.llvm.org/D75543
2020-03-04[SDAG] simplify FP binops to undefSanjay Patel2-3/+34
As discussed in the commit thread for rGa253a2a and D73978, we can do more undef folding for FP ops. The nnan and ninf fast-math-flags specify that if an operand is the disallowed value, the result is poison, so we can produce an undef result. But this doesn't work as expected (the undef operand cases remain) because of a Flags propagation problem in SelectionDAGBuilder. I've added DAGCombiner calls to enable these for the other cases because we've shown in other patches that (because of the limited way that SDAG iterates), it is possible to miss simplifications like this if they are done only at node creation time. Several potential follow-ups to expand on this patch are possible. Differential Revision: https://reviews.llvm.org/D75576
2020-03-03[GlobalISel][Localizer] Enable intra-block localization of already-local uses.Amara Emerson1-1/+6
This changes the localizer to attempt intra-block localizer of instructions that have local uses. This is useful because sometimes the entry block itself has many uses of constant-like instructions, which would benefit from shortening live ranges. Previously if an inst had no non-local uses, we wouldn't add it to the list of instructions to attempt further intra-block localization. This gives a 0.7% geomean code size improvement on CTMark. Differential Revision: https://reviews.llvm.org/D75555
2020-03-03[MCDwarf] Change emitListsTableHeaderStart to use a reference and fold ↵Fangrui Song1-8/+2
Start/End symbols generation into it Apply @dblaikie's suggestions in a post-commit review for D75375 Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D75568
2020-03-03[DebugInfo] Fix for adding "returns cxx udt" option to functions in CodeView.Amy Huang1-3/+4
Summary: This change checks for the return type in the frontend and adds a flag to the DISubroutineType to indicate that the option should be added in CodeViewDebug. Previously function types sometimes appeared twice in the PDB: once with "returns cxx udt" and once without. See https://bugs.llvm.org/show_bug.cgi?id=44785. Reviewers: rnk, asmith Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D75215
2020-03-03[MachineVerifier] Remove placement rule exception for debug entry valuesVedant Kumar1-1/+1
There should not be an exception allowing debug entry values to be placed after a terminator. Differential Revision: https://reviews.llvm.org/D75559
2020-03-03[LiveDebugValues] Do not insert DBG_VALUEs after a MBB terminatorVedant Kumar1-0/+7
This fixes a miscompile that happened because a DBG_VALUE interfered with the MachineOutliner's liveness analysis. Inserting a DBG_VALUE after a terminator breaks predicates on MBB such as isReturnBlock(). And the resulting DBG_VALUE cannot be "live". I plan to introduce a MachineVerifier check for this situation in a follow up. rdar://59859175 Testing: check-llvm, LNT build with a stage2 compiler & entry values enabled Differential Revision: https://reviews.llvm.org/D75548
2020-03-03[MCDwarf] Generate DWARF v5 .debug_rnglists for assembly filesFangrui Song1-21/+4
``` // clang -c -gdwarf-5 a.s -o a.o .section .init; ret .text; ret ``` .debug_info contains DW_AT_ranges and llvm-dwarfdump will report a verification error because .debug_rnglists does not exist (not implemented). This patch generates .debug_rnglists for assembly files. emitListsTableHeaderStart() in DwarfDebug.cpp can be shared with MCDwarf.cpp. Because CodeGen depends on MC, I move the function to MCDwarf.cpp Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D75375
2020-03-03[DAGCombiner][X86] Improve narrowExtractedVectorLoad to handle cases where ↵Craig Topper1-6/+18
the element size isn't byte sized by the subvector is. Summary: Follow up from D75377. If the subvector is byte sized and the index is aligned to the subvector size, we can shrink the load. Reviewers: spatel, RKSimon Reviewed By: RKSimon Subscribers: dbabokin, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75434