Improve codegen for the LLVM offsetof/sizeof "operator". Before we compiled
authorChris Lattner <sabre@nondot.org>
Thu, 15 Jul 2004 00:58:53 +0000 (00:58 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 15 Jul 2004 00:58:53 +0000 (00:58 +0000)
commitd2995df5b7b94a42899dab266a7e83b316fa818f
tree20e228fb9101e01292161518b1477ab77f55e150
parent6c142300c2ede16bf51669d157f37ee6bca18c43
Improve codegen for the LLVM offsetof/sizeof "operator".  Before we compiled
this LLVM function:

int %foo() {
        ret int cast (int** getelementptr (int** null, int 1) to int)
}

into:

foo:
        mov %EAX, 0
        lea %EAX, DWORD PTR [%EAX + 4]
        ret

now we compile it into:

foo:
        mov %EAX, 4
        ret

This sequence is frequently generated by the MSIL front-end, and soon the malloc lowering pass and
Java front-ends as well..

-Chris

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14834 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/InstSelectSimple.cpp
lib/Target/X86/X86ISelSimple.cpp