X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FTargetFolder.h;h=a02db2fe66681e7c0efa092dd0a7525ed83758fe;hb=5df15c692b944b6c46ec6d532fc286b7e0000d5d;hp=e6b501c88e6c4cd82f03c7f5c91c74a58cebb984;hpb=14732a1f42e9df9c4ca4f6403f67de27b563fcbb;p=oota-llvm.git diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h index e6b501c88e6..a02db2fe666 100644 --- a/include/llvm/Support/TargetFolder.h +++ b/include/llvm/Support/TargetFolder.h @@ -132,36 +132,32 @@ public: Constant *CreateGetElementPtr(Constant *C, ArrayRef IdxList) const { - return Fold(ConstantExpr::getGetElementPtr(C, IdxList.data(), - IdxList.size())); + return Fold(ConstantExpr::getGetElementPtr(C, IdxList)); } Constant *CreateGetElementPtr(Constant *C, Constant *Idx) const { // This form of the function only exists to avoid ambiguous overload // warnings about whether to convert Idx to ArrayRef or // ArrayRef. - return Fold(ConstantExpr::getGetElementPtr(C, &Idx, 1)); + return Fold(ConstantExpr::getGetElementPtr(C, Idx)); } Constant *CreateGetElementPtr(Constant *C, ArrayRef IdxList) const { - return Fold(ConstantExpr::getGetElementPtr(C, IdxList.data(), - IdxList.size())); + return Fold(ConstantExpr::getGetElementPtr(C, IdxList)); } Constant *CreateInBoundsGetElementPtr(Constant *C, ArrayRef IdxList) const { - return Fold(ConstantExpr::getInBoundsGetElementPtr(C, IdxList.data(), - IdxList.size())); + return Fold(ConstantExpr::getInBoundsGetElementPtr(C, IdxList)); } Constant *CreateInBoundsGetElementPtr(Constant *C, Constant *Idx) const { // This form of the function only exists to avoid ambiguous overload // warnings about whether to convert Idx to ArrayRef or // ArrayRef. - return Fold(ConstantExpr::getInBoundsGetElementPtr(C, &Idx, 1)); + return Fold(ConstantExpr::getInBoundsGetElementPtr(C, Idx)); } Constant *CreateInBoundsGetElementPtr(Constant *C, ArrayRef IdxList) const { - return Fold(ConstantExpr::getInBoundsGetElementPtr(C, IdxList.data(), - IdxList.size())); + return Fold(ConstantExpr::getInBoundsGetElementPtr(C, IdxList)); } //===--------------------------------------------------------------------===// @@ -181,7 +177,14 @@ public: return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned)); } Constant *CreatePointerCast(Constant *C, Type *DestTy) const { - return ConstantExpr::getPointerCast(C, DestTy); + if (C->getType() == DestTy) + return C; // avoid calling Fold + return Fold(ConstantExpr::getPointerCast(C, DestTy)); + } + Constant *CreateFPCast(Constant *C, Type *DestTy) const { + if (C->getType() == DestTy) + return C; // avoid calling Fold + return Fold(ConstantExpr::getFPCast(C, DestTy)); } Constant *CreateBitCast(Constant *C, Type *DestTy) const { return CreateCast(Instruction::BitCast, C, DestTy);