summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-01-07 17:16:06 +0000
committerDuncan Sands <baldrick@free.fr>2008-01-07 17:16:06 +0000
commit6c3470efdc59245707c56ad92ab8355afdac2c62 (patch)
tree77b2dcecfd33686814466ce48d121cbdb6f37217 /lib
parent30d15751c8f9d905c1402d9ff84acdcb2265bb8c (diff)
downloadllvm-6c3470efdc59245707c56ad92ab8355afdac2c62.tar.gz
llvm-6c3470efdc59245707c56ad92ab8355afdac2c62.tar.bz2
llvm-6c3470efdc59245707c56ad92ab8355afdac2c62.tar.xz
Small cleanup for handling of type/parameter attribute
incompatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45704 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp4
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp19
-rw-r--r--lib/VMCore/ParameterAttributes.cpp16
-rw-r--r--lib/VMCore/Verifier.cpp8
4 files changed, 26 insertions, 21 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 8e6a3b91c1..3550d71352 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -505,7 +505,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
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 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
// 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));
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 3d37bcd589..19f86f9b9c 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -8097,10 +8097,11 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
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 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
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 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// 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)
diff --git a/lib/VMCore/ParameterAttributes.cpp b/lib/VMCore/ParameterAttributes.cpp
index 840d54b632..77a2a6e7fe 100644
--- a/lib/VMCore/ParameterAttributes.cpp
+++ b/lib/VMCore/ParameterAttributes.cpp
@@ -186,19 +186,21 @@ ParamAttrsList::excludeAttrs(const ParamAttrsList *PAL,
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;
}
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 95f871be33..0f7852d411 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -418,10 +418,10 @@ void Verifier::VerifyParamAttrs(const FunctionType *FT,
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);