[LLVMbugs] [Bug 2655] New: memcpyopt doesn't zap an alloca + memmove
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sat Aug 9 18:35:18 PDT 2008
http://llvm.org/bugs/show_bug.cgi?id=2655
Summary: memcpyopt doesn't zap an alloca + memmove
Product: libraries
Version: 1.0
Platform: PC
OS/Version: All
Status: NEW
Keywords: code-quality
Severity: normal
Priority: P2
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: clattner at apple.com
CC: resistor at mac.com, llvmbugs at cs.uiuc.edu
In this case, memcpyopt should "out->replaceAllUsesWith(agg.result)" and then
nuke the memmove as an identity memmove:
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 = "i686-pc-linux-gnu"
%struct.out = type <{ i32, i32 }>
define void @foo(%struct.out* sret %agg.result) {
entry:
%out = alloca %struct.out, align 4 ; <%struct.out*>
[#uses=3]
%tmp = getelementptr %struct.out* %out, i32 0, i32 0 ;
<i32*> [#uses=1]
%call = call i32 @bar( ) ; <i32> [#uses=1]
store i32 %call, i32* %tmp
%tmp1 = getelementptr %struct.out* %out, i32 0, i32 1 ;
<i32*> [#uses=1]
%call2 = call i32 @bar( ) ; <i32> [#uses=1]
store i32 %call2, i32* %tmp1
%tmp3 = bitcast %struct.out* %agg.result to i8* ; <i8*>
[#uses=1]
%tmp4 = bitcast %struct.out* %out to i8* ; <i8*>
[#uses=1]
call void @llvm.memmove.i32( i8* %tmp3, i8* %tmp4, i32 8, i32 4 )
ret void
}
declare void @llvm.memmove.i32(i8*, i8*, i32, i32) nounwind
declare i32 @bar()
This produces:
define void @foo(%struct.out* sret %agg.result) {
entry:
%call = call i32 @bar( ) ; <i32> [#uses=1]
%call2 = call i32 @bar( ) ; <i32> [#uses=1]
%tmp3 = bitcast %struct.out* %agg.result to i8* ; <i8*>
[#uses=0]
%agg.result.0 = getelementptr %struct.out* %agg.result, i32 0, i32 0
; <i32*> [#uses=1]
store i32 %call, i32* %agg.result.0
%agg.result.1 = getelementptr %struct.out* %agg.result, i32 0, i32 1
; <i32*> [#uses=1]
store i32 %call2, i32* %agg.result.1
ret void
}
--
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