Skip to content

Commit 4daf7f1

Browse files
committedMay 27, 2016
Disable lifetime-start-on-first-use analysis.
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
1 parent a6e3e93 commit 4daf7f1

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed
 

‎llvm/lib/CodeGen/StackColoring.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ ProtectFromEscapedAllocas("protect-from-escaped-allocas",
7575
/// Enable enhanced dataflow scheme for lifetime analysis (treat first
7676
/// use of stack slot as start of slot lifetime, as opposed to looking
7777
/// for LIFETIME_START marker). See "Implementation notes" below for
78-
/// more info.
78+
/// more info. FIXME: set to false for the moment due to PR27903.
7979
static cl::opt<bool>
8080
LifetimeStartOnFirstUse("stackcoloring-lifetime-start-on-first-use",
81-
cl::init(true), cl::Hidden,
81+
cl::init(false), cl::Hidden,
8282
cl::desc("Treat stack lifetimes as starting on first use, not on START marker."));
8383

8484

‎llvm/test/CodeGen/X86/StackColoring.ll

+53-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; RUN: llc -mcpu=corei7 -no-stack-coloring=false -stackcoloring-lifetime-start-on-first-use=true < %s | FileCheck %s --check-prefix=FIRSTUSE --check-prefix=CHECK
12
; RUN: llc -mcpu=corei7 -no-stack-coloring=false < %s | FileCheck %s --check-prefix=YESCOLOR --check-prefix=CHECK
23
; RUN: llc -mcpu=corei7 -no-stack-coloring=true < %s | FileCheck %s --check-prefix=NOCOLOR --check-prefix=CHECK
34

@@ -87,7 +88,8 @@ bb3:
8788
}
8889

8990
;CHECK-LABEL: myCall_w4:
90-
;YESCOLOR: subq $120, %rsp
91+
;FIRSTUSE: subq $120, %rsp
92+
;YESCOLOR: subq $200, %rsp
9193
;NOCOLOR: subq $408, %rsp
9294

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

433435
;CHECK-LABEL: ifthen_twoslots:
434-
;YESCOLOR: subq $536, %rsp
436+
;FIRSTUSE: subq $536, %rsp
437+
;YESCOLOR: subq $1048, %rsp
435438
;NOCOLOR: subq $1048, %rsp
436439

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

488491
;CHECK-LABEL: while_loop:
489-
;YESCOLOR: subq $1032, %rsp
492+
;FIRSTUSE: subq $1032, %rsp
493+
;YESCOLOR: subq $1544, %rsp
490494
;NOCOLOR: subq $1544, %rsp
491495

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

544+
; Test case motivated by PR27903. Same routine inlined multiple times
545+
; into a caller results in a multi-segment lifetime, but the second
546+
; lifetime has no explicit references to the stack slot.
547+
;
548+
; FIXME: the "FIRSTUSE" stack size (56) below represents buggy/incorrect
549+
; behavior not currently exposed on trunk, due to the fact that
550+
; the "stackcoloring-lifetime-start-on-first-use" now defaults to
551+
; false. When a better fix for PR27903 is checked in, this result
552+
; will change to 96.
553+
554+
;CHECK-LABEL: twobod_b27903:
555+
;FIRSTUSE: subq $56, %rsp
556+
;YESCOLOR: subq $96, %rsp
557+
;NOCOLOR: subq $96, %rsp
558+
559+
define i32 @twobod_b27903(i32 %y, i32 %x) {
560+
entry:
561+
%buffer.i = alloca [12 x i32], align 16
562+
%abc = alloca [12 x i32], align 16
563+
%tmp = bitcast [12 x i32]* %buffer.i to i8*
564+
call void @llvm.lifetime.start(i64 48, i8* %tmp)
565+
%idxprom.i = sext i32 %y to i64
566+
%arrayidx.i = getelementptr inbounds [12 x i32], [12 x i32]* %buffer.i, i64 0, i64 %idxprom.i
567+
call void @inita(i32* %arrayidx.i)
568+
%add.i = add nsw i32 %x, %y
569+
call void @llvm.lifetime.end(i64 48, i8* %tmp)
570+
%tobool = icmp eq i32 %y, 0
571+
br i1 %tobool, label %if.end, label %if.then
572+
573+
if.then: ; preds = %entry
574+
%tmp1 = bitcast [12 x i32]* %abc to i8*
575+
call void @llvm.lifetime.start(i64 48, i8* %tmp1)
576+
%arrayidx = getelementptr inbounds [12 x i32], [12 x i32]* %abc, i64 0, i64 %idxprom.i
577+
call void @inita(i32* %arrayidx)
578+
call void @llvm.lifetime.start(i64 48, i8* %tmp)
579+
call void @inita(i32* %arrayidx.i)
580+
%add.i9 = add nsw i32 %add.i, %y
581+
call void @llvm.lifetime.end(i64 48, i8* %tmp)
582+
call void @llvm.lifetime.end(i64 48, i8* %tmp1)
583+
br label %if.end
584+
585+
if.end: ; preds = %if.then, %entry
586+
%x.addr.0 = phi i32 [ %add.i9, %if.then ], [ %add.i, %entry ]
587+
ret i32 %x.addr.0
588+
}
589+
540590
declare void @inita(i32*) #2
541591

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

0 commit comments

Comments
 (0)
Please sign in to comment.