summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kuperstein <mkuper@google.com>2016-07-25 18:10:54 +0000
committerMichael Kuperstein <mkuper@google.com>2016-07-25 18:10:54 +0000
commit8f8e1d1bf66c273116c64dcb2dfc22ad8d30d785 (patch)
tree47823b219ae3b787f9daf5832d3048ef397e5f19
parent25ef9e34c9de7b1edc327189b78200459337f7e5 (diff)
downloadbcm5719-llvm-8f8e1d1bf66c273116c64dcb2dfc22ad8d30d785.tar.gz
bcm5719-llvm-8f8e1d1bf66c273116c64dcb2dfc22ad8d30d785.zip
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
-rw-r--r--llvm/include/llvm/Transforms/Utils/SymbolRewriter.h48
-rw-r--r--llvm/lib/Transforms/Utils/SymbolRewriter.cpp25
2 files changed, 21 insertions, 52 deletions
diff --git a/llvm/include/llvm/Transforms/Utils/SymbolRewriter.h b/llvm/include/llvm/Transforms/Utils/SymbolRewriter.h
index 5ccee98f97e..39638b3b324 100644
--- a/llvm/include/llvm/Transforms/Utils/SymbolRewriter.h
+++ b/llvm/include/llvm/Transforms/Utils/SymbolRewriter.h
@@ -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
diff --git a/llvm/lib/Transforms/Utils/SymbolRewriter.cpp b/llvm/lib/Transforms/Utils/SymbolRewriter.cpp
index 7523ca527b6..ea0294cdc70 100644
--- a/llvm/lib/Transforms/Utils/SymbolRewriter.cpp
+++ b/llvm/lib/Transforms/Utils/SymbolRewriter.cpp
@@ -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;
}
OpenPOWER on IntegriCloud