Author: baldrick Date: Mon Jan 7 11:16:06 2008 New Revision: 45704 URL: http://llvm.org/viewvc/llvm-project?rev=45704&view=rev Log: Small cleanup for handling of type/parameter attribute incompatibility.
Modified: llvm/trunk/include/llvm/ParameterAttributes.h llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/VMCore/ParameterAttributes.cpp llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/include/llvm/ParameterAttributes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ParameterAttributes.h?rev=45704&r1=45703&r2=45704&view=diff ============================================================================== --- llvm/trunk/include/llvm/ParameterAttributes.h (original) +++ llvm/trunk/include/llvm/ParameterAttributes.h Mon Jan 7 11:16:06 2008 @@ -52,12 +52,6 @@ /// @brief Attributes that only apply to function return values. const uint16_t ReturnOnly = NoReturn | NoUnwind | ReadNone | ReadOnly; -/// @brief Attributes that only apply to integers. -const uint16_t IntegerTypeOnly = SExt | ZExt; - -/// @brief Attributes that only apply to pointers. -const uint16_t PointerTypeOnly = ByVal | Nest | NoAlias | StructRet; - /// @brief Attributes that are mutually incompatible. const uint16_t MutuallyIncompatible[3] = { ByVal | InReg | Nest | StructRet, @@ -65,8 +59,8 @@ ReadNone | ReadOnly }; -/// @brief Which of the given attributes do not apply to the type. -uint16_t incompatibleWithType (const Type *Ty, uint16_t attrs); +/// @brief Which attributes cannot be applied to a type. +uint16_t typeIncompatible (const Type *Ty); } // end namespace ParamAttr Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=45704&r1=45703&r2=45704&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Jan 7 11:16:06 2008 @@ -505,7 +505,7 @@ const Type *RetTy = FTy->getReturnType(); if (DeadRetVal.count(F)) { RetTy = Type::VoidTy; - RAttrs &= ~ParamAttr::incompatibleWithType(RetTy, RAttrs); + RAttrs &= ~ParamAttr::typeIncompatible(RetTy); DeadRetVal.erase(F); } @@ -561,7 +561,7 @@ // The call return attributes. uint16_t RAttrs = PAL ? PAL->getParamAttrs(0) : 0; // Adjust in case the function was changed to return void. - RAttrs &= ~ParamAttr::incompatibleWithType(NF->getReturnType(), RAttrs); + RAttrs &= ~ParamAttr::typeIncompatible(NF->getReturnType()); if (RAttrs) ParamAttrsVec.push_back(ParamAttrsWithIndex::get(0, RAttrs)); Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=45704&r1=45703&r2=45704&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jan 7 11:16:06 2008 @@ -8097,10 +8097,11 @@ FT->getReturnType() != Type::VoidTy) return false; // Cannot transform this return value. - if (!Caller->use_empty() && CallerPAL && - ParamAttr::incompatibleWithType(FT->getReturnType(), - CallerPAL->getParamAttrs(0))) - return false; // Attribute not compatible with transformed value. + if (CallerPAL && !Caller->use_empty()) { + uint16_t RAttrs = CallerPAL->getParamAttrs(0); + if (RAttrs & ParamAttr::typeIncompatible(FT->getReturnType())) + return false; // Attribute not compatible with transformed value. + } // If the callsite is an invoke instruction, and the return value is used by // a PHI node in a successor, we cannot change the return type of the call @@ -8127,9 +8128,11 @@ if (!CastInst::isCastable(ActTy, ParamTy)) return false; // Cannot transform this parameter value. - if (CallerPAL && - ParamAttr::incompatibleWithType(ParamTy, CallerPAL->getParamAttrs(i+1))) - return false; // Attribute not compatible with transformed value. + if (CallerPAL) { + uint16_t PAttrs = CallerPAL->getParamAttrs(i + 1); + if (PAttrs & ParamAttr::typeIncompatible(ParamTy)) + return false; // Attribute not compatible with transformed value. + } ConstantInt *c = dyn_cast<ConstantInt>(*AI); // Some conversions are safe even if we do not have a body. @@ -8168,7 +8171,7 @@ // If the return value is not being used, the type may not be compatible // with the existing attributes. Wipe out any problematic attributes. - RAttrs &= ~ParamAttr::incompatibleWithType(FT->getReturnType(), RAttrs); + RAttrs &= ~ParamAttr::typeIncompatible(FT->getReturnType()); // Add the new return attributes. if (RAttrs) Modified: llvm/trunk/lib/VMCore/ParameterAttributes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ParameterAttributes.cpp?rev=45704&r1=45703&r2=45704&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ParameterAttributes.cpp (original) +++ llvm/trunk/lib/VMCore/ParameterAttributes.cpp Mon Jan 7 11:16:06 2008 @@ -186,19 +186,21 @@ return getModified(PAL, modVec); } -uint16_t ParamAttr::incompatibleWithType (const Type *Ty, uint16_t attrs) { +uint16_t ParamAttr::typeIncompatible (const Type *Ty) { uint16_t Incompatible = None; if (!Ty->isInteger()) - Incompatible |= IntegerTypeOnly; + // Attributes that only apply to integers. + Incompatible |= SExt | ZExt; - if (!isa<PointerType>(Ty)) - Incompatible |= PointerTypeOnly; - else if (attrs & ParamAttr::ByVal) { - const PointerType *PTy = cast<PointerType>(Ty); + if (const PointerType *PTy = dyn_cast<PointerType>(Ty)) { if (!isa<StructType>(PTy->getElementType())) + // Attributes that only apply to pointers to structs. Incompatible |= ParamAttr::ByVal; + } else { + // Attributes that only apply to pointers. + Incompatible |= ByVal | Nest | NoAlias | StructRet; } - return attrs & Incompatible; + return Incompatible; } Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=45704&r1=45703&r2=45704&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Jan 7 11:16:06 2008 @@ -418,10 +418,10 @@ Attrs->getParamAttrsText(MutI) + "are incompatible!", V); } - uint16_t IType = ParamAttr::incompatibleWithType(FT->getParamType(Idx-1), - Attr); - Assert1(!IType, "Wrong type for attribute " + - Attrs->getParamAttrsText(IType), V); + uint16_t TypeI = + Attr & ParamAttr::typeIncompatible(FT->getParamType(Idx-1)); + Assert1(!TypeI, "Wrong type for attribute " + + Attrs->getParamAttrsText(TypeI), V); if (Attr & ParamAttr::Nest) { Assert1(!SawNest, "More than one parameter has attribute nest!", V); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits