From ded2e3b0d02998b3bb99b5089d05fca1e0097868 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Tue, 4 Aug 2009 20:01:11 +0000 Subject: 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 = EXTRACT_SUBREG %R2, 1 %R2H = LOAD16fi , 0, Mem:LD(2,4) [FixedStack-1 + 0] %R1L = EXTRACT_SUBREG %R1, 1 %R0L = EXTRACT_SUBREG %R0, 1 %R0H = ADD16 %R2H, %R2L, %AZ, %AN, %AC0, %V, %VS subreg: CONVERTING: %R2L = EXTRACT_SUBREG %R2, 1 subreg: eliminated! subreg: killed here: %R0H = ADD16 %R2H, %R2L, %R2, %AZ, %AN, %AC0, %V, %VS 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 = LOAD16fi , 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 = EXTRACT_SUBREG %R2, 1 subreg: replace by: %R2L = IMPLICIT_DEF %R2 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 --- test/CodeGen/X86/stack-color-with-reg.ll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/CodeGen/X86/stack-color-with-reg.ll') diff --git a/test/CodeGen/X86/stack-color-with-reg.ll b/test/CodeGen/X86/stack-color-with-reg.ll index 4e277c7..832886b 100644 --- a/test/CodeGen/X86/stack-color-with-reg.ll +++ b/test/CodeGen/X86/stack-color-with-reg.ll @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t ; RUN: grep stackcoloring %t | grep "loads eliminated" ; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 5 -; RUN: grep asm-printer %t | grep 175 +; RUN: grep asm-printer %t | grep 180 type { [62 x %struct.Bitvec*] } ; type %0 type { i8* } ; type %1 -- cgit v1.1