diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-07 17:57:00 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-07 17:57:00 +0000 |
commit | d7fb96e3bfeeaae7e28666b2838b430ff8c26397 (patch) | |
tree | d780b14fefa5bbf5207a6a2e81ed229f9f888d6b /lib/CodeGen/CGExpr.cpp | |
parent | 41a669a30074dcc221ba199e5dde484cc33adba1 (diff) |
remove code to add bound checks for simple array accesses, since those are already covered by the check with the objectsize builtin
remove the comparison of objectsize with -1. since it's an unsigned comparison, it will always succeed if objectsize returns -1, which is enough to have the check removed
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156311 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 6cbf36dc14..f977f5531a 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -525,15 +525,9 @@ void CodeGenFunction::EmitCheck(llvm::Value *Address, unsigned Size) { llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::objectsize, IntPtrTy); - // In time, people may want to control this and use a 1 here. llvm::Value *Arg = Builder.getFalse(); llvm::Value *C = Builder.CreateCall2(F, Address, Arg); llvm::BasicBlock *Cont = createBasicBlock(); - llvm::BasicBlock *Check = createBasicBlock(); - llvm::Value *NegativeOne = llvm::ConstantInt::get(IntPtrTy, -1ULL); - Builder.CreateCondBr(Builder.CreateICmpEQ(C, NegativeOne), Cont, Check); - - EmitBlock(Check); Builder.CreateCondBr(Builder.CreateICmpUGE(C, llvm::ConstantInt::get(IntPtrTy, Size)), Cont, getTrapBB()); @@ -1792,25 +1786,6 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) { // Extend or truncate the index type to 32 or 64-bits. if (Idx->getType() != IntPtrTy) Idx = Builder.CreateIntCast(Idx, IntPtrTy, 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 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr())) { - if (ICE->getCastKind() == CK_ArrayToPointerDecay) { - if (const ConstantArrayType *CAT - = getContext().getAsConstantArrayType(DRE->getType())) { - llvm::APInt Size = CAT->getSize(); - llvm::BasicBlock *Cont = createBasicBlock("cont"); - Builder.CreateCondBr(Builder.CreateICmpULE(Idx, - llvm::ConstantInt::get(Idx->getType(), Size)), - Cont, getTrapBB()); - EmitBlock(Cont); - } - } - } - } - } // We know that the pointer points to a type of the correct size, unless the // size is a VLA or Objective-C interface. |