[cfe-commits] r86741 - /cfe/trunk/lib/CodeGen/CGCXXClass.cpp
Eli Friedman
eli.friedman at gmail.com
Tue Nov 10 14:42:27 PST 2009
Author: efriedma
Date: Tue Nov 10 16:42:26 2009
New Revision: 86741
URL: http://llvm.org/viewvc/llvm-project?rev=86741&view=rev
Log:
Minor optimization to skip null check in generated code where it isn't
necessary.
Modified:
cfe/trunk/lib/CodeGen/CGCXXClass.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXXClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXClass.cpp?rev=86741&r1=86740&r2=86741&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXXClass.cpp Tue Nov 10 16:42:26 2009
@@ -127,7 +127,14 @@
// Just cast back.
return Builder.CreateBitCast(BaseValue, BasePtrTy);
}
-
+
+ llvm::Value *Offset =
+ GetCXXBaseClassOffset(*this, BaseValue, ClassDecl, BaseClassDecl);
+
+ // If there is no offset, simply cast the pointer and return it.
+ if (!Offset)
+ return Builder.CreateBitCast(BaseValue, BasePtrTy);
+
llvm::BasicBlock *CastNull = 0;
llvm::BasicBlock *CastNotNull = 0;
llvm::BasicBlock *CastEnd = 0;
@@ -145,15 +152,10 @@
}
const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
-
- llvm::Value *Offset =
- GetCXXBaseClassOffset(*this, BaseValue, ClassDecl, BaseClassDecl);
- if (Offset) {
- // Apply the offset.
- BaseValue = Builder.CreateBitCast(BaseValue, Int8PtrTy);
- BaseValue = Builder.CreateGEP(BaseValue, Offset, "add.ptr");
- }
+ // Apply the offset.
+ BaseValue = Builder.CreateBitCast(BaseValue, Int8PtrTy);
+ BaseValue = Builder.CreateGEP(BaseValue, Offset, "add.ptr");
// Cast back.
BaseValue = Builder.CreateBitCast(BaseValue, BasePtrTy);
More information about the cfe-commits
mailing list