2008-09-22 01:08:49 +00:00
|
|
|
add_llvm_library(LLVMCodeGen
|
2009-10-26 19:32:42 +00:00
|
|
|
AggressiveAntiDepBreaker.cpp
|
2010-12-10 18:36:02 +00:00
|
|
|
AllocationOrder.cpp
|
2010-06-15 04:08:14 +00:00
|
|
|
Analysis.cpp
|
2014-08-21 21:50:01 +00:00
|
|
|
AtomicExpandPass.cpp
|
Switch TargetTransformInfo from an immutable analysis pass that requires
a TargetMachine to construct (and thus isn't always available), to an
analysis group that supports layered implementations much like
AliasAnalysis does. This is a pretty massive change, with a few parts
that I was unable to easily separate (sorry), so I'll walk through it.
The first step of this conversion was to make TargetTransformInfo an
analysis group, and to sink the nonce implementations in
ScalarTargetTransformInfo and VectorTargetTranformInfo into
a NoTargetTransformInfo pass. This allows other passes to add a hard
requirement on TTI, and assume they will always get at least on
implementation.
The TargetTransformInfo analysis group leverages the delegation chaining
trick that AliasAnalysis uses, where the base class for the analysis
group delegates to the previous analysis *pass*, allowing all but tho
NoFoo analysis passes to only implement the parts of the interfaces they
support. It also introduces a new trick where each pass in the group
retains a pointer to the top-most pass that has been initialized. This
allows passes to implement one API in terms of another API and benefit
when some other pass above them in the stack has more precise results
for the second API.
The second step of this conversion is to create a pass that implements
the TargetTransformInfo analysis using the target-independent
abstractions in the code generator. This replaces the
ScalarTargetTransformImpl and VectorTargetTransformImpl classes in
lib/Target with a single pass in lib/CodeGen called
BasicTargetTransformInfo. This class actually provides most of the TTI
functionality, basing it upon the TargetLowering abstraction and other
information in the target independent code generator.
The third step of the conversion adds support to all TargetMachines to
register custom analysis passes. This allows building those passes with
access to TargetLowering or other target-specific classes, and it also
allows each target to customize the set of analysis passes desired in
the pass manager. The baseline LLVMTargetMachine implements this
interface to add the BasicTTI pass to the pass manager, and all of the
tools that want to support target-aware TTI passes call this routine on
whatever target machine they end up with to add the appropriate passes.
The fourth step of the conversion created target-specific TTI analysis
passes for the X86 and ARM backends. These passes contain the custom
logic that was previously in their extensions of the
ScalarTargetTransformInfo and VectorTargetTransformInfo interfaces.
I separated them into their own file, as now all of the interface bits
are private and they just expose a function to create the pass itself.
Then I extended these target machines to set up a custom set of analysis
passes, first adding BasicTTI as a fallback, and then adding their
customized TTI implementations.
The fourth step required logic that was shared between the target
independent layer and the specific targets to move to a different
interface, as they no longer derive from each other. As a consequence,
a helper functions were added to TargetLowering representing the common
logic needed both in the target implementation and the codegen
implementation of the TTI pass. While technically this is the only
change that could have been committed separately, it would have been
a nightmare to extract.
The final step of the conversion was just to delete all the old
boilerplate. This got rid of the ScalarTargetTransformInfo and
VectorTargetTransformInfo classes, all of the support in all of the
targets for producing instances of them, and all of the support in the
tools for manually constructing a pass based around them.
Now that TTI is a relatively normal analysis group, two things become
straightforward. First, we can sink it into lib/Analysis which is a more
natural layer for it to live. Second, clients of this interface can
depend on it *always* being available which will simplify their code and
behavior. These (and other) simplifications will follow in subsequent
commits, this one is clearly big enough.
Finally, I'm very aware that much of the comments and documentation
needs to be updated. As soon as I had this working, and plausibly well
commented, I wanted to get it committed and in front of the build bots.
I'll be doing a few passes over documentation later if it sticks.
Commits to update DragonEgg and Clang will be made presently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171681 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 01:37:14 +00:00
|
|
|
BasicTargetTransformInfo.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
BranchFolding.cpp
|
2009-12-14 07:43:25 +00:00
|
|
|
CalcSpillWeights.cpp
|
2010-07-07 15:15:27 +00:00
|
|
|
CallingConvLower.cpp
|
2010-10-07 18:41:20 +00:00
|
|
|
CodeGen.cpp
|
2014-02-22 00:07:45 +00:00
|
|
|
CodeGenPrepare.cpp
|
2015-05-20 01:07:23 +00:00
|
|
|
CoreCLRGC.cpp
|
2009-10-26 16:59:04 +00:00
|
|
|
CriticalAntiDepBreaker.cpp
|
2011-12-01 21:49:23 +00:00
|
|
|
DFAPacketizer.cpp
|
2013-01-11 20:05:37 +00:00
|
|
|
DeadMachineInstructionElim.cpp
|
2009-05-22 20:36:31 +00:00
|
|
|
DwarfEHPrepare.cpp
|
2012-07-04 00:09:54 +00:00
|
|
|
EarlyIfConversion.cpp
|
2011-01-04 21:10:05 +00:00
|
|
|
EdgeBundles.cpp
|
2013-03-25 14:12:21 +00:00
|
|
|
ErlangGC.cpp
|
2011-09-28 00:01:54 +00:00
|
|
|
ExecutionDepsFix.cpp
|
2010-11-18 18:45:06 +00:00
|
|
|
ExpandISelPseudos.cpp
|
2011-09-25 16:46:00 +00:00
|
|
|
ExpandPostRAPseudos.cpp
|
2015-06-15 18:44:08 +00:00
|
|
|
FaultMaps.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
GCMetadata.cpp
|
|
|
|
GCMetadataPrinter.cpp
|
2015-01-15 19:29:42 +00:00
|
|
|
GCRootLowering.cpp
|
2015-01-26 18:26:35 +00:00
|
|
|
GCStrategy.cpp
|
2014-06-13 22:57:59 +00:00
|
|
|
GlobalMerge.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
IfConversion.cpp
|
2015-06-15 18:44:27 +00:00
|
|
|
ImplicitNullChecks.cpp
|
2010-06-29 23:58:39 +00:00
|
|
|
InlineSpiller.cpp
|
2011-04-02 06:03:35 +00:00
|
|
|
InterferenceCache.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
IntrinsicLowering.cpp
|
|
|
|
LLVMTargetMachine.cpp
|
2008-11-19 23:18:57 +00:00
|
|
|
LatencyPriorityQueue.cpp
|
2011-08-10 19:04:06 +00:00
|
|
|
LexicalScopes.cpp
|
2010-11-30 02:17:10 +00:00
|
|
|
LiveDebugVariables.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
LiveInterval.cpp
|
|
|
|
LiveIntervalAnalysis.cpp
|
2010-10-22 23:09:15 +00:00
|
|
|
LiveIntervalUnion.cpp
|
2013-01-11 20:05:37 +00:00
|
|
|
LiveRangeCalc.cpp
|
|
|
|
LiveRangeEdit.cpp
|
2012-06-09 02:13:10 +00:00
|
|
|
LiveRegMatrix.cpp
|
2013-12-14 06:52:56 +00:00
|
|
|
LivePhysRegs.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
LiveStackAnalysis.cpp
|
|
|
|
LiveVariables.cpp
|
2010-08-14 01:55:09 +00:00
|
|
|
LocalStackSlotAllocation.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
MachineBasicBlock.cpp
|
2011-07-25 19:25:40 +00:00
|
|
|
MachineBlockFrequencyInfo.cpp
|
Implement a block placement pass based on the branch probability and
block frequency analyses. This differs substantially from the existing
block-placement pass in LLVM:
1) It operates on the Machine-IR in the CodeGen layer. This exposes much
more (and more precise) information and opportunities. Also, the
results are more stable due to fewer transforms ocurring after the
pass runs.
2) It uses the generalized probability and frequency analyses. These can
model static heuristics, code annotation derived heuristics as well
as eventual profile loading. By basing the optimization on the
analysis interface it can work from any (or a combination) of these
inputs.
3) It uses a more aggressive algorithm, both building chains from tho
bottom up to maximize benefit, and using an SCC-based walk to layout
chains of blocks in a profitable ordering without O(N^2) iterations
which the old pass involves.
The pass is currently gated behind a flag, and not enabled by default
because it still needs to grow some important features. Most notably, it
needs to support loop aligning and careful layout of loop structures
much as done by hand currently in CodePlacementOpt. Once it supports
these, and has sufficient testing and quality tuning, it should replace
both of these passes.
Thanks to Nick Lewycky and Richard Smith for help authoring & debugging
this, and to Jakob, Andy, Eric, Jim, and probably a few others I'm
forgetting for reviewing and answering all my questions. Writing
a backend pass is *sooo* much better now than it used to be. =D
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142641 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 06:46:38 +00:00
|
|
|
MachineBlockPlacement.cpp
|
2011-06-16 20:22:37 +00:00
|
|
|
MachineBranchProbabilityInfo.cpp
|
2013-01-11 20:05:37 +00:00
|
|
|
MachineCSE.cpp
|
2014-08-03 21:35:39 +00:00
|
|
|
MachineCombiner.cpp
|
2012-01-07 03:02:36 +00:00
|
|
|
MachineCopyPropagation.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
MachineDominators.cpp
|
2014-07-12 21:59:52 +00:00
|
|
|
MachineDominanceFrontier.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
MachineFunction.cpp
|
2009-07-31 18:50:22 +00:00
|
|
|
MachineFunctionAnalysis.cpp
|
|
|
|
MachineFunctionPass.cpp
|
2010-04-02 23:17:14 +00:00
|
|
|
MachineFunctionPrinterPass.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
MachineInstr.cpp
|
2011-12-14 03:50:53 +00:00
|
|
|
MachineInstrBundle.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
MachineLICM.cpp
|
|
|
|
MachineLoopInfo.cpp
|
|
|
|
MachineModuleInfo.cpp
|
2009-09-16 10:18:36 +00:00
|
|
|
MachineModuleInfoImpls.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
MachinePassRegistry.cpp
|
2013-01-11 20:05:37 +00:00
|
|
|
MachinePostDominators.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
MachineRegisterInfo.cpp
|
2014-07-19 18:29:29 +00:00
|
|
|
MachineRegionInfo.cpp
|
2009-12-02 22:19:31 +00:00
|
|
|
MachineSSAUpdater.cpp
|
2012-01-13 06:30:30 +00:00
|
|
|
MachineScheduler.cpp
|
2010-01-13 01:02:47 +00:00
|
|
|
MachineSink.cpp
|
2012-07-26 18:38:11 +00:00
|
|
|
MachineTraceMetrics.cpp
|
2009-05-16 00:33:53 +00:00
|
|
|
MachineVerifier.cpp
|
2015-06-15 23:52:35 +00:00
|
|
|
MIRPrinter.cpp
|
2015-05-27 18:02:19 +00:00
|
|
|
MIRPrintingPass.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
OcamlGC.cpp
|
2010-02-12 01:30:21 +00:00
|
|
|
OptimizePHIs.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
PHIElimination.cpp
|
2010-12-05 19:51:05 +00:00
|
|
|
PHIEliminationUtils.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
Passes.cpp
|
2010-08-10 05:16:06 +00:00
|
|
|
PeepholeOptimizer.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
PostRASchedulerList.cpp
|
2009-11-04 01:32:06 +00:00
|
|
|
ProcessImplicitDefs.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
PrologEpilogInserter.cpp
|
|
|
|
PseudoSourceValue.cpp
|
2012-01-11 22:28:30 +00:00
|
|
|
RegAllocBase.cpp
|
2010-10-22 23:09:15 +00:00
|
|
|
RegAllocBasic.cpp
|
2010-04-21 18:02:42 +00:00
|
|
|
RegAllocFast.cpp
|
2010-12-08 03:26:16 +00:00
|
|
|
RegAllocGreedy.cpp
|
2008-10-04 21:18:50 +00:00
|
|
|
RegAllocPBQP.cpp
|
2011-06-02 02:19:35 +00:00
|
|
|
RegisterClassInfo.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
RegisterCoalescer.cpp
|
2012-04-24 18:06:49 +00:00
|
|
|
RegisterPressure.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
RegisterScavenging.cpp
|
2008-11-19 23:18:57 +00:00
|
|
|
ScheduleDAG.cpp
|
|
|
|
ScheduleDAGInstrs.cpp
|
|
|
|
ScheduleDAGPrinter.cpp
|
2011-01-09 21:31:39 +00:00
|
|
|
ScoreboardHazardRecognizer.cpp
|
[ShrinkWrap] Add (a simplified version) of shrink-wrapping.
This patch introduces a new pass that computes the safe point to insert the
prologue and epilogue of the function.
The interest is to find safe points that are cheaper than the entry and exits
blocks.
As an example and to avoid regressions to be introduce, this patch also
implements the required bits to enable the shrink-wrapping pass for AArch64.
** Context **
Currently we insert the prologue and epilogue of the method/function in the
entry and exits blocks. Although this is correct, we can do a better job when
those are not immediately required and insert them at less frequently executed
places.
The job of the shrink-wrapping pass is to identify such places.
** Motivating example **
Let us consider the following function that perform a call only in one branch of
a if:
define i32 @f(i32 %a, i32 %b) {
%tmp = alloca i32, align 4
%tmp2 = icmp slt i32 %a, %b
br i1 %tmp2, label %true, label %false
true:
store i32 %a, i32* %tmp, align 4
%tmp4 = call i32 @doSomething(i32 0, i32* %tmp)
br label %false
false:
%tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ]
ret i32 %tmp.0
}
On AArch64 this code generates (removing the cfi directives to ease
readabilities):
_f: ; @f
; BB#0:
stp x29, x30, [sp, #-16]!
mov x29, sp
sub sp, sp, #16 ; =16
cmp w0, w1
b.ge LBB0_2
; BB#1: ; %true
stur w0, [x29, #-4]
sub x1, x29, #4 ; =4
mov w0, wzr
bl _doSomething
LBB0_2: ; %false
mov sp, x29
ldp x29, x30, [sp], #16
ret
With shrink-wrapping we could generate:
_f: ; @f
; BB#0:
cmp w0, w1
b.ge LBB0_2
; BB#1: ; %true
stp x29, x30, [sp, #-16]!
mov x29, sp
sub sp, sp, #16 ; =16
stur w0, [x29, #-4]
sub x1, x29, #4 ; =4
mov w0, wzr
bl _doSomething
add sp, x29, #16 ; =16
ldp x29, x30, [sp], #16
LBB0_2: ; %false
ret
Therefore, we would pay the overhead of setting up/destroying the frame only if
we actually do the call.
** Proposed Solution **
This patch introduces a new machine pass that perform the shrink-wrapping
analysis (See the comments at the beginning of ShrinkWrap.cpp for more details).
It then stores the safe save and restore point into the MachineFrameInfo
attached to the MachineFunction.
This information is then used by the PrologEpilogInserter (PEI) to place the
related code at the right place. This pass runs right before the PEI.
Unlike the original paper of Chow from PLDI’88, this implementation of
shrink-wrapping does not use expensive data-flow analysis and does not need hack
to properly avoid frequently executed point. Instead, it relies on dominance and
loop properties.
The pass is off by default and each target can opt-in by setting the
EnableShrinkWrap boolean to true in their derived class of TargetPassConfig.
This setting can also be overwritten on the command line by using
-enable-shrink-wrap.
Before you try out the pass for your target, make sure you properly fix your
emitProlog/emitEpilog/adjustForXXX method to cope with basic blocks that are not
necessarily the entry block.
** Design Decisions **
1. ShrinkWrap is its own pass right now. It could frankly be merged into PEI but
for debugging and clarity I thought it was best to have its own file.
2. Right now, we only support one save point and one restore point. At some
point we can expand this to several save point and restore point, the impacted
component would then be:
- The pass itself: New algorithm needed.
- MachineFrameInfo: Hold a list or set of Save/Restore point instead of one
pointer.
- PEI: Should loop over the save point and restore point.
Anyhow, at least for this first iteration, I do not believe this is interesting
to support the complex cases. We should revisit that when we motivating
examples.
Differential Revision: http://reviews.llvm.org/D9210
<rdar://problem/3201744>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236507 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-05 17:38:16 +00:00
|
|
|
ShrinkWrap.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
ShadowStackGC.cpp
|
2015-01-28 19:28:03 +00:00
|
|
|
ShadowStackGCLowering.cpp
|
2009-08-17 18:47:11 +00:00
|
|
|
SjLjEHPrepare.cpp
|
2009-11-04 01:32:06 +00:00
|
|
|
SlotIndexes.cpp
|
2011-01-06 01:21:53 +00:00
|
|
|
SpillPlacement.cpp
|
2010-07-20 15:41:07 +00:00
|
|
|
SplitKit.cpp
|
2013-01-11 20:05:37 +00:00
|
|
|
StackColoring.cpp
|
2008-11-04 03:24:04 +00:00
|
|
|
StackProtector.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
StackSlotColoring.cpp
|
2013-12-14 06:53:06 +00:00
|
|
|
StackMapLivenessAnalysis.cpp
|
2013-10-31 22:11:56 +00:00
|
|
|
StackMaps.cpp
|
2015-01-07 19:07:50 +00:00
|
|
|
StatepointExampleGC.cpp
|
2009-11-26 00:32:21 +00:00
|
|
|
TailDuplication.cpp
|
2011-12-15 22:58:58 +00:00
|
|
|
TargetFrameLoweringImpl.cpp
|
2012-11-28 02:35:09 +00:00
|
|
|
TargetInstrInfo.cpp
|
2013-01-11 20:05:37 +00:00
|
|
|
TargetLoweringBase.cpp
|
2010-02-15 22:55:13 +00:00
|
|
|
TargetLoweringObjectFileImpl.cpp
|
2011-12-15 22:58:58 +00:00
|
|
|
TargetOptionsImpl.cpp
|
2012-11-28 02:35:09 +00:00
|
|
|
TargetRegisterInfo.cpp
|
2012-09-14 20:26:46 +00:00
|
|
|
TargetSchedule.cpp
|
2008-09-22 01:08:49 +00:00
|
|
|
TwoAddressInstructionPass.cpp
|
|
|
|
UnreachableBlockElim.cpp
|
|
|
|
VirtRegMap.cpp
|
2015-01-29 00:41:44 +00:00
|
|
|
WinEHPrepare.cpp
|
2015-02-11 03:28:02 +00:00
|
|
|
|
|
|
|
ADDITIONAL_HEADER_DIRS
|
|
|
|
${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen
|
|
|
|
${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen/PBQP
|
2008-09-22 01:08:49 +00:00
|
|
|
)
|
2011-02-18 22:06:14 +00:00
|
|
|
|
2012-06-24 13:32:01 +00:00
|
|
|
add_dependencies(LLVMCodeGen intrinsics_gen)
|
|
|
|
|
2011-02-18 22:06:14 +00:00
|
|
|
add_subdirectory(SelectionDAG)
|
|
|
|
add_subdirectory(AsmPrinter)
|
2015-05-27 18:02:19 +00:00
|
|
|
add_subdirectory(MIRParser)
|