llvm-6502/test/Transforms
Michael Gottesman 03fddb710e Teach TailRecursionElimination to handle certain cases of nocapture escaping allocas.
Without the changes introduced into this patch, if TRE saw any allocas at all,
TRE would not perform TRE *or* mark callsites with the tail marker.

Because TRE runs after mem2reg, this inadequacy is not a death sentence. But
given a callsite A without escaping alloca argument, A may not be able to have
the tail marker placed on it due to a separate callsite B having a write-back
parameter passed in via an argument with the nocapture attribute.

Assume that B is the only other callsite besides A and B only has nocapture
escaping alloca arguments (*NOTE* B may have other arguments that are not passed
allocas). In this case not marking A with the tail marker is unnecessarily
conservative since:

  1. By assumption A has no escaping alloca arguments itself so it can not
     access the caller's stack via its arguments.

  2. Since all of B's escaping alloca arguments are passed as parameters with
     the nocapture attribute, we know that B does not stash said escaping
     allocas in a manner that outlives B itself and thus could be accessed
     indirectly by A.

With the changes introduced by this patch:

  1. If we see any escaping allocas passed as a capturing argument, we do
     nothing and bail early.

  2. If we do not see any escaping allocas passed as captured arguments but we
     do see escaping allocas passed as nocapture arguments:

       i. We do not perform TRE to avoid PR962 since the code generator produces
          significantly worse code for the dynamic allocas that would be created
          by the TRE algorithm.

       ii. If we do not return twice, mark call sites without escaping allocas
           with the tail marker. *NOTE* This excludes functions with escaping
           nocapture allocas.

  3. If we do not see any escaping allocas at all (whether captured or not):

       i. If we do not have usage of setjmp, mark all callsites with the tail
          marker.

       ii. If there are no dynamic/variable sized allocas in the function,
           attempt to perform TRE on all callsites in the function.

Based off of a patch by Nick Lewycky.

rdar://14324281.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186057 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-11 04:40:01 +00:00
..
ADCE
ArgumentPromotion
BBVectorize
BlockPlacement
BranchFolding
CodeExtractor
CodeGenPrepare
ConstantMerge
ConstProp
CorrelatedValuePropagation
DeadArgElim DeadArgumentElimination: keep return value on functions that have a live argument with the 'returned' attribute (rather than generate invalid IR); however, if both can be eliminated, both will be 2013-06-30 20:26:21 +00:00
DeadStoreElimination
DebugIR Adding tests for DebugIR pass 2013-06-28 20:37:20 +00:00
EarlyCSE
FunctionAttrs Extend 'readonly' and 'readnone' to work on function arguments as well as 2013-07-06 00:29:58 +00:00
GCOVProfiling
GlobalDCE
GlobalOpt Always remove an alias when we rename the target. 2013-06-12 16:45:47 +00:00
GVN Eliminate trivial redundant loads across nocapture+readonly calls to uncaptured 2013-07-07 10:15:16 +00:00
IndVarSimplify IndVarSimplify: check if loop invariant expansion can trap 2013-06-04 17:51:58 +00:00
Inline
InstCombine InstSimplify: X >> X -> 0 2013-07-09 22:01:22 +00:00
InstSimplify InstSimplify: X >> X -> 0 2013-07-09 22:01:22 +00:00
Internalize
IPConstantProp
JumpThreading
LCSSA
LICM
LoopDeletion
LoopIdiom
LoopRotate Rotate multi-exit loops even if the latch was simplified. 2013-05-06 17:58:18 +00:00
LoopSimplify
LoopStrengthReduce LSR: Fix the parameters used to compute the scaling factor cost. 2013-06-19 19:59:41 +00:00
LoopUnroll Prevent loop-unroll from making assumptions about undefined behavior. 2013-05-31 23:34:46 +00:00
LoopUnswitch
LoopVectorize LoopVectorize: Math functions only read rounding mode 2013-07-01 00:54:44 +00:00
LowerAtomic
LowerExpectIntrinsic
LowerInvoke
LowerSwitch
Mem2Reg
MemCpyOpt Fix a potential bug in r183584. 2013-06-08 04:56:05 +00:00
MergeFunc
MetaRenamer
ObjCARC [objc-arc] Committed test for r185770 as per dblaikie's suggestion. 2013-07-08 02:13:47 +00:00
PhaseOrdering
PruneEH
Reassociate
Reg2Mem
ScalarRepl Fix SROA to avoid unnecessary scalar conversions for 1-element vectors. 2013-06-25 19:09:50 +00:00
SCCP
SimplifyCFG SimplifyCFG: Teach switch generation some patterns that instcombine forms. 2013-07-04 14:22:02 +00:00
Sink
SLPVectorizer Fix PR16571, which is a bug in the code that checks that all of the types in the bundle are uniform. 2013-07-09 21:38:08 +00:00
SROA
StripSymbols
StructurizeCFG Move StructurizeCFG out of R600 to generic Transforms. 2013-06-19 20:18:24 +00:00
TailCallElim Teach TailRecursionElimination to handle certain cases of nocapture escaping allocas. 2013-07-11 04:40:01 +00:00
TailDup