summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-02-28 22:07:56 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-02-28 22:07:56 +0000
commitc5685438df6105052b02c9e02f01c34489606308 (patch)
treea9eb39fec577180ea59dd27f6401688e0d3da217 /lib
parent212000e24cf11da0badea90c23d4f300da34e607 (diff)
downloadclang-c5685438df6105052b02c9e02f01c34489606308.tar.gz
clang-c5685438df6105052b02c9e02f01c34489606308.tar.bz2
clang-c5685438df6105052b02c9e02f01c34489606308.tar.xz
Prefer bitcast+GEP over ptrtoint+sub+inttoptr: it's semantically equivalent here, and generally nicer to the optimizer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/CGClass.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp
index b9abbf2901..e3b5777387 100644
--- a/lib/CodeGen/CGClass.cpp
+++ b/lib/CodeGen/CGClass.cpp
@@ -249,9 +249,9 @@ CodeGenFunction::GetAddressOfDerivedClass(llvm::Value *Value,
}
// Apply the offset.
- Value = Builder.CreatePtrToInt(Value, NonVirtualOffset->getType());
- Value = Builder.CreateSub(Value, NonVirtualOffset);
- Value = Builder.CreateIntToPtr(Value, DerivedPtrTy);
+ Value = Builder.CreateBitCast(Value, Int8PtrTy);
+ Value = Builder.CreateGEP(Value, Builder.CreateNeg(NonVirtualOffset),
+ "sub.ptr");
// Just cast.
Value = Builder.CreateBitCast(Value, DerivedPtrTy);