Go to file
Tim Northover a4415854db 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.

llvm-svn: 187787
2013-08-06 09:12:35 +00:00
clang Update status of support for variable templates on website. 2013-08-06 07:37:09 +00:00
clang-tools-extra Add test for header guard work-around. 2013-08-06 00:17:40 +00:00
compiler-rt Lint fixes 2013-08-05 13:20:39 +00:00
debuginfo-tests Now that we get non-trivial value parameters locations correct, un-XFAIL these tests. 2013-06-19 22:07:11 +00:00
libclc Add missing integer min/max definitions 2013-07-26 13:02:02 +00:00
libcxx Implement NULL iterators for <list> re: N3644 2013-08-05 21:23:28 +00:00
libcxxabi tip-of-trunk clang has corrected some access checks for special members in a virtual inheritance hierarchy. Change a few private inheritances to protected. This change will not impact what the test was testing. This fixes http://llvm.org/bugs/show_bug.cgi?id=16753. 2013-07-30 19:00:45 +00:00
lld Remove unused using's. 2013-08-02 23:22:46 +00:00
lldb Additional fixes/xfails for icc tests 2013-08-05 17:12:35 +00:00
llvm Refactor isInTailCallPosition handling 2013-08-06 09:12:35 +00:00
polly ScopInfo: add a testcase that share parameters within nested start. 2013-08-06 04:36:45 +00:00