llvm-6502/lib
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 Keep track of DIType. 2009-08-10 22:09:58 +00:00
Archive Factor some of the constants+context related code out into a separate header, to make LLVMContextImpl.h 2009-08-04 22:41:48 +00:00
AsmParser Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs. 2009-08-05 23:16:16 +00:00
Bitcode Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs. 2009-08-05 23:16:16 +00:00
CodeGen Rebuild RegScavenger::DistanceMap each time it is needed. 2009-08-11 06:25:12 +00:00
CompilerDriver Delete the temp dir even when '--temp-dir' is specified. 2009-07-11 19:27:07 +00:00
Debugger Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs. 2009-08-05 23:16:16 +00:00
ExecutionEngine SjLj based exception handling unwinding support. This patch is nasty, brutish 2009-08-11 00:09:57 +00:00
Linker Move a few more APIs back to 2.5 forms. The only remaining ones left to change back are 2009-07-31 20:28:14 +00:00
MC split MachO section handling stuff out to its out .h/.cpp file. 2009-08-10 18:15:01 +00:00
Support Add support for a user supplied pointer argument to llvm_install_error_handler. 2009-08-10 03:36:26 +00:00
System Fix a bunch of namespace pollution. 2009-08-07 01:32:21 +00:00
Target Use vAny type to get rid of Neon intrinsics that differed only in whether 2009-08-11 05:39:44 +00:00
Transforms Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type. 2009-08-10 22:56:29 +00:00
VMCore Add a new overloaded EVT::vAny type for use in TableGen to allow intrinsic 2009-08-11 01:14:02 +00:00
Makefile LLVMC doesn't need ENABLE_PIC to build now. 2009-07-04 03:54:54 +00:00