llvm.org GIT mirror llvm / 7dceebd
Merge from mainline. Special-case static allocas in IndVarSimplify's loop invariant sinking code, since they are special. If the loop preheader happens to be the entry block of a function, don't sink static allocas out of it. This fixes PR4775. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_26@80551 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 10 years ago
2 changed file(s) with 36 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
551551 // dominates the exit block.
552552 if (I->mayHaveSideEffects() || I->mayReadFromMemory())
553553 continue;
554 // Don't sink static AllocaInsts out of the entry block, which would
555 // turn them into dynamic allocas!
556 if (AllocaInst *AI = dyn_cast(I))
557 if (AI->isStaticAlloca())
558 continue;
554559 // Determine if there is a use in or before the loop (direct or
555560 // otherwise).
556561 bool UsedInLoop = false;
0 ; RUN: llvm-as < %s | opt -indvars | llvm-dis | FileCheck %s
1 ; PR4775
2
3 ; Indvars shouldn't sink the alloca out of the entry block, even though
4 ; it's not used until after the loop.
5
6 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"
7 target triple = "i386-apple-darwin10.0"
8
9 @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @main to i8*)],
10 section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
11
12 define i32 @main() nounwind {
13 ; CHECK: entry:
14 ; CHECK-NEXT: %result.i = alloca i32, align 4
15 entry:
16 %result.i = alloca i32, align 4 ; [#uses=2]
17 br label %while.cond
18
19 while.cond: ; preds = %while.cond, %entry
20 %call = call i32 @bar() nounwind ; [#uses=1]
21 %tobool = icmp eq i32 %call, 0 ; [#uses=1]
22 br i1 %tobool, label %while.end, label %while.cond
23
24 while.end: ; preds = %while.cond
25 volatile store i32 0, i32* %result.i
26 %tmp.i = volatile load i32* %result.i ; [#uses=0]
27 ret i32 0
28 }
29
30 declare i32 @bar()