llvm-6502/lib/Transforms/Utils
Chandler Carruth 8d93d41027 Re-implement the analysis of uses in mem2reg to be significantly more
robust. It now uses an InstVisitor and worklist to actually walk the
uses of the Alloca transitively and detect the pattern which we can
directly promote: loads & stores of the whole alloca and instructions we
can completely ignore.

Also, with this new implementation teach both the predicate for testing
whether we can promote and the promotion engine itself to use the same
code so we no longer have strange divergence between the two code paths.

I've added some silly test cases to demonstrate that we can handle
slightly more degenerate code patterns now. See the below for why this
is even interesting.

Performance impact: roughly 1% regression in the performance of SROA or
ScalarRepl on a large C++-ish test case where most of the allocas are
basically ready for promotion. The reason is because of silly redundant
work that I've left FIXMEs for and which I'll address in the next
commit. I wanted to separate this commit as it changes the behavior.
Once the redundant work in removing the dead uses of the alloca is
fixed, this code appears to be faster than the old version. =]

So why is this useful? Because the previous requirement for promotion
required a *specific* visit pattern of the uses of the alloca to verify:
we *had* to look for no more than 1 intervening use. The end goal is to
have SROA automatically detect when an alloca is already promotable and
directly hand it to the mem2reg machinery rather than trying to
partition and rewrite it. This is a 25% or more performance improvement
for SROA, and a significant chunk of the delta between it and
ScalarRepl. To get there, we need to make mem2reg actually capable of
promoting allocas which *look* promotable to SROA without have SROA do
tons of work to massage the code into just the right form.

This is actually the tip of the iceberg. There are tremendous potential
savings we can realize here by de-duplicating work between mem2reg and
SROA.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187191 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 08:20:39 +00:00
..
BasicBlockUtils.cpp Use SmallVectorImpl::iterator/const_iterator instead of SmallVector to avoid specifying the vector size. 2013-07-04 01:31:24 +00:00
BreakCriticalEdges.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
BuildLibCalls.cpp Convert BuildLibCalls.cpp to using the AttributeSet methods instead of AttributeWithIndex. 2013-01-26 00:03:11 +00:00
BypassSlowDivision.cpp Bypass Slow Divides 2013-03-04 18:13:57 +00:00
CloneFunction.cpp Extend RemapInstruction and friends to take an optional new parameter, a ValueMaterializer. 2013-05-28 15:17:05 +00:00
CloneModule.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
CMakeLists.txt Rename BlackList class to SpecialCaseList and move it to Transforms/Utils. 2013-07-09 22:02:49 +00:00
CmpInstAnalysis.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
CodeExtractor.cpp Use SmallVectorImpl::iterator/const_iterator instead of SmallVector to avoid specifying the vector size. 2013-07-04 01:31:24 +00:00
DemoteRegToStack.cpp [SjLj Prepare] When demoting an invoke instructions to the stack, if the normal 2013-02-05 18:23:10 +00:00
InlineFunction.cpp Fix a use after free. RI is freed before the call to getDebugLoc(). To 2013-04-30 22:45:10 +00:00
InstructionNamer.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
IntegerDivision.cpp Enhance integer division emulation support to handle types smaller than 32 bits, 2013-02-26 23:33:20 +00:00
LCSSA.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
LLVMBuild.txt LLVMBuild: Remove trailing newline, which irked me. 2011-12-12 19:48:00 +00:00
Local.cpp Fix spelling 2013-07-23 22:20:57 +00:00
LoopSimplify.cpp Rename LoopSimplify.h to LoopUtils.h 2013-05-20 20:46:30 +00:00
LoopUnroll.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
LoopUnrollRuntime.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
LowerExpectIntrinsic.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
LowerInvoke.cpp Access the TargetLoweringInfo from the TargetMachine object instead of caching it. The TLI may change between functions. No functionality change. 2013-06-19 21:07:11 +00:00
LowerSwitch.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
Makefile
Mem2Reg.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
MetaRenamer.cpp Add 'const' qualifier to some arrays. 2013-07-15 08:02:13 +00:00
ModuleUtils.cpp Respect llvm.used in Internalize. 2013-07-25 03:23:25 +00:00
PromoteMemoryToRegister.cpp Re-implement the analysis of uses in mem2reg to be significantly more 2013-07-26 08:20:39 +00:00
SimplifyCFG.cpp Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size. 2013-07-14 04:42:23 +00:00
SimplifyIndVar.cpp Don't use a potentially expensive shift if all we want is one set bit. 2013-07-11 16:05:50 +00:00
SimplifyInstructions.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
SimplifyLibCalls.cpp Added support for the Builtin attribute. 2013-06-27 00:25:01 +00:00
SpecialCaseList.cpp Make SpecialCaseList match full strings, as documented, using anchors. 2013-07-16 17:56:07 +00:00
SSAUpdater.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
UnifyFunctionExitNodes.cpp Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
Utils.cpp This patch breaks up Wrap.h so that it does not have to include all of 2013-05-01 20:59:00 +00:00
ValueMapper.cpp Extend RemapInstruction and friends to take an optional new parameter, a ValueMaterializer. 2013-05-28 15:17:05 +00:00