aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-12 17:45:29 +0000
committerChris Lattner <sabre@nondot.org>2008-03-12 17:45:29 +0000
commit58d74910c6b82e622ecbb57d6644d48fec5a5c0f (patch)
treef04d1ab294b3379bf97d9f727d4ade9e7079ca48 /lib/Transforms/IPO/GlobalOpt.cpp
parent37f603f5d78f735e8de92113429b67c77aa58086 (diff)
Reimplement the parameter attributes support, phase #1. hilights:
1. There is now a "PAListPtr" class, which is a smart pointer around the underlying uniqued parameter attribute list object, and manages its refcount. It is now impossible to mess up the refcount. 2. PAListPtr is now the main interface to the underlying object, and the underlying object is now completely opaque. 3. Implementation details like SmallVector and FoldingSet are now no longer part of the interface. 4. You can create a PAListPtr with an arbitrary sequence of ParamAttrsWithIndex's, no need to make a SmallVector of a specific size (you can just use an array or scalar or vector if you wish). 5. All the client code that had to check for a null pointer before dereferencing the pointer is simplified to just access the PAListPtr directly. 6. The interfaces for adding attrs to a list and removing them is a bit simpler. Phase #2 will rename some stuff (e.g. PAListPtr) and do other less invasive changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48289 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 7bfed8afc6..5bb7494cd1 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -21,7 +21,6 @@
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Module.h"
-#include "llvm/ParamAttrsList.h"
#include "llvm/Pass.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Target/TargetData.h"
@@ -1592,18 +1591,13 @@ static void ChangeCalleesToFastCall(Function *F) {
}
}
-static const ParamAttrsList *StripNest(const ParamAttrsList *Attrs) {
- if (!Attrs)
- return NULL;
-
- for (unsigned i = 0, e = Attrs->size(); i != e; ++i) {
- if ((Attrs->getParamAttrsAtIndex(i) & ParamAttr::Nest) == 0)
+static PAListPtr StripNest(const PAListPtr &Attrs) {
+ for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
+ if ((Attrs.getSlot(i).Attrs & ParamAttr::Nest) == 0)
continue;
- Attrs = ParamAttrsList::excludeAttrs(Attrs, Attrs->getParamIndex(i),
- ParamAttr::Nest);
// There can be only one.
- break;
+ return Attrs.removeAttr(Attrs.getSlot(i).Index, ParamAttr::Nest);
}
return Attrs;
@@ -1640,8 +1634,7 @@ bool GlobalOpt::OptimizeFunctions(Module &M) {
Changed = true;
}
- if (F->getParamAttrs() &&
- F->getParamAttrs()->hasAttrSomewhere(ParamAttr::Nest) &&
+ if (F->getParamAttrs().hasAttrSomewhere(ParamAttr::Nest) &&
OnlyCalledDirectly(F)) {
// The function is not used by a trampoline intrinsic, so it is safe
// to remove the 'nest' attribute.