llvm-6502/test
Jakob Stoklund Olesen 8c54a62061 Rebuild RegScavenger::DistanceMap each time it is needed.
The register scavenger maintains a DistanceMap that maps MI pointers to their
distance from the top of the current MBB. The DistanceMap is built
incrementally in forward() and in bulk in findFirstUse(). It is used by
scavengeRegister() to determine which candidate register has the longest
unused interval.

Unfortunately the DistanceMap contents can become outdated. The first time
scavengeRegister() is called, the DistanceMap is filled to cover the MBB. If
then instructions are inserted in the MBB (as they always are following
scavengeRegister()), the recorded distances are too short. This causes bad
behaviour in the included test case where a register use /after/ the current
position is ignored because findFirstUse() thinks is is /before/ the current
position. A "using an undefined register" assertion follows promptly.

The fix is to build a fresh DistanceMap at the top of scavengeRegister(), and
discard it after use. This means that DistanceMap is no longer needed as a
RegScavenger member variable, and forward() doesn't need to update it.

The fix then discloses issue number two in the same test case: The candidate
search in scavengeRegister() finds a CSR that has been saved in the prologue,
but is currently unused. It would be both inefficient and wrong to spill such
a register in the emergency spill slot. In the present case, the emergency
slot restore is placed immediately before the normal epilogue restore, leading
to a "Redefining a live register" assertion.

Fix number two: When scavengerRegister() stumbles upon an unused register that
is overwritten later in the MBB, return that register early. It is important
to verify that the register is defined later in the MBB, otherwise it might be
an unspilled CSR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78650 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-11 06:25:12 +00:00
..
Analysis Add another Strong-SIV testcase. 2009-08-08 00:21:49 +00:00
Archive
Assembler
Bindings/Ocaml
Bitcode Use separate ValueList for metadata. 2009-08-04 06:00:18 +00:00
BugPoint remove nondeterminstic test. 2009-08-08 22:56:37 +00:00
CodeGen Rebuild RegScavenger::DistanceMap each time it is needed. 2009-08-11 06:25:12 +00:00
DebugInfo
ExecutionEngine
Feature Do not use abbrev while writing NamedMDNode name. 2009-07-30 23:06:35 +00:00
FrontendAda
FrontendC Testcase for llvm-gcc 78324 (although in normal 2009-08-06 17:28:23 +00:00
FrontendC++ XFAIL 2006-11-06-StackTrace.cpp on powerpc-apple-darwin9 until someone feels 2009-08-07 20:50:58 +00:00
FrontendFortran
FrontendObjC Adjust test for llvm-gcc checkin 78249. 2009-08-05 22:18:47 +00:00
FrontendObjC++
Integer
lib
Linker
LLVMC
MC/AsmParser llvm-mc/X86: Parse '*' correctly (in the way the matcher expects). 2009-08-11 05:00:25 +00:00
Other
Scripts
TableGen
Transforms Add -disable-output. Thanks Bill! 2009-08-03 22:24:22 +00:00
Verifier
Makefile Fix ocaml "make check" tests, that wasn't finding the proper c++ compiler. 2009-08-10 19:45:05 +00:00
Makefile.tests
TestRunner.sh