Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit f908e37

Browse files
author
Hal Finkel
committed
Revert "r226071 - [RegisterCoalescer] Remove copies to reserved registers"
Reverting this while I investigate some bad behavior this is causing. As a possibly-related issue, adding -verify-machineinstrs to one of the test cases now fails because of this change: llc test/CodeGen/X86/2009-02-12-DebugInfoVLA.ll -march=x86-64 -o - -verify-machineinstrs *** Bad machine code: No instruction at def index *** - function: foo - basic block: BB#0 return (0x10007e21f10) [0B;736B) - liverange: [128r,128d:9)[160r,160d:8)[176r,176d:7)[336r,336d:6)[464r,464d:5)[480r,480d:4)[624r,624d:3)[752r,752d:2)[768r,768d:1)[78 4r,784d:0) 0@784r 1@768r 2@752r 3@624r 4@480r 5@464r 6@336r 7@176r 8@160r 9@128r - register: %DS Valno #3 is defined at 624r *** Bad machine code: Live segment doesn't end at a valid instruction *** - function: foo - basic block: BB#0 return (0x10007e21f10) [0B;736B) - liverange: [128r,128d:9)[160r,160d:8)[176r,176d:7)[336r,336d:6)[464r,464d:5)[480r,480d:4)[624r,624d:3)[752r,752d:2)[768r,768d:1)[78 4r,784d:0) 0@784r 1@768r 2@752r 3@624r 4@480r 5@464r 6@336r 7@176r 8@160r 9@128r - register: %DS [624r,624d:3) LLVM ERROR: Found 2 machine code errors. where 624r corresponds exactly to the interval combining change: 624B %RSP<def> = COPY %vreg16; GR64:%vreg16 Considering merging %vreg16 with %RSP RHS = %vreg16 [608r,624r:0) 0@608r updated: 608B %RSP<def> = MOV64rm <fi#3>, 1, %noreg, 0, %noreg; mem:LD8[%saved_stack.1] Success: %vreg16 -> %RSP Result = %RSP git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226086 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent dd1b7ed commit f908e37

File tree

3 files changed

+7
-39
lines changed

3 files changed

+7
-39
lines changed

lib/CodeGen/RegisterCoalescer.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,10 +1209,10 @@ bool RegisterCoalescer::canJoinPhys(const CoalescerPair &CP) {
12091209
}
12101210

12111211
LiveInterval &JoinVInt = LIS->getInterval(CP.getSrcReg());
1212-
if (JoinVInt.containsOneValue())
1212+
if (CP.isFlipped() && JoinVInt.containsOneValue())
12131213
return true;
12141214

1215-
DEBUG(dbgs() << "\tCannot join complex intervals into reserved register.\n");
1215+
DEBUG(dbgs() << "\tCannot join defs into reserved register.\n");
12161216
return false;
12171217
}
12181218

@@ -1431,7 +1431,8 @@ bool RegisterCoalescer::joinReservedPhysReg(CoalescerPair &CP) {
14311431
LiveInterval &RHS = LIS->getInterval(CP.getSrcReg());
14321432
DEBUG(dbgs() << "\t\tRHS = " << RHS << '\n');
14331433

1434-
assert(RHS.containsOneValue() && "Invalid join with reserved register");
1434+
assert(CP.isFlipped() && RHS.containsOneValue() &&
1435+
"Invalid join with reserved register");
14351436

14361437
// Optimization for reserved registers like ESP. We can only merge with a
14371438
// reserved physreg if RHS has a single value that is a copy of CP.DstReg().
@@ -1452,18 +1453,7 @@ bool RegisterCoalescer::joinReservedPhysReg(CoalescerPair &CP) {
14521453
// defs are there.
14531454

14541455
// Delete the identity copy.
1455-
MachineInstr *CopyMI;
1456-
if (CP.isFlipped()) {
1457-
CopyMI = MRI->getVRegDef(RHS.reg);
1458-
} else {
1459-
if (!MRI->hasOneNonDBGUse(RHS.reg)) {
1460-
DEBUG(dbgs() << "\t\tMultiple vreg uses\n");
1461-
return false;
1462-
}
1463-
1464-
CopyMI = &*MRI->use_instr_nodbg_begin(RHS.reg);
1465-
}
1466-
1456+
MachineInstr *CopyMI = MRI->getVRegDef(RHS.reg);
14671457
LIS->RemoveMachineInstrFromMaps(CopyMI);
14681458
CopyMI->eraseFromParent();
14691459

test/CodeGen/ARM/dyn-stackalloc.ll

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -mcpu=generic -mtriple=arm-eabi < %s | FileCheck %s
1+
; RUN: llc -mtriple=arm-eabi %s -o /dev/null
22

33
%struct.comment = type { i8**, i32*, i32, i8* }
44
%struct.info = type { i32, i32, i32, i32, i32, i32, i32, i8* }
@@ -7,18 +7,6 @@
77
@str215 = external global [2 x i8]
88

99
define void @t1(%struct.state* %v) {
10-
11-
; Make sure we generate:
12-
; sub sp, sp, r1
13-
; instead of:
14-
; sub r1, sp, r1
15-
; mov sp, r1
16-
17-
; CHECK-LABEL: @t1
18-
; CHECK: bic [[REG1:r[0-9]+]],
19-
; CHECK-NOT: sub r{{[0-9]+}}, sp, [[REG1]]
20-
; CHECK: sub sp, sp, [[REG1]]
21-
2210
%tmp6 = load i32* null
2311
%tmp8 = alloca float, i32 %tmp6
2412
store i32 1, i32* null

test/CodeGen/X86/2009-02-12-DebugInfoVLA.ll

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
; RUN: llc < %s
2-
; RUN: llc < %s -march=x86-64 | FileCheck %s
2+
; RUN: llc < %s -march=x86-64
33
; PR3538
44
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
55
target triple = "i386-apple-darwin9"
66
define signext i8 @foo(i8* %s1) nounwind ssp {
7-
8-
; Make sure we generate:
9-
; movq -40(%rbp), %rsp
10-
; Instead of:
11-
; movq -40(%rbp), %rax
12-
; movq %rax, %rsp
13-
14-
; CHECK-LABEL: @foo
15-
; CHECK: movq -40(%rbp), %rsp
16-
177
entry:
188
%s1_addr = alloca i8* ; <i8**> [#uses=2]
199
%retval = alloca i32 ; <i32*> [#uses=2]

0 commit comments

Comments
 (0)