mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Remove some introspection functions.
The 'getSlot' function and its ilk allow introspection into the AttributeSet class. However, that class should be opaque. Allow access through accessor methods instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173522 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -146,20 +146,6 @@ public:
|
|||||||
|
|
||||||
uint64_t Raw() const;
|
uint64_t Raw() const;
|
||||||
|
|
||||||
/// \brief Which attributes cannot be applied to a type.
|
|
||||||
static Attribute typeIncompatible(Type *Ty);
|
|
||||||
|
|
||||||
/// \brief This returns an integer containing an encoding of all the LLVM
|
|
||||||
/// attributes found in the given attribute bitset. Any change to this
|
|
||||||
/// encoding is a breaking change to bitcode compatibility.
|
|
||||||
static uint64_t encodeLLVMAttributesForBitcode(Attribute Attrs);
|
|
||||||
|
|
||||||
/// \brief This returns an attribute bitset containing the LLVM attributes
|
|
||||||
/// that have been decoded from the given integer. This function must stay in
|
|
||||||
/// sync with 'encodeLLVMAttributesForBitcode'.
|
|
||||||
static Attribute decodeLLVMAttributesForBitcode(LLVMContext &C,
|
|
||||||
uint64_t EncodedAttrs);
|
|
||||||
|
|
||||||
/// \brief The Attribute is converted to a string of equivalent mnemonic. This
|
/// \brief The Attribute is converted to a string of equivalent mnemonic. This
|
||||||
/// is, presumably, for writing out the mnemonics for the assembly writer.
|
/// is, presumably, for writing out the mnemonics for the assembly writer.
|
||||||
std::string getAsString() const;
|
std::string getAsString() const;
|
||||||
@ -236,6 +222,7 @@ public:
|
|||||||
|
|
||||||
/// \brief Return an AttributeSet with the specified parameters in it.
|
/// \brief Return an AttributeSet with the specified parameters in it.
|
||||||
static AttributeSet get(LLVMContext &C, ArrayRef<AttributeWithIndex> Attrs);
|
static AttributeSet get(LLVMContext &C, ArrayRef<AttributeWithIndex> Attrs);
|
||||||
|
static AttributeSet get(LLVMContext &C, ArrayRef<AttributeSet> Attrs);
|
||||||
static AttributeSet get(LLVMContext &C, unsigned Idx,
|
static AttributeSet get(LLVMContext &C, unsigned Idx,
|
||||||
Attribute::AttrKind Kind);
|
Attribute::AttrKind Kind);
|
||||||
static AttributeSet get(LLVMContext &C, unsigned Idx, AttrBuilder &B);
|
static AttributeSet get(LLVMContext &C, unsigned Idx, AttrBuilder &B);
|
||||||
@ -296,6 +283,10 @@ public:
|
|||||||
/// \brief Return true if attribute exists at the given index.
|
/// \brief Return true if attribute exists at the given index.
|
||||||
bool hasAttributes(unsigned Index) const;
|
bool hasAttributes(unsigned Index) const;
|
||||||
|
|
||||||
|
/// \brief Returns the alignment field of an attribute as a byte alignment
|
||||||
|
/// value.
|
||||||
|
unsigned getAlignment(unsigned Index) const;
|
||||||
|
|
||||||
/// \brief Get the stack alignment.
|
/// \brief Get the stack alignment.
|
||||||
unsigned getStackAlignment(unsigned Index) const;
|
unsigned getStackAlignment(unsigned Index) const;
|
||||||
|
|
||||||
@ -342,6 +333,9 @@ public:
|
|||||||
/// \brief Return the index for the given slot.
|
/// \brief Return the index for the given slot.
|
||||||
unsigned getSlotIndex(unsigned Slot) const;
|
unsigned getSlotIndex(unsigned Slot) const;
|
||||||
|
|
||||||
|
/// \brief Return the attributes at the given slot.
|
||||||
|
AttributeSet getSlotAttributes(unsigned Slot) const;
|
||||||
|
|
||||||
/// \brief Return the AttributeWithIndex at the specified slot. This holds a
|
/// \brief Return the AttributeWithIndex at the specified slot. This holds a
|
||||||
/// index number plus a set of attributes.
|
/// index number plus a set of attributes.
|
||||||
const AttributeWithIndex &getSlot(unsigned Slot) const;
|
const AttributeWithIndex &getSlot(unsigned Slot) const;
|
||||||
@ -479,6 +473,24 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace AttributeFuncs {
|
||||||
|
|
||||||
|
/// \brief Which attributes cannot be applied to a type.
|
||||||
|
Attribute typeIncompatible(Type *Ty);
|
||||||
|
|
||||||
|
/// \brief This returns an integer containing an encoding of all the LLVM
|
||||||
|
/// attributes found in the given attribute bitset. Any change to this encoding
|
||||||
|
/// is a breaking change to bitcode compatibility.
|
||||||
|
uint64_t encodeLLVMAttributesForBitcode(AttributeSet Attrs, unsigned Index);
|
||||||
|
|
||||||
|
/// \brief This returns an attribute bitset containing the LLVM attributes that
|
||||||
|
/// have been decoded from the given integer. This function must stay in sync
|
||||||
|
/// with 'encodeLLVMAttributesForBitcode'.
|
||||||
|
Attribute decodeLLVMAttributesForBitcode(LLVMContext &C,
|
||||||
|
uint64_t EncodedAttrs);
|
||||||
|
|
||||||
|
} // end AttributeFuncs namespace
|
||||||
|
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -465,7 +465,7 @@ bool BitcodeReader::ParseAttributeBlock() {
|
|||||||
|
|
||||||
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
for (unsigned i = 0, e = Record.size(); i != e; i += 2) {
|
||||||
Attribute ReconstitutedAttr =
|
Attribute ReconstitutedAttr =
|
||||||
Attribute::decodeLLVMAttributesForBitcode(Context, Record[i+1]);
|
AttributeFuncs::decodeLLVMAttributesForBitcode(Context, Record[i+1]);
|
||||||
Record[i+1] = ReconstitutedAttr.Raw();
|
Record[i+1] = ReconstitutedAttr.Raw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,9 +173,11 @@ static void WriteAttributeTable(const ValueEnumerator &VE,
|
|||||||
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
|
||||||
const AttributeSet &A = Attrs[i];
|
const AttributeSet &A = Attrs[i];
|
||||||
for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
|
for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i) {
|
||||||
const AttributeWithIndex &PAWI = A.getSlot(i);
|
unsigned Index = A.getSlotIndex(i);
|
||||||
Record.push_back(A.getSlotIndex(i));
|
Record.push_back(Index);
|
||||||
Record.push_back(Attribute::encodeLLVMAttributesForBitcode(PAWI.Attrs));
|
Record.push_back(AttributeFuncs::
|
||||||
|
encodeLLVMAttributesForBitcode(A.getSlotAttributes(i),
|
||||||
|
Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
|
Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
|
||||||
|
@ -104,6 +104,8 @@ public:
|
|||||||
/// \brief This class represents a set of attributes that apply to the function,
|
/// \brief This class represents a set of attributes that apply to the function,
|
||||||
/// return type, and parameters.
|
/// return type, and parameters.
|
||||||
class AttributeSetImpl : public FoldingSetNode {
|
class AttributeSetImpl : public FoldingSetNode {
|
||||||
|
friend class AttributeSet;
|
||||||
|
|
||||||
LLVMContext &Context;
|
LLVMContext &Context;
|
||||||
SmallVector<AttributeWithIndex, 4> AttrList;
|
SmallVector<AttributeWithIndex, 4> AttrList;
|
||||||
|
|
||||||
@ -126,6 +128,10 @@ public:
|
|||||||
// FIXME: This needs to use AttrNodes instead.
|
// FIXME: This needs to use AttrNodes instead.
|
||||||
return AttrList[Slot].Index;
|
return AttrList[Slot].Index;
|
||||||
}
|
}
|
||||||
|
AttributeSet getSlotAttributes(unsigned Slot) const {
|
||||||
|
// FIXME: This needs to use AttrNodes instead.
|
||||||
|
return AttributeSet::get(Context, AttrList[Slot]);
|
||||||
|
}
|
||||||
|
|
||||||
void Profile(FoldingSetNodeID &ID) const {
|
void Profile(FoldingSetNodeID &ID) const {
|
||||||
Profile(ID, AttrList);
|
Profile(ID, AttrList);
|
||||||
|
@ -103,63 +103,6 @@ uint64_t Attribute::Raw() const {
|
|||||||
return pImpl ? pImpl->Raw() : 0;
|
return pImpl ? pImpl->Raw() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attribute Attribute::typeIncompatible(Type *Ty) {
|
|
||||||
AttrBuilder Incompatible;
|
|
||||||
|
|
||||||
if (!Ty->isIntegerTy())
|
|
||||||
// Attribute that only apply to integers.
|
|
||||||
Incompatible.addAttribute(Attribute::SExt)
|
|
||||||
.addAttribute(Attribute::ZExt);
|
|
||||||
|
|
||||||
if (!Ty->isPointerTy())
|
|
||||||
// Attribute that only apply to pointers.
|
|
||||||
Incompatible.addAttribute(Attribute::ByVal)
|
|
||||||
.addAttribute(Attribute::Nest)
|
|
||||||
.addAttribute(Attribute::NoAlias)
|
|
||||||
.addAttribute(Attribute::NoCapture)
|
|
||||||
.addAttribute(Attribute::StructRet);
|
|
||||||
|
|
||||||
return Attribute::get(Ty->getContext(), Incompatible);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// encodeLLVMAttributesForBitcode - This returns an integer containing an
|
|
||||||
/// encoding of all the LLVM attributes found in the given attribute bitset.
|
|
||||||
/// Any change to this encoding is a breaking change to bitcode compatibility.
|
|
||||||
uint64_t Attribute::encodeLLVMAttributesForBitcode(Attribute Attrs) {
|
|
||||||
// FIXME: It doesn't make sense to store the alignment information as an
|
|
||||||
// expanded out value, we should store it as a log2 value. However, we can't
|
|
||||||
// just change that here without breaking bitcode compatibility. If this ever
|
|
||||||
// becomes a problem in practice, we should introduce new tag numbers in the
|
|
||||||
// bitcode file and have those tags use a more efficiently encoded alignment
|
|
||||||
// field.
|
|
||||||
|
|
||||||
// Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
|
|
||||||
// log2 encoded value. Shift the bits above the alignment up by 11 bits.
|
|
||||||
uint64_t EncodedAttrs = Attrs.Raw() & 0xffff;
|
|
||||||
if (Attrs.hasAttribute(Attribute::Alignment))
|
|
||||||
EncodedAttrs |= Attrs.getAlignment() << 16;
|
|
||||||
EncodedAttrs |= (Attrs.Raw() & (0xffffULL << 21)) << 11;
|
|
||||||
return EncodedAttrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
|
|
||||||
/// the LLVM attributes that have been decoded from the given integer. This
|
|
||||||
/// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
|
|
||||||
Attribute Attribute::decodeLLVMAttributesForBitcode(LLVMContext &C,
|
|
||||||
uint64_t EncodedAttrs) {
|
|
||||||
// The alignment is stored as a 16-bit raw value from bits 31--16. We shift
|
|
||||||
// the bits above 31 down by 11 bits.
|
|
||||||
unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
|
|
||||||
assert((!Alignment || isPowerOf2_32(Alignment)) &&
|
|
||||||
"Alignment must be a power of two.");
|
|
||||||
|
|
||||||
AttrBuilder B(EncodedAttrs & 0xffff);
|
|
||||||
if (Alignment)
|
|
||||||
B.addAlignmentAttr(Alignment);
|
|
||||||
B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
|
|
||||||
return Attribute::get(C, B);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Attribute::getAsString() const {
|
std::string Attribute::getAsString() const {
|
||||||
std::string Result;
|
std::string Result;
|
||||||
if (hasAttribute(Attribute::ZExt))
|
if (hasAttribute(Attribute::ZExt))
|
||||||
@ -666,6 +609,18 @@ AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx,
|
|||||||
return get(C, AttributeWithIndex::get(Idx, Attribute::get(C, Kind)));
|
return get(C, AttributeWithIndex::get(Idx, Attribute::get(C, Kind)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef<AttributeSet> Attrs) {
|
||||||
|
SmallVector<AttributeWithIndex, 8> AttrList;
|
||||||
|
for (ArrayRef<AttributeSet>::iterator I = Attrs.begin(), E = Attrs.end();
|
||||||
|
I != E; ++I) {
|
||||||
|
AttributeSet AS = *I;
|
||||||
|
if (!AS.AttrList) continue;
|
||||||
|
AttrList.append(AS.AttrList->AttrList.begin(), AS.AttrList->AttrList.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
return get(C, AttrList);
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// AttributeSet Method Implementations
|
// AttributeSet Method Implementations
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -688,6 +643,12 @@ unsigned AttributeSet::getSlotIndex(unsigned Slot) const {
|
|||||||
return AttrList->getSlotIndex(Slot);
|
return AttrList->getSlotIndex(Slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AttributeSet AttributeSet::getSlotAttributes(unsigned Slot) const {
|
||||||
|
assert(AttrList && Slot < AttrList->getNumAttributes() &&
|
||||||
|
"Slot # out of range!");
|
||||||
|
return AttrList->getSlotAttributes(Slot);
|
||||||
|
}
|
||||||
|
|
||||||
/// getSlot - Return the AttributeWithIndex at the specified slot. This
|
/// getSlot - Return the AttributeWithIndex at the specified slot. This
|
||||||
/// holds a number plus a set of attributes.
|
/// holds a number plus a set of attributes.
|
||||||
const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
|
const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
|
||||||
@ -859,3 +820,66 @@ void AttributeSet::dump() const {
|
|||||||
|
|
||||||
dbgs() << "]\n";
|
dbgs() << "]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// AttributeFuncs Function Defintions
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
Attribute AttributeFuncs::typeIncompatible(Type *Ty) {
|
||||||
|
AttrBuilder Incompatible;
|
||||||
|
|
||||||
|
if (!Ty->isIntegerTy())
|
||||||
|
// Attribute that only apply to integers.
|
||||||
|
Incompatible.addAttribute(Attribute::SExt)
|
||||||
|
.addAttribute(Attribute::ZExt);
|
||||||
|
|
||||||
|
if (!Ty->isPointerTy())
|
||||||
|
// Attribute that only apply to pointers.
|
||||||
|
Incompatible.addAttribute(Attribute::ByVal)
|
||||||
|
.addAttribute(Attribute::Nest)
|
||||||
|
.addAttribute(Attribute::NoAlias)
|
||||||
|
.addAttribute(Attribute::NoCapture)
|
||||||
|
.addAttribute(Attribute::StructRet);
|
||||||
|
|
||||||
|
return Attribute::get(Ty->getContext(), Incompatible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// encodeLLVMAttributesForBitcode - This returns an integer containing an
|
||||||
|
/// encoding of all the LLVM attributes found in the given attribute bitset.
|
||||||
|
/// Any change to this encoding is a breaking change to bitcode compatibility.
|
||||||
|
uint64_t AttributeFuncs::encodeLLVMAttributesForBitcode(AttributeSet Attrs,
|
||||||
|
unsigned Index) {
|
||||||
|
// FIXME: It doesn't make sense to store the alignment information as an
|
||||||
|
// expanded out value, we should store it as a log2 value. However, we can't
|
||||||
|
// just change that here without breaking bitcode compatibility. If this ever
|
||||||
|
// becomes a problem in practice, we should introduce new tag numbers in the
|
||||||
|
// bitcode file and have those tags use a more efficiently encoded alignment
|
||||||
|
// field.
|
||||||
|
|
||||||
|
// Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
|
||||||
|
// log2 encoded value. Shift the bits above the alignment up by 11 bits.
|
||||||
|
uint64_t EncodedAttrs = Attrs.Raw(Index) & 0xffff;
|
||||||
|
if (Attrs.hasAttribute(Index, Attribute::Alignment))
|
||||||
|
EncodedAttrs |= Attrs.getParamAlignment(Index) << 16;
|
||||||
|
EncodedAttrs |= (Attrs.Raw(Index) & (0xffffULL << 21)) << 11;
|
||||||
|
return EncodedAttrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
|
||||||
|
/// the LLVM attributes that have been decoded from the given integer. This
|
||||||
|
/// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
|
||||||
|
Attribute AttributeFuncs::decodeLLVMAttributesForBitcode(LLVMContext &C,
|
||||||
|
uint64_t EncodedAttrs){
|
||||||
|
// The alignment is stored as a 16-bit raw value from bits 31--16. We shift
|
||||||
|
// the bits above 31 down by 11 bits.
|
||||||
|
unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
|
||||||
|
assert((!Alignment || isPowerOf2_32(Alignment)) &&
|
||||||
|
"Alignment must be a power of two.");
|
||||||
|
|
||||||
|
AttrBuilder B(EncodedAttrs & 0xffff);
|
||||||
|
if (Alignment)
|
||||||
|
B.addAlignmentAttr(Alignment);
|
||||||
|
B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
|
||||||
|
return Attribute::get(C, B);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -693,9 +693,9 @@ void Verifier::VerifyParameterAttrs(AttributeSet Attrs, uint64_t Idx, Type *Ty,
|
|||||||
"'noinline and alwaysinline' are incompatible!", V);
|
"'noinline and alwaysinline' are incompatible!", V);
|
||||||
|
|
||||||
Assert1(!AttrBuilder(Attrs, Idx).
|
Assert1(!AttrBuilder(Attrs, Idx).
|
||||||
hasAttributes(Attribute::typeIncompatible(Ty)),
|
hasAttributes(AttributeFuncs::typeIncompatible(Ty)),
|
||||||
"Wrong types for attribute: " +
|
"Wrong types for attribute: " +
|
||||||
Attribute::typeIncompatible(Ty).getAsString(), V);
|
AttributeFuncs::typeIncompatible(Ty).getAsString(), V);
|
||||||
|
|
||||||
if (PointerType *PTy = dyn_cast<PointerType>(Ty))
|
if (PointerType *PTy = dyn_cast<PointerType>(Ty))
|
||||||
Assert1(!Attrs.hasAttribute(Idx, Attribute::ByVal) ||
|
Assert1(!Attrs.hasAttribute(Idx, Attribute::ByVal) ||
|
||||||
|
@ -474,7 +474,7 @@ void CppWriter::printAttributes(const AttributeSet &PAL,
|
|||||||
Out << "AttributeWithIndex PAWI;"; nl(Out);
|
Out << "AttributeWithIndex PAWI;"; nl(Out);
|
||||||
for (unsigned i = 0; i < PAL.getNumSlots(); ++i) {
|
for (unsigned i = 0; i < PAL.getNumSlots(); ++i) {
|
||||||
unsigned index = PAL.getSlotIndex(i);
|
unsigned index = PAL.getSlotIndex(i);
|
||||||
AttrBuilder attrs(PAL.getSlot(i).Attrs);
|
AttrBuilder attrs(PAL.getSlotAttributes(i), index);
|
||||||
Out << "PAWI.Index = " << index << "U;\n";
|
Out << "PAWI.Index = " << index << "U;\n";
|
||||||
Out << " {\n AttrBuilder B;\n";
|
Out << " {\n AttrBuilder B;\n";
|
||||||
|
|
||||||
|
@ -273,13 +273,15 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
|||||||
// Drop any attributes that were on the vararg arguments.
|
// Drop any attributes that were on the vararg arguments.
|
||||||
AttributeSet PAL = CS.getAttributes();
|
AttributeSet PAL = CS.getAttributes();
|
||||||
if (!PAL.isEmpty() && PAL.getSlotIndex(PAL.getNumSlots() - 1) > NumArgs) {
|
if (!PAL.isEmpty() && PAL.getSlotIndex(PAL.getNumSlots() - 1) > NumArgs) {
|
||||||
SmallVector<AttributeWithIndex, 8> AttributesVec;
|
SmallVector<AttributeSet, 8> AttributesVec;
|
||||||
for (unsigned i = 0; PAL.getSlotIndex(i) <= NumArgs; ++i)
|
for (unsigned i = 0; PAL.getSlotIndex(i) <= NumArgs; ++i)
|
||||||
AttributesVec.push_back(PAL.getSlot(i));
|
AttributesVec.push_back(PAL.getSlotAttributes(i));
|
||||||
if (PAL.hasAttributes(AttributeSet::FunctionIndex))
|
if (PAL.hasAttributes(AttributeSet::FunctionIndex))
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(Fn.getContext(),
|
AttributesVec.push_back(
|
||||||
|
AttributeSet::get(Fn.getContext(),
|
||||||
|
AttributeWithIndex::get(Fn.getContext(),
|
||||||
AttributeSet::FunctionIndex,
|
AttributeSet::FunctionIndex,
|
||||||
PAL.getFnAttributes()));
|
PAL.getFnAttributes())));
|
||||||
PAL = AttributeSet::get(Fn.getContext(), AttributesVec);
|
PAL = AttributeSet::get(Fn.getContext(), AttributesVec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,10 +767,10 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
RAttrs =
|
RAttrs =
|
||||||
AttributeSet::get(NRetTy->getContext(), AttributeSet::ReturnIndex,
|
AttributeSet::get(NRetTy->getContext(), AttributeSet::ReturnIndex,
|
||||||
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
||||||
removeAttributes(Attribute::typeIncompatible(NRetTy)));
|
removeAttributes(AttributeFuncs::typeIncompatible(NRetTy)));
|
||||||
else
|
else
|
||||||
assert(!AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
assert(!AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
||||||
hasAttributes(Attribute::typeIncompatible(NRetTy)) &&
|
hasAttributes(AttributeFuncs::typeIncompatible(NRetTy)) &&
|
||||||
"Return attributes no longer compatible?");
|
"Return attributes no longer compatible?");
|
||||||
|
|
||||||
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
|
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
|
||||||
@ -846,7 +848,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
RAttrs =
|
RAttrs =
|
||||||
AttributeSet::get(NF->getContext(), AttributeSet::ReturnIndex,
|
AttributeSet::get(NF->getContext(), AttributeSet::ReturnIndex,
|
||||||
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
||||||
removeAttributes(Attribute::typeIncompatible(NF->getReturnType())));
|
removeAttributes(AttributeFuncs::typeIncompatible(NF->getReturnType())));
|
||||||
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
|
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(NF->getContext(),
|
AttributesVec.push_back(AttributeWithIndex::get(NF->getContext(),
|
||||||
AttributeSet::ReturnIndex,
|
AttributeSet::ReturnIndex,
|
||||||
|
@ -2068,11 +2068,12 @@ static void ChangeCalleesToFastCall(Function *F) {
|
|||||||
|
|
||||||
static AttributeSet StripNest(LLVMContext &C, const AttributeSet &Attrs) {
|
static AttributeSet StripNest(LLVMContext &C, const AttributeSet &Attrs) {
|
||||||
for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
|
for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
|
||||||
if (!Attrs.getSlot(i).Attrs.hasAttribute(Attribute::Nest))
|
unsigned Index = Attrs.getSlotIndex(i);
|
||||||
|
if (!Attrs.getSlotAttributes(i).hasAttribute(Index, Attribute::Nest))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// There can be only one.
|
// There can be only one.
|
||||||
return Attrs.removeAttribute(C, Attrs.getSlotIndex(i), Attribute::Nest);
|
return Attrs.removeAttribute(C, Index, Attribute::Nest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Attrs;
|
return Attrs;
|
||||||
|
@ -1015,7 +1015,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
|
|
||||||
if (!CallerPAL.isEmpty() && !Caller->use_empty()) {
|
if (!CallerPAL.isEmpty() && !Caller->use_empty()) {
|
||||||
AttrBuilder RAttrs(CallerPAL, AttributeSet::ReturnIndex);
|
AttrBuilder RAttrs(CallerPAL, AttributeSet::ReturnIndex);
|
||||||
if (RAttrs.hasAttributes(Attribute::typeIncompatible(NewRetTy)))
|
if (RAttrs.hasAttributes(AttributeFuncs::typeIncompatible(NewRetTy)))
|
||||||
return false; // Attribute not compatible with transformed value.
|
return false; // Attribute not compatible with transformed value.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1045,7 +1045,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
return false; // Cannot transform this parameter value.
|
return false; // Cannot transform this parameter value.
|
||||||
|
|
||||||
if (AttrBuilder(CallerPAL.getParamAttributes(i + 1), i + 1).
|
if (AttrBuilder(CallerPAL.getParamAttributes(i + 1), i + 1).
|
||||||
hasAttributes(Attribute::typeIncompatible(ParamTy)))
|
hasAttributes(AttributeFuncs::typeIncompatible(ParamTy)))
|
||||||
return false; // Attribute not compatible with transformed value.
|
return false; // Attribute not compatible with transformed value.
|
||||||
|
|
||||||
// If the parameter is passed as a byval argument, then we have to have a
|
// If the parameter is passed as a byval argument, then we have to have a
|
||||||
@ -1101,11 +1101,13 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
// won't be dropping them. Check that these extra arguments have attributes
|
// won't be dropping them. Check that these extra arguments have attributes
|
||||||
// that are compatible with being a vararg call argument.
|
// that are compatible with being a vararg call argument.
|
||||||
for (unsigned i = CallerPAL.getNumSlots(); i; --i) {
|
for (unsigned i = CallerPAL.getNumSlots(); i; --i) {
|
||||||
if (CallerPAL.getSlotIndex(i - 1) <= FT->getNumParams())
|
unsigned Index = CallerPAL.getSlotIndex(i - 1);
|
||||||
|
if (Index <= FT->getNumParams())
|
||||||
break;
|
break;
|
||||||
Attribute PAttrs = CallerPAL.getSlot(i - 1).Attrs;
|
|
||||||
// Check if it has an attribute that's incompatible with varargs.
|
// Check if it has an attribute that's incompatible with varargs.
|
||||||
if (PAttrs.hasAttribute(Attribute::StructRet))
|
AttributeSet PAttrs = CallerPAL.getSlotAttributes(i - 1);
|
||||||
|
if (PAttrs.hasAttribute(Index, Attribute::StructRet))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,7 +1124,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
|
|
||||||
// If the return value is not being used, the type may not be compatible
|
// If the return value is not being used, the type may not be compatible
|
||||||
// with the existing attributes. Wipe out any problematic attributes.
|
// with the existing attributes. Wipe out any problematic attributes.
|
||||||
RAttrs.removeAttributes(Attribute::typeIncompatible(NewRetTy));
|
RAttrs.removeAttributes(AttributeFuncs::typeIncompatible(NewRetTy));
|
||||||
|
|
||||||
// Add the new return attributes.
|
// Add the new return attributes.
|
||||||
if (RAttrs.hasAttributes())
|
if (RAttrs.hasAttributes())
|
||||||
|
Reference in New Issue
Block a user