[LLVMbugs] [Bug 7136] New: InstCombine lowerize w/TD to lose type information
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu May 13 21:02:45 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7136
Summary: InstCombine lowerize w/TD to lose type information
Product: libraries
Version: trunk
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: geek4civic at gmail.com
CC: llvmbugs at cs.uiuc.edu
A simple example to allocate and initialize an object.
---
define %struct.A* @foo(i32 %a, i32 %b) nounwind {
entry:
%0 = call noalias i8* @malloc(i32 8) nounwind ; <i8*> [#uses=1]
%1 = bitcast i8* %0 to %struct.A* ; <%struct.A*> [#uses=4]
%2 = icmp ne %struct.A* %1, null ; <i1> [#uses=1]
br i1 %2, label %bb, label %return
bb:
%3 = getelementptr inbounds %struct.A* %1, i32 0, i32 0 ; <i32*> [#uses=1]
store i32 %a, i32* %3, align 4
%4 = getelementptr inbounds %struct.A* %1, i32 0, i32 1 ; <i32*> [#uses=1]
store i32 %b, i32* %4, align 4
br label %return
return:
ret %struct.A* %1
}
---
The pass "InstCombine" strips and lowerizes type information as below.
---
define %struct.A* @foo(i32 %a, i32 %b) nounwind {
entry:
%0 = call noalias i8* @malloc(i32 8) nounwind ; <i8*> [#uses=4]
%1 = bitcast i8* %0 to %struct.A* ; <%struct.A*> [#uses=1]
%2 = icmp eq i8* %0, null ; <i1> [#uses=1]
br i1 %2, label %return, label %bb
bb: ; preds = %entry
%3 = bitcast i8* %0 to i32* ; <i32*> [#uses=1]
store i32 %a, i32* %3, align 4
%4 = getelementptr inbounds i8* %0, i32 4 ; <i8*> [#uses=1]
%5 = bitcast i8* %4 to i32* ; <i32*> [#uses=1]
store i32 %b, i32* %5, align 4
br label %return
return: ; preds = %bb, %entry
ret %struct.A* %1
}
---
It makes following analysis harder, I guess.
I think, it would not needed to convert when;
* origBase has generic pointer type (eg. i8 *)
* origBase is derived from allocation
at InstCombiner::commonPointerCastTransforms(CastInst &CI);
(FYI, my environment as below)
---
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:32:32"
target triple = "i386-mingw32"
%struct.A = type { i32, i32 }
declare noalias i8* @malloc(i32) nounwind
---
--
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