Skip to content

Commit

Permalink
Disable lifetime-start-on-first-use analysis.
Browse files Browse the repository at this point in the history
Summary:
Turn off lifetime-start-on-first-use enhancement for the moment
pending a fix for bug 27903.

Bug: 27903

Reviewers: tejohnson, wmi, qcolombet, gbiv

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D20731

llvm-svn: 271003
  • Loading branch information
thanm committed May 27, 2016
1 parent a6e3e93 commit 4daf7f1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/StackColoring.cpp
Expand Up @@ -75,10 +75,10 @@ ProtectFromEscapedAllocas("protect-from-escaped-allocas",
/// Enable enhanced dataflow scheme for lifetime analysis (treat first
/// use of stack slot as start of slot lifetime, as opposed to looking
/// for LIFETIME_START marker). See "Implementation notes" below for
/// more info.
/// more info. FIXME: set to false for the moment due to PR27903.
static cl::opt<bool>
LifetimeStartOnFirstUse("stackcoloring-lifetime-start-on-first-use",
cl::init(true), cl::Hidden,
cl::init(false), cl::Hidden,
cl::desc("Treat stack lifetimes as starting on first use, not on START marker."));


Expand Down
56 changes: 53 additions & 3 deletions llvm/test/CodeGen/X86/StackColoring.ll
@@ -1,3 +1,4 @@
; RUN: llc -mcpu=corei7 -no-stack-coloring=false -stackcoloring-lifetime-start-on-first-use=true < %s | FileCheck %s --check-prefix=FIRSTUSE --check-prefix=CHECK
; RUN: llc -mcpu=corei7 -no-stack-coloring=false < %s | FileCheck %s --check-prefix=YESCOLOR --check-prefix=CHECK
; RUN: llc -mcpu=corei7 -no-stack-coloring=true < %s | FileCheck %s --check-prefix=NOCOLOR --check-prefix=CHECK

Expand Down Expand Up @@ -87,7 +88,8 @@ bb3:
}

;CHECK-LABEL: myCall_w4:
;YESCOLOR: subq $120, %rsp
;FIRSTUSE: subq $120, %rsp
;YESCOLOR: subq $200, %rsp
;NOCOLOR: subq $408, %rsp

define i32 @myCall_w4(i32 %in) {
Expand Down Expand Up @@ -431,7 +433,8 @@ define i32 @shady_range(i32 %argc, i8** nocapture %argv) uwtable {
; start. See llvm bug 25776.

;CHECK-LABEL: ifthen_twoslots:
;YESCOLOR: subq $536, %rsp
;FIRSTUSE: subq $536, %rsp
;YESCOLOR: subq $1048, %rsp
;NOCOLOR: subq $1048, %rsp

define i32 @ifthen_twoslots(i32 %x) #0 {
Expand Down Expand Up @@ -486,7 +489,8 @@ cleanup: ; preds = %if.else, %if.then
; markers only.

;CHECK-LABEL: while_loop:
;YESCOLOR: subq $1032, %rsp
;FIRSTUSE: subq $1032, %rsp
;YESCOLOR: subq $1544, %rsp
;NOCOLOR: subq $1544, %rsp

define i32 @while_loop(i32 %x) #0 {
Expand Down Expand Up @@ -537,6 +541,52 @@ if.end: ; preds = %if.end.loopexit, %i
ret i32 0
}

; Test case motivated by PR27903. Same routine inlined multiple times
; into a caller results in a multi-segment lifetime, but the second
; lifetime has no explicit references to the stack slot.
;
; FIXME: the "FIRSTUSE" stack size (56) below represents buggy/incorrect
; behavior not currently exposed on trunk, due to the fact that
; the "stackcoloring-lifetime-start-on-first-use" now defaults to
; false. When a better fix for PR27903 is checked in, this result
; will change to 96.

;CHECK-LABEL: twobod_b27903:
;FIRSTUSE: subq $56, %rsp
;YESCOLOR: subq $96, %rsp
;NOCOLOR: subq $96, %rsp

define i32 @twobod_b27903(i32 %y, i32 %x) {
entry:
%buffer.i = alloca [12 x i32], align 16
%abc = alloca [12 x i32], align 16
%tmp = bitcast [12 x i32]* %buffer.i to i8*
call void @llvm.lifetime.start(i64 48, i8* %tmp)
%idxprom.i = sext i32 %y to i64
%arrayidx.i = getelementptr inbounds [12 x i32], [12 x i32]* %buffer.i, i64 0, i64 %idxprom.i
call void @inita(i32* %arrayidx.i)
%add.i = add nsw i32 %x, %y
call void @llvm.lifetime.end(i64 48, i8* %tmp)
%tobool = icmp eq i32 %y, 0
br i1 %tobool, label %if.end, label %if.then

if.then: ; preds = %entry
%tmp1 = bitcast [12 x i32]* %abc to i8*
call void @llvm.lifetime.start(i64 48, i8* %tmp1)
%arrayidx = getelementptr inbounds [12 x i32], [12 x i32]* %abc, i64 0, i64 %idxprom.i
call void @inita(i32* %arrayidx)
call void @llvm.lifetime.start(i64 48, i8* %tmp)
call void @inita(i32* %arrayidx.i)
%add.i9 = add nsw i32 %add.i, %y
call void @llvm.lifetime.end(i64 48, i8* %tmp)
call void @llvm.lifetime.end(i64 48, i8* %tmp1)
br label %if.end

if.end: ; preds = %if.then, %entry
%x.addr.0 = phi i32 [ %add.i9, %if.then ], [ %add.i, %entry ]
ret i32 %x.addr.0
}

declare void @inita(i32*) #2

declare void @bar([100 x i32]* , [100 x i32]*) nounwind
Expand Down

0 comments on commit 4daf7f1

Please sign in to comment.