summaryrefslogtreecommitdiffstats
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
commit8754926feb62c553b7af118597d9c1a088f35e38 (patch)
treee9855c679f935748c94dd6753c15f7c077807198
parent2fbad222e1a89a28d5bb7a034218b0bed86a070f (diff)
downloadbcm5719-llvm-8754926feb62c553b7af118597d9c1a088f35e38.tar.gz
bcm5719-llvm-8754926feb62c553b7af118597d9c1a088f35e38.zip
Prefer bitcast+GEP over ptrtoint+sub+inttoptr: it's semantically equivalent here, and generally nicer to the optimizer.
llvm-svn: 151659
-rw-r--r--clang/lib/CodeGen/CGClass.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index b9abbf29012..e3b57773870 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud