[cfe-commits] r106963 - /cfe/trunk/lib/CodeGen/CGExpr.cpp
Chris Lattner
sabre at nondot.org
Sat Jun 26 15:40:46 PDT 2010
Author: lattner
Date: Sat Jun 26 17:40:46 2010
New Revision: 106963
URL: http://llvm.org/viewvc/llvm-project?rev=106963&view=rev
Log:
minor cleanup: don't emit the base of an array subscript until after
we're done diddling around with the index stuff. Use a cheaper type
comparison.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=106963&r1=106962&r2=106963&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Jun 26 17:40:46 2010
@@ -1335,19 +1335,15 @@
E->getBase()->getType().getCVRQualifiers());
}
- // The base must be a pointer, which is not an aggregate. Emit it.
- llvm::Value *Base = EmitScalarExpr(E->getBase());
-
// Extend or truncate the index type to 32 or 64-bits.
- unsigned IdxBitwidth = cast<llvm::IntegerType>(Idx->getType())->getBitWidth();
- if (IdxBitwidth != LLVMPointerWidth)
+ if (!Idx->getType()->isIntegerTy(LLVMPointerWidth))
Idx = Builder.CreateIntCast(Idx,
- llvm::IntegerType::get(VMContext, LLVMPointerWidth),
+ llvm::IntegerType::get(VMContext, LLVMPointerWidth),
IdxSigned, "idxprom");
-
+
// FIXME: As llvm implements the object size checking, this can come out.
if (CatchUndefined) {
- if (const ImplicitCastExpr *ICE=dyn_cast<ImplicitCastExpr>(E->getBase())) {
+ if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E->getBase())){
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr())) {
if (ICE->getCastKind() == CastExpr::CK_ArrayToPointerDecay) {
if (const ConstantArrayType *CAT
@@ -1364,6 +1360,9 @@
}
}
+ // The base must be a pointer, which is not an aggregate. Emit it.
+ llvm::Value *Base = EmitScalarExpr(E->getBase());
+
// We know that the pointer points to a type of the correct size, unless the
// size is a VLA or Objective-C interface.
llvm::Value *Address = 0;
More information about the cfe-commits
mailing list