[LLVMbugs] [Bug 4775] New: -indvars pass turning static alloca into dynamic alloca

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Aug 25 10:16:50 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=4775

           Summary: -indvars pass turning static alloca into dynamic alloca
           Product: libraries
           Version: 1.0
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: code-quality, regression
          Severity: normal
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: clattner at apple.com
                CC: gohman at apple.com, llvmbugs at cs.uiuc.edu


This seems pretty bad: opt -indvars turns this:

; ModuleID = '<stdin>'
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"
target triple = "i386-apple-darwin10.0"

@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @main to i8*)],
section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]

define i32 @main() nounwind ssp {
entry:
  %result.i = alloca i32, align 4                 ; <i32*> [#uses=2]
  br label %while.cond

while.cond:                                       ; preds = %while.cond, %entry
  %call = call i32 @bar() nounwind ssp            ; <i32> [#uses=1]
  %tobool = icmp eq i32 %call, 0                  ; <i1> [#uses=1]
  br i1 %tobool, label %while.end, label %while.cond

while.end:                                        ; preds = %while.cond
  volatile store i32 0, i32* %result.i
  %tmp.i = volatile load i32* %result.i           ; <i32> [#uses=0]
  ret i32 0
}

declare i32 @bar() ssp

into:

...
  br i1 %tobool, label %while.end, label %while.cond

while.end:                                        ; preds = %while.cond
  %result.i = alloca i32, align 4                 ; <i32*> [#uses=2]
  volatile store i32 0, i32* %result.i
  %tmp.i = volatile load i32* %result.i           ; <i32> [#uses=0]
  ret i32 0

Dynamic allocas are *much* more expensive than static ones.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list