[LLVMbugs] [Bug 19569] New: Instcombine removes inalloca flag from alloca instruction

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Apr 25 18:00:49 PDT 2014


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

            Bug ID: 19569
           Summary: Instcombine removes inalloca flag from alloca
                    instruction
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.majnemer at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

consider:
; ModuleID = '<stdin>'
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-msvc"

%struct.gfx_size = type { i32, i32 }

; Function Attrs: nounwind
define void @"\01?doit@@YAXAAUgfx_size@@@Z"(%struct.gfx_size* %a) #0 {
entry:
  %inalloca.save = call i8* @llvm.stacksave()
  %argmem = alloca inalloca <{ %struct.gfx_size }>
  %0 = getelementptr inbounds <{ %struct.gfx_size }>* %argmem, i32 0, i32 0
  %1 = bitcast %struct.gfx_size* %0 to i8*
  %2 = bitcast %struct.gfx_size* %a to i8*
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* %2, i32 8, i32 4, i1 false)
  call void @"\01?f@@YAXUgfx_size@@@Z"(<{ %struct.gfx_size }>* inalloca
%argmem)
  call void @llvm.stackrestore(i8* %inalloca.save)
  ret void
}

declare void @"\01?f@@YAXUgfx_size@@@Z"(<{ %struct.gfx_size }>* inalloca) #1

; Function Attrs: nounwind
declare i8* @llvm.stacksave() #2

; Function Attrs: nounwind
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly,
i32, i32, i1) #2

; Function Attrs: nounwind
declare void @llvm.stackrestore(i8*) #2

attributes #0 = { nounwind "less-precise-fpmad"="false"
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
"no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
"unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #2 = { nounwind }

!llvm.ident = !{!0}

!0 = metadata !{metadata !"clang version 3.5.0 "}

running with ~/llvm/build/bin/opt -instcombine shows that we will produce the
following IR:
define void @"\01?doit@@YAXAAUgfx_size@@@Z"(%struct.gfx_size* %a) #0 {
entry:
  %argmem = alloca i64, align 8
  %tmpcast = bitcast i64* %argmem to <{ %struct.gfx_size }>*
  %0 = bitcast %struct.gfx_size* %a to i64*
  %1 = load i64* %0, align 4
  store i64 %1, i64* %argmem, align 8
  call void @"\01?f@@YAXUgfx_size@@@Z"(<{ %struct.gfx_size }>* inalloca
%tmpcast) #2
  ret void
}

note that we have removed the inalloca marker from our alloca instruction,
dooming the call to @"\01?f@@YAXUgfx_size@@@Z"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140426/162f25f5/attachment.html>


More information about the llvm-bugs mailing list