[LLVMbugs] [Bug 13246] New: LLVM doesn't optimize away allocas whose address is passed to only "nocapture" parameters

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 30 14:13:30 PDT 2012


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

             Bug #: 13246
           Summary: LLVM doesn't optimize away allocas whose address is
                    passed to only "nocapture" parameters
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Core LLVM classes
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: schaub.johannes at googlemail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


LLVM ("opt -std-compile-opts") doesn't optimize this

declare void @negate(i32* nocapture, i32* nocapture);
declare void @print(i32* nocapture)

define void @f() {
entry:
  %a = alloca i32
  %b = alloca i32
  %c = alloca i32

  call void @negate(i32* %a, i32* %b)

  %d = load i32* %b
  store i32 %d, i32* %c

  call void @print(i32* %c)
  ret void
}

To this:

declare void @negate(i32* nocapture, i32* nocapture);
declare void @print(i32* nocapture)

define void @f() {
entry:
  %a = alloca i32
  %b = alloca i32

  call void @negate(i32* %a, i32* %b)

  call void @print(i32* %b)
  ret void
}

The load and store to "c" occured as output from a code generator that relied
on LLVM to optimize this code.

-- 
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