summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-04-12 00:38:00 +0000
committerReid Kleckner <rnk@google.com>2017-04-12 00:38:00 +0000
commitc2cb5600450b8c4e5fdd915bd8c848319c5e57e1 (patch)
tree621b8f69c41b1b0aead20855cdede8ddd54eae70 /llvm/lib/Transforms
parentbdbdd229375f1b7c112bb5ecef8aeb603ad8d07f (diff)
downloadbcm5719-llvm-c2cb5600450b8c4e5fdd915bd8c848319c5e57e1.tar.gz
bcm5719-llvm-c2cb5600450b8c4e5fdd915bd8c848319c5e57e1.zip
[IR] Add AttributeSet to hide AttributeSetNode* again, NFC
Summary: For now, it just wraps AttributeSetNode*. Eventually, it will hold AvailableAttrs as an inline bitset, and adding and removing enum attributes will be super cheap. This sinks AttributeSetNode back down to lib/IR/AttributeImpl.h. Reviewers: pete, chandlerc Subscribers: llvm-commits, jfb Differential Revision: https://reviews.llvm.org/D31940 llvm-svn: 300014
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/ArgumentPromotion.cpp12
-rw-r--r--llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp16
-rw-r--r--llvm/lib/Transforms/IPO/MergeFunctions.cpp3
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp7
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp12
5 files changed, 23 insertions, 27 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 1646237b096..c43557b4e1a 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -42,7 +42,6 @@
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
-#include "llvm/IR/AttributeSetNode.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
@@ -103,7 +102,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
// Attribute - Keep track of the parameter attributes for the arguments
// that we are *not* promoting. For the ones that we do promote, the parameter
// attributes are lost
- SmallVector<AttributeSetNode *, 8> AttributesVec;
+ SmallVector<AttributeSet, 8> AttributesVec;
const AttributeList &PAL = F->getAttributes();
// Add any return attributes.
@@ -118,7 +117,8 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
Type *AgTy = cast<PointerType>(I->getType())->getElementType();
StructType *STy = cast<StructType>(AgTy);
Params.insert(Params.end(), STy->element_begin(), STy->element_end());
- AttributesVec.insert(AttributesVec.end(), STy->getNumElements(), nullptr);
+ AttributesVec.insert(AttributesVec.end(), STy->getNumElements(),
+ AttributeSet());
++NumByValArgsPromoted;
} else if (!ArgsToPromote.count(&*I)) {
// Unchanged argument
@@ -168,7 +168,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
Params.push_back(GetElementPtrInst::getIndexedType(
cast<PointerType>(I->getType()->getScalarType())->getElementType(),
ArgIndex.second));
- AttributesVec.push_back(nullptr);
+ AttributesVec.push_back(AttributeSet());
assert(Params.back());
}
@@ -240,7 +240,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
STy, *AI, Idxs, (*AI)->getName() + "." + Twine(i), Call);
// TODO: Tell AA about the new values?
Args.push_back(new LoadInst(Idx, Idx->getName() + ".val", Call));
- AttributesVec.push_back(nullptr);
+ AttributesVec.push_back(AttributeSet());
}
} else if (!I->use_empty()) {
// Non-dead argument: insert GEPs and loads as appropriate.
@@ -283,7 +283,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
newLoad->setAAMetadata(AAInfo);
Args.push_back(newLoad);
- AttributesVec.push_back(nullptr);
+ AttributesVec.push_back(AttributeSet());
}
}
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index c7138bfbc8b..66eb33f246a 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -21,7 +21,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
-#include "llvm/IR/AttributeSetNode.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constant.h"
@@ -686,12 +685,12 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
bool HasLiveReturnedArg = false;
// Set up to build a new list of parameter attributes.
- SmallVector<AttributeSetNode *, 8> AttributesVec;
+ SmallVector<AttributeSet, 8> AttributesVec;
const AttributeList &PAL = F->getAttributes();
// Reserve an empty slot for the return value attributes, which we will
// compute last.
- AttributesVec.push_back(nullptr);
+ AttributesVec.push_back(AttributeSet());
// Remember which arguments are still alive.
SmallVector<bool, 10> ArgAlive(FTy->getNumParams(), false);
@@ -792,7 +791,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
assert(!RAttrs.overlaps(AttributeFuncs::typeIncompatible(NRetTy)) &&
"Return attributes no longer compatible?");
- AttributesVec[0] = AttributeSetNode::get(F->getContext(), RAttrs);
+ AttributesVec[0] = AttributeSet::get(F->getContext(), RAttrs);
// Transfer the function attributes, if any.
AttributesVec.push_back(PAL.getFnAttributes());
@@ -833,7 +832,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
// return void.
AttrBuilder RAttrs(CallPAL.getRetAttributes());
RAttrs.remove(AttributeFuncs::typeIncompatible(NRetTy));
- AttributesVec.push_back(AttributeSetNode::get(F->getContext(), RAttrs));
+ AttributesVec.push_back(AttributeSet::get(F->getContext(), RAttrs));
// Declare these outside of the loops, so we can reuse them for the second
// loop, which loops the varargs.
@@ -845,15 +844,14 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
if (ArgAlive[i]) {
Args.push_back(*I);
// Get original parameter attributes, but skip return attributes.
- AttributeSetNode *Attrs = CallPAL.getParamAttributes(i + 1);
- if (NRetTy != RetTy && Attrs &&
- Attrs->hasAttribute(Attribute::Returned)) {
+ AttributeSet Attrs = CallPAL.getParamAttributes(i + 1);
+ if (NRetTy != RetTy && Attrs.hasAttribute(Attribute::Returned)) {
// If the return type has changed, then get rid of 'returned' on the
// call site. The alternative is to make all 'returned' attributes on
// call sites keep the return value alive just like 'returned'
// attributes on function declaration but it's less clearly a win and
// this is not an expected case anyway
- AttributesVec.push_back(AttributeSetNode::get(
+ AttributesVec.push_back(AttributeSet::get(
F->getContext(),
AttrBuilder(Attrs).removeAttribute(Attribute::Returned)));
} else {
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index 5d41ca9f9fc..4ce4de13c93 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -439,7 +439,8 @@ void MergeFunctions::replaceDirectCallers(Function *Old, Function *New) {
Context, AttributeList::ReturnIndex, NewFuncAttrs.getRetAttributes());
for (unsigned argIdx = 0; argIdx < CS.arg_size(); argIdx++) {
- if (AttributeSetNode *Attrs = NewFuncAttrs.getParamAttributes(argIdx))
+ AttributeSet Attrs = NewFuncAttrs.getParamAttributes(argIdx);
+ if (Attrs.hasAttributes())
CallSiteAttrs = CallSiteAttrs.addAttributes(Context, argIdx, Attrs);
}
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index c850e2e7393..cdae9571851 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -23,7 +23,6 @@
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/ValueTracking.h"
-#include "llvm/IR/AttributeSetNode.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
@@ -4119,7 +4118,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
}
}
- AttributeSetNode *FnAttrs = CallerPAL.getFnAttributes();
+ AttributeSet FnAttrs = CallerPAL.getFnAttributes();
if (CallerPAL.hasAttributes(AttributeList::FunctionIndex))
attrVec.push_back(AttributeList::get(Callee->getContext(),
AttributeList::FunctionIndex,
@@ -4218,7 +4217,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
if (!NestAttrs.isEmpty()) {
unsigned NestIdx = 1;
Type *NestTy = nullptr;
- AttributeSetNode *NestAttr;
+ AttributeSet NestAttr;
// Look for a parameter marked with the 'nest' attribute.
for (FunctionType::param_iterator I = NestFTy->param_begin(),
@@ -4233,7 +4232,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
if (NestTy) {
Instruction *Caller = CS.getInstruction();
std::vector<Value*> NewArgs;
- std::vector<AttributeSetNode *> NewAttrs;
+ std::vector<AttributeSet> NewAttrs;
NewArgs.reserve(CS.arg_size() + 1);
NewAttrs.reserve(CS.arg_size() + 2);
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index f4803028f3c..3a78158478c 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -103,23 +103,21 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges,
TypeMapper, Materializer));
- SmallVector<std::pair<unsigned, AttributeSetNode*>, 4> AttrVec;
+ SmallVector<AttributeSet, 4> AttrVec(NewFunc->arg_size() + 2);
AttributeList OldAttrs = OldFunc->getAttributes();
// Copy the return attributes.
- if (auto *RetAttrs = OldAttrs.getRetAttributes())
- AttrVec.emplace_back(AttributeList::ReturnIndex, RetAttrs);
+ AttrVec[0] = OldAttrs.getRetAttributes();
// Clone any argument attributes that are present in the VMap.
for (const Argument &OldArg : OldFunc->args())
if (Argument *NewArg = dyn_cast<Argument>(VMap[&OldArg])) {
- if (auto *ParmAttrs = OldAttrs.getParamAttributes(OldArg.getArgNo() + 1))
- AttrVec.emplace_back(NewArg->getArgNo() + 1, ParmAttrs);
+ AttrVec[NewArg->getArgNo() + 1] =
+ OldAttrs.getParamAttributes(OldArg.getArgNo() + 1);
}
// Copy any function attributes.
- if (auto *FnAttrs = OldAttrs.getFnAttributes())
- AttrVec.emplace_back(AttributeList::FunctionIndex, FnAttrs);
+ AttrVec.back() = OldAttrs.getFnAttributes();
NewFunc->setAttributes(AttributeList::get(NewFunc->getContext(), AttrVec));
OpenPOWER on IntegriCloud