llvm-project/llvm/lib/CodeGen
Paul Walker 96c8d615d6 [SVE] Extend findMoreOptimalIndexType so BUILD_VECTORs do not force 64bit indices.
Extends findMoreOptimalIndexType to allow ISD::BUILD_VECTOR based
indices to be truncated when such truncation is lossless. This can
enable the use of 32bit gather/scatter indices thus making it less
likely to have to split a gather/scatter in two.

Depends on D125194

Differential Revision: https://reviews.llvm.org/D130533
2022-08-18 18:00:53 +01:00
..
AsmPrinter Untangle the mess which is MachineBasicBlock::hasAddressTaken(). 2022-08-16 16:15:44 -07:00
GlobalISel Untangle the mess which is MachineBasicBlock::hasAddressTaken(). 2022-08-16 16:15:44 -07:00
LiveDebugValues LiveDebugValues: Fix another crash related to unreachable blocks 2022-08-09 10:34:57 -07:00
MIRParser Untangle the mess which is MachineBasicBlock::hasAddressTaken(). 2022-08-16 16:15:44 -07:00
SelectionDAG [SVE] Extend findMoreOptimalIndexType so BUILD_VECTORs do not force 64bit indices. 2022-08-18 18:00:53 +01:00
AggressiveAntiDepBreaker.cpp
AggressiveAntiDepBreaker.h
AllocationOrder.cpp
AllocationOrder.h
Analysis.cpp
AtomicExpandPass.cpp [IRBuilder] Add assert for AtomicRMW ordering 2022-07-25 22:51:25 +00:00
BasicBlockSections.cpp Add a nop instruction if a section starts with landing pad for function splitter 2022-07-22 15:20:10 -07:00
BasicBlockSectionsProfileReader.cpp
BasicTargetTransformInfo.cpp
BranchFolding.cpp
BranchFolding.h
BranchRelaxation.cpp
BreakFalseDeps.cpp
CFGuardLongjmp.cpp
CFIFixup.cpp
CFIInstrInserter.cpp
CMakeLists.txt [mlgo] Don't provide default model URLs 2022-07-11 07:37:14 -07:00
CalcSpillWeights.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
CallingConvLower.cpp
CodeGen.cpp
CodeGenCommonISel.cpp [GlobalISel][DebugInfo] salvageDebugInfo analogue for gMIR 2022-08-01 11:14:53 +02:00
CodeGenPassBuilder.cpp
CodeGenPrepare.cpp [CostModel] Replace getUserCost with getInstructionCost 2022-08-18 11:55:23 +01:00
CommandFlags.cpp
CriticalAntiDepBreaker.cpp
CriticalAntiDepBreaker.h
DFAPacketizer.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
DeadMachineInstructionElim.cpp
DetectDeadLanes.cpp
DwarfEHPrepare.cpp
EHContGuardCatchret.cpp
EarlyIfConversion.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
EdgeBundles.cpp
ExecutionDomainFix.cpp
ExpandMemCmp.cpp
ExpandPostRAPseudos.cpp
ExpandReductions.cpp
ExpandVectorPredication.cpp [llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 11:24:15 -07:00
FEntryInserter.cpp
FaultMaps.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
FinalizeISel.cpp
FixupStatepointCallerSaved.cpp
FuncletLayout.cpp
GCMetadata.cpp
GCMetadataPrinter.cpp
GCRootLowering.cpp
GlobalMerge.cpp
HardwareLoops.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
IfConversion.cpp
ImplicitNullChecks.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
IndirectBrExpandPass.cpp
InlineSpiller.cpp [llvm] Fix comment typos (NFC) 2022-08-07 00:16:14 -07:00
InterferenceCache.cpp
InterferenceCache.h
InterleavedAccessPass.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
InterleavedLoadCombinePass.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
IntrinsicLowering.cpp
JMCInstrumenter.cpp
LLVMTargetMachine.cpp
LatencyPriorityQueue.cpp
LazyMachineBlockFrequencyInfo.cpp
LexicalScopes.cpp
LiveDebugVariables.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
LiveDebugVariables.h
LiveInterval.cpp
LiveIntervalCalc.cpp
LiveIntervalUnion.cpp
LiveIntervals.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
LivePhysRegs.cpp
LiveRangeCalc.cpp
LiveRangeEdit.cpp Fix subrange liveness checking at rematerialization 2022-08-16 10:50:09 -07:00
LiveRangeShrink.cpp
LiveRangeUtils.h
LiveRegMatrix.cpp
LiveRegUnits.cpp
LiveStacks.cpp
LiveVariables.cpp [CodeGen] Use range-based for loops (NFC) 2022-07-23 16:10:46 -07:00
LocalStackSlotAllocation.cpp
LoopTraversal.cpp
LowLevelType.cpp
LowerEmuTLS.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
MBFIWrapper.cpp
MIRCanonicalizerPass.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
MIRFSDiscriminator.cpp
MIRNamerPass.cpp
MIRPrinter.cpp [llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 11:24:15 -07:00
MIRPrintingPass.cpp
MIRSampleProfile.cpp
MIRVRegNamerUtils.cpp
MIRVRegNamerUtils.h
MIRYamlMapping.cpp
MLRegallocEvictAdvisor.cpp [mlgo] Add ability to create feature-gated development features in regalloc advisor 2022-08-15 16:01:37 -07:00
MachineBasicBlock.cpp Untangle the mess which is MachineBasicBlock::hasAddressTaken(). 2022-08-16 16:15:44 -07:00
MachineBlockFrequencyInfo.cpp
MachineBlockPlacement.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
MachineBranchProbabilityInfo.cpp
MachineCSE.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
MachineCheckDebugify.cpp
MachineCombiner.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
MachineCopyPropagation.cpp
MachineCycleAnalysis.cpp
MachineDebugify.cpp
MachineDominanceFrontier.cpp
MachineDominators.cpp
MachineFrameInfo.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
MachineFunction.cpp [llvm] LLVM_NODISCARD => [[nodiscard]]. NFC 2022-08-07 00:26:33 +00:00
MachineFunctionPass.cpp [MachineFunctionPass] Support -print-changed={,c}diff{,-quiet} 2022-08-01 12:56:15 -07:00
MachineFunctionPrinterPass.cpp
MachineFunctionSplitter.cpp Split EH code by default 2022-08-17 12:40:31 -07:00
MachineInstr.cpp [RISCV] Pre-RA expand pseudos pass 2022-07-31 23:19:00 +02:00
MachineInstrBundle.cpp
MachineLICM.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
MachineLoopInfo.cpp
MachineLoopUtils.cpp
MachineModuleInfo.cpp
MachineModuleInfoImpls.cpp
MachineModuleSlotTracker.cpp
MachineOperand.cpp
MachineOptimizationRemarkEmitter.cpp
MachineOutliner.cpp
MachinePassManager.cpp
MachinePipeliner.cpp Revert "[ModuloSchedule] Add interface call to accept/reject SMS schedules" 2022-08-17 09:32:43 -07:00
MachinePostDominators.cpp
MachineRegionInfo.cpp
MachineRegisterInfo.cpp Use hasNItemsOrLess() in MRI::hasAtMostUserInstrs(). 2022-07-27 11:42:14 -07:00
MachineSSAContext.cpp
MachineSSAUpdater.cpp
MachineScheduler.cpp [CodeGen] Fixed undeclared MISchedCutoff in case of NDEBUG and LLVM_ENABLE_ABI_BREAKING_CHECKS 2022-07-30 18:24:50 +02:00
MachineSink.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
MachineSizeOpts.cpp
MachineStableHash.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
MachineStripDebug.cpp
MachineTraceMetrics.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
MachineVerifier.cpp Untangle the mess which is MachineBasicBlock::hasAddressTaken(). 2022-08-16 16:15:44 -07:00
MacroFusion.cpp
ModuloSchedule.cpp [MachinePipeliner] Fix Phi generation failure for large stages 2022-08-09 13:14:26 +09:00
MultiHazardRecognizer.cpp
NonRelocatableStringpool.cpp
OptimizePHIs.cpp
PHIElimination.cpp
PHIEliminationUtils.cpp
PHIEliminationUtils.h
ParallelCG.cpp
PatchableFunction.cpp
PeepholeOptimizer.cpp
PostRAHazardRecognizer.cpp
PostRASchedulerList.cpp
PreISelIntrinsicLowering.cpp [WinEH] Apply funclet operand bundles to nounwind intrinsics that lower to function calls in the course of IR transforms 2022-07-26 17:52:43 +02:00
ProcessImplicitDefs.cpp [llvm] Remove redundaunt virtual specifiers (NFC) 2022-07-24 21:50:35 -07:00
PrologEpilogInserter.cpp
PseudoProbeInserter.cpp
PseudoSourceValue.cpp
RDFGraph.cpp Recommit [RDF] Remove explicit template arguments from Print 2022-08-08 07:28:45 -07:00
RDFLiveness.cpp Recommit [RDF] Remove explicit template arguments from Print 2022-08-08 07:28:45 -07:00
RDFRegisters.cpp
README.txt
ReachingDefAnalysis.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
RegAllocBase.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
RegAllocBase.h
RegAllocBasic.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
RegAllocEvictionAdvisor.cpp
RegAllocEvictionAdvisor.h [CodeGen] Remove unused member variable NextCascade (NFC) 2022-07-10 18:57:40 -07:00
RegAllocFast.cpp Revert "(Reland) [fastalloc] Support allocating specific register class in fastalloc" 2022-08-15 20:33:15 +08:00
RegAllocGreedy.cpp RAGreedyStats: Ignore identity COPYs; count COPYs from/to physregs 2022-08-17 12:53:29 -07:00
RegAllocGreedy.h RegAllocGreedy: Fix nondeterminism in tryLastChanceRecoloring 2022-07-27 19:02:06 -04:00
RegAllocPBQP.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
RegAllocScore.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
RegAllocScore.h CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
RegUsageInfoCollector.cpp
RegUsageInfoPropagate.cpp
RegisterBank.cpp
RegisterBankInfo.cpp [globalisel] Select register bank for DBG_VALUE 2022-08-09 13:11:51 +08:00
RegisterClassInfo.cpp
RegisterCoalescer.cpp [llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 11:24:15 -07:00
RegisterCoalescer.h
RegisterPressure.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
RegisterScavenging.cpp
RegisterUsageInfo.cpp
RemoveRedundantDebugValues.cpp
RenameIndependentSubregs.cpp
ReplaceWithVeclib.cpp
ResetMachineFunctionPass.cpp
SafeStack.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
SafeStackLayout.cpp
SafeStackLayout.h
ScheduleDAG.cpp
ScheduleDAGInstrs.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
ScheduleDAGPrinter.cpp
ScoreboardHazardRecognizer.cpp [llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 11:24:15 -07:00
SelectOptimize.cpp [llvm][NFC] Refactor code to use ProfDataUtils 2022-08-03 00:09:45 +00:00
ShadowStackGCLowering.cpp
ShrinkWrap.cpp
SjLjEHPrepare.cpp
SlotIndexes.cpp [LiveIntervals] Find better anchoring end points when repairing ranges 2022-07-18 19:34:43 +01:00
SpillPlacement.cpp
SpillPlacement.h
SplitKit.cpp CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
SplitKit.h CodeGen: Remove AliasAnalysis from regalloc 2022-07-18 17:23:41 -04:00
StackColoring.cpp
StackMapLivenessAnalysis.cpp
StackMaps.cpp [CodeGen] Qualify auto variables in for loops (NFC) 2022-07-17 01:33:28 -07:00
StackProtector.cpp
StackSlotColoring.cpp
SwiftErrorValueTracking.cpp Use any_of (NFC) 2022-07-30 10:35:56 -07:00
SwitchLoweringUtils.cpp
TailDuplication.cpp
TailDuplicator.cpp [nfc] Remove unused parameter in TailDuplicator::duplicateSimpleBB 2022-08-02 13:39:34 -07:00
TargetFrameLoweringImpl.cpp
TargetInstrInfo.cpp Outliner: add "target-cpu" feature from source function to outlined 2022-08-02 09:33:29 +01:00
TargetLoweringBase.cpp [NFCI] Move cost estimation from TargetLowering to TargetTransformInfo. 2022-08-18 00:38:55 +03:00
TargetLoweringObjectFileImpl.cpp [Windows] Put init_seg(compiler/lib) in llvm.global_ctors 2022-08-16 08:16:18 -07:00
TargetOptionsImpl.cpp
TargetPassConfig.cpp [llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 11:24:15 -07:00
TargetRegisterInfo.cpp
TargetSchedule.cpp
TargetSubtargetInfo.cpp
TwoAddressInstructionPass.cpp [llvm] Use llvm::any_of and llvm::none_of (NFC) 2022-07-20 00:36:19 -07:00
TypePromotion.cpp [TypePromotion] Don't promote PHI + ZExt if wider than RegisterBitWidth 2022-08-17 09:54:15 +01:00
UnreachableBlockElim.cpp
VLIWMachineScheduler.cpp [llvm] Fix comment typos (NFC) 2022-08-07 00:16:14 -07:00
ValueTypes.cpp
VirtRegMap.cpp
WasmEHPrepare.cpp
WinEHPrepare.cpp
XRayInstrumentation.cpp

README.txt

//===---------------------------------------------------------------------===//

Common register allocation / spilling problem:

        mul lr, r4, lr
        str lr, [sp, #+52]
        ldr lr, [r1, #+32]
        sxth r3, r3
        ldr r4, [sp, #+52]
        mla r4, r3, lr, r4

can be:

        mul lr, r4, lr
        mov r4, lr
        str lr, [sp, #+52]
        ldr lr, [r1, #+32]
        sxth r3, r3
        mla r4, r3, lr, r4

and then "merge" mul and mov:

        mul r4, r4, lr
        str r4, [sp, #+52]
        ldr lr, [r1, #+32]
        sxth r3, r3
        mla r4, r3, lr, r4

It also increase the likelihood the store may become dead.

//===---------------------------------------------------------------------===//

bb27 ...
        ...
        %reg1037 = ADDri %reg1039, 1
        %reg1038 = ADDrs %reg1032, %reg1039, %noreg, 10
    Successors according to CFG: 0x8b03bf0 (#5)

bb76 (0x8b03bf0, LLVM BB @0x8b032d0, ID#5):
    Predecessors according to CFG: 0x8b0c5f0 (#3) 0x8b0a7c0 (#4)
        %reg1039 = PHI %reg1070, mbb<bb76.outer,0x8b0c5f0>, %reg1037, mbb<bb27,0x8b0a7c0>

Note ADDri is not a two-address instruction. However, its result %reg1037 is an
operand of the PHI node in bb76 and its operand %reg1039 is the result of the
PHI node. We should treat it as a two-address code and make sure the ADDri is
scheduled after any node that reads %reg1039.

//===---------------------------------------------------------------------===//

Use local info (i.e. register scavenger) to assign it a free register to allow
reuse:
        ldr r3, [sp, #+4]
        add r3, r3, #3
        ldr r2, [sp, #+8]
        add r2, r2, #2
        ldr r1, [sp, #+4]  <==
        add r1, r1, #1
        ldr r0, [sp, #+4]
        add r0, r0, #2

//===---------------------------------------------------------------------===//

LLVM aggressively lift CSE out of loop. Sometimes this can be negative side-
effects:

R1 = X + 4
R2 = X + 7
R3 = X + 15

loop:
load [i + R1]
...
load [i + R2]
...
load [i + R3]

Suppose there is high register pressure, R1, R2, R3, can be spilled. We need
to implement proper re-materialization to handle this:

R1 = X + 4
R2 = X + 7
R3 = X + 15

loop:
R1 = X + 4  @ re-materialized
load [i + R1]
...
R2 = X + 7 @ re-materialized
load [i + R2]
...
R3 = X + 15 @ re-materialized
load [i + R3]

Furthermore, with re-association, we can enable sharing:

R1 = X + 4
R2 = X + 7
R3 = X + 15

loop:
T = i + X
load [T + 4]
...
load [T + 7]
...
load [T + 15]
//===---------------------------------------------------------------------===//

It's not always a good idea to choose rematerialization over spilling. If all
the load / store instructions would be folded then spilling is cheaper because
it won't require new live intervals / registers. See 2003-05-31-LongShifts for
an example.

//===---------------------------------------------------------------------===//

With a copying garbage collector, derived pointers must not be retained across
collector safe points; the collector could move the objects and invalidate the
derived pointer. This is bad enough in the first place, but safe points can
crop up unpredictably. Consider:

        %array = load { i32, [0 x %obj] }** %array_addr
        %nth_el = getelementptr { i32, [0 x %obj] }* %array, i32 0, i32 %n
        %old = load %obj** %nth_el
        %z = div i64 %x, %y
        store %obj* %new, %obj** %nth_el

If the i64 division is lowered to a libcall, then a safe point will (must)
appear for the call site. If a collection occurs, %array and %nth_el no longer
point into the correct object.

The fix for this is to copy address calculations so that dependent pointers
are never live across safe point boundaries. But the loads cannot be copied
like this if there was an intervening store, so may be hard to get right.

Only a concurrent mutator can trigger a collection at the libcall safe point.
So single-threaded programs do not have this requirement, even with a copying
collector. Still, LLVM optimizations would probably undo a front-end's careful
work.

//===---------------------------------------------------------------------===//

The ocaml frametable structure supports liveness information. It would be good
to support it.

//===---------------------------------------------------------------------===//

The FIXME in ComputeCommonTailLength in BranchFolding.cpp needs to be
revisited. The check is there to work around a misuse of directives in inline
assembly.

//===---------------------------------------------------------------------===//

It would be good to detect collector/target compatibility instead of silently
doing the wrong thing.

//===---------------------------------------------------------------------===//

It would be really nice to be able to write patterns in .td files for copies,
which would eliminate a bunch of explicit predicates on them (e.g. no side
effects).  Once this is in place, it would be even better to have tblgen
synthesize the various copy insertion/inspection methods in TargetInstrInfo.

//===---------------------------------------------------------------------===//

Stack coloring improvements:

1. Do proper LiveStacks analysis on all stack objects including those which are
   not spill slots.
2. Reorder objects to fill in gaps between objects.
   e.g. 4, 1, <gap>, 4, 1, 1, 1, <gap>, 4 => 4, 1, 1, 1, 1, 4, 4

//===---------------------------------------------------------------------===//

The scheduler should be able to sort nearby instructions by their address. For
example, in an expanded memset sequence it's not uncommon to see code like this:

  movl $0, 4(%rdi)
  movl $0, 8(%rdi)
  movl $0, 12(%rdi)
  movl $0, 0(%rdi)

Each of the stores is independent, and the scheduler is currently making an
arbitrary decision about the order.

//===---------------------------------------------------------------------===//

Another opportunitiy in this code is that the $0 could be moved to a register:

  movl $0, 4(%rdi)
  movl $0, 8(%rdi)
  movl $0, 12(%rdi)
  movl $0, 0(%rdi)

This would save substantial code size, especially for longer sequences like
this. It would be easy to have a rule telling isel to avoid matching MOV32mi
if the immediate has more than some fixed number of uses. It's more involved
to teach the register allocator how to do late folding to recover from
excessive register pressure.