Constant fold: getelementptr (i8* inttoptr (i64 1 to i8*), i32 -1)
authorChris Lattner <sabre@nondot.org>
Mon, 13 Aug 2007 17:09:08 +0000 (17:09 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 13 Aug 2007 17:09:08 +0000 (17:09 +0000)
commitfe9d82a71bac418d82f14d28d654dedea66083d5
tree960759c1095a962c1635dedb2c1c50d541f398f1
parent6047dd928067c9e2127c74152d22517ef3940d87
Constant fold: getelementptr (i8* inttoptr (i64 1 to i8*), i32 -1)
Into: inttoptr (i64 0 to i8*)  -> null

This occurs in the example in PR1602.  With this fixed, we now compile
the example in PR1602 into fully "devirtualized" code:

define void @_Z1g1S(%struct.S* noalias  %s) {
entry:        %tmp131415 = getelementptr %struct.S* %s, i32 0, i32 0          ; <i32 (...)***> [#uses=1]        %tmp16 = load i32 (...)*** %tmp131415, align 4          ; <i32 (...)**> [#uses=1]
        %tmp26277 = load i32 (...)** %tmp16             ; <i32 (...)*> [#uses=1]
        %tmp2829 = bitcast i32 (...)* %tmp26277 to void (%struct.S*)*           ; <void (%struct.S*)*> [#uses=1]
        tail call void %tmp2829( %struct.S* %s )
        ret void
}

This still has the vtable dispatch (as required) but does not have any pointer
to method cruft left.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41046 91177308-0d34-0410-b5e6-96231b3b80d8
lib/VMCore/ConstantFold.cpp