[LLVMbugs] [Bug 4589] New: Invalid GEP optimization after bitcast
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sun Jul 19 19:05:52 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=4589
Summary: Invalid GEP optimization after bitcast
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: stein at ir.iit.edu
CC: llvmbugs at cs.uiuc.edu
A bitcast followed by a getelementptr causes an
optimization in instcombine that only works on
some machines, but is applied generally.
Here is a small test program:
*================================================*
%dt = type {i32, i32 *}
define i32 **@get_el(i8 *%arg) {
%der = bitcast i8 *%arg to %dt *
%ptr = getelementptr %dt *%der, i32 0, i32 1
ret i32 **%ptr
}
*================================================*
Run it through:
opt -instcombine
And you get:
*================================================*
%dt = type { i32, i32* }
define i32** @get_el(i8* %arg) {
%ptr = getelementptr i8* %arg, i64 8 ; <i8*> [#uses=1]
%1 = bitcast i8* %ptr to i32** ; <i32**> [#uses=1]
ret i32** %1
}
*================================================*
This will happen to work on AMD64 where
dt's 2nd member's offset is 8.
However, this optimization is also applied on 32-bit systems,
where the offset should instead be 4.
So, ptr will then point to the wrong place.
Thus, the optimization is invalid.
--
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