llvm-6502/lib/Target/Hexagon
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
..
InstPrinter Hexagon: Avoid unused variable warnings in Release builds. 2013-07-02 17:24:00 +00:00
MCTargetDesc Remove the MachineMove class. 2013-05-13 01:16:13 +00:00
TargetInfo Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
CMakeLists.txt Target/*/CMakeLists.txt: Add the dependency to CommonTableGen explicitly for each corresponding CodeGen. 2013-08-06 06:38:37 +00:00
Hexagon.h Access the TargetLoweringInfo from the TargetMachine object instead of caching it. The TLI may change between functions. No functionality change. 2013-06-19 21:36:55 +00:00
Hexagon.td Hexagon: Fix switch statements in GetDotOldOp and IsNewifyStore. 2013-05-10 20:58:11 +00:00
HexagonAsmPrinter.cpp Hexagon: Move HexagonMCInst.h to MCTargetDesc/HexagonMCInst.h. 2013-02-20 16:13:27 +00:00
HexagonAsmPrinter.h Delete executive bit on ./lib/Target/Hexagon/HexagonAsmPrinter.h. 2012-12-29 15:23:06 +00:00
HexagonCallingConv.td Hexagon V5 FP Support. 2012-05-10 20:20:25 +00:00
HexagonCallingConvLower.cpp Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size. 2013-07-14 04:42:23 +00:00
HexagonCallingConvLower.h Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size. 2013-07-14 04:42:23 +00:00
HexagonCFGOptimizer.cpp Print IR from Hexagon MI passes with -print-before/after-all. 2013-05-06 21:58:00 +00:00
HexagonCopyToCombine.cpp Hexagon: Typo fix. 2013-05-28 19:01:45 +00:00
HexagonExpandPredSpillCode.cpp Print IR from Hexagon MI passes with -print-before/after-all. 2013-05-06 21:58:00 +00:00
HexagonFixupHwLoops.cpp Extend Hexagon hardware loop generation to handle various additional cases: 2013-02-11 21:37:55 +00:00
HexagonFrameLowering.cpp Remove dead calls to addFrameMove. 2013-05-16 15:08:37 +00:00
HexagonFrameLowering.h Move the eliminateCallFramePseudoInstr method from TargetRegisterInfo 2013-02-21 20:05:00 +00:00
HexagonHardwareLoops.cpp Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size. 2013-07-14 04:42:23 +00:00
HexagonInstrFormats.td Hexagon: Fix switch cases in HexagonVLIWPacketizer.cpp. 2013-05-10 20:27:34 +00:00
HexagonInstrFormatsV4.td Hexagon: Change insn class to support instruction encoding. 2013-02-14 19:57:17 +00:00
HexagonInstrInfo.cpp DebugInfo: remove target-specific Frame Index handling for DBG_VALUE MachineInstrs 2013-06-16 20:34:27 +00:00
HexagonInstrInfo.h DebugInfo: remove target-specific Frame Index handling for DBG_VALUE MachineInstrs 2013-06-16 20:34:27 +00:00
HexagonInstrInfo.td Hexagon: Pass to replace tranfer/copy instructions into combine instruction 2013-05-14 18:54:06 +00:00
HexagonInstrInfoV3.td Hexagon: Use multiclass for Jump instructions. 2013-05-01 21:37:34 +00:00
HexagonInstrInfoV4.td Hexagon: Add patterns to generate 'combine' instructions. 2013-05-14 17:16:38 +00:00
HexagonInstrInfoV5.td Hexagon: Fix switch cases in HexagonVLIWPacketizer.cpp. 2013-05-10 20:27:34 +00:00
HexagonIntrinsics.td Hexagon V5 intrinsics support. 2012-05-11 19:39:13 +00:00
HexagonIntrinsicsDerived.td Hexagon V5 intrinsics support. 2012-05-11 19:39:13 +00:00
HexagonIntrinsicsV3.td
HexagonIntrinsicsV4.td
HexagonIntrinsicsV5.td Remove tabs. 2012-07-19 00:25:04 +00:00
HexagonISelDAGToDAG.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:36:55 +00:00
HexagonISelLowering.cpp Refactor isInTailCallPosition handling 2013-08-06 09:12:35 +00:00
HexagonISelLowering.h Refactor isInTailCallPosition handling 2013-08-06 09:12:35 +00:00
HexagonMachineFunctionInfo.h Hexagon: Use multiclass for Jump instructions. 2013-05-01 21:37:34 +00:00
HexagonMachineScheduler.cpp Fix a memory leak in the hexagon scheduler. We call initialize here more 2013-07-27 10:48:45 +00:00
HexagonMachineScheduler.h Don't cache the instruction and register info from the TargetMachine, because 2013-06-07 06:19:56 +00:00
HexagonMCInstLower.cpp Hexagon: Move HexagonMCInst.h to MCTargetDesc/HexagonMCInst.h. 2013-02-20 16:13:27 +00:00
HexagonNewValueJump.cpp Suppress GCC compiler warnings in release builds about variables that are only 2013-05-13 07:50:47 +00:00
HexagonOperands.td Move all operand definitions into HexagonOperands.td 2012-12-04 05:00:31 +00:00
HexagonPeephole.cpp Print IR from Hexagon MI passes with -print-before/after-all. 2013-05-06 21:58:00 +00:00
HexagonRegisterInfo.cpp Don't cache the instruction and register info from the TargetMachine, because 2013-06-07 06:19:56 +00:00
HexagonRegisterInfo.h Don't cache the instruction and register info from the TargetMachine, because 2013-06-07 06:19:56 +00:00
HexagonRegisterInfo.td Make SubRegIndex size mandatory, following r183020. 2013-05-31 23:45:26 +00:00
HexagonRemoveSZExtArgs.cpp Print IR from Hexagon MI passes with -print-before/after-all. 2013-05-06 21:58:00 +00:00
HexagonSchedule.td Hexagon: Change insn class to support instruction encoding. 2013-02-14 19:57:17 +00:00
HexagonScheduleV4.td Hexagon: Change insn class to support instruction encoding. 2013-02-14 19:57:17 +00:00
HexagonSelectCCInfo.td Emacs-tag and some comment fix for all ARM, CellSPU, Hexagon, MBlaze, MSP430, PPC, PTX, Sparc, X86, XCore. 2012-02-18 12:03:15 +00:00
HexagonSelectionDAGInfo.cpp Track IR ordering of SelectionDAG nodes 2/4. 2013-05-25 02:42:55 +00:00
HexagonSelectionDAGInfo.h Track IR ordering of SelectionDAG nodes 2/4. 2013-05-25 02:42:55 +00:00
HexagonSplitConst32AndConst64.cpp Hexagon: Fix Small Data support to handle -G 0 correctly. 2013-05-07 19:53:00 +00:00
HexagonSplitTFRCondSets.cpp Print IR from Hexagon MI passes with -print-before/after-all. 2013-05-06 21:58:00 +00:00
HexagonSubtarget.cpp Hexagon: Add and enable memops setbit, clrbit, &,|,+,- for byte, short, and word. 2013-03-22 18:41:34 +00:00
HexagonSubtarget.h Sort includes for all of the .h files under the 'lib' tree. These were 2012-12-04 07:12:27 +00:00
HexagonTargetMachine.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:36:55 +00:00
HexagonTargetMachine.h Switch TargetTransformInfo from an immutable analysis pass that requires 2013-01-07 01:37:14 +00:00
HexagonTargetObjectFile.cpp Hexagon: Fix Small Data support to handle -G 0 correctly. 2013-05-07 19:53:00 +00:00
HexagonTargetObjectFile.h Hexagon: Fix Small Data support to handle -G 0 correctly. 2013-05-07 19:53:00 +00:00
HexagonVarargsCallingConvention.h Move TargetData to DataLayout. 2012-10-08 16:38:25 +00:00
HexagonVLIWPacketizer.cpp Hexagon: Make helper functions static. 2013-05-23 15:43:11 +00:00
LLVMBuild.txt Hexagon: enable assembler output through the MC layer. 2012-04-12 17:55:53 +00:00
Makefile Hexagon: enable assembler output through the MC layer. 2012-04-12 17:55:53 +00:00