llvm-6502/include/llvm
Tim Northover d113448c1d Refactor isInTailCallPosition handling
This change came about primarily because of two issues in the existing code.
Niether of:

define i64 @test1(i64 %val) {
  %in = trunc i64 %val to i32
  tail call i32 @ret32(i32 returned %in)
  ret i64 %val
}

define i64 @test2(i64 %val) {
  tail call i32 @ret32(i32 returned undef)
  ret i32 42
}

should be tail calls, and the function sameNoopInput is responsible. The main
problem is that it is completely symmetric in the "tail call" and "ret" value,
but in reality different things are allowed on each side.

For these cases:
1. Any truncation should lead to a larger value being generated by "tail call"
   than needed by "ret".
2. Undef should only be allowed as a source for ret, not as a result of the
   call.

Along the way I noticed that a mismatch between what this function treats as a
valid truncation and what the backends see can lead to invalid calls as well
(see x86-32 test case).

This patch refactors the code so that instead of being based primarily on
values which it recurses into when necessary, it starts by inspecting the type
and considers each fundamental slot that the backend will see in turn. For
example, given a pathological function that returned {{}, {{}, i32, {}}, i32}
we would consider each "real" i32 in turn, and ask if it passes through
unchanged. This is much closer to what the backend sees as a result of
ComputeValueVTs.

Aside from the bug fixes, this eliminates the recursion that's going on and, I
believe, makes the bulk of the code significantly easier to understand. The
trade-off is the nasty iterators needed to find the real types inside a
returned value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187787 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-06 09:12:35 +00:00
..
ADT Fix -Wdocumentation warnings. 2013-07-28 23:43:28 +00:00
Analysis Fix missing -*- C++ -*-s 2013-08-06 00:16:21 +00:00
Assembly
Bitcode Make .bc en/decoding of AttrKind stable 2013-07-26 04:16:55 +00:00
CodeGen Put an llvm_unreachable at the end of getSplatIndex as its loop should never find all undef elements. 2013-08-06 05:41:22 +00:00
Config Link with -rdynamic instead of -Wl,-export-dynamic. 2013-08-02 22:51:06 +00:00
DebugInfo
ExecutionEngine
IR AVX-512 set: added mask operations, lowering BUILD_VECTOR for i1 vector types. 2013-08-05 08:52:21 +00:00
IRReader
MC Fixed the Intel-syntax X86 disassembler to respect the (existing) option for hexadecimal immediates, to match AT&T syntax. This also brings a new option for C-vs-MASM-style hex. 2013-08-01 21:18:16 +00:00
Object Add support for the 's' operation to llvm-ar. 2013-07-29 12:40:31 +00:00
Option Option parsing: add support for alias arguments. 2013-07-31 22:44:41 +00:00
Support Introduce Regex::isLiteralERE function. 2013-08-05 17:47:59 +00:00
TableGen
Target Refactor isInTailCallPosition handling 2013-08-06 09:12:35 +00:00
Transforms Factor FlattenCFG out from SimplifyCFG 2013-08-06 02:43:45 +00:00
AutoUpgrade.h Remove trailing whitespace, fix file path in comment 2013-07-20 17:46:00 +00:00
CMakeLists.txt
DebugInfo.h Temporarily revert "Debug Info Finder|Verifier: handle DbgLoc attached to 2013-08-02 00:49:44 +00:00
DIBuilder.h
GVMaterializer.h
InitializePasses.h Factor FlattenCFG out from SimplifyCFG 2013-08-06 02:43:45 +00:00
InstVisitor.h
LinkAllIR.h
LinkAllPasses.h
Linker.h
Pass.h
PassAnalysisSupport.h
PassManager.h
PassManagers.h
PassRegistry.h
PassSupport.h