forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RegAlloc] Make tryInstructionSplit less aggressive.
The greedy register allocator tries to split a live-range around each instruction where it is used or defined to relax the constraints on the entire live-range (this is a last chance split before falling back to spill). The goal is to have a big live-range that is unconstrained (i.e., that can use the largest legal register class) and several small local live-range that carry the constraints implied by each instruction. E.g., Let csti be the constraints on operation i. V1= op1 V1(cst1) op2 V1(cst2) V1 live-range is constrained on the intersection of cst1 and cst2. tryInstructionSplit relaxes those constraints by aggressively splitting each def/use point: V1= V2 = V1 V3 = V2 op1 V3(cst1) V4 = V2 op2 V4(cst2) Because of how the coalescer infrastructure works, each new variable (V3, V4) that is alive at the same time as V1 (or its copy, here V2) interfere with V1. Thus, we end up with an uncoalescable copy for each split point. To make tryInstructionSplit less aggressive, we check if the split point actually relaxes the constraints on the whole live-range. If it does not, we do not insert it. Indeed, it will not help the global allocation problem: - V1 will have the same constraints. - V1 will have the same interference + possibly the newly added split variable VS. - VS will produce an uncoalesceable copy if alive at the same time as V1. <rdar://problem/15570057> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198369 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Quentin Colombet
committed
Jan 2, 2014
1 parent
79d8722
commit fb57392
Showing
5 changed files
with
159 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; RUN: llc -O1 -regalloc=greedy -mtriple=x86_64-apple-macosx -march x86-64 < %s -o - | FileCheck %s | ||
; Check that last chance split (RAGreedy::tryInstructonSplit) just split | ||
; when this is beneficial, otherwise we end up with uncoalesced copies. | ||
; <rdar://problem/15570057> | ||
|
||
target datalayout = "e-i64:64-f80:128-s:64-n8:16:32:64-S128" | ||
|
||
@f = external constant void (i32)* | ||
|
||
; CHECK-LABEL: test: | ||
; Get the address of f in the GOT. | ||
; CHECK: movq _f@{{[^,]+}}, [[F_ENTRY_ADDR:%[a-z0-9]+]] | ||
; Read the actual address of f. | ||
; CHECK: movq ([[F_ENTRY_ADDR]]), [[F_ADDR:%[a-z0-9]+]] | ||
; Check that we do not have useless split points before each call. | ||
; CHECK-NOT: movq | ||
; CHECK: callq *[[F_ADDR]] | ||
; Check that we do not have useless split points before each call. | ||
; CHECK-NOT: movq | ||
; CHECK: callq *[[F_ADDR]] | ||
; Last call is a tail call, thus the address of the function cannot use | ||
; a callee saved register. | ||
; CHECK: movq [[F_ADDR]], [[F_ADDR_TC:%[a-z0-9]+]] | ||
; CHECK: popq [[F_ADDR]] | ||
; CHECK: jmpq *[[F_ADDR_TC]] | ||
define void @test(i32 %a, i32 %b, i32 %c) { | ||
entry: | ||
%fct_f = load void (i32)** @f, align 8 | ||
tail call void %fct_f(i32 %a) | ||
tail call void %fct_f(i32 %b) | ||
tail call void %fct_f(i32 %c) | ||
ret void | ||
} |