[LLVMbugs] [Bug 1851] New: instcombine removes stacksave/stackrestore around alloca

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Dec 10 05:58:01 PST 2007


           Summary: instcombine removes stacksave/stackrestore around alloca
           Product: libraries
           Version: 2.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jay.foad at antixlabs.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=1282)
 --> (http://llvm.org/bugs/attachment.cgi?id=1282)
test case

The attached test case is based on gcc.c-torture/execute/20040811-1.c in the
GCC testsuite. If I run it through "opt -f -o post.o pre.o -instcombine" I get

loop:           ; preds = %cleanup, %entry
        %n = phi i32 [ 1, %entry ], [ %phitmp, %cleanup ]               ; <i32>
        %mem1 = alloca [1000 x i32]             ; <[1000 x i32]*> [#uses=1]
        %mem1.sub = getelementptr [1000 x i32]* %mem1, i32 0, i32 0            
; <i32*> [#uses=1]
        call void @foo( i32* %mem1.sub )
        %cond = icmp slt i32 %n, 1000000                ; <i1> [#uses=1]
        br i1 %cond, label %cleanup, label %return

cleanup:                ; preds = %loop
        %phitmp = add i32 %n, 1         ; <i32> [#uses=1]
        br label %loop

It has completely removed the calls to llvm.stacksave and llvm.stackrestore
around the large alloca!

I think the problem is that InstructionCombining.cpp's TryToSinkInstruction()
thinks it's OK to sink the call to llvm.stacksave past the alloca.

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