mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Add an enum for the return and function indexes into the AttrListPtr object. This gets rid of some magic numbers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165924 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ad4643f54b
commit
07aae2e7d5
@ -330,6 +330,12 @@ class AttributeListImpl;
|
|||||||
/// AttrListPtr - This class manages the ref count for the opaque
|
/// AttrListPtr - This class manages the ref count for the opaque
|
||||||
/// AttributeListImpl object and provides accessors for it.
|
/// AttributeListImpl object and provides accessors for it.
|
||||||
class AttrListPtr {
|
class AttrListPtr {
|
||||||
|
public:
|
||||||
|
enum AttrIndex {
|
||||||
|
ReturnIndex = 0U,
|
||||||
|
FunctionIndex = ~0U
|
||||||
|
};
|
||||||
|
private:
|
||||||
/// AttrList - The attributes that we are managing. This can be null
|
/// AttrList - The attributes that we are managing. This can be null
|
||||||
/// to represent the empty attributes list.
|
/// to represent the empty attributes list.
|
||||||
AttributeListImpl *AttrList;
|
AttributeListImpl *AttrList;
|
||||||
@ -368,12 +374,12 @@ public:
|
|||||||
/// getRetAttributes - The attributes for the ret value are
|
/// getRetAttributes - The attributes for the ret value are
|
||||||
/// returned.
|
/// returned.
|
||||||
Attributes getRetAttributes() const {
|
Attributes getRetAttributes() const {
|
||||||
return getAttributes(0);
|
return getAttributes(ReturnIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getFnAttributes - The function attributes are returned.
|
/// getFnAttributes - The function attributes are returned.
|
||||||
Attributes getFnAttributes() const {
|
Attributes getFnAttributes() const {
|
||||||
return getAttributes(~0U);
|
return getAttributes(FunctionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// paramHasAttr - Return true if the specified parameter index has the
|
/// paramHasAttr - Return true if the specified parameter index has the
|
||||||
|
@ -1274,7 +1274,7 @@ public:
|
|||||||
void setIsNoInline() {
|
void setIsNoInline() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoInline);
|
B.addAttribute(Attributes::NoInline);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Return true if the call can return twice
|
/// @brief Return true if the call can return twice
|
||||||
@ -1284,7 +1284,7 @@ public:
|
|||||||
void setCanReturnTwice() {
|
void setCanReturnTwice() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReturnsTwice);
|
B.addAttribute(Attributes::ReturnsTwice);
|
||||||
addAttribute(~0U, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access memory.
|
/// @brief Determine if the call does not access memory.
|
||||||
@ -1294,7 +1294,7 @@ public:
|
|||||||
void setDoesNotAccessMemory() {
|
void setDoesNotAccessMemory() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadNone);
|
B.addAttribute(Attributes::ReadNone);
|
||||||
addAttribute(~0U, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access or only reads memory.
|
/// @brief Determine if the call does not access or only reads memory.
|
||||||
@ -1304,7 +1304,7 @@ public:
|
|||||||
void setOnlyReadsMemory() {
|
void setOnlyReadsMemory() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadOnly);
|
B.addAttribute(Attributes::ReadOnly);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot return.
|
/// @brief Determine if the call cannot return.
|
||||||
@ -1312,7 +1312,7 @@ public:
|
|||||||
void setDoesNotReturn() {
|
void setDoesNotReturn() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoReturn);
|
B.addAttribute(Attributes::NoReturn);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot unwind.
|
/// @brief Determine if the call cannot unwind.
|
||||||
@ -1320,7 +1320,7 @@ public:
|
|||||||
void setDoesNotThrow() {
|
void setDoesNotThrow() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call returns a structure through first
|
/// @brief Determine if the call returns a structure through first
|
||||||
@ -3029,7 +3029,7 @@ public:
|
|||||||
void setIsNoInline() {
|
void setIsNoInline() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoInline);
|
B.addAttribute(Attributes::NoInline);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access memory.
|
/// @brief Determine if the call does not access memory.
|
||||||
@ -3039,7 +3039,7 @@ public:
|
|||||||
void setDoesNotAccessMemory() {
|
void setDoesNotAccessMemory() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadNone);
|
B.addAttribute(Attributes::ReadNone);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call does not access or only reads memory.
|
/// @brief Determine if the call does not access or only reads memory.
|
||||||
@ -3049,7 +3049,7 @@ public:
|
|||||||
void setOnlyReadsMemory() {
|
void setOnlyReadsMemory() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadOnly);
|
B.addAttribute(Attributes::ReadOnly);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot return.
|
/// @brief Determine if the call cannot return.
|
||||||
@ -3057,7 +3057,7 @@ public:
|
|||||||
void setDoesNotReturn() {
|
void setDoesNotReturn() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoReturn);
|
B.addAttribute(Attributes::NoReturn);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call cannot unwind.
|
/// @brief Determine if the call cannot unwind.
|
||||||
@ -3065,7 +3065,7 @@ public:
|
|||||||
void setDoesNotThrow() {
|
void setDoesNotThrow() {
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
addAttribute(~0, Attributes::get(getContext(), B));
|
addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Determine if the call returns a structure through first
|
/// @brief Determine if the call returns a structure through first
|
||||||
|
@ -2771,9 +2771,10 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
|||||||
SmallVector<AttributeWithIndex, 8> Attrs;
|
SmallVector<AttributeWithIndex, 8> Attrs;
|
||||||
|
|
||||||
if (RetAttrs.hasAttributes())
|
if (RetAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(0,
|
Attrs.push_back(
|
||||||
Attributes::get(RetType->getContext(),
|
AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
RetAttrs)));
|
Attributes::get(RetType->getContext(),
|
||||||
|
RetAttrs)));
|
||||||
|
|
||||||
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
|
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
|
||||||
ParamTypeList.push_back(ArgList[i].Ty);
|
ParamTypeList.push_back(ArgList[i].Ty);
|
||||||
@ -2782,9 +2783,10 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FuncAttrs.hasAttributes())
|
if (FuncAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(~0,
|
Attrs.push_back(
|
||||||
Attributes::get(RetType->getContext(),
|
AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
FuncAttrs)));
|
Attributes::get(RetType->getContext(),
|
||||||
|
FuncAttrs)));
|
||||||
|
|
||||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||||
|
|
||||||
@ -3306,9 +3308,10 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
|
|||||||
// Set up the Attributes for the function.
|
// Set up the Attributes for the function.
|
||||||
SmallVector<AttributeWithIndex, 8> Attrs;
|
SmallVector<AttributeWithIndex, 8> Attrs;
|
||||||
if (RetAttrs.hasAttributes())
|
if (RetAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(0,
|
Attrs.push_back(
|
||||||
Attributes::get(Callee->getContext(),
|
AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
RetAttrs)));
|
Attributes::get(Callee->getContext(),
|
||||||
|
RetAttrs)));
|
||||||
|
|
||||||
SmallVector<Value*, 8> Args;
|
SmallVector<Value*, 8> Args;
|
||||||
|
|
||||||
@ -3336,9 +3339,10 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
|
|||||||
return Error(CallLoc, "not enough parameters specified for call");
|
return Error(CallLoc, "not enough parameters specified for call");
|
||||||
|
|
||||||
if (FnAttrs.hasAttributes())
|
if (FnAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(~0,
|
Attrs.push_back(
|
||||||
Attributes::get(Callee->getContext(),
|
AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
FnAttrs)));
|
Attributes::get(Callee->getContext(),
|
||||||
|
FnAttrs)));
|
||||||
|
|
||||||
// Finish off the Attributes and check them
|
// Finish off the Attributes and check them
|
||||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||||
@ -3706,9 +3710,10 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
|||||||
// Set up the Attributes for the function.
|
// Set up the Attributes for the function.
|
||||||
SmallVector<AttributeWithIndex, 8> Attrs;
|
SmallVector<AttributeWithIndex, 8> Attrs;
|
||||||
if (RetAttrs.hasAttributes())
|
if (RetAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(0,
|
Attrs.push_back(
|
||||||
Attributes::get(Callee->getContext(),
|
AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
RetAttrs)));
|
Attributes::get(Callee->getContext(),
|
||||||
|
RetAttrs)));
|
||||||
|
|
||||||
SmallVector<Value*, 8> Args;
|
SmallVector<Value*, 8> Args;
|
||||||
|
|
||||||
@ -3736,9 +3741,10 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
|||||||
return Error(CallLoc, "not enough parameters specified for call");
|
return Error(CallLoc, "not enough parameters specified for call");
|
||||||
|
|
||||||
if (FnAttrs.hasAttributes())
|
if (FnAttrs.hasAttributes())
|
||||||
Attrs.push_back(AttributeWithIndex::get(~0,
|
Attrs.push_back(
|
||||||
Attributes::get(Callee->getContext(),
|
AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
FnAttrs)));
|
Attributes::get(Callee->getContext(),
|
||||||
|
FnAttrs)));
|
||||||
|
|
||||||
// Finish off the Attributes and check them
|
// Finish off the Attributes and check them
|
||||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||||
|
@ -520,7 +520,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
// Add any return attributes.
|
// Add any return attributes.
|
||||||
Attributes attrs = PAL.getRetAttributes();
|
Attributes attrs = PAL.getRetAttributes();
|
||||||
if (attrs.hasAttributes())
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
|
attrs));
|
||||||
|
|
||||||
// First, determine the new argument list
|
// First, determine the new argument list
|
||||||
unsigned ArgIndex = 1;
|
unsigned ArgIndex = 1;
|
||||||
@ -592,7 +593,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
// Add any function attributes.
|
// Add any function attributes.
|
||||||
attrs = PAL.getFnAttributes();
|
attrs = PAL.getFnAttributes();
|
||||||
if (attrs.hasAttributes())
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
|
attrs));
|
||||||
|
|
||||||
Type *RetTy = FTy->getReturnType();
|
Type *RetTy = FTy->getReturnType();
|
||||||
|
|
||||||
@ -639,7 +641,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
// Add any return attributes.
|
// Add any return attributes.
|
||||||
Attributes attrs = CallPAL.getRetAttributes();
|
Attributes attrs = CallPAL.getRetAttributes();
|
||||||
if (attrs.hasAttributes())
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
|
attrs));
|
||||||
|
|
||||||
// Loop over the operands, inserting GEP and loads in the caller as
|
// Loop over the operands, inserting GEP and loads in the caller as
|
||||||
// appropriate.
|
// appropriate.
|
||||||
@ -720,7 +723,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
// Add any function attributes.
|
// Add any function attributes.
|
||||||
attrs = CallPAL.getFnAttributes();
|
attrs = CallPAL.getFnAttributes();
|
||||||
if (attrs.hasAttributes())
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
|
attrs));
|
||||||
|
|
||||||
Instruction *New;
|
Instruction *New;
|
||||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
||||||
|
@ -278,7 +278,8 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
|||||||
AttributesVec.push_back(PAL.getSlot(i));
|
AttributesVec.push_back(PAL.getSlot(i));
|
||||||
Attributes FnAttrs = PAL.getFnAttributes();
|
Attributes FnAttrs = PAL.getFnAttributes();
|
||||||
if (FnAttrs.hasAttributes())
|
if (FnAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
|
FnAttrs));
|
||||||
PAL = AttrListPtr::get(AttributesVec);
|
PAL = AttrListPtr::get(AttributesVec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,7 +773,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
"Return attributes no longer compatible?");
|
"Return attributes no longer compatible?");
|
||||||
|
|
||||||
if (RAttrs.hasAttributes())
|
if (RAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
|
RAttrs));
|
||||||
|
|
||||||
// Remember which arguments are still alive.
|
// Remember which arguments are still alive.
|
||||||
SmallVector<bool, 10> ArgAlive(FTy->getNumParams(), false);
|
SmallVector<bool, 10> ArgAlive(FTy->getNumParams(), false);
|
||||||
@ -800,7 +802,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FnAttrs.hasAttributes())
|
if (FnAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
|
FnAttrs));
|
||||||
|
|
||||||
// Reconstruct the AttributesList based on the vector we constructed.
|
// Reconstruct the AttributesList based on the vector we constructed.
|
||||||
AttrListPtr NewPAL = AttrListPtr::get(AttributesVec);
|
AttrListPtr NewPAL = AttrListPtr::get(AttributesVec);
|
||||||
@ -840,7 +843,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
Attributes::get(NF->getContext(), Attributes::Builder(RAttrs).
|
Attributes::get(NF->getContext(), Attributes::Builder(RAttrs).
|
||||||
removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
|
removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
|
||||||
if (RAttrs.hasAttributes())
|
if (RAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
|
RAttrs));
|
||||||
|
|
||||||
// Declare these outside of the loops, so we can reuse them for the second
|
// Declare these outside of the loops, so we can reuse them for the second
|
||||||
// loop, which loops the varargs.
|
// loop, which loops the varargs.
|
||||||
@ -866,7 +870,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FnAttrs.hasAttributes())
|
if (FnAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
|
FnAttrs));
|
||||||
|
|
||||||
// Reconstruct the AttributesList based on the vector we constructed.
|
// Reconstruct the AttributesList based on the vector we constructed.
|
||||||
AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec);
|
AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec);
|
||||||
|
@ -215,12 +215,14 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
|
|||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::ReadOnly)
|
B.addAttribute(Attributes::ReadOnly)
|
||||||
.addAttribute(Attributes::ReadNone);
|
.addAttribute(Attributes::ReadNone);
|
||||||
F->removeAttribute(~0, Attributes::get(F->getContext(), B));
|
F->removeAttribute(AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(F->getContext(), B));
|
||||||
|
|
||||||
// Add in the new attribute.
|
// Add in the new attribute.
|
||||||
B.clear();
|
B.clear();
|
||||||
B.addAttribute(ReadsMemory ? Attributes::ReadOnly : Attributes::ReadNone);
|
B.addAttribute(ReadsMemory ? Attributes::ReadOnly : Attributes::ReadNone);
|
||||||
F->addAttribute(~0, Attributes::get(F->getContext(), B));
|
F->addAttribute(AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(F->getContext(), B));
|
||||||
|
|
||||||
if (ReadsMemory)
|
if (ReadsMemory)
|
||||||
++NumReadOnly;
|
++NumReadOnly;
|
||||||
|
@ -1118,7 +1118,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
// Add the new return attributes.
|
// Add the new return attributes.
|
||||||
if (RAttrs.hasAttributes())
|
if (RAttrs.hasAttributes())
|
||||||
attrVec.push_back(
|
attrVec.push_back(
|
||||||
AttributeWithIndex::get(0, Attributes::get(FT->getContext(), RAttrs)));
|
AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
|
Attributes::get(FT->getContext(), RAttrs)));
|
||||||
|
|
||||||
AI = CS.arg_begin();
|
AI = CS.arg_begin();
|
||||||
for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
|
for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
|
||||||
@ -1170,7 +1171,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
|
|
||||||
Attributes FnAttrs = CallerPAL.getFnAttributes();
|
Attributes FnAttrs = CallerPAL.getFnAttributes();
|
||||||
if (FnAttrs.hasAttributes())
|
if (FnAttrs.hasAttributes())
|
||||||
attrVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
attrVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
|
FnAttrs));
|
||||||
|
|
||||||
if (NewRetTy->isVoidTy())
|
if (NewRetTy->isVoidTy())
|
||||||
Caller->setName(""); // Void type should not have a name.
|
Caller->setName(""); // Void type should not have a name.
|
||||||
@ -1280,7 +1282,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
|
|||||||
// Add any result attributes.
|
// Add any result attributes.
|
||||||
Attributes Attr = Attrs.getRetAttributes();
|
Attributes Attr = Attrs.getRetAttributes();
|
||||||
if (Attr.hasAttributes())
|
if (Attr.hasAttributes())
|
||||||
NewAttrs.push_back(AttributeWithIndex::get(0, Attr));
|
NewAttrs.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
|
||||||
|
Attr));
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned Idx = 1;
|
unsigned Idx = 1;
|
||||||
@ -1312,7 +1315,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
|
|||||||
// Add any function attributes.
|
// Add any function attributes.
|
||||||
Attr = Attrs.getFnAttributes();
|
Attr = Attrs.getFnAttributes();
|
||||||
if (Attr.hasAttributes())
|
if (Attr.hasAttributes())
|
||||||
NewAttrs.push_back(AttributeWithIndex::get(~0, Attr));
|
NewAttrs.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
|
||||||
|
Attr));
|
||||||
|
|
||||||
// The trampoline may have been bitcast to a bogus type (FTy).
|
// The trampoline may have been bitcast to a bogus type (FTy).
|
||||||
// Handle this by synthesizing a new function type, equal to FTy
|
// Handle this by synthesizing a new function type, equal to FTy
|
||||||
|
@ -1790,8 +1790,9 @@ Constant *ObjCARCOpt::getRetainRVCallee(Module *M) {
|
|||||||
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
|
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes =
|
||||||
Attributes::get(M->getContext(), B));
|
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(M->getContext(), B));
|
||||||
RetainRVCallee =
|
RetainRVCallee =
|
||||||
M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy,
|
M->getOrInsertFunction("objc_retainAutoreleasedReturnValue", FTy,
|
||||||
Attributes);
|
Attributes);
|
||||||
@ -1807,8 +1808,9 @@ Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) {
|
|||||||
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
|
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes =
|
||||||
Attributes::get(C, B));
|
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(C, B));
|
||||||
AutoreleaseRVCallee =
|
AutoreleaseRVCallee =
|
||||||
M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy,
|
M->getOrInsertFunction("objc_autoreleaseReturnValue", FTy,
|
||||||
Attributes);
|
Attributes);
|
||||||
@ -1822,8 +1824,9 @@ Constant *ObjCARCOpt::getReleaseCallee(Module *M) {
|
|||||||
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
|
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes =
|
||||||
Attributes::get(C, B));
|
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(C, B));
|
||||||
ReleaseCallee =
|
ReleaseCallee =
|
||||||
M->getOrInsertFunction(
|
M->getOrInsertFunction(
|
||||||
"objc_release",
|
"objc_release",
|
||||||
@ -1839,8 +1842,9 @@ Constant *ObjCARCOpt::getRetainCallee(Module *M) {
|
|||||||
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
|
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes =
|
||||||
Attributes::get(C, B));
|
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(C, B));
|
||||||
RetainCallee =
|
RetainCallee =
|
||||||
M->getOrInsertFunction(
|
M->getOrInsertFunction(
|
||||||
"objc_retain",
|
"objc_retain",
|
||||||
@ -1871,8 +1875,9 @@ Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) {
|
|||||||
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
|
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes =
|
||||||
Attributes::get(C, B));
|
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(C, B));
|
||||||
AutoreleaseCallee =
|
AutoreleaseCallee =
|
||||||
M->getOrInsertFunction(
|
M->getOrInsertFunction(
|
||||||
"objc_autorelease",
|
"objc_autorelease",
|
||||||
@ -3850,7 +3855,8 @@ Constant *ObjCARCContract::getStoreStrongCallee(Module *M) {
|
|||||||
Attributes::Builder BNoCapture;
|
Attributes::Builder BNoCapture;
|
||||||
BNoCapture.addAttribute(Attributes::NoCapture);
|
BNoCapture.addAttribute(Attributes::NoCapture);
|
||||||
AttrListPtr Attributes = AttrListPtr()
|
AttrListPtr Attributes = AttrListPtr()
|
||||||
.addAttr(M->getContext(), ~0u, Attributes::get(C, BNoUnwind))
|
.addAttr(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(C, BNoUnwind))
|
||||||
.addAttr(M->getContext(), 1, Attributes::get(C, BNoCapture));
|
.addAttr(M->getContext(), 1, Attributes::get(C, BNoCapture));
|
||||||
|
|
||||||
StoreStrongCallee =
|
StoreStrongCallee =
|
||||||
@ -3870,8 +3876,9 @@ Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) {
|
|||||||
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
|
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes =
|
||||||
Attributes::get(C, B));
|
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(C, B));
|
||||||
RetainAutoreleaseCallee =
|
RetainAutoreleaseCallee =
|
||||||
M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes);
|
M->getOrInsertFunction("objc_retainAutorelease", FTy, Attributes);
|
||||||
}
|
}
|
||||||
@ -3886,8 +3893,9 @@ Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) {
|
|||||||
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
|
FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false);
|
||||||
Attributes::Builder B;
|
Attributes::Builder B;
|
||||||
B.addAttribute(Attributes::NoUnwind);
|
B.addAttribute(Attributes::NoUnwind);
|
||||||
AttrListPtr Attributes = AttrListPtr().addAttr(M->getContext(), ~0u,
|
AttrListPtr Attributes =
|
||||||
Attributes::get(C, B));
|
AttrListPtr().addAttr(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::get(C, B));
|
||||||
RetainAutoreleaseRVCallee =
|
RetainAutoreleaseRVCallee =
|
||||||
M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy,
|
M->getOrInsertFunction("objc_retainAutoreleaseReturnValue", FTy,
|
||||||
Attributes);
|
Attributes);
|
||||||
|
@ -43,7 +43,7 @@ Value *llvm::EmitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout *TD,
|
|||||||
AttributeWithIndex AWI[2];
|
AttributeWithIndex AWI[2];
|
||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u,
|
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
@ -70,7 +70,7 @@ Value *llvm::EmitStrNLen(Value *Ptr, Value *MaxLen, IRBuilder<> &B,
|
|||||||
AttributeWithIndex AWI[2];
|
AttributeWithIndex AWI[2];
|
||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u,
|
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
@ -97,7 +97,7 @@ Value *llvm::EmitStrChr(Value *Ptr, char C, IRBuilder<> &B,
|
|||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||||
AttributeWithIndex AWI =
|
AttributeWithIndex AWI =
|
||||||
AttributeWithIndex::get(M->getContext(), ~0u,
|
AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
Type *I8Ptr = B.getInt8PtrTy();
|
Type *I8Ptr = B.getInt8PtrTy();
|
||||||
@ -123,7 +123,7 @@ Value *llvm::EmitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len,
|
|||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||||
AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u,
|
AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
@ -152,7 +152,8 @@ Value *llvm::EmitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
|
|||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[2];
|
AttributeWithIndex AWI[2];
|
||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::NoUnwind);
|
||||||
Type *I8Ptr = B.getInt8PtrTy();
|
Type *I8Ptr = B.getInt8PtrTy();
|
||||||
Value *StrCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
Value *StrCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
||||||
I8Ptr, I8Ptr, I8Ptr, NULL);
|
I8Ptr, I8Ptr, I8Ptr, NULL);
|
||||||
@ -174,7 +175,8 @@ Value *llvm::EmitStrNCpy(Value *Dst, Value *Src, Value *Len,
|
|||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[2];
|
AttributeWithIndex AWI[2];
|
||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::NoUnwind);
|
||||||
Type *I8Ptr = B.getInt8PtrTy();
|
Type *I8Ptr = B.getInt8PtrTy();
|
||||||
Value *StrNCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
Value *StrNCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
||||||
I8Ptr, I8Ptr, I8Ptr,
|
I8Ptr, I8Ptr, I8Ptr,
|
||||||
@ -197,7 +199,8 @@ Value *llvm::EmitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
|
|||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI;
|
AttributeWithIndex AWI;
|
||||||
AWI = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
AWI = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::NoUnwind);
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
Value *MemCpy = M->getOrInsertFunction("__memcpy_chk",
|
Value *MemCpy = M->getOrInsertFunction("__memcpy_chk",
|
||||||
AttrListPtr::get(AWI),
|
AttrListPtr::get(AWI),
|
||||||
@ -225,7 +228,7 @@ Value *llvm::EmitMemChr(Value *Ptr, Value *Val,
|
|||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI;
|
AttributeWithIndex AWI;
|
||||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||||
AWI = AttributeWithIndex::get(M->getContext(), ~0u,
|
AWI = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(AWI),
|
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(AWI),
|
||||||
@ -254,7 +257,7 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
|
|||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||||
AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u,
|
AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||||
|
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
@ -332,7 +335,8 @@ Value *llvm::EmitPutS(Value *Str, IRBuilder<> &B, const DataLayout *TD,
|
|||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[2];
|
AttributeWithIndex AWI[2];
|
||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::NoUnwind);
|
||||||
|
|
||||||
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI),
|
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI),
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
@ -354,7 +358,8 @@ Value *llvm::EmitFPutC(Value *Char, Value *File, IRBuilder<> &B,
|
|||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
AttributeWithIndex AWI[2];
|
AttributeWithIndex AWI[2];
|
||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::NoUnwind);
|
||||||
Constant *F;
|
Constant *F;
|
||||||
if (File->getType()->isPointerTy())
|
if (File->getType()->isPointerTy())
|
||||||
F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI),
|
F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI),
|
||||||
@ -386,7 +391,8 @@ Value *llvm::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B,
|
|||||||
AttributeWithIndex AWI[3];
|
AttributeWithIndex AWI[3];
|
||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attributes::NoCapture);
|
||||||
AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::NoUnwind);
|
||||||
StringRef FPutsName = TLI->getName(LibFunc::fputs);
|
StringRef FPutsName = TLI->getName(LibFunc::fputs);
|
||||||
Constant *F;
|
Constant *F;
|
||||||
if (File->getType()->isPointerTy())
|
if (File->getType()->isPointerTy())
|
||||||
@ -417,7 +423,8 @@ Value *llvm::EmitFWrite(Value *Ptr, Value *Size, Value *File,
|
|||||||
AttributeWithIndex AWI[3];
|
AttributeWithIndex AWI[3];
|
||||||
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attributes::NoCapture);
|
||||||
AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attributes::NoCapture);
|
AWI[1] = AttributeWithIndex::get(M->getContext(), 4, Attributes::NoCapture);
|
||||||
AWI[2] = AttributeWithIndex::get(M->getContext(), ~0u, Attributes::NoUnwind);
|
AWI[2] = AttributeWithIndex::get(M->getContext(), AttrListPtr::FunctionIndex,
|
||||||
|
Attributes::NoUnwind);
|
||||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||||
StringRef FWriteName = TLI->getName(LibFunc::fwrite);
|
StringRef FWriteName = TLI->getName(LibFunc::fwrite);
|
||||||
Constant *F;
|
Constant *F;
|
||||||
|
@ -98,11 +98,13 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
|
|||||||
Anew->addAttr( OldFunc->getAttributes()
|
Anew->addAttr( OldFunc->getAttributes()
|
||||||
.getParamAttributes(I->getArgNo() + 1));
|
.getParamAttributes(I->getArgNo() + 1));
|
||||||
NewFunc->setAttributes(NewFunc->getAttributes()
|
NewFunc->setAttributes(NewFunc->getAttributes()
|
||||||
.addAttr(NewFunc->getContext(), 0,
|
.addAttr(NewFunc->getContext(),
|
||||||
|
AttrListPtr::ReturnIndex,
|
||||||
OldFunc->getAttributes()
|
OldFunc->getAttributes()
|
||||||
.getRetAttributes()));
|
.getRetAttributes()));
|
||||||
NewFunc->setAttributes(NewFunc->getAttributes()
|
NewFunc->setAttributes(NewFunc->getAttributes()
|
||||||
.addAttr(NewFunc->getContext(), ~0,
|
.addAttr(NewFunc->getContext(),
|
||||||
|
AttrListPtr::FunctionIndex,
|
||||||
OldFunc->getAttributes()
|
OldFunc->getAttributes()
|
||||||
.getFnAttributes()));
|
.getFnAttributes()));
|
||||||
|
|
||||||
|
@ -1383,7 +1383,7 @@ void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
|
|||||||
const AttrListPtr PAL = Func->getAttributes();
|
const AttrListPtr PAL = Func->getAttributes();
|
||||||
Attributes::Builder B(PA);
|
Attributes::Builder B(PA);
|
||||||
const AttrListPtr PALnew =
|
const AttrListPtr PALnew =
|
||||||
PAL.addAttr(Func->getContext(), ~0U,
|
PAL.addAttr(Func->getContext(), AttrListPtr::FunctionIndex,
|
||||||
Attributes::get(Func->getContext(), B));
|
Attributes::get(Func->getContext(), B));
|
||||||
Func->setAttributes(PALnew);
|
Func->setAttributes(PALnew);
|
||||||
}
|
}
|
||||||
@ -1393,7 +1393,7 @@ void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
|
|||||||
const AttrListPtr PAL = Func->getAttributes();
|
const AttrListPtr PAL = Func->getAttributes();
|
||||||
Attributes::Builder B(PA);
|
Attributes::Builder B(PA);
|
||||||
const AttrListPtr PALnew =
|
const AttrListPtr PALnew =
|
||||||
PAL.removeAttr(Func->getContext(), ~0U,
|
PAL.removeAttr(Func->getContext(), AttrListPtr::FunctionIndex,
|
||||||
Attributes::get(Func->getContext(), B));
|
Attributes::get(Func->getContext(), B));
|
||||||
Func->setAttributes(PALnew);
|
Func->setAttributes(PALnew);
|
||||||
}
|
}
|
||||||
|
@ -343,10 +343,11 @@ void CallInst::removeAttribute(unsigned i, Attributes attr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CallInst::hasFnAttr(Attributes::AttrVal A) const {
|
bool CallInst::hasFnAttr(Attributes::AttrVal A) const {
|
||||||
if (AttributeList.getParamAttributes(~0U).hasAttribute(A))
|
if (AttributeList.getParamAttributes(AttrListPtr::FunctionIndex)
|
||||||
|
.hasAttribute(A))
|
||||||
return true;
|
return true;
|
||||||
if (const Function *F = getCalledFunction())
|
if (const Function *F = getCalledFunction())
|
||||||
return F->getParamAttributes(~0U).hasAttribute(A);
|
return F->getParamAttributes(AttrListPtr::FunctionIndex).hasAttribute(A);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,10 +572,11 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool InvokeInst::hasFnAttr(Attributes::AttrVal A) const {
|
bool InvokeInst::hasFnAttr(Attributes::AttrVal A) const {
|
||||||
if (AttributeList.getParamAttributes(~0U).hasAttribute(A))
|
if (AttributeList.getParamAttributes(AttrListPtr::FunctionIndex).
|
||||||
|
hasAttribute(A))
|
||||||
return true;
|
return true;
|
||||||
if (const Function *F = getCalledFunction())
|
if (const Function *F = getCalledFunction())
|
||||||
return F->getParamAttributes(~0U).hasAttribute(A);
|
return F->getParamAttributes(AttrListPtr::FunctionIndex).hasAttribute(A);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,8 +606,8 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
|
|||||||
OS << " AttrVec.push_back(Attributes::ReadNone);\n";
|
OS << " AttrVec.push_back(Attributes::ReadNone);\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, ~0, "
|
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(C, "
|
||||||
<< "AttrVec);\n";
|
<< "AttrListPtr::FunctionIndex, AttrVec);\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numAttrs) {
|
if (numAttrs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user