llvm-6502/test
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
..
Analysis Add the nearbyint -> FNEARBYINT mapping to BasicTargetTransformInfo 2013-07-08 03:24:07 +00:00
Assembler Fix test: It was missing run lines and llvm-dis has no -disable-verify option. 2013-07-03 16:27:55 +00:00
Bindings/Ocaml Fix %t typo in Ocaml bindings test. 2013-07-10 18:55:06 +00:00
Bitcode
BugPoint
CodeGen Move r186044 tests into CodeGen/X86 2013-07-11 01:55:55 +00:00
DebugInfo Add a comment. 2013-07-10 21:08:02 +00:00
ExecutionEngine
Feature
FileCheck Prefix failing commands with not to make clear they are expected to fail. 2013-07-03 16:41:29 +00:00
Instrumentation [msan] Unpoison stack allocations and undef values in blacklisted functions. 2013-07-03 14:39:14 +00:00
Integer
JitListener
Linker
MC Put ELF COMDAT relocations into the relevant COMDAT group. 2013-07-10 20:58:17 +00:00
Object Remove this test for now. 2013-07-10 22:15:29 +00:00
Other Move r186044 tests into CodeGen/X86 2013-07-11 01:55:55 +00:00
TableGen
tools Revert: Fix wrong code offset for unwind code SET_FPREG. 2013-07-08 04:48:34 +00:00
Transforms Teach TailRecursionElimination to handle certain cases of nocapture escaping allocas. 2013-07-11 04:40:01 +00:00
Unit
Verifier
YAMLParser
CMakeLists.txt llvm/test/CMakeLists.txt: Add llvm-cov in "check-clang". 2013-07-08 08:44:36 +00:00
lit.cfg
lit.site.cfg.in
Makefile
Makefile.tests
TestRunner.sh