llvm-6502/lib
Jakob Stoklund Olesen ded2e3b0d0 LowerSubregsInstructionPass::LowerExtract should not extend the live range of registers.
When LowerExtract eliminates an EXTRACT_SUBREG with a kill flag, it moves the
kill flag to the place where the sub-register is killed. This can accidentally
overlap with the use of a sibling sub-register, and we have trouble.

In the test case we have this code:

Live Ins: %R0 %R1 %R2
	%R2L<def> = EXTRACT_SUBREG %R2<kill>, 1
	%R2H<def> = LOAD16fi <fi#-1>, 0, Mem:LD(2,4) [FixedStack-1 + 0]
	%R1L<def> = EXTRACT_SUBREG %R1<kill>, 1
	%R0L<def> = EXTRACT_SUBREG %R0<kill>, 1
	%R0H<def> = ADD16 %R2H<kill>, %R2L<kill>, %AZ<imp-def>, %AN<imp-def>, %AC0<imp-def>, %V<imp-def>, %VS<imp-def>

subreg: CONVERTING: %R2L<def> = EXTRACT_SUBREG %R2<kill>, 1
subreg: eliminated!
subreg: killed here: %R0H<def> = ADD16 %R2H, %R2L, %R2<imp-use,kill>, %AZ<imp-def>, %AN<imp-def>, %AC0<imp-def>, %V<imp-def>, %VS<imp-def>

The kill flag on %R2 is moved to the last instruction, and the live range overlaps with the definition of %R2H:

*** Bad machine code: Redefining a live physical register ***
- function:    f
- basic block:  0x18358c0 (#0)
- instruction: %R2H<def> = LOAD16fi <fi#-1>, 0, Mem:LD(2,4) [FixedStack-1 + 0]
Register R2H was defined but already live.

The fix is to replace EXTRACT_SUBREG with IMPLICIT_DEF instead of eliminating
it completely:

subreg: CONVERTING: %R2L<def> = EXTRACT_SUBREG %R2<kill>, 1
subreg: replace by: %R2L<def> = IMPLICIT_DEF %R2<kill>

Note that these IMPLICIT_DEF instructions survive to the asm output. It is
necessary to fix the stack-color-with-reg test case because of that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78093 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-04 20:01:11 +00:00
..
Analysis Restrict LDA to affine subscripts. 2009-08-03 01:03:48 +00:00
Archive Fix some non-sensical code. 2009-07-13 05:29:34 +00:00
AsmParser Move the metadata constructors back to 2.5 syntax. 2009-07-31 21:35:40 +00:00
Bitcode Use separate ValueList for metadata. 2009-08-04 06:00:18 +00:00
CodeGen LowerSubregsInstructionPass::LowerExtract should not extend the live range of registers. 2009-08-04 20:01:11 +00:00
CompilerDriver Delete the temp dir even when '--temp-dir' is specified. 2009-07-11 19:27:07 +00:00
Debugger Make the use of const with respect to LLVMContext sane. Hopefully this is the last time, for the 2009-07-01 23:13:44 +00:00
ExecutionEngine No really, it's unused. 2009-08-04 04:08:40 +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 Change SectionKind to be a property that is true of a *section*, it 2009-08-01 21:11:14 +00:00
Support Remove now unused arguments from TargetRegistry::lookupTarget. 2009-08-03 04:20:57 +00:00
System Fix a race condition in getting the process exit code on Win32. 2009-08-03 05:02:46 +00:00
Target Most flags are reserved registers on Blackfin. 2009-08-04 19:16:55 +00:00
Transforms Add a new Constant::getIntegerValue helper function, and convert a 2009-08-03 22:07:33 +00:00
VMCore switch ValueMap to using AssertingVH. This is an old patch I had laying 2009-08-04 04:31:02 +00:00
Makefile LLVMC doesn't need ENABLE_PIC to build now. 2009-07-04 03:54:54 +00:00