llvm-6502/include/llvm
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
..
ADT add a simple back() method to StringRef. 2009-08-10 00:44:02 +00:00
Analysis Keep track of DIType. 2009-08-10 22:09:58 +00:00
Assembly 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
Bitcode 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
CodeGen Rebuild RegScavenger::DistanceMap each time it is needed. 2009-08-11 06:25:12 +00:00
CompilerDriver
Config
Debugger 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
ExecutionEngine To catch bugs like the one fixed in 2009-08-07 19:54:29 +00:00
MC split MachO section handling stuff out to its out .h/.cpp file. 2009-08-10 18:15:01 +00:00
Support Convert comments to C90-style so llvm-c can import DataTypes.h. 2009-08-10 19:44:53 +00:00
System
Target SjLj based exception handling unwinding support. This patch is nasty, brutish 2009-08-11 00:09:57 +00:00
Transforms 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
AbstractTypeUser.h
Argument.h
Attributes.h
AutoUpgrade.h
BasicBlock.h 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
CallGraphSCCPass.h
CallingConv.h
CMakeLists.txt
Constant.h 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
Constants.h Rename ConvertType to ConvertConstant to avoid a name conflict on llvm-gcc. 2009-08-10 20:56:46 +00:00
DerivedTypes.h Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs. 2009-08-05 23:16:16 +00:00
Function.h 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
GlobalAlias.h
GlobalValue.h
GlobalVariable.h 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
InlineAsm.h
InstrTypes.h 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
Instruction.def
Instruction.h 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
Instructions.h 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
IntrinsicInst.h
Intrinsics.h Add a new overloaded EVT::vAny type for use in TableGen to allow intrinsic 2009-08-11 01:14:02 +00:00
Intrinsics.td Add a new overloaded EVT::vAny type for use in TableGen to allow intrinsic 2009-08-11 01:14:02 +00:00
IntrinsicsAlpha.td
IntrinsicsARM.td Use vAny type to get rid of Neon intrinsics that differed only in whether 2009-08-11 05:39:44 +00:00
IntrinsicsBlackfin.td
IntrinsicsCellSPU.td
IntrinsicsPowerPC.td
IntrinsicsX86.td Fix some cut and paste-os. 2009-08-08 20:09:33 +00:00
IntrinsicsXCore.td
LinkAllPasses.h Add a basic static ProfileInfo provider (ProfileEstimatorPass). 2009-08-08 18:44:18 +00:00
LinkAllVMCore.h
Linker.h 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
LLVMContext.h Remove unused forward decls. 2009-08-05 11:33:27 +00:00
Metadata.h We are not using FoldingSet for metadata uniquing anymore. 2009-08-10 18:59:07 +00:00
Module.h Align comments. 2009-08-10 22:20:38 +00:00
ModuleProvider.h
OperandTraits.h
Operator.h
Pass.h
PassAnalysisSupport.h
PassManager.h
PassManagers.h Fix a bunch of namespace pollution. 2009-08-07 01:32:21 +00:00
PassSupport.h
SymbolTableListTraits.h
Type.h
TypeSymbolTable.h Don't search the entire type table just to delete a type by name. 2009-08-06 06:04:35 +00:00
Use.h
User.h
Value.h revert r78048, it isn't worth using assertingvh here. 2009-08-04 23:07:12 +00:00
ValueSymbolTable.h revert r78048, it isn't worth using assertingvh here. 2009-08-04 23:07:12 +00:00