forked from OSchip/llvm-project
Don't use iplist in SymbolRewriter. NFC.
There didn't appear to be a good reason to use iplist in this case, a regular list of unique_ptr works just as well. Change made in preparation to a new PM port (since iplist is not moveable). llvm-svn: 276668
This commit is contained in:
parent
25ef9e34c9
commit
8f8e1d1bf6
|
@ -30,12 +30,11 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TRANSFORMS_UTILS_SYMBOL_REWRITER_H
|
||||
#define LLVM_TRANSFORMS_UTILS_SYMBOL_REWRITER_H
|
||||
#ifndef LLVM_TRANSFORMS_UTILS_SYMBOLREWRITER_H
|
||||
#define LLVM_TRANSFORMS_UTILS_SYMBOLREWRITER_H
|
||||
|
||||
#include "llvm/ADT/ilist.h"
|
||||
#include "llvm/ADT/ilist_node.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include <list>
|
||||
|
||||
namespace llvm {
|
||||
class MemoryBuffer;
|
||||
|
@ -59,7 +58,7 @@ namespace SymbolRewriter {
|
|||
/// be rewritten or providing a (posix compatible) regular expression that will
|
||||
/// select the symbols to rewrite. This descriptor list is passed to the
|
||||
/// SymbolRewriter pass.
|
||||
class RewriteDescriptor : public ilist_node<RewriteDescriptor> {
|
||||
class RewriteDescriptor {
|
||||
RewriteDescriptor(const RewriteDescriptor &) = delete;
|
||||
|
||||
const RewriteDescriptor &
|
||||
|
@ -86,7 +85,7 @@ private:
|
|||
const Type Kind;
|
||||
};
|
||||
|
||||
typedef iplist<RewriteDescriptor> RewriteDescriptorList;
|
||||
typedef std::list<std::unique_ptr<RewriteDescriptor>> RewriteDescriptorList;
|
||||
|
||||
class RewriteMapParser {
|
||||
public:
|
||||
|
@ -110,43 +109,8 @@ private:
|
|||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct ilist_traits<SymbolRewriter::RewriteDescriptor>
|
||||
: public ilist_default_traits<SymbolRewriter::RewriteDescriptor> {
|
||||
mutable ilist_half_node<SymbolRewriter::RewriteDescriptor> Sentinel;
|
||||
|
||||
public:
|
||||
// createSentinel is used to get a reference to a node marking the end of
|
||||
// the list. Because the sentinel is relative to this instance, use a
|
||||
// non-static method.
|
||||
SymbolRewriter::RewriteDescriptor *createSentinel() const {
|
||||
// since i[p] lists always publicly derive from the corresponding
|
||||
// traits, placing a data member in this class will augment the
|
||||
// i[p]list. Since the NodeTy is expected to publicly derive from
|
||||
// ilist_node<NodeTy>, there is a legal viable downcast from it to
|
||||
// NodeTy. We use this trick to superpose i[p]list with a "ghostly"
|
||||
// NodeTy, which becomes the sentinel. Dereferencing the sentinel is
|
||||
// forbidden (save the ilist_node<NodeTy>) so no one will ever notice
|
||||
// the superposition.
|
||||
return static_cast<SymbolRewriter::RewriteDescriptor *>(&Sentinel);
|
||||
}
|
||||
void destroySentinel(SymbolRewriter::RewriteDescriptor *) {}
|
||||
|
||||
SymbolRewriter::RewriteDescriptor *provideInitialHead() const {
|
||||
return createSentinel();
|
||||
}
|
||||
|
||||
SymbolRewriter::RewriteDescriptor *
|
||||
ensureHead(SymbolRewriter::RewriteDescriptor *&) const {
|
||||
return createSentinel();
|
||||
}
|
||||
|
||||
static void noteHead(SymbolRewriter::RewriteDescriptor *,
|
||||
SymbolRewriter::RewriteDescriptor *) {}
|
||||
};
|
||||
|
||||
ModulePass *createRewriteSymbolsPass();
|
||||
ModulePass *createRewriteSymbolsPass(SymbolRewriter::RewriteDescriptorList &);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif //LLVM_TRANSFORMS_UTILS_SYMBOLREWRITER_H
|
||||
|
|
|
@ -361,9 +361,11 @@ parseRewriteFunctionDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
|
|||
// TODO see if there is a more elegant solution to selecting the rewrite
|
||||
// descriptor type
|
||||
if (!Target.empty())
|
||||
DL->push_back(new ExplicitRewriteFunctionDescriptor(Source, Target, Naked));
|
||||
DL->push_back(
|
||||
make_unique<ExplicitRewriteFunctionDescriptor>(Source, Target, Naked));
|
||||
else
|
||||
DL->push_back(new PatternRewriteFunctionDescriptor(Source, Transform));
|
||||
DL->push_back(
|
||||
make_unique<PatternRewriteFunctionDescriptor>(Source, Transform));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -421,11 +423,12 @@ parseRewriteGlobalVariableDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
|
|||
}
|
||||
|
||||
if (!Target.empty())
|
||||
DL->push_back(new ExplicitRewriteGlobalVariableDescriptor(Source, Target,
|
||||
/*Naked*/false));
|
||||
DL->push_back(
|
||||
make_unique<ExplicitRewriteGlobalVariableDescriptor>(Source, Target,
|
||||
/*Naked*/ false));
|
||||
else
|
||||
DL->push_back(new PatternRewriteGlobalVariableDescriptor(Source,
|
||||
Transform));
|
||||
DL->push_back(
|
||||
make_unique<PatternRewriteGlobalVariableDescriptor>(Source, Transform));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -483,10 +486,12 @@ parseRewriteGlobalAliasDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
|
|||
}
|
||||
|
||||
if (!Target.empty())
|
||||
DL->push_back(new ExplicitRewriteNamedAliasDescriptor(Source, Target,
|
||||
/*Naked*/false));
|
||||
DL->push_back(
|
||||
make_unique<ExplicitRewriteNamedAliasDescriptor>(Source, Target,
|
||||
/*Naked*/ false));
|
||||
else
|
||||
DL->push_back(new PatternRewriteNamedAliasDescriptor(Source, Transform));
|
||||
DL->push_back(
|
||||
make_unique<PatternRewriteNamedAliasDescriptor>(Source, Transform));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -524,7 +529,7 @@ bool RewriteSymbols::runOnModule(Module &M) {
|
|||
|
||||
Changed = false;
|
||||
for (auto &Descriptor : Descriptors)
|
||||
Changed |= Descriptor.performOnModule(M);
|
||||
Changed |= Descriptor->performOnModule(M);
|
||||
|
||||
return Changed;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue