llvm-6502/include/llvm/CodeGen
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
..
AsmPrinter.h Add support for printing loop structure information in asm comments. 2009-08-10 16:38:07 +00:00
BinaryObject.h ELF improvements: 2009-08-08 17:29:04 +00:00
BreakCriticalMachineEdge.h Tidy up #includes, deleting a bunch of unnecessary #includes. 2009-01-05 17:59:02 +00:00
CallingConvLower.h Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type. 2009-08-10 22:56:29 +00:00
DAGISelHeader.h Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type. 2009-08-10 22:56:29 +00:00
Dump.h Re-apply LiveInterval index dumping patch, with fixes suggested by Bill 2009-08-03 21:55:09 +00:00
DwarfWriter.h Revert 71165. It did more than just revert 71158 and it introduced 2009-05-07 19:46:24 +00:00
ELFRelocation.h Tidy up #includes, deleting a bunch of unnecessary #includes. 2009-01-05 17:59:02 +00:00
FastISel.h Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type. 2009-08-10 22:56:29 +00:00
FileWriters.h Add the Object Code Emitter class. Original patch by Aaron Gray, I did some 2009-07-06 05:09:34 +00:00
GCMetadata.h Rename some GC classes so that their roll will hopefully be clearer. 2008-08-17 18:44:35 +00:00
GCMetadataPrinter.h Tidy up #includes, deleting a bunch of unnecessary #includes. 2009-01-05 17:59:02 +00:00
GCs.h Rename some GC classes so that their roll will hopefully be clearer. 2008-08-17 18:44:35 +00:00
GCStrategy.h Tidy up #includes, deleting a bunch of unnecessary #includes. 2009-01-05 17:59:02 +00:00
IntrinsicLowering.h Get rid of these cache variables, which are a holdover from the days when 2009-06-26 20:33:47 +00:00
JITCodeEmitter.h 1) Proper emit displacements for x86, using absolute relocations where necessary 2009-08-05 00:11:21 +00:00
LatencyPriorityQueue.h Fix some register-alias-related bugs in the post-RA scheduler liveness 2008-12-16 03:25:46 +00:00
LazyLiveness.h Reapply r77654 with a fix: MachineFunctionPass's getAnalysisUsage 2009-07-31 18:16:33 +00:00
LinkAllAsmWriterComponents.h Tidy up #includes, deleting a bunch of unnecessary #includes. 2009-01-05 17:59:02 +00:00
LinkAllCodegenComponents.h Removed the BigBlock register allocator. 2009-07-30 23:18:43 +00:00
LiveInterval.h Modified VNInfo. The "copy" member is now a union which holds the copy for a register interval, or the defining register for a stack interval. Access is via getCopy/setCopy and getReg/setReg. 2009-08-10 23:43:28 +00:00
LiveIntervalAnalysis.h Re-apply LiveInterval index dumping patch, with fixes suggested by Bill 2009-08-03 21:55:09 +00:00
LiveStackAnalysis.h Update to in-place spilling framework. Includes live interval scaling and trivial rewriter. 2009-06-02 16:53:25 +00:00
LiveVariables.h LiveVariables::VarInfo contains an AliveBlocks BitVector, which has as many 2009-05-26 18:27:15 +00:00
MachineBasicBlock.h Re-apply LiveInterval index dumping patch, with fixes suggested by Bill 2009-08-03 21:55:09 +00:00
MachineCodeEmitter.h 1) Proper emit displacements for x86, using absolute relocations where necessary 2009-08-05 00:11:21 +00:00
MachineCodeInfo.h Add missing file. 2009-05-18 21:08:45 +00:00
MachineConstantPool.h make Constant::getRelocationInfo return an enum, as suggested by Duncan. 2009-07-24 03:27:21 +00:00
MachineDominators.h Tidy up #includes, deleting a bunch of unnecessary #includes. 2009-01-05 17:59:02 +00:00
MachineFrameInfo.h Fix some comments referring to std::cerr. 2009-08-03 01:02:24 +00:00
MachineFunction.h SjLj based exception handling unwinding support. This patch is nasty, brutish 2009-08-11 00:09:57 +00:00
MachineFunctionAnalysis.h Give MachineFunctionAnalysis a destructor so it can verify that 2009-08-01 04:19:43 +00:00
MachineFunctionPass.h Reapply r77654 with a fix: MachineFunctionPass's getAnalysisUsage 2009-07-31 18:16:33 +00:00
MachineInstr.h stub out some hacky code for wiring up the new asmprinter interfaces 2009-06-19 23:59:57 +00:00
MachineInstrBuilder.h add default ctor. 2009-07-09 06:44:01 +00:00
MachineJumpTableInfo.h Fix some comments referring to std::cerr. 2009-08-03 01:02:24 +00:00
MachineLocation.h Switch the MachineOperand accessors back to the short names like 2008-10-03 15:45:36 +00:00
MachineLoopInfo.h Move isLCSSAForm, isLoopInvariant, getCanonicalInductionVariable, 2009-07-13 22:02:44 +00:00
MachineMemOperand.h Change the FoldingSetNodeID usage for objects which carry 2008-08-20 15:58:01 +00:00
MachineModuleInfo.h implement a new magic global "llvm.compiler.used" which is like llvm.used, but 2009-07-20 06:14:25 +00:00
MachineOperand.h Add isMetadata() to check metadata operand. 2009-07-06 23:46:02 +00:00
MachinePassRegistry.h Don't attribute in file headers anymore. See llvmdev for the 2007-12-29 19:59:42 +00:00
MachineRegisterInfo.h Part 1. 2009-06-15 08:28:29 +00:00
MachineRelocation.h Fix MachineCodeEmitter to use uintptr_t instead of intptr_t. This avoids some overflow issues. Patch by Thomas Jablin. 2008-12-10 02:32:19 +00:00
MachORelocation.h Don't attribute in file headers anymore. See llvmdev for the 2007-12-29 19:59:42 +00:00
ObjectCodeEmitter.h 1) Proper emit displacements for x86, using absolute relocations where necessary 2009-08-05 00:11:21 +00:00
Passes.h Fix some comments referring to std::cerr. 2009-08-03 01:02:24 +00:00
PseudoSourceValue.h Have PseudoSourceValue override Value::dump, so that it works 2008-12-03 21:37:21 +00:00
RegAllocRegistry.h Reformat. 2009-07-08 21:57:46 +00:00
RegisterCoalescer.h Delete spurious semicolons. 2009-07-31 18:59:29 +00:00
RegisterScavenging.h Rebuild RegScavenger::DistanceMap each time it is needed. 2009-08-11 06:25:12 +00:00
RuntimeLibcalls.h Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type. 2009-08-10 22:56:29 +00:00
ScheduleDAG.h Add a new bit to SUnit to record whether a node has implicit physreg 2009-03-23 16:10:52 +00:00
ScheduleHazardRecognizer.h Post RA scheduler changes. Introduce a hazard recognizer that uses the target schedule information to accurately model the pipeline. Update the scheduler to correctly handle multi-issue targets. 2009-08-10 15:55:25 +00:00
SchedulerRegistry.h Instead of passing in an unsigned value for the optimization level, use an enum, 2009-04-29 23:29:43 +00:00
SelectionDAG.h Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type. 2009-08-10 22:56:29 +00:00
SelectionDAGISel.h Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type. 2009-08-10 22:56:29 +00:00
SelectionDAGNodes.h SjLj based exception handling unwinding support. This patch is nasty, brutish 2009-08-11 00:09:57 +00:00
ValueTypes.h Add a new overloaded EVT::vAny type for use in TableGen to allow intrinsic 2009-08-11 01:14:02 +00:00
ValueTypes.td Add a new overloaded EVT::vAny type for use in TableGen to allow intrinsic 2009-08-11 01:14:02 +00:00